Summary -

In this topic, we described about the below sections -

COBOL programming language has its own programming structure, and it applies to every program written in COBOL language. The COBOL program structure is hierarchical (Top to Bottom structure). COBOL program structure consists of Divisions, Sections, Paragraphs, Sentences, Statements, and Character strings.

A division may contain one or more sections. A section may contain one or more paragraphs. A paragraph may contain one or more sentences, and a sentence may contain one or more statements. A statement is constructed with one or more character strings. An element in the hierarchy at least contain one or more subordinate elements.

COBOL Program pictorial structure -

COBOL Program Structure

Statements -

The statement is a combination of COBOL verb/keyword and an operand or multiple operands. A statement specifies an action to be taken by the program.

Statement targets to process a task with a combination of COBOL verb/keyword and operands that the process may be conditional or unconditional.

A Statement should have COBOL verb/keyword with an operand and may/may not be marked with a period in the end. All Statements should code in AREA-B but not in AREA-A. All statements code in the PROCEDURE DIVISION.

Below is the list of statements categories in COBOL -

For example -

DISPLAY "PROGRAM EXECUTION STARTS..."

Sentences -

A sentence contains two or more statements and is marked with a period at the end of the last statement. If the first statement is marked with a period in the end, then it is considered a statement but not as a sentence. All sentences should code in AREA-B but not in AREA-A.

For example -

DISPLAY "PROGRAM EXECUTION STARTS..."                        
PERFORM NEW-SEC-DISP.

Paragraphs -

A paragraph is a block of code that contains one or more sentences/a set of statements. A paragraph begins with the paragraph name and ends at the next paragraph starting or the explicit scope terminator of the paragraph. A paragraph can be ended in another way at another section starts, or the program ends. All paragraphs should code in AREA-A.

For example -

PARAGRAPH1.                                                      
    DISPLAY "ENTERING INTO NEW PARAGRAPH...".

Sections -

A section is a block of code that contains one or more paragraphs or a set of sentences, or a block of statements. The section begins with the section name and ends at another section starting, or the program ends. All sections should code in AREA-A.

For example -

NEW-SEC-DISP SECTION.                                            
    DISPLAY "ENTERING INTO NEW SECTION...". 
PARAGRAPH1.                                                      
    DISPLAY "ENTERING INTO NEW PARAGRAPH...".

Divisions -

A division is a block of code that contains one or more sections or sets of sentences or a block of statements. Division begins with division name and ends at the beginning of the subsequent division or when the program ends. All division headers should code in AREA-A. There are four divisions in COBOL -

Click on each division to get more detailed information about each DIVISION. The syntactical hierarchy follows the below form -

Syntactical Hierarchy

Practical Example -

Scenario - Below example describes how the program structure appears in COBOL programming.

Code -

Program Structure Code
----+----1----+----2----+----3----+----4----+----5----+----6----+----7--
***************************** Top of Data ******************************
       IDENTIFICATION DIVISION.                                         
       PROGRAM-ID. PRSTRUCT.                                            
       AUTHOR. MTH.                                                     
                                                                        
       ENVIRONMENT DIVISION.                                            
       INPUT-OUTPUT SECTION.                                            
                                                                        
       DATA DIVISION.                                                   
       FILE SECTION.                                                    
       WORKING-STORAGE SECTION.                                         
       LINKAGE SECTION.                                                 
                                                                        
       PROCEDURE DIVISION.                                              
                                                                        
           DISPLAY "PROGRAM EXECUTION STARTS..."                        
           PERFORM NEW-SEC-DISP.                                        
           STOP RUN.                                                    
                                                                        
       NEW-SEC-DISP SECTION.                                            
           DISPLAY "ENTERING INTO NEW SECTION...".                      
       PARAGRAPH1.                                                      
           DISPLAY "ENTERING INTO NEW PARAGRAPH...".                    
**************************** Bottom of Data ****************************

Output -

Program Structure Output

Explaining Example -

The STATEMENT coding in the program is -

DISPLAY "PROGRAM EXECUTION STARTS..."

The SENTENCE coding in the program is (because the display statement has no period) -

DISPLAY "PROGRAM EXECUTION STARTS..."                        
PERFORM NEW-SEC-DISP.

The PARAGRAPH coding in the program is -

PARAGRAPH1.                                                      
    DISPLAY "ENTERING INTO NEW PARAGRAPH...".

The SECTION calling and section coding in the program is -

NEW-SEC-DISP SECTION.                                            
    DISPLAY "ENTERING INTO NEW SECTION...". 
PARAGRAPH1.                                                      
    DISPLAY "ENTERING INTO NEW PARAGRAPH...".

Note! "ENTERING INTO PARAGRAPH..." printed when the section executed. Because Section consider its end when another section starts or end of the program. In the above program, no other section coded after the NEW-SEC-DISP. So it considers the PARAGRAPH is part of the section.