Exercise 1.3: Creating the Java method
Before you begin, you must complete Exercise 1.2: Setting up the Web Project and Java Interface and Implementations .
Creating 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.
- In the Snippets view, select J2C. Right click Add Java method to J2C Java bean.
- In the Java method name field, type getCustomer for the name of the operation. Click Next.
Creating the input and output data mapping between COBOL and Java
In this step, you will import the taderc99.cbl (COBOL) file that is needed to create your application. The taderc99.cbl file is located in <RSDP_installdir>\rad\eclipse\plugins\com.ibm.j2c.cheatsheet.content_6.0.0\Samples\CICS\taderc99, where <RSDP_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 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 field.
- Locate the taderc99.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 DFHCOMMAREA for Data structures.
- In the Saving properties page,
- Select Default for Generation Style.
- Click Browse.
- Select the Web project CustomerProj. ClickOpen.
- In the Package Name field, enter sample.cics.data
- In the Class Name field, enter CustomerInfo.
Click Finish.
- In the Java method page, select Use Input for output.
Click Finish.
- On the Java Method page, click Finish to complete the operation.
- In the functionName field, type the COBOL program id (TADERC99). Click Next.
Now you are ready to begin Exercise 1.4: Deploying the application.