Return code summary
A return code can be returned using the Return code (RTNCDE) parameter on the Retrieve Job Attributes (RTVJOBA) command .
The return code is a 5-digit decimal value with no decimal positions (12345. for example). The decimal value indicates the status of called programs. CL programs do not set the return code. However, you can retrieve the current value of the return code as set by another program in a CL program. You can do this by using the RTNCDE parameter of the Retrieve Job Attributes (RTVJOBA) command.
The following list summarizes the return codes used by languages supported on the IBM® i operating system:
- RPG IV programs
The return codes sent by the RPG IV compiler are:
- 0
- When the program is created
- 2
- When the program is not created
The return codes sent by running RPG IV programs are:
- 0
- When a program is started, or by the CALL operation before a program is called
- 1
- When a program ends with LR set on
- 2
- When a program ends with an error (response of C, D, F, or S to an inquiry message)
- 3
- When a program ends because of a halt indicator (H1-H9)
RPG IV return codes are tested only after a CALL:
- 0 or 1 indicate no error
- 3 gives an RPG IV status code of 231
- Any other value gives an RPG IV status code 202 (call ended in error)
The return code cannot be tested directly by the user in the RPG IV program.
- ILE COBOL and OPM COBOL programs
The return codes sent by running COBOL programs are:
- 0
- By each CALL statement before a program is called
- 2
- When a program receives a function check (CPF9999) or the generic I/O exception handler gets control and there is no applicable USE procedure
COBOL programs cannot retrieve these return codes. For OPM COBOL, a return code value of 2 sends message LBE9001. For ILE COBOL, a return code value of 2 sends message CEE9001.
- ILE C programs
The current value of the integer return code is returned by the last ILE C return statement in an ILE C program.