SECTIONs in COBOL can be required or optional, depending on which DIVISION they are in.
DATA DIVISION.
FILE SECTION.
FD SAMPLE-FILE
01 FILE-NAME PIC X(20).
WORKING-STORAGE SECTION.
01 WS-STUDENT PIC A(10).
01 WS-ID PIC 9(5).
LOCAL-STORAGE SECTION.
01 LS-CLASS PIC 9(3).
LINKAGE SECTION.
01 LS-ID PIC 9(5).
In the above example, 01's are level numbers.
Level number is used to specify the level of data in a record. They are used to differentiate between elementary items and group items. Elementary items can be grouped together to create group items.
DATA DIVISION.
WORKING-STORAGE SECTION.
01 WS-NAME PIC X(25). ---> ELEMENTARY ITEM
01 WS-SURNAME PIC X(25). ---> ELEMENTARY ITEM
01 WS-ADDRESS. ---> GROUP ITEM
05 WS-HOUSE-NUMBER PIC 9(3). ---> ELEMENTARY ITEM
05 WS-STREET PIC X(15). ---> ELEMENTARY ITEM
01 YES-NO PIC X.
88 ANSWER-IS-YES VALUE "Y".
Both of the following conditions test whether YES-NO is equal to "Y":
IF YES-NO = "Y"
IF ANSWER-IS-YES
A level 88 condition name can be used for an alphanumeric or numeric variable.
The PICTURE CLAUSE defines two things about a variable: the size of the variable (the number of bytes used in memory for the value) and the type of data that can be stored in the variable.