IBM Extension

GOBACK Statement

The GOBACK statement functions like the EXIT PROGRAM statement when it is coded as part of a program that is a subprogram in a COBOL run unit, and like the STOP RUN statement when coded in a program that is a main program in a COBOL run unit.

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

GOBACK Statement - 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 statements following the GOBACK statement are not executed.

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.

The RETURN-CODE special register can be used to pass return code information before executing a GOBACK statement. See RETURN-CODE Special Register.

In a multi-threaded environment (for example, when the THREAD(SERIALIZE) PROCESS option has been specified), the GOBACK statement returns to the caller of the program without terminating the thread and run unit. For further information, see the chapter on Preparing ILE COBOL Programs for Multithreading in the IBM® Rational® Development Studio for i: ILE COBOL Programmer's Guide.

For further information about COBOL run units, see the chapter on Calling and Sharing Data Between ILE COBOL Programs in the IBM Rational Development Studio for i: ILE COBOL Programmer's Guide.

End of IBM Extension