EXIT PROGRAM Statement

The EXIT PROGRAM statement specifies the end of a called program and returns control to the calling program. It must not be used in the range of a global declarative unless it is in a different program called by the statement in the range of the global declarative.

Read syntax diagramSkip visual syntax diagram
EXIT PROGRAM Statement

>>-EXIT PROGRAM--+---------------------------+-----------------><
                 |                       (1) |   
                 '-AND CONTINUE RUN UNIT-----'   

Notes:
  1. IBM Extension
AND CONTINUE RUN UNIT
Exits the called program without stopping the run unit.

If control reaches an EXIT PROGRAM statement in a program that does not possess the INITIAL attribute while operating under the control of a calling program, control returns to the CALL statement of the calling program.

The program state of the calling program is identical to that which existed at the time it executed the CALL statement except that the contents of data items and the contents of the data files shared between the two programs may have been changed. The program state of the called program is not altered except that the ends of the ranges of all PERFORM statements executed by that called program are considered to have been reached.

The execution of an EXIT PROGRAM statement in a called program that possesses the INITIAL attribute performs an implicit CANCEL of the referenced program.

If control reaches an EXIT PROGRAM statement without the continue phrase in the main program, control passes through the exit point to the next executable statement.

The EXIT PROGRAM statement should appear as the last statement in a series of imperative statements within a sentence.

When there is no next executable statement in a called program, an implicit EXIT PROGRAM statement is assumed, and executed.

The RETURN-CODE special register can be used to pass return code information from a program to its caller. See RETURN-CODE Special Register for further information.