When you compare the System/36 JOBQ command with the AS/400 Submit Job (SBMJOB) command, you may be tempted to conclude that the AS/400 is a terribly complicated machine, and may even convince yourself that you will never master it. After all, the JOBQ command had only a few parameters (priority, library, procedure, and procedure parameters), whereas the SBMJOB has a couple dozen, all of which have weird names that do not mean much to you.
Fortunately, however, most parameters in the SBMJOB command have useful defaults that will make it work almost like the JOBQ command did on the S/36. If you still shy away from the SBMJOB command, perhaps you could use our Submit Command (SBMCMD) command, a simplified version of SBMJOB. Like all commands, SBMCMD has an associated processing program (CPP), which is named CMD002CL in this case. The command definition and the CPP are shown in Figures 1 and 2, respectively.
The SBMCMD command has three parameters only. Let's see what they are.
CMD: The command string you are submitting to batch processing. Notice that it has been specified with TYPE(*CMDSTR) command string with a maximum length of 3000 characters. Having MIN(1), the parameter is required.
JOBQ: The name of the job queue where the command will be placed. The default value is QBATCH, which is probably correct in most cases.
JOB: The name of the job you are submitting. It defaults to *CMD, which is interpreted as "give the job the same name as the command being submitted."
One feature worth mentioning is that when you prompt the SBMCMD command with the F4 key, you will get the CMD parameter as the first input field. Placing a command name in this field and pressing F4 again will display the prompt panel for the command you typed in. In other words, it is a prompt within a prompt. We really urge you to try it, as follows.
Type SBMCMD at the command line and press F4. Now type CRTLIB and press F4 a second time. The command prompter will show the CRTLIB prompt panel. Type TESTLIB, then press Enter. The command prompter will return to the SBMCMD prompt panel, showing the complete command string for the CRTLIB command: CRTLIB LIB(TESTLIB).
Now let's look at the command processing program, CMD002CL. First, it validates your input, making sure that the job queue you specified exists and that you are authorized to use it. Then it extracts from the &CMD (command line) variable the ten-character name of the command being submitted. Finally, it submits the job by calling QCMDEXC.
In case you are wondering why the SBMJOB command is not used, it is because SBMJOB does not accept input coming from a variable (such as &CMD) in its CMD parameter. The work-around solution presented here is to build a character string (&SBMJOB) having the entire SBMJOB command line. This character string is built by the previous CHGVAR command using several concatenation operations.
Midrange Computing
TechTalk: An Alternative to SBMJOB
Figure 1 Command SBMCMD
SBMCMD: CMD PROMPT('Submit Command to Batch') PARM KWD(CMD) TYPE(*CMDSTR) LEN(3000) MIN(1) + PROMPT('Command') PARM KWD(JOBQ) TYPE(*SNAME) LEN(10) DFT(QBATCH) + PROMPT('Job queue') PARM KWD(JOB) TYPE(*SNAME) LEN(10) DFT(*CMD) + SPCVAL((*CMD)) PROMPT('Job name')
TechTalk: An Alternative to SBMJOB
Figure 2 CL program CMD002CL
CMD002CL: + PGM PARM(&CMD &JOBQ &JOB) DCL VAR(&CMD) TYPE(*CHAR) LEN(3000) DCL VAR(&JOBQ) TYPE(*CHAR) LEN(10) DCL VAR(&JOB) TYPE(*CHAR) LEN(10) DCL VAR(&CMD_NAME) TYPE(*CHAR) LEN(10) DCL VAR(&VAR_POS) TYPE(*DEC) LEN(4 0) DCL VAR(&STR_POS) TYPE(*DEC) LEN(4 0) DCL VAR(&LENGTH) TYPE(*DEC) LEN(4 0) DCL VAR(&MSGDTA) TYPE(*CHAR) LEN(80) DCL VAR(&SBMJOB) TYPE(*CHAR) LEN(3060) /* Validate input */ CHKOBJ OBJ(&JOBQ) OBJTYPE(*JOBQ) MONMSG MSGID(CPF9801) EXEC(DO) CHGVAR VAR(&MSGDTA) VALUE('Job queue' *BCAT &JOBQ *TCAT ' not + found') GOTO CMDLBL(ERROR) ENDDO CHKOBJ OBJ(&JOBQ) OBJTYPE(*JOBQ) AUT(*USE) MONMSG MSGID(CPF9802) EXEC(DO) CHGVAR VAR(&MSGDTA) VALUE('You are not authorized to use job + queue' *BCAT &JOBQ) GOTO CMDLBL(ERROR) ENDDO /* Extract from &CMD the name of the command being submitted */ CHGVAR VAR(&STR_POS) VALUE(1) CHGVAR VAR(&VAR_POS) VALUE(2) LOOP: + IF COND(%SST(&CMD &VAR_POS 1) *EQ '/') THEN(DO) CHGVAR VAR(&STR_POS) VALUE(&VAR_POS + 1) ENDDO IF COND(%SST(&CMD &VAR_POS 1) *EQ ' ') THEN(DO) CHGVAR VAR(&LENGTH) VALUE(&VAR_POS - &STR_POS) CHGVAR VAR(&CMD_NAME) VALUE(%SST(&CMD &STR_POS &LENGTH)) GOTO CMDLBL(LEAVE) ENDDO CHGVAR VAR(&VAR_POS) VALUE(&VAR_POS + 1) GOTO CMDLBL(LOOP) /* Reject attempts to submit either SBMCMD or SBMJOB to batch */ LEAVE: + IF COND(&CMD_NAME *EQ 'SBMCMD' *OR &CMD_NAME *EQ 'SBMJOB') THEN(DO) CHGVAR VAR(&MSGDTA) VALUE('Command' *BCAT &CMD_NAME *TCAT ' + cannot be submitted to batch.') GOTO CMDLBL(ERROR) ENDDO IF COND(&JOB *EQ '*CMD') THEN(DO) CHGVAR VAR(&JOB) VALUE(&CMD_NAME) ENDDO /* Submit command to batch */ CHGVAR VAR(&SBMJOB) VALUE('SBMJOB CMD(' *CAT &CMD *TCAT ') JOB(' + *CAT &JOB *TCAT ') JOBQ(' *CAT &JOBQ *TCAT ')') CALL PGM(QCMDEXC) PARM(&SBMJOB 3060) SNDPGMMSG MSGID(CPF9898) MSGF(QCPFMSG) MSGDTA('Command' *BCAT + &CMD_NAME *TCAT ' submitted to batch') MSGTYPE(*COMP) GOTO CMDLBL(ENDPGM) /* Send error messages */ ERROR: + SNDPGMMSG MSGID(CPF9898) MSGF(QCPFMSG) MSGDTA(&MSGDTA) + MSGTYPE(*DIAG) SNDPGMMSG MSGID(CPF0002) MSGF(QCPFMSG) MSGTYPE(*ESCAPE) /* End program */ ENDPGM: + ENDPGM
LATEST COMMENTS
MC Press Online