Home
 

 

Example of display mode

The below display shows a typical output after typing WRKPGMINU, using its default parameters of All-User-Library programs.  The display shows a list of interactive and batch jobs which were running the selected programs.

Beside each job is a list of the top five programs that the job had from the most recent program and in reverse order.  From the below display we can see that some users are sitting on the menu program while others are using menu options.  There are also two batch jobs displayed.


For Change mode, use the command RVC userid instead.

 

Example of API #1 - see if the Invoice Run is active

The below CL program checks to see if the ‘Invoice Run’ is being used, and returns an error to the user if it is.  In this example BIL900 represents the invoicing program.  WRKPGIU is the API program and is being used in its 'simple' mode.

PGM
   DCL &INUSE *CHAR 1
   .
   .
   .
   CALL WRKPGIU (‘BIL900’ ‘*LIBL’ &INUSE)
   IF (&INUSE = ‘Y’) DO
      SNDPGMMSG ‘The invoicing program is in use’ +
                TOPGM(*SAME)
      GOTO REDISPLAY
   ENDDO
   .
   .
   .
ENDPGM


Example of API #2 - determine the current & previous program

The below CL program calls the API to retrieve the 2 most recent entries of the call stack.  It then extracts the program and library names of the current and previous programs for display.  RTVCALST is the API and is being used with the backward format '110'.  By using the Backward format, the return array can be a fixed 40 character field - there is no need for array processing.

PGM

   DCL VAR(&PROV) TYPE(*DEC) LEN(5 0) VALUE(2)
   DCL VAR(&AVAL) TYPE(*DEC) LEN(5 0)
   DCL VAR(&RTN)  TYPE(*CHAR) LEN(40)
   DCL VAR(&THSPGM) TYPE(*CHAR) LEN(10)
   DCL VAR(&THSLIB) TYPE(*CHAR) LEN(10)
   DCL VAR(&PRVPGM) TYPE(*CHAR) LEN(10)
   DCL VAR(&PRVLIB) TYPE(*CHAR) LEN(10)

   CALL PGM(RTVCALST) PARM('*' '110' &PROV &AVAL &RTN)

   CHGVAR VAR(&THSPGM) VALUE(%SST(&RTN 01 10))
   CHGVAR VAR(&THSLIB) VALUE(%SST(&RTN 11 10))
   CHGVAR VAR(&PRVPGM) VALUE(%SST(&RTN 21 10))
   CHGVAR VAR(&PRVLIB) VALUE(%SST(&RTN 31 10))

   SNDPGMMSG MSG('This program is ' *CAT &THSLIB *TCAT +
                 '/' *CAT &THSPGM)
   SNDPGMMSG MSG('Calling program is ' *CAT &PRVLIB *TCAT +
                 '/' *CAT &PRVPGM)

ENDPGM

Example output when calling above program:

This program is QTEMP/TEST2
  Calling program is QSYS/QCMD