returnCode

The sysVar.returnCode system variable contains an external return code, as set by your program. A main program uses sysVar.returnCode to pass a return code to the operating system-which might mean JCL, CL, a batch file, or a command processor. A called program uses sysVar.returnCode to pass a return code to a non-EGL program.

It is not possible to pass return codes from one EGL program to another. For example, a non-zero value in sysVar.returnCode does not cause EGL to run an onException block.

The initial value of sysVar.returnCode is zero. For COBOL output, the value must be in the range of 0 to 512, inclusive.

Characteristics

sysVar.returnCode has the following characteristics:
Primitive type
INT
Data length
9
Value saved across segmented converse?
Yes

Example

The following example sets a return code to pass to the operating system.

  sysVar.returnCode = 6;

Compatibility

Table 1. Compatibility considerations for returnCode
Platform Issue
Java™ generation
  • The value of sysVar.returnCode must be in the range -2147483648 to 2147483647, inclusive.
  • sysVar.returnCode is only available from programs invoked via the command line or a script (that is, from a main text program, or a main batch program). The purpose of sysVar.returnCode in this context is to provide a code for the command file or exec that invokes the program.
  • If the program ends with an error that is not under the program's control, the EGL runtime ignores the setting of sysVar.returnCode and attempts to return the value 693.
  • On Windows® you can get the value by checking %ERRORLEVEL% in the command prompt. Other operating systems have similar variables.
  • After a successful call to sysLib.callCmd(), the called command's return code is placed in sysVar.returnCode.
COBOL generation
  • The value of sysVar.returnCode must be in the range 0 to 512, inclusive.
  • sysVar.returnCode contains a code that in most cases is provided to the operating system and to any caller that is not an EGL-generated program. If the program ends with an error that is not handled by your code, the EGL runtime attempts to return a value greater than 512.
  • sysVar.returnCode is implemented using the COBOL RETURN-CODE special register.
CICS® for z/OS® sysVar.returnCode is available after the program ends only if the program is called from another program in the same CICS region and is not invoked by an EXEC CICS LINK command. The return code is meaningful only if the CICS-based program is called (and only if the program is called from a non-EGL-generated program).
IMS/VS sysVar.returnCode is not passed back from main programs.

Feedback