Lesson 1: COBOL Overview, Program Structure, and Coding Form
Learning goals
After studying this lesson, learners should be able to:
- Describe what COBOL is and why it is still used.
- Identify major features of COBOL programs.
- Explain the four main COBOL divisions.
- Read the traditional COBOL coding form and understand Area A and Area B.
What COBOL is
COBOL stands for Common Business-Oriented Language. It was designed mainly for business, finance, government, and administrative data processing. Because many organizations built large, long-running systems in COBOL, the language remains important in legacy systems, especially where reliability and large-volume file processing matter.
COBOL is known for:
- English-like statements such as
ADD,MOVE,READ,WRITE, andDISPLAY. - A highly organized program structure divided into major sections called divisions.
- Strong support for file processing and report generation.
- Fixed-format coding traditions that came from punched-card systems.
A short history of COBOL
COBOL was specified in 1959 by a committee that wanted a common language for business applications. Early COBOL work was influenced by earlier business-oriented languages, including FLOW-MATIC. The first COBOL compilers appeared around 1960, and later standards were published to reduce incompatibilities between vendors.
Important standard milestones include:
- COBOL-68
- COBOL-74
- COBOL-85
- COBOL 2002
Modern COBOL implementations may include features such as object-oriented programming, Unicode support, XML processing, and interoperability with other languages or platforms.
Why COBOL became widely used
COBOL succeeded because it matched the needs of business computing:
- Readability: Many statements resemble English instructions.
- Maintainability: The rigid structure makes old programs easier to inspect and modify.
- Portability: Standard COBOL can be moved across different machines with fewer changes than many machine-specific languages.
- File handling: COBOL is strong at reading, writing, sorting, and producing reports from large files.
- Business-rule focus: COBOL programs often encode rules for payroll, billing, inventory, banking, insurance, and records processing.
Common COBOL features
COBOL programs often have the following characteristics:
- They can be long and verbose compared with programs in C, Java, or Python.
- They are column-sensitive in older fixed-format style.
- They rely heavily on divisions, sections, paragraphs, records, and data descriptions.
- They separate data declarations from processing instructions.
- They use punctuation carefully; in many older examples, periods terminate divisions, sections, paragraphs, and sentences.
COBOL syntax examples
COBOL can express common operations using English-like statements.
ADD YEARS TO AGE.
This is similar in meaning to:
AGE = AGE + YEARS
A COBOL condition may also use abbreviated comparisons. For example:
IF SALARY > 9000 OR > SUPERVISOR-SALARY OR = PREVIOUS-SALARY
This means:
IF SALARY > 9000
OR SALARY > SUPERVISOR-SALARY
OR SALARY = PREVIOUS-SALARY
The hierarchy of COBOL code
COBOL code is organized from small units to large units:
| Unit | Meaning |
|---|---|
| Character | A single symbol, letter, digit, or space. |
| Word | One or more characters forming a COBOL word or user-defined name. |
| Clause | A group of words that describes an attribute of an entry. |
| Statement | A valid instruction, usually beginning with a COBOL verb in the Procedure Division. |
| Sentence | One or more statements ending with a period. |
| Paragraph | One or more sentences under a paragraph name. |
| Section | A named grouping of related paragraphs or entries. |
| Division | A major part of the program. |
The four COBOL divisions
Every traditional COBOL program is organized into four main divisions in this order:
- IDENTIFICATION DIVISION - identifies the program and usually contains the program name.
- ENVIRONMENT DIVISION - describes the computer environment and file assignments.
- DATA DIVISION - defines files, records, constants, variables, and storage areas.
- PROCEDURE DIVISION - contains the executable instructions.
Common sections and paragraphs
A simple COBOL program may use the following structure:
IDENTIFICATION DIVISION
PROGRAM-ID
AUTHOR (optional in older examples)
DATE-WRITTEN (optional in older examples)
DATE-COMPILED (optional in older examples)
ENVIRONMENT DIVISION
CONFIGURATION SECTION
SOURCE-COMPUTER
OBJECT-COMPUTER
SPECIAL-NAMES
INPUT-OUTPUT SECTION
FILE-CONTROL
DATA DIVISION
FILE SECTION
WORKING-STORAGE SECTION
PROCEDURE DIVISION
User-defined paragraphs and statements
For modern learning material, student-facing examples can focus on PROGRAM-ID, file assignment, data definitions, and executable logic rather than author, school, or lab documentation fields.
Traditional 80-column coding form
Older COBOL uses a fixed-format layout based on 80 columns:
| Columns | Area | Purpose |
|---|---|---|
| 1-6 | Sequence area | Historically used for page/line numbers. Usually ignored in modern editing. |
| 7 | Indicator area | Holds special indicators such as comment, page break, or continuation. |
| 8-11 | Area A | Used for division names, section names, paragraph names, and level numbers such as 01. |
| 12-72 | Area B | Used for most statements and subordinate entries. |
| 73-80 | Identification area | Historically used for card identification; ignored by the compiler in fixed format. |
Column 7 indicators
In fixed-format COBOL, column 7 has special meanings:
| Indicator | Meaning |
|---|---|
* | Comment line; ignored by the compiler. |
/ | Page break for listing/report output in older environments. |
- | Continuation of the previous line. |
Area A and Area B
In traditional fixed-format COBOL:
- Area A begins at column 8. Use it for divisions, sections, paragraph names, file descriptions, and level
01records. - Area B begins at column 12. Use it for most statements and subordinate data items.
Example structure:
IDENTIFICATION DIVISION.
PROGRAM-ID. HELLO-WORLD.
PROCEDURE DIVISION.
MAIN-PARAGRAPH.
DISPLAY "Hello, world.".
STOP RUN.
Simple COBOL template
A basic COBOL template can be written as:
IDENTIFICATION DIVISION.
PROGRAM-ID. SAMPLE-PROGRAM.
ENVIRONMENT DIVISION.
INPUT-OUTPUT SECTION.
FILE-CONTROL.
SELECT INPUT-FILE ASSIGN TO "INPUT.DAT".
SELECT OUTPUT-FILE ASSIGN TO "OUTPUT.DAT".
DATA DIVISION.
FILE SECTION.
FD INPUT-FILE.
01 INPUT-RECORD.
05 INPUT-FIELD PIC X(20).
FD OUTPUT-FILE.
01 OUTPUT-RECORD PIC X(80).
WORKING-STORAGE SECTION.
01 EOF-SW PIC 9 VALUE 0.
PROCEDURE DIVISION.
MAIN-PROCEDURE.
STOP RUN.