Continuation Line Example


Scenario - Explaining how to continue a line if it is more than 72 characters.

Code -

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

       DATA DIVISION.
       WORKING-STORAGE SECTION.                                         
       01 WS-CONT-LINE1 PIC X(160) VALUE "THIS PART IS CONTINUED LINE & 
      -    "THIS PART IS CONTINUTION LINE1............................. 
      -    "THIS PART IS CONTINUTION LINE2".                            
       01 WS-CONT-LINE2 PIC X(080) VALUE "THIS IS CONTINUED LINE &      
      -    "THIS PART IS CONTINUTION LINE1".                            
       01 WS-CONT-LINE3 PIC X(040) VALUE "THIS IS CONTINUED LINE & ".

       PROCEDURE DIVISION.
 
           DISPLAY "Line1: " WS-CONT-LINE1. 
           DISPLAY "Line2: " WS-CONT-LINE2. 
           DISPLAY "Line3: " WS-CONT-LINE3.

           STOP RUN.

Output -

Line1: THIS PART IS CONTINUED LINE & THIS PART IS CONTINUTION LINE1............................. THIS PART IS CONTINUTION LINE2
Line2: THIS IS CONTINUED LINE &      THIS PART IS CONTINUTION LINE1
Line3: THIS IS CONTINUED LINE 

Explaining Example -

In the above example:

  • WS-CONT-LINE1, WS-CONT-LINE2 has the multiline values which spread across the multiple lines using the continution indicator (-).
  • WS-CONT-LINE3 value is single line value.