The Four COBOL Divisions Explained With a Working Program
Every COBOL program has up to four divisions, identification, environment, data and procedure. See what each holds with a complete program and its output.

A COBOL program is not a list of statements run from the top. It is a document with a fixed outline, and the outline has four parts called divisions, always in the same order. Knowing what belongs in each one answers most of the "where do I put this?" questions a new COBOL programmer asks, and it explains why a compiler error often points at a line that looks fine. This post builds a small pay calculation with Enterprise COBOL for z/OS 6.4, names every part as it appears and shows the output. It assumes you have never written COBOL and defines each term the first time it is used. Compiling and running the program on z/OS is the next post's job.
The four divisions in order
| Division | What it holds |
|---|---|
IDENTIFICATION DIVISION | The name of the program |
ENVIRONMENT DIVISION | How the program connects to its surroundings: the computer settings and the files it will use |
DATA DIVISION | Every variable, record layout and file description |
PROCEDURE DIVISION | The statements that do the work |
The order is fixed by the language. A program with no files can leave out the environment division, and a program with no data can leave out the data division, but the ones present keep this order.
The whole program first
IDENTIFICATION DIVISION.
PROGRAM-ID. PAYSLIP.
ENVIRONMENT DIVISION.
DATA DIVISION.
WORKING-STORAGE SECTION.
01 WS-EMPLOYEE-NAME PIC X(20) VALUE 'ADA LOVELACE'.
01 WS-HOURS PIC 9(3) VALUE 160.
01 WS-RATE PIC 9(3)V99 VALUE 25.50.
01 WS-GROSS PIC 9(6)V99.
01 WS-GROSS-OUT PIC ZZZ,ZZ9.99.
PROCEDURE DIVISION.
MAIN-PARA.
COMPUTE WS-GROSS = WS-HOURS * WS-RATE
MOVE WS-GROSS TO WS-GROSS-OUT
DISPLAY 'EMPLOYEE: ' WS-EMPLOYEE-NAME
DISPLAY 'GROSS PAY: ' WS-GROSS-OUT
GOBACK.EMPLOYEE: ADA LOVELACE
GROSS PAY: 4,080.00The first line of output ends with spaces, because the name field is 20 characters long and DISPLAY writes all of it. The pay is 160 hours at 25.50, which is 4,080.00.
Reading the layout of the page
COBOL source on z/OS is fixed-format, and columns carry meaning. The first six columns are for sequence numbers and the compiler ignores them. Column 7 is the indicator area: an asterisk there makes the whole line a comment. Columns 8 to 11 are Area A, where division, section and paragraph names start, along with 01 and 77 level numbers. Columns 12 to 72 are Area B, where statements and the rest of a data description go. Columns 73 to 80 are ignored. That is why every line above begins with seven spaces: the code starts in column 8 or later.
In the program, IDENTIFICATION DIVISION. starts in column 8, as does MAIN-PARA., while COMPUTE starts in column 12.
The identification division
The only required entry is PROGRAM-ID. followed by a name. The name is up to eight characters on z/OS for a program that is link-edited as a load module, since that name becomes the module's member name in the load library. Older programs also have entries such as AUTHOR and DATE-WRITTEN. They are still accepted but are treated as comments and flagged as obsolete, so leave them out of new code.
The environment division
The program above uses no files, so the environment division is empty. When a program reads or writes files, this division is where each file is given a name the program can use, in the INPUT-OUTPUT SECTION and its FILE-CONTROL paragraph. A SELECT ... ASSIGN TO entry links the program's file name to a DD name in the JCL. A later post covers that mapping in detail. The CONFIGURATION SECTION holds machine-related settings and the SPECIAL-NAMES paragraph, which among other things lets you change the decimal point to a comma.
The data division
The data division describes every item the program uses. It has sections, and the one in the example is WORKING-STORAGE SECTION, where ordinary variables live:
FILE SECTIONdescribes the records of files named in the environment division.WORKING-STORAGE SECTIONholds variables that exist for the whole run of the program.LOCAL-STORAGE SECTIONholds variables created fresh on each call.LINKAGE SECTIONdescribes data passed in from a calling program.
A variable is declared with a level number, a name and a picture or PIC clause that gives its size and type. PIC X(20) is 20 characters of any kind. PIC 9(3) is three decimal digits. PIC 9(3)V99 is three digits, an implied decimal point and two more digits: the V is not stored, but the compiler remembers where the point is. PIC ZZZ,ZZ9.99 is an edited picture, which is made for display: Z replaces a leading zero with a space, the comma and the point are printed, and the final 9 always shows a digit.
VALUE sets the starting value. A field without VALUE, like WS-GROSS, has no defined content until the program sets it, so never read a field before you assign it.
The procedure division
The procedure division holds the logic. Its statements are grouped in paragraphs, each starting with a name in Area A and ending with a full stop, and sometimes in sections. This program has one paragraph, MAIN-PARA. Execution starts at the first statement of the division and runs down the page unless a statement such as PERFORM or GO TO redirects it.
The statements used are the basics of the language:
COMPUTE WS-GROSS = WS-HOURS * WS-RATEcalculates a value and stores it.MOVE WS-GROSS TO WS-GROSS-OUTcopies one field to another, and because the target has an edited picture, it formats the number as it copies.DISPLAYwrites to the standard output, which on z/OS isSYSOUT.GOBACKends the program and returns to whatever called it, which is the operating system for a main program.
The last statement of the paragraph carries the full stop. A stray full stop earlier in a paragraph ends the paragraph's scope for statements such as IF, and is a common source of surprising behaviour for beginners.
Why the structure is fixed
The fixed outline looks old-fashioned, but it solves a real problem. The compiler can read all declarations before any statement, so it can lay out storage and check every reference in one pass. A reader can also find everything in one place: to learn what a variable is, look in the data division, and to learn what the program does, read the procedure division. A COBOL program of ten thousand lines keeps the same four-part shape as this one of twenty lines.
Common beginner mistakes
Starting a division name in column 7 or earlier is the first error most people hit, and the compiler reports a message for the line. Writing a statement in Area A instead of Area B is the second: the compiler takes it for a paragraph name. Forgetting the full stop after a division header, a section header or a data description is the third, and it produces a cascade of messages, so fix the first error and recompile before you read the rest.
The language is defined in the Enterprise COBOL for z/OS documentation, in the Language Reference.


