GOBACK statement

The GOBACK statement functions like the EXIT PROGRAM statement when it is coded as part of a called program and like the STOP RUN statement when coded in a main program.

The GOBACK statement specifies the logical end of a called program.

Format

Read syntax diagramSkip visual syntax diagramGOBACK

A GOBACK statement should appear as the only statement or as the last of a series of imperative statements in a sentence because any statements following the GOBACK are not executed. GOBACK must not be used in a declarative procedure in which the GLOBAL phrase is specified.

If control reaches a GOBACK statement while a CALL statement is active, control returns to the point in the calling program immediately following the CALL statement, as in the EXIT PROGRAM statement.

In addition, the execution of a GOBACK statement in a called program that possesses the INITIAL attribute is equivalent to executing a CANCEL statement referencing that program.

The table below shows the action taken for the GOBACK statement in a main program or a subprogram.

Termination statement Main program Subprogram
GOBACK Returns to the calling program. (Can be the system, which causes the application to end.) Returns to the calling program.