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:
- If the currently running program is a
CALL
’ed subroutine, theGOBACK
statement terminates the execution of the subroutine, and returns control to theCALL
’ing program on the next instruction after theCALL
statement. - If the currently running program is not a
CALL
’ed subroutine, theGOBACK
statement performs theSTOP RUN
operation, terminating the current runtime session. - The statement
GOBACK RETURNING identifier-1
MOVE
'sidentifier-1
to the special return code register, and then performs theGOBACK
statement. - In the statement
GOBACK RETURNING identifier-1
, theRETURNING
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.