COBOL Data item declarationCOBOL Procedure Division COBOL Level Numbers
In COBOL, the variable declaration can consists 5 different parts which are provided below.
- Level number
- Variable/data item
- Picture clause
- Data type
Let’s see one example to see which part will call as what.
01 A PIC X(10) VALUE ‘MAINFRAMES’.
Level Number plays most important role in the declaration of the variables in the application programming of COBOL.
Level number describes the hierarchy of the data items/variable declared.
The level numbers includes 01 to 49 and special purpose level numbers 66, 77 and 88.
The level number describes the properties of data declared such as general purpose or special purpose and etc..
The level numbers topic explained in detail here
A variable or identifier or data-name is a name which is used to identify a memory location.
In other words, a variable is a name for the memory location which is allocated.
A Variable is a pointer to the starting memory bytes and up to the bytes declared in Declaration.
The Variables topic explained in detail here
PICTURE clause specifies the characteristics of the elementary items. i.e. type of data item, length etc,.
PICTURE clause comes up with elementary items only.
PICTURE clause should not come with 88 level number, USAGE is COMP-1 & COMP-2.
PICTURE clause can be edited to represent the data in the user expected format.
PICTURE clause editing has two types of Editing to represent the data in user specified format.
The PICTURE clause topic explained in detail here
Data type describes the characteristics of the data items declared in the program.
All data items will be declared in DATA DIVISION. But based on the usage of the data items, declaring sections will change.
There are mainly five data types in COBOL.
- Assumed decimal point
The Data types topic explained in detail here
Value clause defines a value to a data item or conditional name from a literal or from other data item.
Value clause has so many formats to assign the value during the declaration.
The VALUE clause topic explained in detail here
COBOL Procedure Division COBOL Level Numbers