C ERRCOD BEGSR
C QUSBNC IFGT ð .13/
C\
C\ Process errors returned from the API.
C\
C SETON ð1
C Z-ADD65 LENSTR 155
C MOVELQUSBND MSGIDD
C CALL 'QCMDEXC'
C PARM MSG2
C PARM LENSTR
C END
C ENDSR
The QUSBN error-code data structure is defined in the include file QUSEC (.14/ on
page 3-12), and the program initializes the bytes provided field (QUSBNB) with a
value of 16 (.15/ on page 3-13). This sets the first field of the error code structure
to tell the API not to send an exception but to use the first 16 bytes of the QUSBN
parameter to return the error information. After the CALL to the API, the program
accesses the bytes available (QUSBNC) (.13/ on page 3-14). This contains the
number of bytes of information about the error condition. The program is coded so
that it tests if the number exceeds zero. This is the correct method of determining
whether an error has occurred.
If an error occurred, you may want to handle the error in many different methods.
The program shown extracts the specific error message ID that occurred and sends
the 7-character value as a message. The QUSBN parameter is used for both input
and output (see “Format of an Error Code Structure” on page 3-12). The first 4
bytes are input to the API to tell it how to handle exceptions. The remaining bytes
are output from the API about any exception conditions.
To see the value of the HOLD attribute, use the following call statement to run the
program against the QBATCH job description in library QGPL:
CALL JOBDAPI (QBATCH QGPL)
You should see that the value of the HOLD attribute is *NO:
à ð
Display Messages
System: GENSYS9ð
Queue . . . . . : QPGMR Program . . . . : \DSPMSG
Library . . . : QUSRSYS Library . . . :
Severity . . . : ðð Delivery . . . : \HOLD
Type reply (if required), press Enter.
From . . . : SMITH ð7/23/94 1ð:25:14
HOLD value is \NO
Handling Error Conditions—OPM RPG Example
For this error condition, you should assume that the XYZ job description does not
exist. Use the following call statement to run the error condition:
CALL JOBDAPI (XYZ \LIBL)
You should see that the CPF9801 message (Object not found) was issued:
3-14 System API Programming V4R1