欢迎来到萧静默的博客

书山有路勤为径,学海无涯苦作舟。

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.

 

posted @ 2021-09-15 16:51  萧静默  阅读(1231)  评论(0编辑  收藏  举报