Midrange News for the IBM i Community


Posted by: Bob Cozzi
Rogue Programmer
Cozzi Productions, Inc.
Chicagoland
Display Cmd String Behind Menu Option: UPDATED
has no ratings.
Published: 02 Oct 2014
Revised: 09 Oct 2014 - 895 days ago
Last viewed on: 22 Mar 2017 (1720 views) 

Using IBM i? Need to create Excel, CSV, HTML, JSON, PDF, SPOOL reports? Learn more about the fastest and least expensive tool for the job: SQL iQuery.

Display Cmd String Behind Menu Option: UPDATED Published by: Bob Cozzi on 02 Oct 2014 view comments

Display Menu Option (DSPMNUOPT) Command

The DSPMNUOPT command writes the CL command behind a menu option to the joblog as a message. Used from Command Entry, the user can view the program or CL command stored behind any classic user-created Menu option. This command supports only the IBM style Menus that use DDS and a message file to store the menu. It does not work with UIM menus or 3rd-party menus.

[UPDATE: I've updated the command since it was originally posted. This version now accepts OPTION(*ALL) for the menu option. When OPTION(*ALL) is specified, all menu options are listed with their corresponding command/program-to-call. In addition the OPTION parameter now defaults to *ALL.]

DSPMNUOPT:  CMD        PROMPT('Display Menu Option')          
                                                                      
            PARM       KWD(MENU) TYPE(QMENU) MIN(1) PROMPT('Menu')    
QMENU:      QUAL       TYPE(*NAME) LEN(10) EXPR(*YES)                 
            QUAL       TYPE(*NAME) LEN(10) SPCVAL((*CURLIB) +         
                         (*LIBL)) DFT(*LIBL) EXPR(*YES) PROMPT('Library')        
            PARM       KWD(OPTION) TYPE(*INT4) DFT(*ALL) RANGE(1 99) + 
                          SPCVAL((*ALL 0)) PROMPT('Menu option')       

The CL routine that drives the DSPMNUOPT command follows:

DSPMNUOPT:  PGM        PARM(&MENU &OPT)                   
            DCL        VAR(&MENU) TYPE(*CHAR) LEN(20)     
            DCL        VAR(&OPT) TYPE(*INT) LEN(4)        
            DCL        VAR(&START) TYPE(*INT) LEN(4)      
            DCL        VAR(&LIMIT) TYPE(*INT) LEN(4)      
            DCL        VAR(&CMDLEN) TYPE(*DEC) LEN(5 0)   
            DCL        VAR(&CMD) TYPE(*CHAR) LEN(132)     
            DCL        VAR(&OPTNBR)  TYPE(*CHAR) LEN(4)   
            DCL        VAR(&MENUKEY) TYPE(*CHAR) LEN(7)   
            DCL        VAR(&MSG) TYPE(*CHAR) LEN(30)      
            DCL        VAR(&OPTION)  TYPE(*CHAR) LEN(2)   
            DCL        VAR(&MENUOPT) TYPE(*CHAR) LEN(132) 
            DCL        VAR(&MSGKEY) TYPE(*CHAR) LEN(4)    
            MONMSG     MSGID(CPF0000)                     
                                                          
            IF (&OPT *GT 0) THEN(DO)                      
               chgvar &start value(&opt)                  
               chgvar &limit value(&opt)                  
            ENDDO
            ELSE DO                                                                   
               chgvar &start value(1)                                                 
               chgvar &limit value(99)                                                
            ENDDO                                                                     
                                                                                      
            DOFOR   VAR(&OPT) FROM(&START) TO(&LIMIT)                                 
              CHGVAR     VAR(&OPTNBR) VALUE(&OPT)                                     
              CHGVAR     VAR(&MENUKEY) VALUE('USR' *CAT &OPTNBR)                      
              SNDPGMMSG  MSGID(&MENUKEY) MSGF(%SST(&MENU 11 +                         
                           10)/%SST(&MENU 01 10)) TOPGMQ(*PRV) +                      
                           MSGTYPE(*INFO) KEYVAR(&MSGKEY)                             
              MONMSG     MSGID(CPF2400 CPF2700)                                       
              RCVMSG     PGMQ(*PRV) MSGTYPE(*INFO) MSGKEY(&MSGKEY) +                  
                           RMV(*YES) MSG(&MENUOPT)                                    
              CHGVAR     VAR(&MSG) VALUE(&MENUOPT)                                    
              IF (&MSG *NE 'Text not available for message') THEN(DO)                 
              CHGVAR     VAR(&OPTION) VALUE(&OPT)                                     
                IF (%SST(&OPTION 1 1) = '0') CHGVAR VAR(%SST(&OPTION 1 1)) VALUE(' ') 
                SNDPGMMSG  MSG(&OPTION *TCAT '.' *BCAT &MENUOPT) +
                             TOPGMQ(*PRV) MSGTYPE(*INFO)          
              ENDDO                                               
            ENDDO
ENDPGM:     ENDPGM                                            

Return to midrangenews.com home page.
Sort Ascend | Descend

COMMENTS