技术开发 频道

事务码查找所在菜单路径

    【IT168 信息化

    * This program displays the menu path for a transaction. If the user 
    * clicks on the transaction line, 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. 
    ************************************************************************ 
    INCLUDE <ICON>. 
    TABLES: SMENSAPNEW, SMENSAPT, TSTC.

    DATA: BEGIN OF ITAB OCCURS 10. 
    INCLUDE STRUCTURE SMENSAPNEW. 
    DATA: END OF ITAB. 
    DATA: BEGIN OF STACK OCCURS 10, 
    ID(5) TYPE N, 
    END OF STACK. 
    DATA: I TYPE I. 
    DATA: TEXT LIKE TSTCT-TCODE. 
    PARAMETERS: TRANS LIKE TSTC-TCODE.

    * Get the ID of the Transaction 
    SELECT * FROM SMENSAPNEW WHERE REPORT = TRANS AND CUSTOMIZED = 'S'. 
    MOVE-CORRESPONDING SMENSAPNEW TO ITAB. 
    APPEND ITAB. 
    ENDSELECT. 
    * If transaction is not in SMENSAPNEW 
    IF SY-SUBRC <> 0. 
    * WRITE AT /TRANS COLOR 5. 
    WRITE: /(80) 'Main Menu' COLOR 2. 
    SKIP. 
    WRITE: /'Not in the profile generator''s table'. 
    EXIT. 
    ENDIF.

    * Get the parent ID that links 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 Grandparents... 
    DO. 
    CLEAR ITAB. 
    REFRESH ITAB. 
    SELECT * FROM SMENSAPNEW WHERE OBJECT_ID = STACK-ID AND 
    CUSTOMIZED = 'S'. 
    MOVE-CORRESPONDING SMENSAPNEW 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.

    SELECT SINGLE TTEXT INTO TEXT FROM TSTCT WHERE TCODE = TRANS 
    AND SPRSL = 'EN'.

    * Display the result 
    FORMAT HOTSPOT ON. 
    WRITE: /(80) ICON_DISPLAY_MORE AS ICON,TEXT COLOR 3. 
    HIDE TRANS. 
    CLEAR TRANS. 
    WRITE: ICON_GIS_PAN AS ICON, 
    '<<<< Click on line to go to the transaction'. 
    FORMAT HOTSPOT OFF. 
    SKIP. 
    WRITE: /(80) 'Main Menu' COLOR 2. 
    SORT STACK. 
    LOOP AT STACK. 
    I = I + 3. 
    SELECT SINGLE * FROM SMENSAPT WHERE SPRAS = 'E' 
    AND OBJECT_ID = STACK-ID. 
    WRITE: at /I icon_incoming_object as icon, 
    (80) SMENSAPT-TEXT COLOR 2. 
    ENDLOOP. 
    SKIP 10. 
    FORMAT COLOR 4. 
    WRITE: /80 text-001 right-justified.

    * Display the transaction when the user clicks on trans. 
    AT LINE-SELECTION. 
    IF NOT TRANS IS INITIAL. 
    SELECT SINGLE * FROM TSTC WHERE TCODE = TRANS. 
    CALL TRANSACTION TRANS. 
    ENDIF. 
    CLEAR TRANS.
 

0
相关文章