This example expects errors sent as escape messages.
Refer to Example in OPM RPG: Retrieving the HOLD parameter (exception message) for the original example. The following program also works for OPM COBOL.
IDENTIFICATION DIVISION. ***************************************************************** ***************************************************************** * *Program Name: JOBDAPI * *Programming Language: COBOL * *Description: This example expects errors sent as * escape messages. * *Header Files Included: QUSEC - Error Code Parameter * QWDRJOBD - Retrieve Job Description API * ***************************************************************** ***************************************************************** * PROGRAM-ID. JOBDAPI. * ENVIRONMENT DIVISION. CONFIGURATION SECTION. SOURCE-COMPUTER. IBM-AS400. OBJECT-COMPUTER. IBM-AS400. * DATA DIVISION. WORKING-STORAGE SECTION. COPY QUSEC OF QSYSINC-QLBLSRC. * * Retrieve Job Description API Include * COPY QWDRJOBD OF QSYSINC-QLBLSRC. (2) * * Command String Data Structure * 01 COMMAND-STRING. 05 TEXT1 PIC X(26) VALUE 'SNDMSG MSG(''HOLD value is'. 05 HOLD PIC X(10). 05 TEXT2 PIC X(15) VALUE ''') TOUSR(QPGMR)'. * 01 COMMAND-LENGTH PIC S9(10)V99999 COMP-3. 01 RECEIVER-LENGTH PIC S9(9) COMP-4. (4) 01 FORMAT-NAME PIC X(8) VALUE 'JOBD0100'. (5) 01 QCMDEXC PIC X(10) VALUE 'QCMDEXC'. * * Job Description and Library Name Structure * 01 JOBD-AND-LIB-NAME. 05 JOB-DESC PIC X(10). 05 JOB-DESC-LIB PIC X(10). * LINKAGE SECTION. * * Two Parameters are being passed into this program. * 01 JOBD PIC X(10). 01 JOBDL PIC X(10). * PROCEDURE DIVISION USING JOBD, JOBDL. (8) MAIN-LINE. * * Beginning of Mainline * * Move the two parameters passed into JOB-DESC and JOB-DESC-LIB. (9) MOVE JOBD TO JOB-DESC. MOVE JOBDL TO JOB-DESC-LIB. * * Error Code Parameter is set to 0. * MOVE 0 TO BYTES-PROVIDED. (6) * * Receiver Length Set to 390. * MOVE 390 TO RECEIVER-LENGTH. (3) * * Call the QWDRJOBD API. * CALL QWDRJOBD USING QWD-JOBD0100, RECEIVER-LENGTH, FORMAT-NAME, JOBD-AND-LIB-NAME, QUS-EC. * * Move HOLD-JOB-QUEUE to HOLD so that we can display the value using * the command string. * MOVE HOLD-JOB-QUEUE TO HOLD. * * Let's tell everyone what the hold value was for this job. * MOVE 51 TO COMMAND-LENGTH. CALL QCMDEXC USING COMMAND-STRING, COMMAND-LENGTH. * STOP RUN.