Understanding Level Numbers
Level numbers are two-digit numbers, typically written 01 through 49, that appear before every data name in DATA DIVISION and express hierarchy rather than indentation alone. A 01-level entry always starts a new record or standalone item; any level number greater than the previous one and less than 50 declares a field subordinate to the nearest preceding lower-numbered item, regardless of exactly how much they differ, so jumping from 01 to 05 to 10 is just as valid as 01 to 02 to 03. Indentation in source code is purely a human readability convention, since the compiler only reads the numeric value itself to determine nesting, which is why COBOL style guides still insist on consistent indentation to keep large record layouts comprehensible.
Cricket analogy: Level numbers are like a squad's numbered batting order, where the exact gaps between numbers 1, 4, and 7 don't matter mechanically, only that each successive number bats after the one before it in the same innings.
Group Items vs Elementary Items
An elementary item is a data name that carries a PICTURE clause and directly holds data, such as 05 EMP-SALARY PIC 9(7)V99. A group item, by contrast, has no PICTURE clause of its own; it is simply the sum of its subordinate elementary items and is treated as one large alphanumeric field whose size equals the total bytes of everything nested beneath it. This means MOVEing a group item moves the entire concatenated block of bytes at once, ignoring the individual field types of its subordinates, which is a powerful shortcut for copying a whole record but also a common source of bugs when a programmer forgets that a group MOVE is always alphanumeric, not numeric, even if every field inside happens to be numeric.
Cricket analogy: A group item is like an entire innings summary block on a scorecard, a single unit combining runs, wickets, and overs, that gets photocopied as one image even though each number inside means something different.
Special Level Numbers: 66, 77, and 88
Three level numbers break the normal 01-49 hierarchy rules. Level 77 declares a standalone elementary item with no subordinates and no relation to any group, historically used for simple scratch variables, though modern style tends to prefer 01-level items instead. Level 66 introduces a RENAMES clause, letting a programmer create an alternate grouping over an existing set of consecutively defined fields without duplicating storage, for example 66 WS-FULL-NAME RENAMES WS-FIRST-NAME THRU WS-LAST-NAME. Level 88 declares a condition name tied to one or more specific values of its parent item, occupying zero bytes of its own storage, and is what powers readable conditional logic like IF WS-STATUS-APPROVED instead of IF WS-STATUS = 'A', which is by far the most commonly used of the three special levels in modern COBOL code.
Cricket analogy: An 88-level condition name is like a stadium announcer saying Century instead of reading out the raw number 100 from the scoreboard, giving a meaningful label to a specific value.
01 WS-CUSTOMER-RECORD.
05 WS-FIRST-NAME PIC X(15).
05 WS-LAST-NAME PIC X(20).
05 WS-ACCOUNT-STATUS PIC X.
88 WS-STATUS-ACTIVE VALUE 'A'.
88 WS-STATUS-CLOSED VALUE 'C'.
88 WS-STATUS-SUSPENDED VALUE 'S'.
05 WS-BALANCE PIC S9(7)V99.
66 WS-FULL-NAME RENAMES WS-FIRST-NAME THRU WS-LAST-NAME.
77 WS-SCRATCH-COUNT PIC 9(3) VALUE ZERO.
PROCEDURE DIVISION.
IF WS-STATUS-ACTIVE
DISPLAY 'CUSTOMER: ' WS-FULL-NAME
DISPLAY 'BALANCE: ' WS-BALANCE
END-IF.Qualification and Reference Modification
Because two different 01-level records can legally reuse the same subordinate field name, COBOL provides qualification with OF or IN to disambiguate, so WS-STATUS OF WS-CUSTOMER-RECORD refers unambiguously to a specific field even if WS-STATUS also exists inside WS-ORDER-RECORD elsewhere in the same DATA DIVISION. Separately, reference modification lets a programmer extract a substring of any elementary item without declaring a new field, using the syntax identifier(start-position:length), so WS-FULL-NAME(1:5) grabs the first five characters of that group item regardless of its PICTURE clause. Reference modification is especially useful for parsing fixed-format legacy records where a single 20-byte field actually packs three logically distinct sub-values that were never broken out with their own level numbers.
Cricket analogy: Qualification with OF is like distinguishing Kohli of India from a different Kohli playing club cricket for Delhi, using the team name to remove any ambiguity about which player is meant.
The COBOL 2014 standard raised the traditional 49-level subordinate limit's practical depth concerns somewhat, but 01 through 49 remains the working range for hierarchical nesting in virtually all production code; levels above 49 are never used for ordinary group and elementary items.
MOVEing one group item to another only works safely when both groups have byte-for-byte identical internal layouts. If the subordinate PICTURE clauses differ even slightly, a group MOVE silently misaligns the data since COBOL treats the entire operation as alphanumeric, performing no field-by-field conversion.
- Level numbers 01-49 express hierarchy by relative value, not by consecutive numbering or indentation alone.
- An elementary item carries a PICTURE clause and holds data directly; a group item has no PICTURE and is the concatenation of its subordinates.
- MOVEing a group item transfers the entire byte block at once, treated as alphanumeric regardless of the subordinates' actual types.
- Level 77 declares a standalone elementary item with no subordinates or group relationship.
- Level 66 introduces a RENAMES clause to create an alternate grouping over existing consecutive fields.
- Level 88 declares a zero-storage condition name tied to specific values, enabling readable conditional logic.
- Qualification with OF/IN and reference modification with (start:length) resolve ambiguous names and extract substrings.
Practice what you learned
1. What determines whether one data item is subordinate to another in COBOL's DATA DIVISION?
2. What is the defining characteristic of a group item?
3. What kind of MOVE occurs when you MOVE one group item to another?
4. What does a level-88 item declare, and how much storage does it occupy?
5. What does reference modification, written as identifier(start:length), do?
Was this page helpful?
You May Also Like
Data Division Basics
An introduction to the COBOL Data Division, the section of a COBOL program where every variable, file layout, and record structure is declared before any executable logic runs.
Working-Storage Section
How the WORKING-STORAGE SECTION declares a COBOL program's in-memory variables, initial values, flags, and constants that persist for the life of the run unit.
REDEFINES and OCCURS Clauses
How the REDEFINES clause overlays alternate views of the same storage and the OCCURS clause builds arrays and tables in COBOL, including indexing and variable-length tables.
Related Reading
Related Study Notes in Programming
Browse all study notesApache Spark Study Notes
Programming · 30 topics
ProgrammingApache Flink Study Notes
Programming · 30 topics
ProgrammingHadoop Study Notes
Programming · 30 topics
ProgrammingSnowflake Study Notes
Programming · 30 topics
ProgrammingApache Airflow Study Notes
Programming · 30 topics
Programmingdbt (Data Build Tool) Study Notes
Programming · 30 topics