Level number
The two-digit number before a COBOL field. It shows which fields sit inside which.
Also written 01 level, 88 level, group item
Why it matters. Records are groups with fields inside them. The level numbers are how COBOL knows the shape.
See it
77 is a stand-alone item. It has no parts.
Syntax
level-number data-name PIC picture [VALUE literal]. 88 condition-name VALUE literal.
- 01
- A record, or a single item on its own.
- 02 to 49
- A field inside the group above. 05, 10 and 15 are the usual steps.
- 66
- RENAMES: gives another name to a range of fields.
- 77
- An independent item with no structure.
- 88
- A condition name: a true or false test on the value of the field above.
Try it LEVEL NUMBER
- 1
In the program LVL, WS-BRANCH is a group. Add the field WS-CITY inside it: 8 characters of text, starting as LONDON. Use level 05.
COBOL 05 WS-CITY PIC X(8) VALUE 'LONDON'. - 2
Run LVL. It shows the whole group, and then WS-CITY on its own.
RUNCOBOL 'ZB0001.DEV.COBOL(LVL)'
Remember
- 01 starts a record. A higher number, up to 49, nests inside the one above it.
- 05, 10, 15 are common. The gaps are on purpose, so you can add a level later.
- A group has no PIC. Only the fields inside it do. Three levels are special: 77 is a single item on its own, 88 names a value (a yes or no test), and 66 renames a range of fields.
The usual mistake
01 WS-CITY PIC X(8).
Level 01 starts a new record. WS-CITY would stand alone, outside WS-BRANCH, and DISPLAY WS-BRANCH would not show it.
05 WS-CITY PIC X(8).
On real z/OS
MF/OS handles levels 01 to 49, 77 and 88 (including VALUE THRU ranges). Level 66 RENAMES is read but skipped.
Where can I practise Level number?
Right here, at ZedBank. You take a junior job at a simulated bank and use Level number in real work, with Zed beside you. There's nothing to install.
Start at ZedBankRelated
- DATA DIVISIONThe part of a COBOL program that declares every record layout and variable it will use.
- PICTURE clauseThe COBOL declaration that says what kind of data a field holds and how long it is, written as PIC.
- WORKING-STORAGEThe section of a COBOL program that declares its internal variables: counters, totals, flags and work areas.
- CopybookA shared block of COBOL declarations kept in a library and included into programs, so a record layout is defined once.
- COBOLThe programming language most business logic on the mainframe is written in. Verbose by design, and still running the world's payments.