Variables and PICTURE clauses
| Level numbers | |
| PICTURE clauses | |
| VALUE and INITIALIZE |
Level numbers
Every data item starts with a level number from 01 to 49. Level 01 is a record or group, and deeper numbers nest inside it. Level 77 declares a standalone item, and 88 declares a condition name.
01 WS-EMPLOYEE.
05 WS-FIRST-NAME PIC X(20).
05 WS-LAST-NAME PIC X(20).
05 WS-SALARY PIC 9(6)V99.
PICTURE clauses
PICTURE (or PIC) defines the shape of a field. X is an alphanumeric character, 9 is a digit, V is an implied decimal point, and S adds a sign:
01 WS-CODE PIC XX.
01 WS-COUNT PIC 9(4).
01 WS-RATE PIC S9(5)V99.
VALUE and INITIALIZE
VALUE sets a starting value at declaration time. INITIALIZE resets fields to their default values, spaces for X fields and zeros for 9 fields:
01 WS-COUNT PIC 9(4) VALUE 0.
INITIALIZE WS-EMPLOYEE.
Next: Numbers: USAGE, COMP and COMP-3
Article author: Arthur Isaev