Problem solve Get help with specific problems with your technologies, process and projects.

Know what user pressed what from any system command screen

In any application, you are surely using one of the iSeries system functions or commands (i.e. WRKSPLF, etc). And in some cases you want to easily track down programmatically what user pressed when they left a system command screen, so that you can do next appropriate action. The only way to do that is to use system API. How easy is always the question. Cheers, here is the simple program to make it easy for you. Just make a call to the program below passing a 3-char parameter after calling any system command.

In any application, you are surely using one of the iSeries system functions or commands (i.e. WRKSPLF, etc). And in some cases you want to easily track down programmatically what the user pressed when he left a system command screen, so that you can do next appropriate action. The only way to do that is to use the system API. How easy is always the question. Cheers, here is the simple program to make it easy for you. Just make a call to the program below passing a 3-char parameter after calling any system command. See the code below. Temporarily I have name this program 'CHKF3_F12', but you can name it anyway you want. You can cut and paste the code to your source member and compile.


   
/*  FUNCTION:                                                     */
/*  CHECK IF USER PRESSED F3 OR F12 FROM ANY SYSTEM COMMAND       */
/*  RETURNS PARAMETER VALUE OF 'F3' OR 'F12' ACCORDINGLY.         */
/*                                                                */
/*  Note: This program can be called after running system command */

Pgm &KEYPRESSED

             Dcl        &KEYPRESSED  *CHAR      (     3 )
             Dcl        &JOB         *CHAR      (    26 )  VALUE('*')
             Dcl        &INTJOBID    *CHAR      (    16 )
             Dcl        &JOBINFO     *CHAR      (   350 )
             Dcl        &F3POS       *DEC       (   5 0 )  VALUE(103)
             Dcl        &F12POS      *DEC       (   5 0 )  VALUE(104)
             Dcl        &RTNLEN      *CHAR      (     4 )  VALUE(X'00000000')

             ChgVar     %BIN( &RTNLEN ) ( 350 )
             Call       QUSRJOBI (&JOBINFO &RTNLEN 'JOBI0600' &JOB &INTJOBID)

             ChgVar     &KEYPRESSED '   '

             If         (%SST(&JOBINFO &F3POS 1) = '1') +
                        Then( ChgVar &KEYPRESSED 'F3 ' )

             If         (%SST(&JOBINFO &F12POS 1) = '1') +
                        Then( ChgVar &KEYPRESSED 'F12' )

EndPgm
------test program----
PGM
     DCL &KEY *CHAR (  3 )
     WRKSPLF
     CALL CHKF3_F12  &KEY
     IF (&KEY ª= ' ') THEN(SNDPGMMSG ('YOU PRESSED ' *CAT &KEY))
     IF (&KEY = ' ') THEN(SNDPGMMSG ('YOU PRESSED OTHER KEYS')) ENDPGM
  
  

Dig Deeper on Systems Management Tools

Join the conversation

1 comment

Send me notifications when other members comment.

Please create a username to comment.

that is awesome tip and very useful.
Cancel

-ADS BY GOOGLE

SearchDataCenter

Close