Chapter 7. Advanced topics for decision authoring 211
7.3.1 Mapping Java data structures to COBOL
This section explains mapping Java data structures to COBOL.
Aggregation data structure
When mapping Java BOMs to COBOL, only BOM classes with aggregation relationships are
supported. If there are object references, a simple hierarchical data structure is supported.
Complex object graphs are not supported. For example, the Insurance class has a field called
Vehicle of type Vehicle. The vehicle information is part of the insurance data, and it is a simple
hierarchical data structure. This example is supported.
But, if the Vehicle class references Insurance either directly or indirectly through other
classes, the data structure is not hierarchical. It contains loops. In this case, the BOM to
COBOL mapping is not supported. In addition, class inheritance is not supported. The BOM
must not include the following usage:
򐂰 Inheritance
򐂰 Loop reference, including self-reference
򐂰 Static attribute
Also, ensure that the BOM classes follow Java Bean naming guidelines, such as well-formed
getters and setters; otherwise, generated marshaller classes contain incorrect code.
General mapping rule
A BOM class is mapped to a COBOL group. Fields of the basic Java type are mapped to child
elementary data items. And, fields of the class type are mapped as subgroups (Example 7-6).
Example 7-6 A BOM with two classes
package xom;
public class Request {
public xom.Driver primaryDriver;
public xom.Driver secodaryDriver;
}
public class Driver {
public short age;
public string name;
}
When this BOM is mapped to a COBOL copybook, the primaryDriver and secodaryDriver
fields are generated as two groups with the same structure (Example 7-7).
Example 7-7 Copybook with two similar groups
01 request.
02 primaryDriver.
03 age pic S9(5).
03 name pic X(20) value SPACE.
02 secodaryDriver.
03 age pic S9(5).
03 name pic X(20) value SPACE.
An array is mapped to a table, and a collection is mapped to a size data item and a table
(Example 7-8 on page 212).
212 Flexible Decision Automation for Your zEnterprise with Business Rules and Events
Example 7-8 A BOM with an array and list
package xom;
public class Request {
public xom.Driver[] drivers;
public java.util.List vehicles domain 0,* class xom.Vehicle;
}
public class Driver {
public short age;
public string name;
}
public class Vehicle {
public string vehicleId;
public double vehicleValue;
}
The drivers field is an array, so the COBOL data item is a fixed-length table. The vehicles field
is a list of Vehicle objects. So, in the generated copybook, vehicles-Num is used as the actual
size of the table vehicles (Example 7-9).
Example 7-9 Copybook for array and list sample
01 request.
02 drivers Occurs 10 Times.
03 age pic S9(5).
03 name pic X(20) value SPACE.
02 vehicles-Num pic 9(9).
02 vehicles Occurs 10 Times.
03 vehicleId pic X(20) value SPACE.
03 vehicleValue usage COMP-2.
Mapping the basic Java type
Table 7-3 lists the Java to COBOL mapping.
Table 7-3 Java to COBOL mapping
Java type Default COBOL mapping Configuration
byte S9(3) Sign and length
USAGE BINARY,
PACKED-DECIMAL, COMP-5
short S9(5)
int S9(10)
long S9(18)
java.math.BigInteger S9(18)
float COMP-1 Sign and length
USAGE BINARY,
PACKED-DECIMAL, COMP-5,
and COMP-1
double COMP-2
java.math.BigDecimal S9(9)V9(8)
java.lang.String X(20) X/N, length
java.util.Date 9(8) [yyyyMMdd] 9/X, date format
boolean

Get Flexible Decision Automation for Your zEnterprise with Business Rules and Events now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.