COBOL Usage clause/Computations
USAGE clause used to reduce the storage space indirectly increasing the efficiency of the program.
The USAGE clause specifies how the data item being stored internally.
Every variable/data-item declared in COBOL has a USAGE clause.
If no USAGE clause specified, the default USAGE clause would USAGE IS DISPLAY.
The USAGE clause specifies the format of a data item/variable in memory or in a file record.
USAGE clause should not come with 66, 77 and 88 level numbers.
If the USAGE clause is specified at group level, the USAGE clause applies to all elementary levels under the group item.
The below 5 USAGE CLAUSES are regularly in COBOL.
|DISPLAY||9/A/X (default computation)|
|COMP||Numeric Data type (9)|
|COMP-1||Numeric Data type (9)|
|COMP-2||Numeric Data type (9)|
|COMP-3||Numeric Data type (9)|
DISPLAY is the default computation.
DISPLAY internal memory format is ASCII.
The DISPLAY usage clause topic explained in detail here
COMP usage clause will be called as BINARY or COMPUTATION.
COMP usage clause applicable to Numeric data type only.
The Computation topic explained in detail here
COMP-1 usage clause will be called as Floating point.
COMP-1 usage clause is applicable to single floating point data type.
The COMP-1 topic explained in detail here
COMP-2 usage clause will be called as Hexadecimal form.
COMP-2 usage clause applicable to double floating point data type.
The COMP-2 topic explained in detail here
COMP-3 usage clause will be called as packed decimal form.
COMP-3 usage clause is applicable for numeric data type.
The COMP-3 topic explained in detail here
COBOL Data Type Justifications COBOL Display Computation