Continue Statement
Continue Statement Example
Scenario - Add 2000 to salary if it is less than 5000.
Input - 6000
Code -
----+----1----+----2----+----3----+----4----+----5----+
IDENTIFICATION DIVISION.
PROGRAM-ID. CONTINST.
AUTHOR. MTH.
DATA DIVISION.
WORKING-STORAGE SECTION.
01 WS-SALARY PIC 9(04).
PROCEDURE DIVISION.
* Accepting salary amount from input
ACCEPT WS-SALARY.
* Salary is greater than 5000, Do Nothing
IF WS-SALARY GREATER THAN 5000
NEXT SENTENCE
END-IF
COMPUTE WS-SALARY = WS-SALARY + 2000.
* Displaying Salary
DISPLAY "SALARY: " WS-SALARY.
STOP RUN.
Run JCL -
//MATESYD JOB MSGLEVEL=(1,1),NOTIFY=&SYSUID //* //STEP01 EXEC PGM=CONTINST //STEPLIB DD DSN=MATESY.COBOL.LOADLIB,DISP=SHR //SYSOUT DD SYSOUT=* //SYSIN DD * 6000 /*
Output -
SALARY: 6000
Explaining Example -
In the above example:
- The input salary is 6000, which is greater than 5000. So, CONTINUE gets executed, and control transfers to the next statement in the flow (the DISPLAY statement).