Lesson 1.3 leads you through the creation of a Java™ method.
Before you begin, you must complete Lesson 1.2: Setting up the Web
project and Java Interface and Implementations. In this lesson you
will:
- Create a Java method
- Create the input and output data mapping between COBOL and Java
- First you will create a Java method: You will now create a Java method
that will use the COBOL importer to map the data types between the COBOL source
and the data in your Java method.
- Open the Snippets view by clicking on Window > Show
View > Snippets. In the Snippets view, click on J2C.
- Right click Add Java method to J2C Java bean and
select Insert.
- In the New Java Method page, click Add.
- In the Java method name field, type getCustomerInfo for
the name of the operation. Click Next.
- Next you will create the input parameter data mapping: In
this step, you will import the taderc25.cbl (COBOL)
file that is needed to create your application. The taderc25.cbl file is located
in <installdir>\IBM\SDP70Shared\plugins\com.ibm.j2c.cheatsheet.content_7.0.0\Samples\CICS\taderc25,
where <installdir> is the directory where this product is installed. The
COBOL file contains the program that runs on the CICS® server. It has the definition of the
structure to be passed to the CICS server via the communications area
(COMMAREA). This structure represents the customer records being returned
from the CICS application.
Before you can work with a file, you must import it from the file system into
the workbench. In the Specify the input/output type field
of the Java Method page, click New.
- In the Data Import page, ensure that the Choose mapping field
is COBOL_TO_JAVA. Click Browse beside
the COBOL file
- Locate the taderc25.cbl file in the file system, and click Open.
- Click Next.
- In the COBOL Importer page, select a communication data
structure:
- Select Win32 for Platform
Name.
- Select ISO-8859-1 for Code
page.
- Click Query.
- Select ICOMMAREA for Data
structures.
- Click Next.
- In the Saving properties page:
- Select Default for Generation
Style.
- Click Browse to choose the Web project Taderc25Sample.
- In the Package Name field, type sample.cics.data
- In the Class Name field, the default
value is ICOMMAREA; replace it with InputComm.
- Click Finish.
- Next you will create the multiple possible outputs for the output
parameter: In the Specify the input/output type field
in the Java Method page, click New beside
the Output type area.
- In the Data Import page, ensure that the Choose mapping field is COBOL_MPO_TO_JAVA.
- Click New beside the multiple possible output
area.
- Click Browse beside the Cobol file name
field, and locate the location of the taderc25.cbl file.
Click Open.
- Click Next.
- In the COBOL Importer page, select a communication data
structure:
- Select Win32 for Platform
Name.
- Select ISO-8859-1 for Code
page.
- Click Query.
- Select PREFCUST, REGCUST,
and BADCUST for Data structures.
- Click Finish. In the Specify data import
configuration properties page, you will see the three data types listed.
- Click Next.
- Next you will specify the saving properties: In the Saving
Properties page, you will see default values set for each of the customer
type record. Ensure that Taderc25Sample appears in
the Project Name field. Click Browse and
choose the Web project Taderc25Sample.
- In the Specify the Saving properties page, highlight COBOL
MPO to Java Save Properties.
- Type sample.cics.data in the Package
Name field
- TypeOutputComm in the Class Name field.
- You can select Overwrite existing class .
- Expand COBOL MPO to Java Save Properties.
The three data binding elements should appear.
- Highlight COBOL To Java Save Properties For "PREFCUST"
in File taderc25.cbl
- For Generation Style, select Default.
- Type sample.cics.data in the Package
Name field
- TypePrefCust in the Class Name field.
- You can select Overwrite existing class .
- Highlight COBOL To Java Save Properties For "REGCUST"
in File taderc25.cbl.
- Type sample.cics.data in the Package
Name field
- TypeRegCust in the Class Name field.
- You can select Overwrite existing class .
- Highlight COBOL To Java Save Properties For "BADCUST"
in File taderc25.cbl.
- Type sample.cics.data in the Package
Name field
- TypeBadCust in the Class Name field.
- You can select Overwrite existing class .
- Click Finish. Expand OutputComm,
and you will see that it contains PrefCust, RegCust and BadCust in the Output
type field.
- On the Java Method page, click Finish.
- In the Java methods page:
- Type TADERC25 (the COBOL program id)
in the functionName field.
- Select Show Advanced.
- Select SYNC_SEND_RECEIVE(1) in the interactionVerb field.
- Type -1 in the replyLength field.
- Click Finish.
- Now you will Add the recognition pattern tag to the generate Java output
data mapping file: Since the output coming back can be any one of the
data types, the only way to match it is to have some pattern predefined in
the data stream. The match method checks the recognition pattern.

- To add the recognition pattern for PrefCust:
- To add the recognition pattern for RegCust:
- To add the recognition pattern for BadCust: