STOP RUN
STOP RUN Example
Scenario - Usage of the STOP RUN in COBOL programming.
Code -
----+----1----+----2----+----3----+----4----+----5----+
IDENTIFICATION DIVISION.
PROGRAM-ID. STOPRUNE.
AUTHOR. MTH.
DATA DIVISION.
WORKING-STORAGE SECTION.
01 WS-AGE PIC 9(3).
PROCEDURE DIVISION.
ACCEPT WS-AGE.
IF WS-AGE >= 18
DISPLAY "Person is an adult."
ELSE
DISPLAY "Person is not an adult."
END-IF.
STOP RUN.
Run JCL -
//MATEPKRJ JOB MSGLEVEL=(1,1),NOTIFY=&SYSUID //********************************************** //* RUN A COBOL PROGRAM //********************************************** //STEP01 EXEC PGM=STOPRUNE //STEPLIB DD DSN=MATEPK.COBOL.LOADLIB,DISP=SHR //SYSOUT DD SYSOUT=* //SYSIN DD * 21 /*
Output -
Person is an Adult
Explaining Example -
In the above example:
- STOPRUNE is the main program and coded with STOP RUN which returns the control to the system where the control is received.
- WS-AGE is the received from run JCL and validates the input, displays the corresponding output.
- Then, the STOP RUN statement is executed, which terminates the program and returns control to the environment that initiated the program.