COBOL | Java |
---|---|
Elementary COBOL types | |
PIC X | byte |
PIC X(n) DISPLAY
PIC N(n) NATIONAL PIC U(n) UTF-8 |
String |
PIC S9(n) COMP-5, where ≥ 1 n ≤ 4 | short |
PIC S9(n) COMP-5, where ≥ 5 n ≤ 9 | int |
PIC S9(n) COMP-5, where ≥ 10 n ≤ 18 | long |
COMP-1 | float |
COMP-2 | double |
usage COMP-3/PACKED-DECIMAL numeric | java.math.BigDecimal |
usage DISPLAY numeric (zoned) | java.math.BigDecimal |
01 flag pic x. 88 f-false value x'00'. 88 f-true value x'01'. |
boolean |
Array COBOL types | |
01 byte-list. 03 byte-1 pic x occurs n times. |
byte[n] |
01 short-list. 03 short-1 pic s9(n) comp-5 occurs x times.where >=1 n <= 4 |
short[x] |
01 int-list. 03 int-1 pic s9(n) comp-5 occurs x times.where >= 5 n <= 9 |
int[x] |
01 long-list. 03 long-1 pic s9(n) comp-5 occurs x times.where >= 10 n <= 18 |
long[x] |
01 float-list. 03 float-1 pic comp-1 occurs n times. |
float[n] |
01 double-list. 03 dub-1 pic comp-2 occurs n times. |
double[n] |
01 bool-list. 03 bool-1 pic x occurs n times. 88 f-false value x'00'. 88 f-true value x'01'. |
boolean[n] |
01 dec-list. 03 num-1 pic s9(n)[v9(n))] display/comp-3 occurs x times. |
BigDecimal[x] |
01 alpha-list. 03 str-1 pic x(n) occurs x times.where n ≥ 1 |
String[x] |
01 nat-list. 03 nat-1 pic n(n) occurs x times. |
String[x] |
01 utf8-list. 03 utf-1 pic u(n) occurs x times. |
String[x] |
Alphanumeric group COBOL types | |
Any alphanumeric group item that does not conform to a Java-compatible array type is mapped to a Java byte array (byte[]); see the note below. | byte[] |
When the group containing such an item is an argument used when calling a static Java method, the Java method must assume that it is receiving a Java byte array object (byte[]), and wraps it in a ByteBuffer in order to extract data out of the byte array in such a way as to conform to the same layout of bytes as the corresponding COBOL group.
When the group is a parameter of a COBOL program being called by Java, the data is also processed as a byte array object (byte[]), and the responsibility of the calling Java method to match the byte layout of the receiving COBOL group item.
This process allows greater interoperability between COBOL and Java programs when complex group items are involved for which there is no valid mapping available.
Also, any alphanumeric group being passed to Java or returned from Java under CHARSET(EBCDIC) is assumed to only contain PIC X data items.