Find Username base on Transaction Code (TCode)

*&---------------------------------------------------------------------*

*& Report YABAP_TOOLS_FIND_AUTH_BY_TCODE *

*& *

*&---------------------------------------------------------------------*

*& Find Username base on Transaction Code (TCode) *

*& *

*&---------------------------------------------------------------------*

REPORT yabap_tools_find_auth_by_tcode NO STANDARD PAGE HEADING.

*----------------------------------------------------------------------*

* Tables

*----------------------------------------------------------------------*

TABLES : tstct,uststcap,ust04,usr03,ust10s,ust10c, ust12.

*----------------------------------------------------------------------*

*GLOBAL VARIABLE DECRALATION

*----------------------------------------------------------------------*

TYPE-POOLS: kkblo, slis.

DATA : gi_uststcap LIKE STANDARD TABLE OF uststcap WITH HEADER LINE,

gi_ust04 LIKE STANDARD TABLE OF ust04 WITH HEADER LINE,

gi_ust10s LIKE STANDARD TABLE OF ust10s WITH HEADER LINE,

gi_ust10c LIKE STANDARD TABLE OF ust10c WITH HEADER LINE,

gi_ust12 LIKE STANDARD TABLE OF ust12 WITH HEADER LINE.

DATA : lv_count TYPE i,

lv_ttext LIKE tstct-ttext.

*----------------------------------------------------------------------*

*Input Screen/Selection

*----------------------------------------------------------------------*

SELECTION-SCREEN BEGIN OF LINE.

SELECTION-SCREEN COMMENT 1(18) text_101 FOR FIELD pa_tcode.

PARAMETER : pa_tcode LIKE tstc-tcode OBLIGATORY.

SELECTION-SCREEN END OF LINE.

*----------------------------------------------------------------------*

*EVENT

*----------------------------------------------------------------------*

AT SELECTION-SCREEN OUTPUT.

text_101 = 'Transaction Code'.

*----------------------------------------------------------------------*

*INITIALIZATION

*----------------------------------------------------------------------*

INITIALIZATION.

*======================================================================*

*MAIN PROGRAM

*Execute after Input Screen

*======================================================================*

START-OF-SELECTION.

PERFORM fm_collect_data.

PERFORM fm_display_data.

*======================================================================*

*SUB PROGRAM / SUB ROUTINE

*======================================================================*

*---------------------------------------------------------------------*

* FORM fm_collect_data *

*---------------------------------------------------------------------*

* ........ *

*---------------------------------------------------------------------*

FORM fm_collect_data.

REFRESH : gi_uststcap, gi_ust04, gi_ust10s, gi_ust10c.

SELECT *

INTO TABLE gi_ust12

FROM ust12

WHERE

objct = 'S_TCODE' AND

field = 'TCD' AND

( von = pa_tcode OR von = '*' ).

SELECT *

INTO TABLE gi_ust10s

FROM ust10s

FOR ALL ENTRIES IN gi_ust12

WHERE

auth = gi_ust12-auth AND

objct = 'S_TCODE'.

DESCRIBE TABLE gi_ust10s LINES lv_count.

IF lv_count > 0.

SELECT *

APPENDING TABLE gi_ust04

FROM ust04

FOR ALL ENTRIES IN gi_ust10s

WHERE

profile = gi_ust10s-profn.

ENDIF.

ENDFORM. "fm_collect_data

*---------------------------------------------------------------------*

* FORM fm_display_data *

*---------------------------------------------------------------------*

* ........ *

*---------------------------------------------------------------------*

FORM fm_display_data.

SELECT SINGLE ttext

INTO lv_ttext

FROM tstct

WHERE

tcode = pa_tcode and

SPRSL = sy-langu.

SORT gi_ust04 BY bname.

DELETE ADJACENT DUPLICATES FROM gi_ust04

COMPARING bname.

DESCRIBE TABLE gi_ust04 LINES lv_count.

WRITE : / 'TCode : ', pa_tcode COLOR 1, lv_ttext.

WRITE : / 'Total User : ', lv_count COLOR 2.

SKIP 1.

WRITE : /(30) sy-uline.

WRITE : / '|', (5) 'Nomor', '|', (18) 'Username', '|'.

WRITE : /(30) sy-uline.

lv_count = 0.

LOOP AT gi_ust04.

ADD 1 TO lv_count.

WRITE : / '|', (5) lv_count, '|', (18) gi_ust04-bname HOTSPOT, '|'.

ENDLOOP.

WRITE : /(30) sy-uline.

ENDFORM. "fm_display_data

*----------------------------------------------------------------------*

*Event Click

*----------------------------------------------------------------------*

AT LINE-SELECTION.

DATA : lv_obj_name LIKE gi_ust04-bname,

rs_selfield TYPE slis_selfield,

* kkblo_tabname TYPE slis_tabname,

l_tabname TYPE kkblo_tabname.

GET CURSOR FIELD rs_selfield-sel_tab_field VALUE rs_selfield-value.

SPLIT rs_selfield-sel_tab_field AT '-' INTO l_tabname

rs_selfield-fieldname.

CASE rs_selfield-fieldname.

WHEN 'BNAME'.

MOVE rs_selfield-value TO lv_obj_name.

CONDENSE lv_obj_name.

SUBMIT yabap_tools_find_auth_by_bname

WITH pa_bname = lv_obj_name

AND RETURN.

WHEN OTHERS.

ENDCASE.

Comments