Skip to content

GOBACK Statemen

The GOBACK statement ends a program. If the program is a CALL'ed program, control is returned to the CALL'ing program. Otherwise, the program terminates.

General Format:

GOBACK [RETURNING] [identifier-1].

Syntax:

Identifier-n is a numeric or alphanumeric literal or data item.

General Rules:

  1. If the currently running program is a CALL’ed subroutine, the GOBACK statement terminates the execution of the subroutine, and returns control to the CALL’ing program on the next instruction after the CALL statement.
  2. If the currently running program is not a CALL’ed subroutine, the GOBACK statement performs the STOP RUN operation, terminating the current runtime session.
  3. The statement GOBACK RETURNING identifier-1 MOVE's identifier-1 to the special return code register, and then performs the GOBACK statement.
  4. In the statement GOBACK RETURNING identifier-1, the RETURNING phrase is optional.

Code Sample:

       IDENTIFICATION DIVISION. 
       PROGRAM-ID. GOBACK-1. 
       ENVIRONMENT DIVISION. 
       DATA DIVISION. 
       WORKING-STORAGE SECTION. 
       77 DUMMY      PIC X. 
       PROCEDURE DIVISION. 
       MAIN. 
              DISPLAY "GOBACK-1 FINISHED!" LINE 10 COL 10. 
              ACCEPT DUMMY LINE 10 COL 30. 
              GOBACK.
Back to top