Imagine you've just compiled a program through PDM (it happens). Now you need to test it in a batch environment. This replaces keying the SBMJOB command with a PDM option and also works from the command line as SBMPGM.
PDM options file : Option = 'SB' (or whatever) Command = SBMPGM PROGRAM(*LIBL/&N) PROMPT(*YES)
COMMAND Source:
CMD PROMPT('Submit a pgm')
PARM KWD(PROGRAM) TYPE(PGMD) PROMPT('Program name')
PARM KWD(PROMPT) TYPE(*CHAR) LEN(4) RSTD(*YES) +
DFT(*NO) VALUES(*NO *YES) MIN(0) +
CHOICE('Prompt for additional parms?')
PGMD: QUAL TYPE(*NAME)
QUAL TYPE(*NAME) DFT(*LIBL) SPCVAL((*LIBL)) +
PROMPT('Library name')
CL PROGRAM source (some leading blanks removed)
PGM PARM(&PGM.LIB &PROMPT)
Requires Free Membership to View
Register today to access targeted resources from our editorial writers and independent industry experts including news, tips, and advice to help you do your job more efficiently and effectively. Stay informed on the hottest topics and biggest challenges faced by IT professionals working with iSeries products and services.
DCL VAR(&PGM) TYPE(*CHAR) LEN(10)
DCL VAR(&LIB) TYPE(*CHAR) LEN(10)
DCL VAR(&JOBNAME) TYPE(*CHAR) LEN(10)
DCL VAR(&PROMPT) TYPE(*CHAR) LEN(4)
DCL VAR(&PROMPTSTR) TYPE(*CHAR) LEN(300)
DCL VAR(&PROMPTLNG) TYPE(*DEC) LEN(15 5) VALUE(300)
DCL VAR(&MSGKEY) TYPE(*CHAR) LEN(4)
DCL VAR(&MSGTYPES) TYPE(*CHAR) LEN(10) +
VALUE('*COMP')
DCL VAR(&TYPECOUNT) TYPE(*CHAR) LEN(4) +
VALUE(X'00000001')
DCL VAR(&STACKENTRY) TYPE(*CHAR) LEN(10) VALUE('*')
DCL VAR(&STACKCOUNT) TYPE(*CHAR) LEN(4) +
VALUE(X'00000001')
DCL VAR(&ERRORDS) TYPE(*CHAR) LEN(4) +
VALUE(X'00000000')
CHGVAR &PGM VALUE(%SST(&PGM.LIB 1 10))
CHGVAR &LIB VALUE(%SST(&PGM.LIB 11 10))
/* setup the SBMJOB cmd */
CHGVAR VAR(&PROMPTSTR) VALUE('SBMJOB ' *CAT &PGM +
*CAT ' CMD(CALL ' *CAT &LIB *TCAT '/' +
*CAT &PGM *CAT ')')
/* if prompt = *yes, add a '?' */
IF COND(&PROMPT *EQ *YES) THEN(DO)
CHGVAR VAR(&PROMPTSTR) VALUE('?' *CAT &PROMPTSTR)
ENDDO
/* do it */
CALL PGM(QCMDEXC) PARM(&PROMPTSTR &PROMPTLNG)
/* send back the resulting message */
CALL PGM(QMHMOVPM) PARM(&MSGKEY &MSGTYPES +
&TYPECOUNT &STACKENTRY &STACKCOUNT &ERRORDS)
ENDPGM
This was first published in March 2001