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