Master Mainframe Technologies - COBOL, JCL, DB2, VSAM, CICS & More
ABEND Codes SQLCODEs File Status Interview Prep Contact
💻 COBOL

COBOL CONTINUE and NEXT SENTENCE

Beginner 🕑 6 min read 👁 0 views

COBOL CONTINUE and NEXT SENTENCE

The CONTINUE and NEXT SENTENCE statements provide flow control in conditional structures.

CONTINUE Statement

```cobol IF condition CONTINUE ELSE statement END-IF ```

CONTINUE is a no-operation placeholder that explicitly does nothing. Use it when syntax requires a statement but no action is needed.

NEXT SENTENCE

```cobol IF condition NEXT SENTENCE ELSE statement. ```

NEXT SENTENCE transfers control to the statement following the next period. It's considered obsolete in structured programming.

Key Differences

  • CONTINUE respects END-IF scope
  • NEXT SENTENCE jumps to next period (ignores END-IF)
  • CONTINUE is preferred for modern COBOL

Best Practices

  • Use CONTINUE instead of NEXT SENTENCE
  • Avoid NEXT SENTENCE in structured code
  • Use CONTINUE as a placeholder during development

Code Example

       IDENTIFICATION DIVISION.
       PROGRAM-ID. CONTINUE-DEMO.
       DATA DIVISION.
       WORKING-STORAGE SECTION.
       01 WS-CODE PIC X VALUE 'A'.
       PROCEDURE DIVISION.
      * Using CONTINUE
           IF WS-CODE = 'A'
               CONTINUE
           ELSE
               DISPLAY 'Not A'
           END-IF
           
      * Better than empty IF
           IF WS-CODE = 'B'
               CONTINUE
           END-IF
           
           DISPLAY 'Program continues'
           STOP RUN.