Summary -

In this topic, we described about the below sections -

A comment line is any line that starts with comment character (*, /) in column-7 or starts with character string *> in the program text area (either in Area-A or Area-B).

Note! Slash (/) is print stopper indicator. However, the line with / also treats as comment during the program execution.

A comment line can have a floating comment indicator (*>) as the first character-string in the program text area (either in Area A or Area B).

For example -

----+----1----+----2----+----3----+----4----+----5----+----6----+----7-- 
       01 WS-VAR        PIC X(12).    *> INLINE COMMENT in Area-B    
	   
	    *> INLINE COMMENT starts in Area-A

A comment line can be created with a combination of any allowed computer characters. i.e, A-Z, a-z, 0-9, and all computer-supported characters.

For example -

----+----1----+----2----+----3----+----4----+----5----+----6----+----7--
      * daakfa;kfaf *&%$#2)() - Valid Comment         

Comment lines can be placed anywhere in a program.

For example -

----+----1----+----2----+----3----+----4----+----5----+----6----+----7--
      * THIS IS COMMENT1                        
                                                                        
       DATA DIVISION.  
       WORKING-STORAGE SECTION.

      * THIS IS COMMENT2 

       PROCEDURE DIVISION.

      * THIS IS COMMENT3 	   

Each comment lines must begin with an asterisk (*) or a slash (/) in the indicator area, or with a floating comment indicator (*>).

For example -

----+----1----+----2----+----3----+----4----+----5----+----6----+----7--
                                                                        
      * FULL LINE COMMENT WITH * IN COLUMN-7.  
      / PRINTER ESCAPE LINE COMMENT .   
                                                                        
       DATA DIVISION.                                                   
       WORKING-STORAGE SECTION.
	   
       01 WS-VAR        PIC X(12).    *> INLINE COMMENT  

The compiler treats a comment line as documentation and does not check for syntax errors.

Practical Example -

Scenario - Below example describes how the comments added in COBOL programming.

Code -

Comments program Code
----+----1----+----2----+----3----+----4----+----5----+----6----+----7--
***************************** Top of Data ******************************
       IDENTIFICATION DIVISION.                                         
       PROGRAM-ID. COMMENTS.                                            
                                                                        
       AUTHOR. THE PROGRAM WRITTEN BY MAINFRAMESTECHHELP FOR            
               EXPLAINING ABOUT COMMENTS IN DETAIL.                     
       INSTALLATION. 01-JAN-2000.                                       
       DATE-WRITTEN. 11-MAY-2021.                                       
       DATE-COMPILED. 11-MAY-2021.                                      
       SECURITY. NORMAL.                                                
                                                                        
       DATA DIVISION.                                                   
       WORKING-STORAGE SECTION.                                         
                                                                        
      * FULL LINE COMMENT WITH * IN COLUMN-7.                           
      / FULL LINE COMMENT WITH / IN COLUMN-7.                           
                                                                        
       01 WS-VAR        PIC X(12).                                      
                                                                        
       PROCEDURE DIVISION.                                              
                                                                        
      * FULL LINE COMMENT IN THE PROCEDURE DIVISION                     
           DISPLAY "SPECIFYING COMMENTS IN THE PROGRAM".                
                                                                        
           STOP RUN.                                                    
**************************** Bottom of Data ****************************