Summary -

In this topic, we explain about the Debugging Lines with detailed examples.

Debugging line is a line which only enabled when DEBUGGING MODE is ON. A debugging line is any line with a ‘D’ or ‘d’ in the indicator area (column 7).

For example -

----+----1----+----2----+----3----+----4----+----5----+----6----+----7--
      D    DISPLAY "DEBUGGING MODE ON".                                 
      d    DISPLAY "DEBUGGING MODE END".                                

Debugging lines can be written in the ENVIRONMENT DIVISION, the DATA DIVISION, and the PROCEDURE DIVISION. If a debugging line contains only spaces in Area A and Area B, it is considered a blank line.

For example -

----+----1----+----2----+----3----+----4----+----5----+----6----+----7--
      D                                             

The SOURCE-COMPUTER statement should specify with “DEBUGGING MODE” in the CONFIGURATION-SECTION of ENVIRONMENT DIVISION to enable debugging lines.

For example -

----+----1----+----2----+----3----+----4----+----5----+----6----+----7--
       ENVIRONMENT DIVISION.                                            
       CONFIGURATION SECTION.                                           
       SOURCE-COMPUTER. IBM-370 WITH DEBUGGING MODE.                    
       OBJECT-COMPUTER. IBM-370.                                        

The SOURCE-COMPUTER paragraph describes the computer name on which the source code is to be compiled.

For example -

----+----1----+----2----+----3----+----4----+----5----+----6----+----7--
       ENVIRONMENT DIVISION.                                            
       CONFIGURATION SECTION.                                           
       SOURCE-COMPUTER. IBM-370 WITH DEBUGGING MODE.                    
       OBJECT-COMPUTER. IBM-370.                                        

Syntax -

SOURCE-COMPUTER Paragraph Syntax

computer-name - A system-name.

WITH DEBUGGING MODE

DEBUGGING MODE activates a compile-time switch for debugging lines written in the source text. A debugging line statement compiles only when switch is activated at the compile-time .

For example - DEBUGGING MODE should activated like below during the compilation time.

----+----1----+----2----+----3----+----4----+----5----+----6----+----7-- 
       SOURCE-COMPUTER. IBM-370 WITH DEBUGGING MODE.                    

Successive debugging lines can include in the program, but each line must have a D in column 7. All debugging lines should be syntactically correct.

For example -

----+----1----+----2----+----3----+----4----+----5----+----6----+----7--
      D    DISPLAY "DEBUGGING MODE ON".                                 
      D    DISPLAY "DEBUGGING MODE END".                                

The existence or non-existence of the DEBUGGING MODE clause is logically decided after all COPY and REPLACE statements are processed. Debugging lines can be coded in the ENVIRONMENT DIVISION, DATA DIVISION, and PROCEDURE DIVISION.

If the DEBUGGING MODE on SOURCE-COMPUTER is enabled, the program recognizes all the statements that are having D in the 7th column as part of the code. During the execution, the statements get executed along with the flow.

If the DEBUGGING MODE on SOURCE-COMPUTER is not enabled, the program doesn’t recognize the statements which had D in the 7th column as a part of the code. During the execution, the statements got ignored and not considered.

Practical Example -

Scenario1 - Below example describes how the DEBUGGING LINES enabled in COBOL programming.

Code -

Debugging Lines Code
----+----1----+----2----+----3----+----4----+----5----+----6----+----7--
***************************** Top of Data ******************************
       IDENTIFICATION DIVISION.                                         
       PROGRAM-ID. DEBUGLIN.                                            
       AUTHOR. MTH.                                                     
                                                                        
       ENVIRONMENT DIVISION.                                            
       CONFIGURATION SECTION.                                           
       SOURCE-COMPUTER. IBM-370 WITH DEBUGGING MODE.                    
       OBJECT-COMPUTER. IBM-370.                                        
                                                                        
       DATA DIVISION.                                                   
       WORKING-STORAGE SECTION.                                         
      D 01 WS-VAR1       PIC X(10) VALUE "MAINFRAMES".                  
                                                                        
       PROCEDURE DIVISION.                                              
                                                                        
      D    DISPLAY "DEBUGGING MODE ON".                                 
           DISPLAY "DEBUGGING MODE EXAMLE".                             
      D    DISPLAY "WS-VAR1: " WS-VAR1.                                 
      D    DISPLAY "DEBUGGING MODE END".                                
                                                                        
           STOP RUN.                                                    
**************************** Bottom of Data ****************************

Output -

Debugging Lines Output

Explaining Example -

In the above example, DEBUGGING MODE is ON. So all the statements having D in the 7th column considers as part of the code along with other statements and produces the above result.


Scenario2 - Below example describes how the DEBUGGING LINES disabled in COBOL programming.

Code -

Debugging Lines Code
----+----1----+----2----+----3----+----4----+----5----+----6----+----7--
***************************** Top of Data ******************************
       IDENTIFICATION DIVISION.                                         
       PROGRAM-ID. DEBUGLIN.                                            
       AUTHOR. MTH.                                                     
                                                                        
       ENVIRONMENT DIVISION.                                            
       CONFIGURATION SECTION.                                           
       SOURCE-COMPUTER. IBM-370.                                        
       OBJECT-COMPUTER. IBM-370.                                        
                                                                        
       DATA DIVISION.                                                   
       WORKING-STORAGE SECTION.                                         
      D 01 WS-VAR1       PIC X(10) VALUE "MAINFRAMES".                  
                                                                        
       PROCEDURE DIVISION.                                              
                                                                        
      D    DISPLAY "DEBUGGING MODE ON".                                 
           DISPLAY "DEBUGGING MODE EXAMLE".                             
      D    DISPLAY "WS-VAR1: " WS-VAR1.                                 
      D    DISPLAY "DEBUGGING MODE END".                                
                                                                        
           STOP RUN.                                                    
**************************** Bottom of Data ****************************

Output -

Debugging Lines Output

Explaining Example -

In the above example, DEBUGGING MODE is OFF. So all the statements having D in the 7th column considers as a dummy lines. The statements which are not having D in the 7th column are considers as part of code and produces the above output.