COBOL and type tree mapping

The COBOL Copybook Importer operation maps data names to type tree names.

The COBOL Copybook data names are converted to type tree names according to the following rules:

  • Characters that are not valid in type tree element names are replaced with the underscore (_) character. For example, the invalid $ character in monthly$total is replaced with the underscore (_) character. Therefore, monthly$total becomes monthly_total.
  • Duplicate names are made unique by appending one or more numeric digits to the names. For example, there are two instances of year. You can make one of the instances year1 and leave the other instance as year.

The COBOL Copybook Importer maps COBOL Copybook data types to type tree elements according to the following table. The importer operation maps FILLER items by appending a number incrementally to the end of the name. Examples are FILLER1, FILLER2, FILLER3, and so on. COBOL Copybook types that are not shown in the table are not supported by the importer.

The following table lists COBOL Copybook data types and the corresponding properties in the resulting type tree.

COBOL Copybook data type Type tree properties
String, length n

Examples of PICTURE clauses for alphanumeric data:


PIC X(n)
PIC A(n)
                        
  • Item Subclass > Text
  • Interpret as > Character
  • Size (content) > Max > Bytes = n
  • Pad > Yes
  • Padded to > Fixed Size
  • Length = n
  • Sized As > Bytes
External decimal, length n, virtual places m

Example of a PICTURE clause for external decimal data:


PIC 9(11)V99
                        
  • Item Subclass > Number
  • Interpret as > Character
  • Presentation > > Zoned
  • Size (digits) > Max > Bytes = n + m
  • Sign > Yes or No
  • Pad > Yes
  • Padded to > Fixed Size
  • Length = n + m
  • Places > Implied = n + m
Packed decimal, length n, virtual places m

Examples of the USAGE clause for packed-decimal data:

  • USAGE COMP-3
  • USAGE PACKED DECIMAL
  • Item Subclass > Number
  • Interpret as > Binary
  • Presentation > > Packed
  • Length = n
  • Implied = m
  • Sign > Yes or No
Integer, length n

For the actual sizes of binary and floating point decimals, see the COBOL Language reference on the IBM website, http://www.ibm.com.

Examples of the USAGE clause for binary integer data:

  • USAGE COMP
  • USAGE COMP-4
  • USAGE COMP-5
  • Item Subclass > Number
  • Interpret as > Binary
  • Presentation > > Packed
  • Length(bytes) = n
  • Implied = m
  • Sign > Yes or No
Float and double

Examples of the USAGE clause for internal floating-point data:

  • USAGE COMP-1 - float, or short, occupying 4 bytes of storage
  • USAGE COMP-2 - double, or long, occupying 8 bytes of storage
  • Item Subclass > Number
  • Interpret as > Binary
  • Presentation > > Integer
  • Length(bytes) = n
  • Sign > Yes or No
External floating point, length n

Example of a PICTURE clause for external floating-point data:


PIC +9(2).9(2)E+99 DISPLAY
                        
  • Item Subclass > Number
  • Interpret as > Binary
  • Presentation > > Float
  • Length(bytes) = 4 or 8
Numeric-edited display, length n

Example of a PICTURE clause for numeric-edited data:


PIC $zz,zz9.99 USAGE DISPLAY
                        
  • Item Subclass > Text
  • Interpret as > Character
  • Size (content) > Max > Bytes = n
  • Pad > Yes
  • Padded to > Fixed Size
  • Sized As > Bystes
National-edited, length n

Example of a PICTURE clause for national-edited data in a date format:


PIC NN/NN/NNNN USAGE NATIONAL
                        
  • Item Subclass > Text
  • Interpret as > Character
  • Size (content) > Max > Bytes = n
  • Pad > Yes
  • Padded to > Fixed Size
  • Length =n
  • Sized As > Bystes
Graphic, length 2 n

Example of a PICTURE clause for graphic (G) data:


PIC G(n)
                        
  • Item Subclass > Text
  • Interpret as > Character
  • Size (content) > Max > Bytes = n
  • Pad > Yes
  • Padded to > Fixed Size
  • Length =2n
  • Sized As > Bystes
  • National Language > Data language > UTF-16
FUNCTION-POINTER, length n

Example of a FUNCTION-POINTER USAGE clause:


FP USAGE FUNCTION-POINTER
                        
  • Item Subclass > Text
  • Interpret as > Character
  • Size (content) > Max > Bytes = n
  • Pad > Yes
  • Padded to > Fixed Size
  • Length =n
Note: The COBOL Copybook Importer is not supported on Linux®.