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

COBOL - STOP RUN Statement


The STOP statement halts execution of the object program either permanently or temporarily.

Statement - Format:

STOP RUN
  1. STOP RUN always coded in the main program.

  2. STOP RUN is the last executable statement in the program which will returns the control back to OS.

  3. When the STOP RUN executed, immediately all running tasks by the program will be closed and control transfers to OS.

  4. STOP RUN closes all opened files in the program.
Tips:

For Example, If STOP RUN coded in the sub program, the control will return to OS instead of returning to main program. In this case, the remaining task coded in main program will be incomplete.


Let see example below,


IDENTIFICATION DIVISION.
PROGRAM-ID.    MAINPROG.
ENVIRONMENT DIVISION.
DATA DIVISION.
WORKING-STORAGE SECTION.
 01 INPUT1            PIC 9(02).
 01 INPUT2            PIC 9(02).
 01 OUTPUT            PIC 9(03).

PROCEDURE DIVISION.
    ACCEPT INPUT1.
    ACCEPT INPUT2.

    COMPUTE OUTPUT = INPUT1 * INPUT2.

    DISPLAY OUTPUT.
    STOP RUN.


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