DATA DIVISION
The part of a COBOL program that declares every record layout and variable it will use.
Also written DATA DIVISION, file section
The DATA DIVISION is where a COBOL program describes its data before using any of it. Nothing is declared on the fly; everything the program touches is laid out here first.
It has two main sections. FILE SECTION describes the records of each file the program reads or writes, giving the exact layout of every field. WORKING-STORAGE SECTION declares the variables the program uses internally: counters, totals, flags, work areas and constants.
Each item is declared with a level number showing how it nests, a name, and a picture clause saying what kind of data it holds and how long it is. Group items contain other items, so a customer record can be declared as a structure of fields, which is precisely how business records are shaped.
In real programs this division is often longer than the logic that follows it, and that is normal. Much of understanding an unfamiliar COBOL program comes from reading its DATA DIVISION carefully first, because the record layouts tell you what the program is actually about.
Related terms
- COBOL divisionsThe four fixed sections every COBOL program is built from, always in the same order.
- WORKING-STORAGEThe section of a COBOL program that declares its internal variables: counters, totals, flags and work areas.
- PICTURE clauseThe COBOL declaration that says what kind of data a field holds and how long it is, written as PIC.
- Level numberThe two-digit number in front of a COBOL data item that shows how fields nest inside a record.
- CopybookA shared block of COBOL declarations kept in a library and included into programs, so a record layout is defined once.
- File descriptionThe FD entry in a COBOL program that describes a file's records, connecting the program to data supplied by the JCL.