Summary -

In this topic, we described about the Continuation Line with detailed example.

Any sentence, entry, clause or phrase that requires more than one line can be continued in Area B of the next line. Continuation line is neither a comment line nor a blank line.

The line being continued is a continued line and the succeeding lines are continuation lines. Area A of a continuation line must be blank.

For example -
Continuation Line Code

If there is no hyphen (-) in the indicator area (column 7) of a line, the last character of the preceding line is assumed to be followed by a space.The items with DBCS cannot be continued.

For example -
Continuation Line Code

The pseudo-text delimiter separator (==), the floating comment indicator (*>) or the compiler directive indicator (>>) have two characters to represent should not be separated and must be on the same line.

For example - Wrong representation
----+----1----+----2----+----3----+----4----+----5----+----6----+----7--
           COPY COPYBOOK REPLACING ==:WS:== BY ==WS1=
      -    =.    

Rules for Alphanumeric literals continuation lines -

  • If the continued line contains an alphanumeric literal without a closing quotation mark/apostrophe, all spaces at the end of the continued line (through column 72) are part of the literal.
    For example -
    Continuation Line Code
    The continuation line must contain a hyphen (-) at 7th column and the first nonblank character must be a quotation mark/apostrophe.
    For example -
    Continuation Line Code
    The continuation of the literal begins with the character immediately following the quotation mark/apostrophe.
    For example -
    Continuation Line Code
  • If an alphanumeric literal that is to be continued on the next line has as its last character a quotation mark/apostrophe in column 72, the continuation line must start with two consecutive quotation marks/apostrophe.
    For example -
    Continuation Line Code
  • This results the quotation mark/apostrophe considered as a part of the value of the literal.
  • If the last character on the continued line of an alphanumeric literal is a quotation mark/apostrophe in Area B, the continuation line can start with a quotation mark/apostrophe. This results two consecutive literals instead of one continued literal. For example -
    Continuation Line Code

Practical Example -

Scenario - Below example describes different ways of continution lines usage in COBOL programming.

Code -

Constant program Code
----+----1----+----2----+----3----+----4----+----5----+----6----+----7--
***************************** Top of Data ******************************
       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(120) VALUE "THIS IS CONTINUED LINE &      
      -    " THIS PART IS CONTINUTION LINE1".                           
                                                                        
       01 WS-CONT-LINE3 PIC X(120) VALUE "THIS PART IS CONTINUED LINE &"
      -    ""THIS PART IS CONTINUTION LINE1".                           
                                                                        
       01 WS-CONT-LINE4 PIC X(120) VALUE "THIS IS CONTINUED LINE & ".
                                                                        
       PROCEDURE DIVISION.                                              
           DISPLAY "DISPLAYING CONTINUTION LINE1: " WS-CONT-LINE1.      
           DISPLAY "DISPLAYING CONTINUTION LINE2: " WS-CONT-LINE2.      
           DISPLAY "DISPLAYING CONTINUTION LINE3: " WS-CONT-LINE3.      
           DISPLAY "DISPLAYING CONTINUTION LINE4: " WS-CONT-LINE4.      
                                                                        
           STOP RUN.                                                    
**************************** Bottom of Data ****************************

Output -

Constant program Output

Explaining Example -

In the above example, we have shown different ways of coding continution lines in COBOL programming.