You can use the RETURN-CODE special register to pass information between separately compiled programs.
You can set RETURN-CODE in a called program before returning to the caller, and then test this returned value in the calling program. This technique is typically used to indicate the level of success of the called program. For example, a RETURN-CODE of zero can be used to indicate that the called program executed successfully.
Normal termination: When a main program ends normally, the value of RETURN-CODE is passed to the operating system as a user return code. However, AIX restricts user return code values to 0 through 255. Therefore, if for example RETURN-CODE contains 258 when the program ends, AIX wraps the value within the supported range, resulting in a user return code of 2.
Unrecoverable exception: When a program encounters an unrecoverable exception, the user return code is set to 128 plus the signal number. For a nonthreaded program, the run unit is terminated; for a threaded program, the thread in which the program is executing, not the run unit, is terminated.
related tasks
Passing return-code information
related references
RETURN-CODE special register (COBOL for AIX Language Reference)