RETURN-CODE
The RETURN-CODE special register can be used to pass a return code to the calling program or operating system when the current COBOL program ends.
When a COBOL program ends:
- If control returns to the operating system, the value of the RETURN-CODE special register is passed to the operating system as a user return code. The supported user return code values are determined by the operating system, and might not include the full range of RETURN-CODE special register values.
- If control returns to a calling program, the value of the RETURN-CODE special register is passed to the calling program. If the calling program is a COBOL program, the RETURN-CODE special register in the calling program is set to the value of the RETURN-CODE special register in the called program.
The RETURN-CODE special register has the implicit definition:
01 RETURN-CODE GLOBAL PICTURE S9(4) USAGE BINARY VALUE ZERO.
When used in nested programs, this special register is implicitly defined with the GLOBAL clause in the outermost program.
The following examples show how to set the RETURN-CODE special register:
COMPUTE RETURN-CODE = 8.
MOVE 8 to RETURN-CODE.
The RETURN-CODE special register does not return a value from an invoked method or from a program that uses CALL ... RETURNING. For more information, see INVOKE statement or CALL statement.
You can specify the RETURN-CODE special register in a function wherever an integer argument is allowed.
The RETURN-CODE special register does not return information from a service call for a Language Environment® callable service. For more information, see Using Language Environment callable services in the Enterprise COBOL Programming Guide and the Language Environment Programming Guide.