Table of Contents Previous Next PDF


Generating a Java Application with the eGen Application Generator

Generating a Java Application with the eGen Application Generator
This document includes the following topics:
Overview
Oracle Tuxedo supports seamless integration of CICS Transaction Gateway (CTG) application running on J2EE application servers and JCA based.
With this feature, Oracle Tuxedo provides a tool to
Therefore, users can pass those classes to a CCI (or ECI-wrapped) interface to perform ART-hosted CICS invocations.
Writing an eGen Script
After you have obtained a COBOL Copybook for the mainframe applications, you are ready to write an eGen script. This eGen script and the COBOL copybook that describes your data structure will be processed by the eGen utility to generate a DataView and application code which will serve as the basis for your custom Java application.
An eGen script has two sections. These are:
Note:
Writing the DataView Section of an eGen Script
The eGen utility parses a COBOL copybook and generates Java DataView code that encapsulates the data record declared in the copybook. It does this by parsing an eGen script file containing a DataView definition similar to the example shown in Listing 1 (keywords are in bold). The section containing the DataView definition is the first section of the eGen script. Application code is generated by the second section.
Listing 1 Sample DataView Section of an eGen Script
generate view examples.CICS.outbound.gateway.EmployeeRecord from emprec.cpy
 
Analyzing the parts of this line of code, we see that generate view tells the eGen utility to generate a Java DataView code file. examples.CICS.outbound.gateway.EmployeeRecord tells the eGen utility to call the DataView file EmployeeRecord.java. The package is called examples.CICS.outbound.gateway. The EmployeeRecord class defined in EmployeeRecord.java is a subclass of the DataView class. The phrase from emprec.cpy tells the eGen utility to form the EmployeeRecord DataView file from the COBOL copybook emprec.cpy.
Additional generate view statements may be added to an eGen script in order to produce all the DataViews required by your application. Also, additional options may be specified in the eGen script to change details of the DataView generation. For example, the following script will generate a DataView class that uses codepage cp500 for conversions to and from mainframe format. If the codepage clause is not specified, the default codepage of cp037 is used.
Listing 2 Sample DataView Section with Codepage Specified
generate view examples.CICS.outbound.gateway.EmployeeRecord from emprec.cpy codepage cp500
 
The following script will generate additional output intended to support use of the DataView class with XML data:
Listing 3 Sample DataView Section Supporting XML
generate view sample.EmployeeRecord from emprec.cpy support xml
 
Additional files generated for XML support are listed in Table 1.
 
Field Name Mapping Rules
When you process a COBOL copybook containing field names, they are mapped to Java names by the eGen utility. All alphabetic characters are mapped to lower case, except in the following two cases.
All dashes are removed and the character following the dash is mapped to upper case.
When a prefix is added to the name (as when creating a field accessor function name), the first character of the base name is mapped to upper case.
Table 2 lists some mapping examples.
 
Field Type Mappings
When you process a COBOL copybook, the data types of fields are mapped to Java data types. The mapping is performed by the eGen utility according to the following rules:
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
 
