Specifies the internal format of a numeric field or specifies a date field. Format { DISPLAY } { BYTE } { WORD } { } { LONG } { QUAD } { } { } { {COMP } } { {INTEGER } } { { } } { } { {COMP-1 } } { { } } { {REAL } } { } { { } } { {COMP-2 } } { {DOUBLE } } { } USAGE [IS] { } { G_FLOATING } { } { } { H_FLOATING } { } { S_FLOATING } { } { } { T_FLOATING } { } { } { {COMP-3 } } { {PACKED } } { { } } { } { {COMP-5 } } { { } } { {ZONED } } { } { } { DATE }
1 – Arguments
DISPLAY Indicates that each digit occupies one byte of storage. DISPLAY is the default if you do not include a USAGE clause. BYTE Indicates that field value is stored in binary format and that the value is stored in one byte of storage. WORD Indicates that field value is stored in binary format and that the value is stored in one word (two bytes) of storage. LONG Indicates that field value is stored in binary format and that the value is stored in one longword (four bytes) of storage. QUAD Indicates that field value is stored in binary format and that the value is stored in one quadword (eight bytes) of storage. COMP Indicates that the field value is stored in binary format. INTEGER is a synonym for COMP. The size of a COMP (or INTEGER) field depends on the number of digit positions specified in its PICTURE clause. You can avoid having both a USAGE IS COMP clause and a PICTURE clause by using the keywords WORD, LONG, and QUAD to specify the three types of storage allocation available with COMP. COMP Storage Allocation Types shows the COMP storage allocation types. Table 1-9 COMP Storage Allocation Types Size of PIC Clause Field Alternate USAGE Type 9(1) to 2 bytes WORD 9(4) 9(5) to 4 bytes LONG 9(9) 9(10) to 8 bytes QUAD 9(18) COMP-1 Indicates that the field value is stored in single-precision real format. REAL is a synonym for COMP-1. COMP-1 fields are four bytes long and they correspond to the Oracle CDD/Repository F_ floating-point data types. COMP-2 Indicates that the field value is stored in double-precision real format. DOUBLE is a synonym for COMP-2. COMP-2 fields are eight bytes long and they correspond to the Oracle CDD/Repository D_ floating-point data types. G_FLOATING Indicates that a field is an extended range 64-bit floating-point number with precision to approximately 15 decimal digits. H_FLOATING Indicates that a field is an extended range 128-bit floating- point number with precision to approximately 33 decimal digits. S_FLOATING Indicates that the field is a floating-point number accurate to approximately 7 decimal digits. An S_floating-point field is 4 bytes long. T_FLOATING Indicates that the field is a floating-point number accurate to approximately 15 decimal digits. T_floating-point fields occupy 8 contiguous bytes in memory. COMP-3 Indicates that the field value is stored in packed-decimal format. PACKED is a synonym for COMP-3. The value is stored two digits per byte. The value of a COMP-3 field must contain a sign. The sign occupies the four low-ordered bits in the rightmost byte. The size of the field depends on the number of digit positions specified by the field's PICTURE clause: size (in bytes) = (digit-positions+1)__ 2 For example, a field with three digit positions is two bytes long. If the field contains an even number of digits, the size is rounded up. Thus, a 6-digit field is stored in four bytes. COMP-5 Indicates that the field value is stored in signed decimal format. ZONED is a synonym for COMP-5. A value in a COMP-5 field is stored one digit per byte. Therefore, the size of a COMP-5 field is the number of digit positions specified in its PICTURE clause. The sign of a COMP-5 value shares the rightmost byte with the lowest-valued digit of the value. The lowercase letters P through Y represent a negative sign for the values 0 through 9. DATE Indicates that the field is a date field.
2 – Examples
The following example defines the field SALE_PRICE as a REAL (COMP-1) field: 05 SALE_PRICE PIC 9(5) USAGE REAL EDIT_STRING IS $(6). The following example defines the field SALE_DATE as a date field, to be printed in the default format for date fields: 06 SALE_DATE USAGE IS DATE.