This program retrieves the HOLD value from a job description. It expects errors to be sent as escape messages.
Refer to Example in OPM RPG: Retrieving the HOLD parameter (exception message) for the original example.
D*************************************************************** D*************************************************************** D* D* Program Name: JOBDAPI D* D* Programming Language: ILE RPG D* D* Description: This program retrieves the HOLD value from D* a job description. It expects errors to be D* sent as escape messages. D* D* Header Files Included: QUSEC - Error Code Parameter D* QWDRJOBD - Retrieve Job Description API D* D*************************************************************** D*************************************************************** D* D* Error Code parameter include D* D/COPY QSYSINC/QRPGLESRC,QUSEC D* D* Retrieve Job Description API Include D* D/COPY QSYSINC/QRPGLESRC,QWDRJOBD (2) D* D* Command string data structure D* DCMD_STRING DS D 26 INZ('SNDMSG MSG(''HOLD value is ') D HOLD 10 D 15 INZ(''') TOUSR(QPGMR)') D* D* Miscellaneous data structure D* (4) (2) (3) DRCVLEN S 9B 0 INZ(%SIZE(QWDD0100)) DFORMAT S 8 INZ('JOBD0100') (5) DLENSTR S 15 5 INZ(%SIZE(CMD_STRING)) C* C* Beginning of mainline C* C* Two parameters are being passed into this program C* C *ENTRY PLIST (8) C PARM JOBD 10 C PARM JOBD_LIB 10 C* C* Move the two parameters passed into LFNAM C* C JOBD CAT JOBD_LIB LFNAM 20 (9) C* C* Error Code Bytes Provided is set to 0 C* C Z-ADD 0 QUSBPRV (6) C* C* Call the API. C* C CALL QWDRJOBD C PARM QWDD0100 C PARM RCVLEN C PARM FORMAT C PARM LFNAM C PARM QUSEC C* C MOVEL QWDHJQ HOLD C* C* Let's tell everyone what the hold value was for this job C* C CALL 'QCMDEXC' C PARM CMD_STRING C PARM LENSTR C* C EVAL *INLR = '1' C RETURN C* C* End of MAINLINE C*
Refer to Example in OPM RPG: Handling error conditions for the original example. This example can be written only in OPM RPG and ILE RPG.
D*************************************************************** D*************************************************************** D* D* Program Name: JOBDAPI D* D* Programming Language: ILE RPG D* D* Description: This program retrieves the HOLD value from D* a job description. It expects errors to be D* sent as escape messages. D* D* Header Files Included: QUSEC - Error Code Parameter D* QWDRJOBD - Retrieve Job Description API D* D*************************************************************** D*************************************************************** D* D* Error Code parameter include D* D/COPY QSYSINC/QRPGLESRC,QUSEC D* D* Retrieve Job Description API Include D* D/COPY QSYSINC/QRPGLESRC,QWDRJOBD D* D* Program status DS D* DPGMSTS SDS (12) D MSG_ID 40 46 D* D* Command string data structure D* DCMD_STRING DS D 26 INZ('SNDMSG MSG(''HOLD value is ') D HOLD 10 D 15 INZ(''') TOUSR(QPGMR)') D* D* Miscellaneous data structure D* DRCVLEN S 9B 0 INZ(%SIZE(QWDD0100)) DFORMAT S 8 INZ('JOBD0100') DLENSTR S 15 5 INZ(%SIZE(CMD_STRING)) DNO_JOBD S 47 INZ('SNDMSG MSG(''No such *JOBD - D exists'') TOUSR(QPGMR)') DNO_JOBD_SZ S 15 5 INZ(%SIZE(NO_JOBD)) C* C* Beginning of mainline C* C* Two parameters are being passed into this program C* C *ENTRY PLIST C PARM JOBD 10 C PARM JOBD_LIB 10 C* C* Move the two parameters passed into LFNAM C* C JOBD CAT JOBD_LIB LFNAM 20 C* C* Error Code Bytes Provided is set to 0 C* C Z-ADD 0 QUSBPRV (11) C* C* Call the API. C* C CALL QWDRJOBD 01 (10) C PARM QWDD0100 C PARM RCVLEN C PARM FORMAT C PARM LFNAM C PARM QUSEC C* C* Test for an error on the API call C* C IF *IN01 = *ON C* C* If there was an error, exit to ERROR subroutine C* C EXSR ERROR C* C* Else, process the HOLD value C* C ELSE C MOVEL QWDHJQ HOLD C* C* Let's tell everyone what the hold value was for this job C* C CALL 'QCMDEXC' C PARM CMD_STRING C PARM LENSTR C END C* C EVAL *INLR = '1' C RETURN C* C* End of MAINLINE C* C* Subroutine to handle errors received on the CALL C* C ERROR BEGSR C IF MSG_ID = 'CPF9801' C* C* Process errors returned from the API C* C CALL 'QCMDEXC' C PARM NO_JOBD C PARM NO_JOBD_SZ C END C ENDSR