📝 COBOL Coding Rules
📏 COBOL Coding Structure Breakdown
| Column Range | Area | Purpose |
|---|---|---|
| 1–6 | Sequence/Tag Area | Optional area for sequence numbers; mostly used in traditional coding sheets and some IDEs for sorting/line tracking. |
| 7 | Indicator Area | Special indicators: * (comment), - (continuation), / (new page), D (debugging line). |
| 8–11 | Area A | Divisions, Sections, Paragraphs, FD entries, and level numbers (like 01, 77) must begin in this area. |
| 12–72 | Area B | COBOL executable statements, clauses, and data entries not starting in Area A must begin here. |
| 73–80 | System Use Area | Generally reserved for system-generated information; not used in modern editors. |
📘 Rules to Write COBOL Divisions, Sections, Paragraphs, Sentences, Statements, and Clauses
🔹 Division
-
Must start in Area A.
-
Only four predefined divisions:
IDENTIFICATION,ENVIRONMENT,DATA,PROCEDURE. -
Must be written in upper case, and the spelling must be exact.
-
Divisions must follow a fixed order.
🔹 Section
-
Appears within a Division (mostly in
PROCEDUREandDATAdivisions). -
Section names must begin in Area A.
-
Ends when another Section or Division begins.
-
Optional in small programs, but useful for organizing code into logical blocks.
🔹 Paragraph
-
Begins in Area A with a user-defined name followed by a period (
.). -
Groups related COBOL statements under one label.
-
Paragraph ends when the next paragraph or section starts.
-
Commonly used in the
PROCEDURE DIVISION.
🔹 Sentence
-
A sentence is a group of one or more statements ending with a period (
.). -
Begins in Area B.
-
Sentences exist only in the PROCEDURE DIVISION.
🔹 Statement
-
A single COBOL instruction (e.g.,
MOVE,DISPLAY,PERFORM). -
May stand alone as a sentence or be part of a longer sentence.
-
Starts in Area B, and ends with a period if it is the final statement in a sentence.
🔹 Clause
-
A part of a statement that provides additional meaning or constraints.
-
Examples include
PIC,VALUE,OCCURSin data declarations. -
Clauses do not end with periods and are typically separated by spaces or commas.