Accessors
This topic includes the following parts.
Group Field Accessors
Each nested group 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 eGen utility 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 MyGrp2V getMyGrp();
public static class MyGrp2V 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:
FieldType
is described in the Field Type Mappings section.
FieldName
is described in the Field Name Mapping Rules section.
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 field accessor rules described in Group Field Accessors and Elementary Field Accessors, 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:
The accessors may be used to get or set any instance up to the maximum array index.
The controlling (DEPENDING ON) variable is evaluated when the DataView is converted to or from an external format, such as a mainframe format. The eGen utility converts only the array elements with subscripts less than the controlling value.
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 WebLogic JAM software. Table 4 lists the COBOL data item definitions recognized by the eGen utility. Table 5 lists the syntactical features and data types recognized by the eGen utility. If a COBOL feature is unsupported and it is not listed as ignored in the table, an error message is generated.
 
 
Program Development
Program development will be accomplished according to program snippet listed in Listing 4 and according to class naming rules outlined here, although this can be adjusted depending on customer requirements.
Listing 4 Program Snippet
try
{
InitialContext context = new InitialContext();
ECIConnectionSpec connSpec = new ECIConnectionSpec();
connSpec.setUserName("TESOP01");
connSpec.setPassword("");
Connection connection = connectionFactory.getConnection(connSpec);
Interaction interaction = connection.createInteraction();
// Create inputBean
K294Bean inRec = new K294Bean();
inRec.setI__Entete__TranId("K294");
inRec.setI__Entete__Vers("0101");
inRec.setI__Entete__Statut("99");
inRec.setI__Entete__Nb__Enreg((short)40);
inRec.setI__Entete__User("TESOP01");
inRec.setI__Entete__Date("2012-01-16");
// Data
inRec.setI__restea__nupy(1);
inRec.setI__restea__cdea(2);
inRec.setI__restea__cdea1(1);
K294Bean outRec = new K294Bean();
// Create InteractionSpec
InteractionSpec interactionSpec = new ECIInteractionSpec();
((ECIInteractionSpec)interactionSpec).setFunctionName("COMPT294");
((ECIInteractionSpec)interactionSpec).setTranName("K294");
((ECIInteractionSpec)interactionSpec).setCommareaLength(7132);
((ECIInteractionSpec)interactionSpec).setInteractionVerb(ECIInteractionSpec.SYNC_SEND_RECEIVE);
// execute transaction
interaction.execute((ECIInteractionSpec)interactionSpec, inRec, outRec);
// Close all
interaction.close();
connection.close();
// List Data
K294bean_output__message_t__o__data__data data[] = outRec.getT__o__data__data();
// Load List
for (int i=0; i<data.length;i++)
{
if (data[i].getT__o__data__data__o__restea__cdea()!=0)
{
out.println(data[i]);
}
}
}
catch (Exception e)
{
System.out.println("Error : " + e.getMessage());
e.printStackTrace();
}
 
Important Areas
The following listings show the important areas for program development. Field name mappings may vary.
Listing 5 Setup Connection
ECIConnectionSpec connSpec = new ECIConnectionSpec();
connSpec.setUserName("TESOP01");
connSpec.setPassword("");
Connection connection = connectionFactory.getConnection(connSpec);
Interaction interaction = connection.createInteraction();
// Create InteractionSpec
InteractionSpec interactionSpec = new ECIInteractionSpec();
((ECIInteractionSpec)interactionSpec).setFunctionName("COMPT294");
((ECIInteractionSpec)interactionSpec).setTranName("K294");
((ECIInteractionSpec)interactionSpec).setCommareaLength(7132);
((ECIInteractionSpec)interactionSpec).setInteractionVerb(ECIInteractionSpec.SYNC_SEND_RECEIVE);
 
Listing 6 Input Bean Usage
// Create inputBean
K294Bean inRec = new K294Bean();
inRec.getDfhcommarea().
getInputMessage().
getIEntete().setIEnteteTranId("K294");
inRec.getDfhcommarea().
getInputMessage().
getIEntete().setIEnteteVers("0101");
inRec.getDfhcommarea().
getInputMessage().
getIEntete().setIEnteteStatut("99");
inRec.getDfhcommarea().
getInputMessage().
getIEntete().setIEnteteNbEnreg((short)40);
// reserve outputBean
K294Bean outRec = new K294Bean();
 
Listing 7 Service Invocation
// execute transaction
interaction.execute((ECIInteractionSpec)interactionSpec, inRec, outRec);
 
Listing 8 Output Bean Usage
K294bean_output__message_t__o__data__data data[] = outRec.getDfhcommarea().getOutputMessage().getTODataData();
 
 

Copyright © 1994, 2017, Oracle and/or its affiliates. All rights reserved.