|
|
|
|
|
Programming Reference
This section provides the rules that enable you to identify what form a generated Java class takes from a given COBOL copybook processed by the EgenCobol tool. This facilitates your being able to correctly code any custom programs that make use of the generated classes.
The EgenCobol tool maps a COBOL copybook into a Java class. The COBOL copybook contains a data record description. The EgenCobol tool derives the generated Java class from the bea.dmd.dataview.DataView class (later referred to as DataView), which is provided on your BEA eLink Java Adapter for Mainframe WLS Edition (JAM) product CDROM in the jam.jar file.
This section gives you data mapping rules. The following topics are discussed:
You should find the COBOL terms in this section easy to understand; however, you may need to use a COBOL reference book or discuss the terms with a COBOL programmer. Also, you can process a copybook with the EgenCobol tool and examine the produced Java code in order to understand the mapping.
Field Name Mapping Rules
When you process a COBOL copybook containing field names, they are mapped to Java names. This is performed by the EgenCobol tool according to the following rules:
Table 6-1 lists some mapping examples.
|
COBOL Field Name |
Java base name |
Sample Accessor Name |
|---|---|---|
|
EMP-REC |
empRec |
setEmpRec |
|
500-REC-CNT |
500RecCnt |
set500RecCnt |
Field Type Mappings
When you process a COBOL copybook with field types, the field types are mapped to Java field types. This is performed by the EgenCobol tool according to the following rules:
|
Number of digits |
Java Type |
|---|---|
|
<= 4 |
short |
|
> 4 and <= 9 |
int |
|
> 9 and <= 18 |
long |
|
> 18 |
BigDecimal |
Group Field Accessors
Each nested group field in a COBOL copybook is mapped to a corresponding DataView subclass. The generated subclasses are nested exactly as the COBOL groups in the copybook. In addition, the EgenCobol tool generates a private instance variable of this class type and a get accessor.
For example, the following copybook:
10 MY-RECORD.
20 MY-GRP.
30 ALNUM-FIELD PIC X(20).
Produces code similar to the following:
public MyGrpV getMyGrp();
public static class MyGrpV extends DataView
{
// Class definition
}
Elementary Field Accessors
Each elementary field is mapped to a private instance variable within the generated DataView subclass. Access to this variable is accomplished by two accessors that are generated (set and get).
These accessors have the following forms:
public void setFieldName(FieldType value);
public FieldType getFieldName();
Where:
For example, the following copybook:
10 MY-RECORD.
20 NUMERIC-FIELD PIC S9(5).
20 ALNUM-FIELD PIC X(20).
Produces the accessors:
public void setNumericField(int value);
public int getNumericField();
public void setAlnumField(String value);
public String getAlnumField();
Array Field Accessors
Array fields are handled according to the other rules in this section, with the addition that each accessor takes an additional int argument that specifies which array entry is to be accessed, for example:
public void setFieldName(int index, FieldType value);
public FieldType getFieldName(int index);
Array fields specified with the DEPENDING ON clause are handled the same as fixed-size arrays with the following special rules:
Fields with REDEFINES Clauses
Fields that participate in a REDEFINES set are handled as a unit. A private byte[] variable is declared to hold the underlying mainframe data, as well as a private DataView variable. Each of the redefined fields has an accessor or accessors. These accessors take more CPU overhead than the normal accessors because they perform conversions to and from the underlying byte[] data.
For example the copybook:
10 MY-RECORD.
20 INPUT-DATA.
30 INPUT-A PIC X(4).
30 INPUT-B PIC X(4).
20 OUTPUT-DATA REDEFINES INPUT-DATA PIC X(8).
Produces Java code similar to the following:
private byte[] m_redef23;
private DataView m_redef23DV;
public InputDataV getInputData();
public String getOutputData();
public void setOutputData(String value);
public static class InputDataV extends DataView
{
// Class definition.
}
COBOL Data Types
This section summarizes the COBOL data types supported by JAM software. Table 6-3 lists the COBOL data item definitions recognized by the EgenCobol tool. Table 6-4 lists the syntactical features and data types recognized by the EgenCobol tool. If a COBOL feature is unsupported, an error message is generated, unless it is listed as ignored in a table.
|
COBOL Feature |
Support |
|---|---|
|
IDENTIFICATION DIVISION |
unsupported |
|
ENVIRONMENT DIVISION |
unsupported |
|
DATA DIVISION |
partially supported |
|
WORKING-STORAGE SECTION |
partially supported |
|
Data record definition |
supported |
|
PROCEDURE DIVISION |
unsupported |
|
COPY |
unsupported |
|
COPY REPLACING |
unsupported |
|
EJECT, SKIP1, SKIP2, SKIP3 |
supported |
|
COBOL Type |
Java Type |
|---|---|
|
COMP, COMP-4, BINARY (integer) |
short/int/long |
|
COMP, COMP-4, BINARY (fixed) |
BigDecimal |
|
COMP-3, PACKED-DECIMAL |
BigDecimal |
|
COMP-5 |
not supported |
|
COMP-X |
not supported |
|
DISPLAY numeric (zoned) |
BigDecimal |
|
BLANK WHEN ZERO (zoned) |
String |
|
SIGN IS LEADING (zoned) |
String |
|
SIGN IS LEADING SEPARATE (zoned) |
String |
|
SIGN IS TRAILING (zoned) |
String |
|
SIGN IS TRAILING SEPARATE (zoned) |
String |
|
edited numeric |
String |
|
COMP-1, COMP-2 (float) |
not supported |
|
edited float numeric |
String |
|
DISPLAY (alphanumeric) |
String |
|
edited alphanumeric |
String |
|
INDEX |
int |
|
POINTER |
not supported |
|
PROCEDURE-POINTER |
not supported |
|
JUSTIFIED RIGHT |
not supported (ignored) |
|
SYNCHRONIZED |
not supported (ignored) |
|
REDEFINES |
supported |
|
66 RENAMES |
not supported |
|
66 RENAMES THRU |
not supported |
|
77 level |
supported |
|
88 level (condition) |
not supported (ignored) |
|
group record |
inner class |
|
OCCURS (fixed array) |
array |
|
OCCURS DEPENDING (variable-length array) |
array |
|
OCCURS INDEXED BY |
not supported (ignored) |
|
OCCURS KEY IS |
not supported (ignored) |
|
|
|
|
|
|
Copyright © 2000 BEA Systems, Inc. All rights reserved.
|