Data Types in COBOL

Data Types:

Data types are used to define the type of variables used in a COBOL program. There are four main data types in Cobol.

COBOL Data Types:

i. Data Name: A data name gives reference to the storage space in the memory where the actual value is stored. This value takes part in the operation when that particular data name is used in the PROCEDURE DIVISION.

Example:
Valid Data Names: NET-SALARY, TOT-MARK

Invalid Data Names: COMPUTE (Reserved word), MULTIPLY (Reserved word)

ii. Level Number: The level number concept is used to describe the hierarchical data structure. A level number is a two-digit number. The allowed level numbers are 01 – 49, 66, 77 and 88. All variables are declared in the working-storage section using appropriate level numbers.

Level NumberDescription
01Record description Entry
02 to 49Group and Elementary Items
66Rename Clause Items
77Items which cannot be sub-divided
88Condition name entry

iii. Picture Clause: The picture clause describes the general characteristics of an elementary data item.

iv. Value Clause: The value clause defines the initial value of the data item. Generally, initialization will be done just before the first statement in the procedure division is executed. It has the following syntax:

VALUE is literal