Data Types in COBOL
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.
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.
|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|
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