Cobol Data types


Data types

Standard COBOL provides the following data types:
Data typeSample declarationNotes
CharacterPIC X(20)
PIC A(4)9(5)X(7)
Alphanumeric and alphabetic-only
Single-byte character set (SBCS)
Edited characterPIC X99BAXXFormatted and inserted characters
Numeric fixed-point binaryPIC S999V99
[USAGE] COMPUTATIONAL

or
BINARY
Binary 16, 32, or 64 bits (2, 4, or 8 bytes)
Signed or unsigned. Conforming compilers limit the maximum value of variables based on the picture clause and not the number of bits reserved for storage.
Numeric fixed-point packed decimalPIC S999V99
PACKED-DECIMAL
1 to 18 decimal digits (1 to 10 bytes)
Signed or unsigned
Numeric fixed-point zoned decimalPIC S999V99
[USAGE DISPLAY]
1 to 18 decimal digits (1 to 18 bytes)
Signed or unsigned
Leading or trailing sign, overpunch or separate
Numeric floating-pointPIC S9V999ES99Binary floating-point
Edited numericPIC +Z,ZZ9.99
PIC $***,**9.99CR
Formatted characters and digits
Group (record)01 CUST-NAME.
  05 CUST-LAST PIC X(20).
  05 CUST-FIRST PIC X(20).
Aggregated elements
Table (array)OCCURS 12 TIMESFixed-size array, row-major order
Up to 7 dimensions
Variable-length tableOCCURS 0 to 12 TIMES
DEPENDING ON CUST-COUNT
Variable-sized array, row-major order
Up to 7 dimensions
Renames (variant or union data)66 RAW-RECORD
  RENAMES CUST-RECORD
Character data overlaying other variables
Condition name88 IS-RETIRED-AGE
  VALUES 65 THRU 150
Boolean value
dependent upon another variable
Array index[USAGE] INDEXArray subscript
Most vendors provide additional types, such as:
Data typeSample declarationNotes
Numeric floating-point
single precision
PIC S9V9999999ES99
[USAGE] COMPUTATIONAL-1
Binary floating-point (32 bits, 7+ digits)
(IBM extension)
Numeric floating-point
double precision
PIC S9V999ES99
[USAGE] COMPUTATIONAL-2
Binary floating-point (64 bits, 16+ digits)
(IBM extension)
Numeric fixed-point packed decimalPIC S9V999
[USAGE] COMPUTATIONAL-3
same as PACKED DECIMAL
(IBM extension)
Numeric fixed-point binaryPIC S999V99
[USAGE] COMPUTATIONAL-4
same as COMPUTATIONAL or BINARY
(IBM extension)
Numeric fixed-point binary
(native binary)
PIC S999V99
[USAGE] COMPUTATIONAL-5
Binary 16, 32, or 64 bits (2, 4, or 8 bytes)
Signed or unsigned. The maximum value of variables based on the number of bits reserved for storage and not on the picture clause.
(IBM extension)
Numeric fixed-point binary
in native byte order
PIC S999V99
[USAGE] COMPUTATIONAL-4
Binary 16, 32, or 64 bits (2, 4, or 8 bytes)
Signed or unsigned
Numeric fixed-point binary
in big-endian byte order
PIC S999V99
[USAGE] COMPUTATIONAL-5
Binary 16, 32, or 64 bits (2, 4, or 8 bytes)
Signed or unsigned
Wide characterPIC G(20)Alphanumeric
Double-byte character set (DBCS)
Edited wide characterPIC G99BGGGFormatted and inserted wide characters
Edited floating-pointPIC +9.9(6)E+99Formatted characters, decimal digits, and exponent
Data pointer[USAGE] POINTERData memory address
Code pointer[USAGE] PROCEDURE-POINTERCode memory address
Bit fieldPIC 1(n) [USAGE] COMPUTATIONAL-5n can be from 1 to 64, defining an n-bit integer
Signed or unsigned
Index[USAGE] INDEXBinary value corresponding to an occurrence of a table element
May be linked to a specific table using INDEXED BY