There are two methods for passing return codes back from the called program to the calling program. You can use the:
- RETURN-CODE special register. The called program puts a value in the RETURN-CODE register before passing control back to
the calling program with an EXIT PROGRAM or GOBACK statement. The RETURN-CODE register of the calling program is then automatically
updated with the called program's return code and this register can be examined accordingly. The RETURN-CODE register is predefined
as PIC S9(9) COMP; this can be changed using the RTNCODE-SIZE Compiler directive.
- RETURNING or GIVING phrase. The preferred, and more flexible, way of handling return codes is to use the RETURNING or GIVING
phrase of the CALL, EXIT PROGRAM, GOBACK, and STOP RUN statements. This phrase enables you to define the format of the return
code yourself and so cope with whatever size of return code you require.