COBOL – Data Types
In programming languages, a data type or simply a type is an attribute of data which is used to explain the compiler or interpreter how the programmer intends to use the data. Every programming language must have data types. So, data types are used to define the type of variables used in a program.
In COBOL program, data division defines the variables used in the program. You must understand the following terms to describe data in the COBOL. Let’s see the following terms:
- Data Name
- Level Number
- Picture Clause
- Value Clause
A level number defines in which position or level, we can define a data in the record.
|01||Record description Entry|
|02 to 49||Group and Elementary Items|
|66||Rename Clause Items|
|77||Items which cannot be sub-divided|
|88||Condition name entry|
Elementary items are the indivisible items. An elementary item contains a level number, picture clause, data name, and value clause (optional).
It is a set of one or more elementary items. A group item contains a level number, data name, and value clause (optional). The level number for group items is always 01.
In the data division section, data names must be specified before they are used in the procedure division.
Data names must have a name specified by the user; the reserved words cannot be used. Data names refer to the memory locations where the actual data is stored. There can be elementary items or group items.
Picture Clause defines the following items:
Data Type: It may be of any type like numeric, alphanumeric, or alphabetic.