I try to create a command that submit a JOB to QBATCH, after that I want to get the returned JOB number for next command
I try RTVJOBA but it's not right
RTVJOBA retrieve my current USER JOB while the submitted command has different job number
Please help me resolve
I attach code here
PGM
DCL VAR(&TEMPFILE) TYPE(*CHAR) LEN(10)
DCL VAR(&LEVEL) TYPE(*CHAR) LEN(10)
DCL VAR(&USER ) TYPE(*CHAR) LEN(10)
DCL VAR(&JOB ) TYPE(*CHAR) LEN(10)
DCL VAR(&NBR ) TYPE(*CHAR) LEN(06)
DCL VAR(&SBMMSGQ) TYPE(*CHAR) LEN(10)
DCLF FILE(MLIB/PGM_LIST)
RTVJOBA USER(&USER)
RTVJOBA NBR(&NBR )
CHGVAR VAR(&TEMPFILE) VALUE(&USER || '01')
CHKOBJ OBJ(TEMPLIB/&TEMPFILE) OBJTYPE(*FILE)
MONMSG MSGID(CPF9801) +
EXEC(GOTO CMDLBL(NEXT1))
DLTF TEMPLIB/&TEMPFILE
NEXT1: CPYF FROMFILE(LIB/PGM_TEMP) +
TOFILE(TEMPLIB/&TEMPFILE) +
CRTFILE(*YES)
/* ADDLIBLE &LEVEL */
MONMSG MSGID(CPF2110) EXEC(GOTO CMDLBL(ERRMSG1))
MONMSG MSGID(CPF2103)
READ: RCVF RCDFMT(RECORD1)
MONMSG MSGID(CPF0864) EXEC(GOTO CMDLBL(CLOSE))
COBLIST (&PGM_NAME) LEVEL(*FULL) /* submit a job to QBATCH */
RTVJOBA NBR(&NBR)
CPYSPLF FILE(&PGM_NAME) TOFILE(TEMPLIB/&TEMPFILE) +
JOB(&NBR/&USER/&PGM_NAME) +
MBROPT(*ADD) SPLNBR(*LAST)
GOTO READ
CLOSE: CLOSE
/* RMVLIBLE &LEVEL */
GOTO RETURN
ERRMSG1: SNDPGMMSG MSG('LIB NOT FOUND')
GOTO CLOSE
RETURN: RETURN
ENDPGM
the only way I've used to achieve this is using the spawn API, maybe you should take a look of it.
I'm sorry I can't bring you an example, 'cause the only code I made with this API is for my company. But the whole idea is you can spawn several process and get those process id. With this process id you can see if still active.