Lesson 3 leads you through the creation of a Java™ method.
In this lesson, you
- Create a Java method
- Create the input and output data mapping between COBOL and Java
- In the Snippets view, select J2C. Double click Add method to J2C Java bean.
- In the Java Methods
page, click Add
- In the Name field, type runPhoneBook.
- In this step, you import the Ex01.cbl (COBOL) file that
is needed to create your application. The Ex01.cbl file is located
in <installdir>\IBM/IBMIMShared/plugins/com.ibm.j2c.cheatsheet.content\Samples/MS/phonebook, where <installdir> is the directory where this product is installed.
The COBOL file contains the application program that runs on the IMS™ server. It has the definition
of the structure to be passed to the IMS server via the communications area. This structure represents
the customer records being returned from the IMS application program. Before you can work
with a file, you must import it from the file system into the workbench.
Beside the Input type field, 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 Ex01.cbl file in the file system, and click Open.
IDENTIFICATION DIVISION.
ENVIRONMENT DIVISION.
CONFIGURATION SECTION.
DATA DIVISION.
*
* IMS Connector for Java, COBOL Transaction Message Source
*
*********************************************************************/
* */
* (c) Copyright IBM Corp. 2003 */
* All Rights Reserved */
* Licensed Materials - Property of IBM */
* */
* DISCLAIMER OF WARRANTIES. */
* */
* The following (enclosed) code is provided to you solely for the */
* purpose of assisting you in the development of your applications. */
* The code is provided "AS IS." IBM MAKES NO WARRANTIES, EXPRESS OR */
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF */
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, REGARDING */
* THE FUNCTION OR PERFORMANCE OF THIS CODE. */
* IBM shall not be liable for any damages arising out of your use */
* of the generated code, even if they have been advised of the */
* possibility of such damages. */
* */
* DISTRIBUTION. */
* */
* This generated code can be freely distributed, copied, altered, */
* and incorporated into other software, provided that: */
* - It bears the above Copyright notice and DISCLAIMER intact */
* - The software is not for resale */
* */
*********************************************************************/
*
LINKAGE SECTION.
01 INPUT-MSG.
02 IN-LL PICTURE S9(3) COMP.
02 IN-ZZ PICTURE S9(3) COMP.
02 IN-TRCD PICTURE X(10).
02 IN-CMD PICTURE X(8).
02 IN-NAME1 PICTURE X(10).
02 IN-NAME2 PICTURE X(10).
02 IN-EXTN PICTURE X(10).
02 IN-ZIP PICTURE X(7).
01 OUTPUT-MSG.
02 OUT-LL PICTURE S9(3) COMP VALUE +0.
02 OUT-ZZ PICTURE S9(3) COMP VALUE +0.
02 OUT-MSG PICTURE X(40) VALUE SPACES.
02 OUT-CMD PICTURE X(8) VALUE SPACES.
02 OUT-NAME1 PICTURE X(10) VALUE SPACES.
02 OUT-NAME2 PICTURE X(10) VALUE SPACES.
02 OUT-EXTN PICTURE X(10) VALUE SPACES.
02 OUT-ZIP PICTURE X(7) VALUE SPACES.
02 OUT-SEGNO PICTURE X(4) VALUE SPACES.
PROCEDURE DIVISION.
- Click Next.
- In the COBOL Importer page, click Show Advanced.
- Select the following options:
Table 1. COBOL Importer Parameter Settings| Parameter |
Value |
| Platform Name |
Z/OS |
| Codepage |
IBM-037 |
| Floating point format name |
IBM® Hexadecimal |
| External decimal sign |
EBCDIC |
| Endian name |
Big |
| Remote integer endian name |
Big |
| Quote name |
DOUBLE |
| Trunc name |
STD |
| Nsymbol name |
DBCS |
- Click Query to load the data.
- A list of data structures from the Ex01.cbl file is
shown. Select INPUT-MSG in the Data
structures field.
- Click Next.
- In the Saving properties page, select the following values
for input type:
- Select Default for Generation Style.
- Click Browse beside the Project Name and choose the web project IMSPhoneBook .
- In the Package Name field, type sample.ims.data.
- In the Class Name field, accept
the default INPUTMSG. Click Finish.
- In the Java method
page, click New next to the Output
type field.
- In the Data Import page, ensure that the Choose
mapping field is COBOL_TO_JAVA.
- Locate the Ex01.cbl file in the
file system, and click Open.
- Click Next.
- In the COBOL Importer page, click Show Advanced.
- Select the following options:
Table 2. COBOL Importer Parameter Settings| Parameter |
Value |
| Platform Name |
Z/OS |
| Codepage |
IBM-037 |
| Floating point format name |
IBM Hexadecimal |
| External decimal sign |
EBCDIC |
| Endian name |
Big |
| Remote integer endian name |
Big |
| Quote name |
DOUBLE |
| Trunc name |
STD |
| Nsymbol name |
DBCS |
- Click Query to load the data.
- A list of data structures from the Ex01.cbl file is
shown. Select OUTPUT-MSG in the Data structures field.
- Click Next.
- In the Saving Properties page,
- Select Default for Generation Style.
- Click Browse beside the Project Name and choose the web project IMSPhoneBook .
- In the Package Name field, type sample.ims.data.
- In the Class Name field, accept
the default OUTPUTMSG . ClickFinish.
- Leave the Save session as Ant script cleared.
- On the Java Method
page, click Finish.
- In the Binding Details page, ensure that the interactionVerb is SYNC_SEND_RECEIVE(1) to indicate that the interaction with IMS involves a send followed by a receive interaction.
- Click Finish.