The USAGE Clause

The USAGE clause specifies the format of a data item in the computer storage.

General Format

Directives

  1. In addition to Compiler directives which provide flagging and modify the reserved word list, the following directives may impact either the syntax or the semantics described in this section.
    • COBOL370 – controls whether four or eight bytes of storage are allocated to USAGE PROCEDURE-POINTER data items.
    • COMP-5 – controls the handling of the operational sign when storing into a USAGE COMP-5 data item.
    • IBMCOMP – controls the storage allocated for USAGE COMP and USAGE COMP-5 data items.

Syntax Rules

  1. The USAGE clause may be written in any data description entry with a level number other than 66 or 88.
  2. If the USAGE clause is written in the data description entry for a group item, it may also be written in the data description entry for any subordinate elementary item or group item, but the same usage must be specified in both entries.
  3. An elementary data item whose declaration contains, or an elementary data item subordinate to a group item whose declaration contains, a USAGE clause specifying COMPUTATIONAL

    ANS85 , BINARY, PACKED-DECIMAL

    OSVSVSC2MFXOPEN , COMPUTATIONAL-3

    OSVSVSC2MF , COMPUTATIONAL-4

    MFXOPENOS390 , or COMPUTATIONAL-5

    must be declared with a PICTURE character-string that describes a numeric item (i.e. a PICTURE character-string that contains only the symbols "P", "S", "V", and "9"). See the topic The PICTURE Clause.

    MF An elementary data item whose declaration contains no USAGE clause and that is subordinate to a group item whose declaration contains a USAGE clause specifying a format from the list may be declared with a PICTURE character-string that describes an alphabetic, alphanumeric, alphanumeric-edited or numeric-edited data item.

  4. MFXOPENOS390 An elementary data item whose declaration contains, or an elementary data item subordinate to a group item whose declaration contains, a USAGE clause specifying COMPUTATIONAL-5

    MF or COMPUTATIONAL-X

    must be declared with a picture character-string that describes a numeric item

    MF or describes an alphanumeric item with a size of between one and sixteen bytes inclusive. If it describes an alphanumeric item of size 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, or 16 bytes, then this is equivalent to specifying an integer item with 2, 4, 7, 9, 12, 14, 16, 18, 19, 21, 24, 26, 28, 31, 33, 36 or 38 decimal digit positions respectively

    .

    MF The PICTURE character-string can contain up to 38 digit positions.

    MF When COMPUTATIONAL-X is specified and the PICTURE character-string describes a numeric item, then that item must be unsigned.

  5. The BLANK WHEN ZERO, JUSTIFIED and SIGN clauses must not be specified for data items whose usage is not explicitly or implicitly DISPLAY.
  6. The SYNCHRONIZED and VALUE clauses must not be specified for data items whose usage is INDEX.

    OSVSVSC2MF The SYNCHRONIZED clause can be specified for data items whose usage is INDEX.

  7. COMP is an abbreviation for COMPUTATIONAL.

    OSVSVSC2MF COMP-1 is an abbreviation for COMPUTATIONAL-1.

    OSVSVSC2MF COMP-2 is an abbreviation for COMPUTATIONAL-2.

    OSVSVSC2MFXOPEN COMP-3 is an abbreviation for COMPUTATIONAL-3.

    OSVSVSC2MF COMP-4 is an abbreviation for COMPUTATIONAL-4.

    MFXOPENOS390 COMP-5 is an abbreviation for COMPUTATIONAL-5.

    MF COMP-X is an abbreviation for COMPUTATIONAL-X.

  8. An index item can be referenced explicitly only in a SEARCH or SET statement, a relation condition, the USING phrase of a Procedure Division,

    OSVSVSC2MF the USING statement of an ENTRY statement,

    ANS85 an intrinsic function argument

    ISO2002MF the USING phrase of an INVOKE statement, an inline method invocation argument

    ANS85 an INITIALIZE statement

    or the USING phrase of a CALL statement.

  9. ISO2002VSC2MFCOB370  ISO2002VSC2MF A pointer

    MFCOB370 or procedure-pointer

    VSC2MF item can be referenced explicitly only in a SET statement, a relation condition, a CALL statement, the USING phrase of a Procedure Division, the USING statement of an ENTRY statement

    ISO2002 an INVOKE statement, the argument list of an inline invocation of a method, the argument list of a function,

  10. An elementary data item described with usage INDEX,

    ISO2002 OBJECT,

    VSC2MF POINTER,

    MFCOB370 or PROCEDURE-POINTER

    MF EVENT-POINTER, MONITOR-POINTER, MUTEX-POINTER, PROCEDURE-POINTER, SEMAPHORE-POINTER or THREAD-POINTER

    clause must not be a conditional variable.

  11. MF Typedef-name-1 must be previously defined in the same source file as a record with the TYPEDEF clause.
  12. MF If USAGE typedef-name-1 is specified, the following clauses cannot also be specified:
    • BLANK
    • JUSTIFIED
    • PICTURE
    • SIGN
    • SYNCHRONIZED
    • VALUE
  13. MF It is an error to specify USAGE typedef-name-1 if there is an explicit USAGE clause at a higher level in the same hierarchy.