TSO-ISPF JCL COBOL VSAM DB2 CICS Tools Articles Job Portal Forum Quiz Interview Q&A

COBOL - 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.

GOBACK Statement - Format:

GOBACK

Let see example below,

Main Program Code:

IDENTIFICATION DIVISION.
PROGRAM-ID.    MAINPROG.

ENVIRONMENT DIVISION.

DATA DIVISION.
WORKING-STORAGE SECTION.
 01 INPUT1            PIC 9(02).
 01 INPUT2            PIC 9(02).
 01 OUT-PUT           PIC 9(03).

PROCEDURE DIVISION.
    ACCEPT INPUT1.
    ACCEPT INPUT2.
    CALL 'SUBPROG' USING INPUT1, INPUT2, OUT-PUT.
    DISPLAY OUT-PUT.
    GOBACK.

SUB/Calling Program Code:

IDENTIFICATION DIVISION.
PROGRAM-ID.    SUBPROG.

ENVIRONMENT DIVISION.

DATA DIVISION.
LINKAGE SECTION.
 01 INPUT-1           PIC 9(02).
 01 INPUT-2           PIC 9(02).
 01 OUTPUT            PIC 9(03).

PROCEDURE DIVISION USING INPUT-1,INPUT-2,OUTPUT.
    COMPUTE OUTPUT = INPUT-1 * INPUT-2.
    GOBACK.


If you have any doubts or queries related to this chapter, get them clarified from our Mainframe experts on ibmmainframer Community!

Are you looking for Job Change? Job Portal