< Previous | Next >

Lesson 3: Create a Java method

Lesson 3 leads you through the creation of a Java™ method.
Before you begin, you must complete Lesson 2: Set up a web project and Java interface and implementations.
In this lesson, you
  1. In the Snippets view, select J2C. Double click Add method to J2C Java bean.
  2. In the Java Methods page, click Add
  3. In the Name field, type runPhoneBook.
  4. 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.
  5. In the Data Import page, ensure that the Choose mapping field is COBOL_TO_JAVA. Click Browse beside the COBOL file
  6. 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.       
    
  7. Click Next.
  8. In the COBOL Importer page, click Show Advanced.
    1. 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
    2. Click Query to load the data.
    3. A list of data structures from the Ex01.cbl file is shown. Select INPUT-MSG in the Data structures field.
    4. Click Next.
  9. In the Saving properties page, select the following values for input type:
    1. Select Default for Generation Style.
    2. Click Browse beside the Project Name and choose the web project IMSPhoneBook .
    3. In the Package Name field, type sample.ims.data.
    4. In the Class Name field, accept the default INPUTMSG. Click Finish.
  10. In the Java method page, click New next to the Output type field.
  11. In the Data Import page, ensure that the Choose mapping field is COBOL_TO_JAVA.
  12. Locate the Ex01.cbl file in the file system, and click Open.
  13. Click Next.
  14. In the COBOL Importer page, click Show Advanced.
    1. 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
    2. Click Query to load the data.
    3. A list of data structures from the Ex01.cbl file is shown. Select OUTPUT-MSG in the Data structures field.
    4. Click Next.
  15. In the Saving Properties page,
    1. Select Default for Generation Style.
    2. Click Browse beside the Project Name and choose the web project IMSPhoneBook .
    3. In the Package Name field, type sample.ims.data.
    4. In the Class Name field, accept the default OUTPUTMSG . ClickFinish.
    5. Leave the Save session as Ant script cleared.
  16. On the Java Method page, click Finish.
  17. 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.
  18. Click Finish.
< Previous | Next >

Feedback