CONTINUE Statement


The CONTINUE statement transfers the control to the immediate COBOL statement that comes next in the program flow. It is a no-operation, and it is a do-nothing statement. It serves no functional purpose in terms of processing logic.

Syntax -

CONTINUE

Points to Note -

  • CONTINUE statement is allowed to code only in the conditional statements like IF, IF..ELSE and EVALAUTE.
  • It is a statement to satisfy syntactic requirements or to improve code readability.

Practical Example -


Scenario - Add 2000 to salary if it is less than 5000.

Code -

----+----1----+----2----+----3----+----4----+----5----+
       IDENTIFICATION DIVISION. 
       PROGRAM-ID. CONTSTMT.
       AUTHOR. MTH.

       DATA DIVISION. 
       WORKING-STORAGE SECTION. 
       01 WS-VAR.
          05 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
              CONTINUE
           ELSE
              COMPUTE WS-SALARY = WS-SALARY + 2000
           END-IF.
      * Displaying Salary
           DISPLAY "SALARY: " WS-SALARY. 
           STOP RUN.

Run JCL -

//MATESYD JOB MSGLEVEL=(1,1),NOTIFY=&SYSUID
//*
//STEP01  EXEC PGM=CONTSTMT
//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, the CONTINUE gets executed and control transfers to the next statement in the flow (DISPLAY statement).