COBOL program structureCOBOL Coding Sheet COBOL Divisions
The structure of the COBOL applies for COBOL Source program which has set of syntactically correct set of statements.
In other words, COBOL source program contains set of syntactically correct set of statements.
COBOL programs contains hierarchical in structure which was shown in the below diagram.
The COBOL program hierarchy consists of Divisions, Sections, Paragraphs, Sentences and Statements.
In other words, Each Division may contain one or more Sections, Each Section may contain one or more Paragraphs, each Paragraph contains one or more Sentences, and each Section contains one or more Statements.
Each element of the hierarchy consists of one or more subordinate elements.
COBOL Program pictorial structure:
Let's start discussing in reverse order starting from statements to understand better.
A statement consists of a COBOL verb and an operand or operands describes about COBOL verb process on the operands either it may be a condition or unconditional.
A Statement should have COBOL verb with an operand and may/may not marked with period at the end.
All Statement should code in the AREA B and should not in AREA A.
There are four categories of Statements in COBOL.
• Delimited scope
• Compiler directing.
Statements can be explained in detail here.
ADD A TO B GIVING C.
As stated above, a sentence contains of one or more statements and those are marked with a period at the last line.
If those are marked with a period in middle, then it will be treated as Statement and those are not considered as Sentence.
All Sentences also should code in AREA B not in AREA A.
MOVE A TO TEMP MOVE B TO A MOVE TEMP TO B.
A paragraph is a block of code which contains one or more sentences/a set of Statements.
A paragraph begins with the paragraph name and ends at the next paragraph starting.
A paragraph can be ended in another way at another section starts or at the end of the program.
All paragraphs should code in the AREA A.
A section is a block of code which contains one or more paragraphs or a set of Sentences or a block of Statements.
Section begins with the section name and ends at another section starting or at the end of the program.
All Sections should code in the AREA A.
A division is a block of code, which contains one or more sections or set of Sections or set of Sentences or a block of Statements.
Division begins with division name and ends at the beginning of the next division or at the end of the program.
All Divisions should code in the AREA A.
There are actually four divisions in COBOL.
Click on each division to get more detailed information about each DIVISION.
A simple program to display the flow of program structure
Above one is the best example for complete cobol structure.
The below is the STATEMENT coding in the above program
DISPLAY 'COBBODY PROGRAM EXECUTION STARTS....'
The below is the SENTENCE coding in the above program
DISPLAY 'COBBODY PROGRAM EXECUTION STARTS....' PERFORM NEW-SEC-DISP.
The below is the PARAGRAPH coding in the above program
PARAGRAPH. DISPLAY 'ENTERING INTO PARAGRAPH...'.
The below is the SECTION calling and section coding in the above program
NEW-SEC-DISP SECTION. DISPLAY 'ENTERING INTO NEW SECTION..'. PARAGRAPH. DISPLAY 'ENTERING INTO PARAGRAPH...'.
The below are the DIVISIONS of Cobol program
IDENTIFICATION DIVISION ENVIRONMENT DIVISION DATA DIVISION PROCEDURE DIVISION
Note:   "ENTERING INTO PARAGRAPH..." will be printed when the section executed. Because Section always consider its end when another section starts or end of the program. In the above program, no other section coded of the NEW-SEC-DISP. So it will consider the PARAGRAPH is part of the section.
COBOL Coding Sheet COBOL Divisions