< Previous | Next >

Lesson 3: Create a message buffer class

Lesson 3 leads you through the creation of a message buffer class.
Before you begin, you must complete Lesson 2: Set up a web project and Java Interface and Implementations.
In this lesson, you
  1. To create a message buffer class, expand the MultiSegOutput project, expand Java Resources, and expand JavaSource.
  2. Right click the sample.ims package, and select New > Class to launch the New Class wizard.
  3. Type CCIBuffer as the name of the class. Accept all default settings.
  4. Click Finish. The CCIBuffer class opens in the Java editor.
  5. In the comment section of the CCIBuffer class, type in the tag @type-descriptor.message-buffer.
  6. Press CTRL-S to save the changes. Note that new code is automatically generated in the CCIBuffer.java file.
    CCIBuffer.java
    /*
     * Created on Oct 13, 2004
     *
     * TODO To change the template for this generated file go to
     * Window - Preferences - Java - Code Style - Code Templates
     */
    package sample.ims;
    
    /**
     * @author ivyho
     *
     * TODO To change the template for this generated type comment go to
     * Window - Preferences - Java - Code Style - Code Templates
     * @type-descriptor.message-buffer
     */
    public class CCIBuffer implements javax.resource.cci.Record,
    		javax.resource.cci.Streamable, com.ibm.etools.marshall.RecordBytes {
    
    	private byte[] buffer_ = null;
    
    	/**
    	 * @generated
    	 */
    	public CCIBuffer() {
    		return;
    	}
    
    	/**
    	 * @generated
    	 * @see javax.resource.cci.Record#getRecordShortDescription()
    	 */
    	public String getRecordShortDescription() {
    		return (this.getClass().getName());
    	}
    
    	/**
    	 * @generated
    	 * @see javax.resource.cci.Record#hashCode()
    	 */
    	public int hashCode() {
    		return (super.hashCode());
    	}
    
    	/**
    	 * @generated
    	 * @see javax.resource.cci.Streamable#write(OutputStream)
    	 */
    	public void write(java.io.OutputStream outputStream)
    			throws java.io.IOException {
    		outputStream.write(buffer_);
    	}
    
    	/**
    	 * @generated
    	 * @see javax.resource.cci.Record#setRecordShortDescription(String)
    	 */
    	public void setRecordShortDescription(String shortDescription) {
    		return;
    	}
    
    	/**
    	 * @generated
    	 */
    	public int getSize() {
    		if (buffer_ != null)
    			return (buffer_.length);
    		else
    			return (0);
    	}
    
    	/**
    	 * @generated
    	 * @see java.lang.Object#toString
    	 */
    	public String toString() {
    		StringBuffer sb = new StringBuffer(super.toString());
    		sb.append("\n");
    		com.ibm.etools.marshall.util.ConversionUtils.dumpBytes(sb, buffer_);
    		return (sb.toString());
    	}
    
    	/**
    	 * @generated
    	 * @see javax.resource.cci.Record#getRecordName()
    	 */
    	public String getRecordName() {
    		return (this.getClass().getName());
    	}
    
    	/**
    	 * @generated
    	 */
    	public byte[] getBytes() {
    		return (buffer_);
    	}
    
    	/**
    	 * @generated
    	 * @see javax.resource.cci.Record#clone()
    	 */
    	public Object clone() throws CloneNotSupportedException {
    		return (super.clone());
    	}
    
    	/**
    	 * @generated
    	 * @see javax.resource.cci.Record#setRecordName(String)
    	 */
    	public void setRecordName(String recordName) {
    		return;
    	}
    
    	/**
    	 * @generated
    	 * @see javax.resource.cci.Record#equals()
    	 */
    	public boolean equals(Object object) {
    		return (super.equals(object));
    	}
    
    	/**
    	 * @generated
    	 * @see javax.resource.cci.Streamable#read(InputStream)
    	 */
    	public void read(java.io.InputStream inputStream)
    			throws java.io.IOException {
    		byte[] input = new byte[inputStream.available()];
    		inputStream.read(input);
    		buffer_ = input;
    	}
    
    	/**
    	 * @generated
    	 */
    	public void setBytes(byte[] bytes) {
    		buffer_ = bytes;
    	}
    
    }
    
  7. To create a method to run the IMS™ transaction and the input message data type, in the Enterprise Explorer view, right click MSOImpl.java, and select Source > Add method to J2C Java bean.
  8. In the New Java Method page, click Add.
  9. In the Name field, type runMultiSegOutput.
  10. Beside the Input type field, click New.
  11. Select COBOL_to_Java mapping. Click Browse.
  12. Locate the MSOut.cbl COBOL file. Click Open.
    MSout.cbl
          IDENTIFICATION DIVISION.
          program-id. pgm1.
          ENVIRONMENT DIVISION.                                             
          CONFIGURATION SECTION.                                            
          DATA DIVISION. 
          *
          *    IMS TOC Connector for Java, Multi-segment Output Example
          *
          *********************************************************************/ 
          *                                                                   */ 
          * (c) Copyright IBM Corp. 1998                                      */ 
          * 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(5).                               
                02  IN-DATA1       PICTURE X(6).
                02  IN-DATA2       PICTURE X(6).
    						  
            01  OUTPUT-MSG.                                                   
                02  OUT-ALLSEGS  PICTURE X(99) VALUE SPACES.
    
            01  OUTPUT-SEG1.
                02  OUT-LL       PICTURE S9(3) COMP VALUE +0.                 
                02  OUT-ZZ       PICTURE S9(3) COMP VALUE +0.                  
                02  OUT-DATA1    PICTURE X(12) VALUE SPACES.
    
            01  OUTPUT-SEG2.
                02  OUT-LL       PICTURE S9(3) COMP VALUE +0.                 
                02  OUT-ZZ       PICTURE S9(3) COMP VALUE +0.                  
                02  OUT-DATA1    PICTURE X(13) VALUE SPACES.
                02  OUT-DATA2    PICTURE X(14) VALUE SPACES.
    
            01  OUTPUT-SEG3.
                02  OUT-LL       PICTURE S9(3) COMP VALUE +0.                 
                02  OUT-ZZ       PICTURE S9(3) COMP VALUE +0.                  
                02  OUT-DATA1    PICTURE X(15) VALUE SPACES.
                02  OUT-DATA2    PICTURE X(16) VALUE SPACES.
                02  OUT-DATA3    PICTURE X(17) VALUE SPACES.                     		   		
                            
            PROCEDURE DIVISION.    
  13. Click Next.
  14. 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 is shown. Select INPUT-MSG in the Data structures field. Click Next.
    4. Leave the Save session as Ant script cleared.
  15. In the Saving Properties page, the default Class Name is INPUTMSG. Overwrite the Class Name with InputMsg. Click Finish.
  16. To create the output message data type, click Browse.
  17. Type CC in the Select a data type field, and CCIBuffer appears in the Matching types field. Select CCIBuffer as the output type. Click Finish.
  18. In the Java Method page, click Finish.
  19. In the Java Methods page, ensure that the interactionVerb is set to SYNC_SEND_RECEIVE (1) to indicate that the interaction with IMS involves a send followed by a receive interaction.
  20. Click Finish.
  21. To create the output segment data mappings, select File > New > Other > CICS/IMS Java Data Binding to invoke the data binding wizard.
  22. Click Next.
  23. Select COBOL_To_Java in the Choose mapping list. Click Browse to find the MSOut.cbl COBOL copy book.
  24. Click Next.
  25. 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 is shown. Select OUTPUT-SEG1 in the Data structures field.
    4. Click Next.
  26. In the Saving properties wizard, click Browse, and select the MultiSegOutput project you created before.
  27. Click Browse to select the package name: sample.ims.data.
  28. Change the Class Name from OUTPUTSEG1 to OutputSeg1.
  29. Click Finish.
  30. Now you create the OutputSeg2.java class: Select File > New > Other > CICS/IMS Java Data Binding to invoke the Data Binding wizard.
  31. Click Next.
  32. Select COBOL_To_Java in the Choose mapping list. Click Browse to find the MSOut.cbl COBOL copy book.
  33. In the COBOL Importer page, click Show Advanced.
    1. Select the following options:
      Table 3. 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 is shown. Select OUTPUT-SEG2 in the Data structures field.
    4. Click Next.
  34. In the Saving properties wizard, click Browse to select the MultiSegOutput project you created before.
  35. Click Browse to select the package name: sample.ims.data.
  36. Change the Class Name from OUTPUTSEG2 to OutputSeg2.
  37. Click Finish.
  38. Now create the OutputSeg3.java class: Select File > New > Other > CICS/IMS Java Data Binding to invoke the Data Binding wizard.
  39. Click Next.
  40. Select COBOL_To_Java in the Choose mapping list. Click Browse to find the MSOut.cbl COBOL copy book.
  41. In the COBOL Importer page, click Show Advanced.
    1. Select the following options:
      Table 4. COBOL Importer Parameter Settings
      Parameter Value
      Platform Name Z/OS
      Codepage 037
      Floating point format name IBM 390 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 is shown. Select OUTPUT-SEG3 in the Data structures field.
    4. Click Next.
  42. In the Saving properties wizard, click Browse to select the MultiSegOutput project you created before.
  43. Click Browse to select the package name: sample.ims.data.
  44. Change the Class Name from OUTPUTSEG3 to OutputSeg3.
  45. Click Finish.
< Previous | Next >

Feedback