Lesson 01
The shape of a program
COBOL is written in four divisions, always in the same order. The order is the discipline: who wrote it, what machine it runs on, what data exists, and only then what happens.
What to hold onto
- IDENTIFICATION DIVISION names the program.
- ENVIRONMENT DIVISION binds the program to files and hardware.
- DATA DIVISION declares every field before a single instruction runs.
- PROCEDURE DIVISION is the only place logic lives.
- Free-format source (COBOL 2002 and later) removes the old column 7-72 rules, but many shops still keep them.
Source
IDENTIFICATION DIVISION.
PROGRAM-ID. HELLO-LEDGER.
ENVIRONMENT DIVISION.
DATA DIVISION.
WORKING-STORAGE SECTION.
01 WS-GREETING PIC X(30) VALUE "LEDGER OPEN.".
PROCEDURE DIVISION.
MAIN-PARA.
DISPLAY WS-GREETING
STOP RUN.Drill
Rewrite the program so it displays two lines: the greeting and today's literal date. Keep the division order intact.
