COBOL to Java mapping

This table outlines the mapping between Java™ and certain COBOL fields.

Use of Occurs

  • An OCCURS or OCCURS DEPENDING ON clause causes array accessors to be generated for the data item.
  • COBOL Groups and Redefines are in general flattened. Accessors are generated for the nested data items.
  • When an OCCURS clause is on a Group, flattening does not happen. Instead a Java type is generated for the Group, and array accessors for the new type are generated.
Table 1. COBOL Mapping
COBOL Model Type COBOL usage and compile options Picture string Example Java type
COBOL AlphabeticType DISPLAY A PIC A(20). String
COBOL AlphaNumericType DISPLAY X and combination of A, X, and 9 PIC X(12). String
COBOL NumericType COMP-5 or BINARY, COMP, COMP-4 with TRUNC(BIN) When compile option trunc(bin) is used then the range for a binary number (binary, comp, comp-4) is constrained by the storage limits, not the picture string. Comp-5 is always constrained by the storage limits. Storage limit is determined by the size of the picture string. S9(1) through S9(4) PIC S9 BINARY short
    S9(5) through S9(9) PIC S999999 BINARY. int
    S9(10) through S9(18) PIC S9999999999 BINARY. long
    9(1) through 9(4) PIC 9 BINARY. int
    9(5) through 9(9) PIC 999999 BINARY. long
    9(10) through 9(18) PIC 9999999999 BINARY. BigInteger
    As above with decimal (V or P) PIC S999V9 BINARY. BigDecimal
  DISPLAY, COMP-3, PACKED-DECIMAL or BINARY, COMP, COMP-4 and not TRUNC(BIN) S9(1) through S9(4) 9(1) through 9(4)   short
    S9(5) through S9(9) 9(5) through 9(9)   int
    S9(10) through S9(18) 9(10) through 9(18)   long
    As above with decimal (V or P)   BigDecimal
  DISPLAY, COMP-3, PACKED-DECIMAL and ARITH(extend) S9(19) through S9(31) 9(19) through 9(31)   BigInteger
  DISPLAY, COMP-3, PACKED-DECIMAL and ARITH(extend) S9(19) through S9(31) 9(19) through 9(31) and decimal (V or P).   BigDecimal
COBOL AlphaNumericEdited Type DISPLAY A X 9 B 0 /   String
COBOL NumericEdited Type DISPLAY B P V Z 9 0 / , . + - CR DB * cs   String
COBOL DBCS Type DBCS G, B, or N with DISPLAY-1. PIC G(10). String
COBOL InternalFloat Type COMP-1     float
  COMP-2     double
COBOL ExternalFloat Type   +- 9 . V E 9 PIC +99V9E99. String
Level 88    
  • 05 TXN_Resp_Code PIC X(3)
  • 88 Business_Code value "AAA" through "XXX"
  • 88 Business_Error value "XYX" through "ZYX"
  • 88 Completed_Code value "COM"
Accessor for main element is the get method for each level88.
COBOL National NATIONAL PIC N(8)   String
    PIC NBN   String
    PIC $9.9   String
    PIC +9.9E+99   String
    PIC 999V9   BigDecimal
    PIC S999V9 SIGN LEADING SEPARATE   BigDecimal
    PIC S999V9 SIGN TRAILING SEPARATE   BigDecimal

Feedback