*********************************************************************
* This program displays the menu path for a transaction. If the user
* doubleclicks on the transaction name, it displays the transaction's
* start screen. It is useful when working with the profile generator,
* because it is much faster than extracting a menu branch and finding a
* transaction code in it. To run this program, the user menu has to be
* generated.
*********************************************************************
REPORT zmenpath NO STANDARD PAGE HEADING.
TABLES: smencusnew, smencust, tstc.
DATA: BEGIN OF itab OCCURS 10.
INCLUDE STRUCTURE smencusnew.
DATA: END OF itab.
DATA: BEGIN OF stack OCCURS 10,
id(5) TYPE n,
END OF stack.
DATA: i TYPE i.
PARAMETERS: trans LIKE tstc-tcode.
* Get the id of our transaction
SELECT * FROM smencusnew WHERE report = trans AND customized = 'S'.
MOVE-CORRESPONDING smencusnew TO itab.
APPEND itab.
ENDSELECT.
* Our transaction is not in smencusnew
IF sy-subrc <> 0.
WRITE: / trans COLOR 5.
SKIP.
WRITE: / 'Not in the profile generator''s table'.
EXIT.
ENDIF.
* Get the parent id that links us to the root with the fewest levels
SORT itab BY menu_level.
READ TABLE itab INDEX 1.
stack = itab-object_id. APPEND stack.
stack = itab-parent_id. APPEND stack.
* Search for the grandparets ...
DO.
CLEAR itab. REFRESH itab.
SELECT * FROM smencusnew WHERE object_id = stack-id AND
customized = 'S'.
MOVE-CORRESPONDING smencusnew TO itab.
APPEND itab.
ENDSELECT.
SORT itab BY menu_level.
READ TABLE itab INDEX 1.
IF itab-parent_id = '00001'. EXIT. ENDIF.
stack = itab-parent_id. APPEND stack.
ENDDO.
* Display the result
WRITE: / trans COLOR 5.HIDE trans. CLEAR trans.
WRITE: ' <<<< Doubleclick to see the transaction'.
SKIP.
WRITE: /(30) 'Main Menu' COLOR 2.
SORT stack.
LOOP AT stack.
i = i + 3.
SELECT SINGLE * FROM smencust WHERE spras = 'E' AND object_id = stack.
WRITE: /i(30) smencust-text COLOR 2.
ENDLOOP.
* Display the transaction when the user doubleclick on trans
AT LINE-SELECTION.
IF NOT trans IS INITIAL.
SELECT SINGLE * FROM tstc WHERE tcode = trans.
CALL TRANSACTION trans.
ENDIF.
CLEAR trans.
阅读(1173) | 评论(0) | 转发(0) |