For RPG, the CALL operation specifies the error indicator. Based on whether the
error indicator is on or off, a set of instructions can be processed. The API must
receive an error code parameter that consists of a binary 4 field with a value of
binary zeros (11 on page 3-10). The message ID can be accessed from the
program-status data structure. You would define this as follows:
Iᑍ Program status DS (12 on page 3-9)
IPGMSTS SDS
I 4 46 MSGIDD
If you are going to do something about an error condition, you must test for an
error condition in RPG:
If you use the error-code data structure, test the bytes available field (13 on
page 3-14).
If you let exceptions occur, test the error indicator on the CALL operation (1
on page 3-10).
Because you must test for some condition (one of the error messages in “Error
Messages” on page 3-36), no great difference exists in how you handle error con-
ditions in RPG. The error-code data structure is a little more straightforward (the
program-status data structure is not used). The only disadvantage of the error-
code data structure is that the escape message that occurred was removed from
the job log.
The following program shows how to code for an error condition, test for that condi-
tion, and send a message to the QPGMR message queue if the condition occurs:
Iᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍ
Iᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍ
Iᑍ
IᑍProgram Name: JOBDAPI
Iᑍ
IᑍLanguage: OPM RPG
Iᑍ
IᑍDescriptive Name: Get Job Description
Iᑍ
IᑍDescription: This program handles any errors that are
Iᑍ returned
Iᑍ
IᑍHeader Files Included: QUSEC - Error Code Parameter
Iᑍ QWDRJOBD - Retrieve Job Description API
Iᑍ
Iᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍ
Iᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍ
Iᑍ
Iᑍ Error Code Parameter Include for the APIs
Iᑍ
I/COPY QSYSINC/QRPGSRC,QUSEC
Iᑍ
Iᑍ Retrieve Job Description API Include
Iᑍ
I/COPY QSYSINC/QRPGSRC,QWDRJOBD
Iᑍ Program status DS
IPGMSTS SDS 12
I 4 46 MSGIDD
Iᑍ
Iᑍ Command String Data Structure
Iᑍ
ICMDSTR DS
I I 'SNDMSG MSG(''HOLD - 1 26 CMD1
I 'value is '
I 27 36 HOLD
I I ''') TOUSR(QPGMR)' 37 51 CMD2
Iᑍ
IMSG3 DS
Chapter 3. Common Information across APIs—Basic (OPM) Example
3-9