SAP根据用户名查找使用的TCODE
由于某些部门的权限变动频繁,设置也比较复杂,现做一个查找TCODE事务代码的程序方便业务部门管理。
*&---------------------------------------------------------------------* *& Report ZMMRP087A *&---------------------------------------------------------------------* *& *&---------------------------------------------------------------------* REPORT ZMMRP087A. TABLES:USR02. TYPES:BEGIN OF TY_DATA, BNAME TYPE USR02-BNAME, TCODE TYPE AGR_TCODES-TCODE, TTEXT TYPE TSTCT-TTEXT,"事务代码描述文本 END OF TY_DATA. DATA:LT_TAB TYPE STANDARD TABLE OF TY_DATA. SELECT-OPTIONS: S_USER FOR USR02-BNAME. "查找母角色的TCODE SELECT USR02~BNAME, *AGR_USERS~AGR_NAME, AGR_TCODES~TCODE, TSTCT~TTEXT FROM USR02 LEFT JOIN AGR_USERS ON AGR_USERS~UNAME = USR02~BNAME LEFT JOIN AGR_TCODES ON AGR_USERS~AGR_NAME = AGR_TCODES~AGR_NAME LEFT JOIN TSTCT ON TSTCT~TCODE = AGR_TCODES~TCODE INTO CORRESPONDING FIELDS OF TABLE @LT_TAB WHERE USR02~BNAME IN @S_USER AND TSTCT~SPRSL = 1. "查找继承角色的TCODE SELECT USR02~BNAME, *AGR_USERS~AGR_NAME, AGR_TCODES~TCODE, TSTCT~TTEXT FROM USR02 LEFT JOIN AGR_USERS ON AGR_USERS~UNAME = USR02~BNAME LEFT JOIN AGR_DEFINE ON AGR_USERS~AGR_NAME = AGR_DEFINE~AGR_NAME LEFT JOIN AGR_TCODES ON AGR_DEFINE~PARENT_AGR = AGR_TCODES~AGR_NAME LEFT JOIN TSTCT ON TSTCT~TCODE = AGR_TCODES~TCODE APPENDING CORRESPONDING FIELDS OF TABLE @LT_TAB WHERE USR02~BNAME IN @S_USER AND TSTCT~SPRSL = 1. SORT LT_TAB BY BNAME TCODE. DELETE ADJACENT DUPLICATES FROM LT_TAB.