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 have one or more paragraphs. A paragraph may include 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(s)/keyword(s) and an operand(s). A statement specifies an action to be performed.

Statement targets to conditional/unconditional process a task with a combination of COBOL verb/keyword and operands.

A Statement should have COBOL verb/keyword with an operand and may or 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 following paragraph starting or the explicit scope terminator of the same paragraph.

A paragraph can end 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 it. 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 at the end) -

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..." displayed when the Section executed. Because the Section NEW-SEC-DISP has not been followed by any other section and considers its ending is when the program ends. So it considers PARAGRAPH1 as part of the Section and executes PARAGRAPH1 as well.