Program Structure
The period problem: a period ends *all* open scopes (IF, PERFORM, …).
6.1 The four divisions
IDENTIFICATION DIVISION. -- who: program name, optional documentation
ENVIRONMENT DIVISION. -- where: computer, special names, files
CONFIGURATION SECTION.
INPUT-OUTPUT SECTION.
FILE-CONTROL. -- SELECT ... ASSIGN ...
DATA DIVISION. -- what: all data
FILE SECTION. -- record layouts of files
WORKING-STORAGE SECTION. -- static program variables
LOCAL-STORAGE SECTION. -- per-invocation variables
LINKAGE SECTION. -- parameters passed in by a caller
PROCEDURE DIVISION. -- how: the executable logic
sections -> paragraphs -> sentences -> statements6.2 Hierarchy of the PROCEDURE DIVISION
Named group of paragraphs; header ends with SECTION. 1000-INIT SECTION.
Named group of sentences; name in Area A ending with a period
One or more statements ending with a period MOVE 0 TO WS-TOTAL. A single verb with its operands ADD 1 TO WS-COUNT
The period problem: a period ends *all* open scopes (IF, PERFORM, …). Modern style uses scope terminators (END-IF, END-READ, …) and puts a single period at the end of each paragraph.
6.3 A complete skeleton
DECIMAL-POINT IS COMMA swaps the roles of . and , in PICTURE strings and numeric literals (European style). Remove it if you want US-style numbers — it is shown only as an example of SPECIAL-NAMES.
AUTHOR, DATE-WRITTEN, SOURCE-COMPUTER, OBJECT-COMPUTER, etc. are documentation only (obsolete in the 2002 standard but still accepted).
Numbering paragraphs (1000-, 2000-, 9000-) is a widespread convention that makes large programs navigable.
IDENTIFICATION DIVISION.
PROGRAM-ID. SKELETON.
AUTHOR. YOUR-NAME.
DATE-WRITTEN. 2026-01-15.
*
ENVIRONMENT DIVISION.
CONFIGURATION SECTION.
SPECIAL-NAMES.
DECIMAL-POINT IS COMMA.
INPUT-OUTPUT SECTION.
FILE-CONTROL.
* SELECT statements go here (Chapter 21)
*
DATA DIVISION.
FILE SECTION.
WORKING-STORAGE SECTION.
01 WS-COUNTER PIC 9(4) VALUE 0.
*
PROCEDURE DIVISION.
0000-MAIN.
PERFORM 1000-INITIALIZE
PERFORM 2000-PROCESS
PERFORM 9000-TERMINATE
STOP RUN.
*
1000-INITIALIZE.
MOVE 0 TO WS-COUNTER.
*
2000-PROCESS.
ADD 1 TO WS-COUNTER.
*
9000-TERMINATE.
DISPLAY "COUNTER = " WS-COUNTER.6.4 Ending a program
Ends the whole run unit (all programs) and returns to the OS
Returns to the caller; in a main program behaves like STOP RUN. Preferred in modern code EXIT PROGRAM
Returns from a subprogram; ignored (falls through) in a main program