Summary -

In this topic, we described about the USAGE Clause/Computations with detailed example.

The USAGE clause specifies the format how the data is stored in memory. USAGE clause used to reduce the storage space and increasing the efficiency of the program.

Every data item declared in COBOL has a USAGE clause directly/indirectly. If the USAGE clause is specified at group level, the USAGE clause applies to all elementary levels under the group item.

The USAGE clause can be specified for a data description entry with any level-number other than 66 or 88. A computational item is a value used in arithmetic operations and must be numeric.

If a group item is defined with a computational usage, the elementary items within the group have that usage.

Syntax -

USAGE Clause Syntax

For data items defined with the DATE FORMAT clause, only usage DISPLAY and COMP-3 are allowed. If no USAGE clause specified, the default USAGE clause is DISPLAY. The PICTURE of a computational item can contain only –

  • 9 - One or more numeric positions
  • S - One operational sign
  • V - One implied decimal point
  • P - One or more decimal scaling positions

The below types of the computations available in COBOL –

ComputationsDescriptions
DISPLAY The data item is stored in character form one character for each byte.
BINARY/ COMP/COMPUTATION Specified for binary data items. This is the equivalent of BINARY.
COMP-1/ COMPUTATION-1 Specified for internal floating-point items (single precision).
COMP-2/COMPUTATION-2 Specified for internal floating-point items (double precision).
COMP-3/COMPUTATION-3/ PACKED-DECIMAL Specified for internal decimal items. This is the equivalent of PACKED-DECIMAL.
COMP-4/COMPUTATION-4 This is the equivalent of BINARY. Same as COMP/BINARY.
COMP-5/COMPUTATION-5 These data items are represented in storage as binary data.