获取当前使用某个TCODE的用户的程序样例

REPORT Z_ABAP_SELECT_USER_BY_TCODE .
 TABLES:
             TSTC,
             TSTCT.
 
DATA OPCODE            TYPE X.
DATA: BEGIN OF USR_TABL OCCURS 10.
        INCLUDE STRUCTURE UINFO.
DATA: END OF USR_TABL.
 
SELECT-OPTIONS: S_TCODE FOR TSTC-TCODE.
 
START-OF-SELECTION.
 
 CLEAR USR_TABL.
 FREE  USR_TABL.
 
* set the function call mode
  OPCODE = 2.
 
* get list of all users actually logging on
  CALL 'ThUsrInfo' ID 'OPCODE' FIELD OPCODE
                   ID 'TAB' FIELD USR_TABL-*SYS*.
 
  SORT USR_TABL BY BNAME TCODE.
 
  LOOP AT USR_TABL WHERE TCODE IN S_TCODE.
 
    SELECT SINGLE TTEXT FROM TSTCT INTO TSTCT-TTEXT
                        WHERE SPRSL = SY-LANGU       AND
                              TCODE = USR_TABL-TCODE.
 
    TRANSLATE TSTCT-TTEXT TO UPPER CASE.
 
    WRITE:/
            USR_TABL-BNAME,
            USR_TABL-TCODE,
            TSTCT-TTEXT.
 
  ENDLOOP.
 
  IF SY-SUBRC <> 0.
     MESSAGE I001(38) WITH 'NO ENTRIES FOR YOUR SELECTION CRITERIA!'.
  ENDIF.
 

posted on 2006-09-04 11:22  毛小娃  阅读(192)  评论(0编辑  收藏  举报

导航