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

COBOL - EXIT Program Statement


The EXIT PROGRAM statement specifies the end of a called program and returns control to the calling program.

Syntax:

EXIT PROGRAM

The EXIT PROGRAM statement should appear as the last statement in a series of imperative statements within a sentence.

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.
    STOP RUN.

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.
    EXIT PROGRAM.


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