87
Summer University IMS Application Programming & Modernization Lab Version V2.11 Monday, 13 September, 2010

LAB IMS zSummerUni 2010 Part 1-7 - uni-hamburg.de · Part 1: Prepare the Development Environment (required) This part describes how prepare the RDz environment to be able to create

  • Upload
    others

  • View
    0

  • Download
    0

Embed Size (px)

Citation preview

Page 1: LAB IMS zSummerUni 2010 Part 1-7 - uni-hamburg.de · Part 1: Prepare the Development Environment (required) This part describes how prepare the RDz environment to be able to create

Summer University

IMS Application Programming & Modernization Lab Version V2.11

Monday, 13 September, 2010

Page 2: LAB IMS zSummerUni 2010 Part 1-7 - uni-hamburg.de · Part 1: Prepare the Development Environment (required) This part describes how prepare the RDz environment to be able to create

© Copyright IBM Corporation 2009. All rights reserved.

9/15/2010 Summer University IMS

Page 2 of 87

Overview This Lab describes the necessary steps to create a simple IMS Java transaction. This transaction is the backorder function. It is called with part number and amount and if the parts can be delivered it will update a DB2 table about the parts that were delivered.

Scenario IMS in this scenario plays the role of the wholesale dealer which delivers goods to its wholesale customers. It implements the backorder function, where the stores can order products to sell. For the backorder function, the IMS transaction uses its own database. This is an IMS database, which is made of the following assumptions:

There are multiple inventory locations, where the items are stored. Think of it like a company that has inventories in Hamburg, Frankfurt and Munich. But not all inventories have all items in stock.

There is a customer database, for which each customer can have multiple mailing addresses (1-n), multiple (1-n) contact persons and multiple orders (1-n).

Each order consists of an item list which holds the part numbers, amount and descriptions.

If a customer orders 100 parts, but this order cannot fulfilled by one inventory the order will be split and separate deliveries (e.g. 50 parts from Frankfurt and 50 parts from Hamburg) will occur. Therefore each item in the order can have 1-n deliveries.

The item database holds the item information and the amount of items that is in stock for each of the inventories. For IMS transactions there is no runtime or test environment within RDz, therefore the code must be uploaded to the host and tested there.

Lab Requirements - IMS V11 or later with IMS Connect - Rational Application Developer for System z for Java 7.6 with RAD 7.5.4 - DB2 for z/OS Version 9 - WebSphere Application Server 7.0 with IMS TM Resource Adapter 11.2 (IMS JCA/J2EE Adapter)

Page 3: LAB IMS zSummerUni 2010 Part 1-7 - uni-hamburg.de · Part 1: Prepare the Development Environment (required) This part describes how prepare the RDz environment to be able to create

© Copyright IBM Corporation 2009. All rights reserved.

9/15/2010 Summer University IMS

Page 3 of 87

Pictogram:

Page 4: LAB IMS zSummerUni 2010 Part 1-7 - uni-hamburg.de · Part 1: Prepare the Development Environment (required) This part describes how prepare the RDz environment to be able to create

© Copyright IBM Corporation 2009. All rights reserved.

9/15/2010 Summer University IMS

Page 4 of 87

Table of Contents Part 1: Prepare the Development Environment ....................................................7 Part 2: Create a simple IMS Java transaction.....................................................12 Part 3: Create a Non Managed Test Client .........................................................24 Part 4: Enhance the simple IMS Java transaction to call DB2 ............................34 Part 5: Use IMS SOAP Gateway to call the IMS Transaction as a Web Service 35 Part 6: Create a Web Service for the IMS transaction with WAS........................50 Part 7: IMS DB Calls and business logic.............................................................64

Page 5: LAB IMS zSummerUni 2010 Part 1-7 - uni-hamburg.de · Part 1: Prepare the Development Environment (required) This part describes how prepare the RDz environment to be able to create

© Copyright IBM Corporation 2009. All rights reserved.

9/15/2010 Summer University IMS

Page 5 of 87

Lab Steps Overview Part 1: Prepare the Development Environment (required)

This part describes how prepare the RDz environment to be able to create a simple IMS Java transaction and to comply with the code requirements on the z/OS host. Part 2: Create a simple IMS Java transaction (required)

This part describes how to create and deploy an IMS Java transaction. In this part, the simple transaction will be coded and IMS will be configured to run that transaction. The result is an IMS transaction that makes one simple Output. Part 3: Create a non managed Test Client (required)

This part describes how a non-managed Test-client for the transaction will be generated and tested. Part 4: Enhance the simple IMS Java transaction to call DB2 (optional / Required for Part 7)

The IMS transaction is enhanced to do a DB2 JDBC Call. In fact, the EXMPCAT DB2 table will be updated with the amount of ordered products that can be delivered by IMS. The delivery amount will be added to the WS_IN_STOCK column and deducted from the WS_ON_ORDER column.

Page 6: LAB IMS zSummerUni 2010 Part 1-7 - uni-hamburg.de · Part 1: Prepare the Development Environment (required) This part describes how prepare the RDz environment to be able to create

© Copyright IBM Corporation 2009. All rights reserved.

9/15/2010 Summer University IMS

Page 6 of 87

Part 5: Use IMS SOAP Gateway to enable the IMS Transaction as a Web Service (optional / Required for CICS Call)

This part describes how a lightweight web services gateway for IMS - the IMS SOAP Gateway - can be used to expose an IMS transaction as a web service. The result of this lab is the possibility to use IMS SOAP Gateway as the web service endpoint for the IMS transaction that implements the Backorder function. Part 6: Create a Web Service for the IMS transaction with WebSphere Application Server (optional / Alternative for Part 5)

In this part of the lab, we create a Web Service that uses IMS Connector for Java to call the IMS transaction. This solution is a little bit more complex but offers also more Features like a automatically generated JSP GUI. The IMS Web Service will be generated and first tested in the RDz WAS 7.0 Test Environment. Finally the IMS Web Service will be installed and can be tested with various options. Part 7: Enhance the IMS Transaction and add IMS DB Calls and business logic (optional)

For the IMS transaction there is still the business logic missing for the order processing. Therefore IMS databases will be created, accessed and updated. You can create your own business logic or take the example. The business logic of the IMS transaction is as follows:

1. Create a new order for the default customer and insert the item to the orders.

2. Query the stock of the backordered item for each inventory and keep it in a local variable.

3. Check the total amount of the backordered item in all inventories. 4. If the total amount is larger or equal to the ordered quantity, check if the

order can be fulfilled by a single inventory. IF YES: Add a single delivery entry for the item in the order, call the DB2 and exit with the result from the DB2 Call. IF NO: Add as many delivery entries for the item in the order, call the DB2 and exit with the result from the DB2 Call.

Page 7: LAB IMS zSummerUni 2010 Part 1-7 - uni-hamburg.de · Part 1: Prepare the Development Environment (required) This part describes how prepare the RDz environment to be able to create

© Copyright IBM Corporation 2009. All rights reserved.

9/15/2010 Summer University IMS

Page 7 of 87

Part 1: Prepare the Development Environment ___1. Open a clean workspace!!! Make sure to use a new RD/z workspace! If an existing workspace was opened, please choose menu File -> Switch Workspace and change the name of the current workspace to workspaceIMSJava. Click OK to create the new workspace.

Important: Some of the screenshots in this tutorial show different path names or usernames (such as ZUSERxx instead of TEAMxx). Make sure to always use TEAMxx and teamxx naming conventions in addition to the correct z/OS ip address 192.168.7.252. ___2. Create the Java Project for the IMS Java Transaction This project needs to be created as part of preparing the IMS Java development environment. First we need to switch to the J2EE (Java EE) Perspective, just in case any other perspective view is opened.

Click on the little icon at the right top of the RDz window

and Select Java EE or if it is not yet listed, Select Other and then in the appearing window select Java EE and click OK. The Java EE Perspective should now be opened. Now continue with creating the IMS Java Project.

Click the right mouse button and Select New Other.

Page 8: LAB IMS zSummerUni 2010 Part 1-7 - uni-hamburg.de · Part 1: Prepare the Development Environment (required) This part describes how prepare the RDz environment to be able to create

© Copyright IBM Corporation 2009. All rights reserved.

9/15/2010 Summer University IMS

Page 8 of 87

When the Select a wizard window appears search for “Java Project” in the list or scroll down to the Java Folder and select “Java Project” and click Next.

Page 9: LAB IMS zSummerUni 2010 Part 1-7 - uni-hamburg.de · Part 1: Prepare the Development Environment (required) This part describes how prepare the RDz environment to be able to create

© Copyright IBM Corporation 2009. All rights reserved.

9/15/2010 Summer University IMS

Page 9 of 87

In the New Java Project Window Enter a new project name (e.g. IMSJava), leave all the other values as defaults

Page 10: LAB IMS zSummerUni 2010 Part 1-7 - uni-hamburg.de · Part 1: Prepare the Development Environment (required) This part describes how prepare the RDz environment to be able to create

© Copyright IBM Corporation 2009. All rights reserved.

9/15/2010 Summer University IMS

Page 10 of 87

Make sure to select Create separate source and output folders, which is the default and click Finish.

When being asked to switch to the associated Java Perspective deny this request by clicking No. The new project should now appear in the Project Explorer.

Page 11: LAB IMS zSummerUni 2010 Part 1-7 - uni-hamburg.de · Part 1: Prepare the Development Environment (required) This part describes how prepare the RDz environment to be able to create

© Copyright IBM Corporation 2009. All rights reserved.

9/15/2010 Summer University IMS

Page 11 of 87

Now the target Project was successfully created.

Page 12: LAB IMS zSummerUni 2010 Part 1-7 - uni-hamburg.de · Part 1: Prepare the Development Environment (required) This part describes how prepare the RDz environment to be able to create

© Copyright IBM Corporation 2009. All rights reserved.

9/15/2010 Summer University IMS

Page 12 of 87

Part 2: Create a simple IMS Java transaction For the simple IMS Java transaction definitions are required for the input and the output message, in addition to a main transaction class that receives the input and sends the output back to the requester. For this task the IMS Java project is used. ___1. Create a new package and prepare classpath for IMS Java

Select the IMS Java project, right click it and select New Package.

In the appearing New Java Package Wizard choose com.ibm.zsummer.ims as the name for the new package. Click Finish. The package should now appear in the expanded IMS Java project.

Next step is to import the imsjava.jar file, which contains all the classes that are required to compile IMS Java applications. We will use an ant script to download the jar file to the local file system. All the ant scripts will be stored in a separate package. The source of the follwing two files can be found in mainframes /usr/lpp/ims/ims11/zsummer directory, just use ftp or the host explorer to download it.

Create a new package com.ibm.zsummer.scripts in the IMSJava project.

Select the new package, click the right mouse button and select New Other.

In the appearing window expand General, select File and click Next.

For the parent folder select the com.ibm.zsummer.scripts package in the IMSJava project, that was just created and enter getfiles.xml as the file name.

Page 13: LAB IMS zSummerUni 2010 Part 1-7 - uni-hamburg.de · Part 1: Prepare the Development Environment (required) This part describes how prepare the RDz environment to be able to create

© Copyright IBM Corporation 2009. All rights reserved.

9/15/2010 Summer University IMS

Page 13 of 87

Click Finish to create the file. It should now appear in the expanded com.ibm.zsummer.scripts package and be open in the editor. Since the complete commons-net package that is required to run ant ftp actions is not included in RDz (FTPClient.class and some other classes are missing), the windows ftp client will be used instead. Therefore an ant script is created that executes the windows ftp client with a parameter file.

For this we need a temporary directory like C:\temp. Be sure that such a directory exists and if not create it.

Please note: The source code for the following two files (getfiles.xml and ftp_getfiles.in) is available in the z/OS hosts FTP directory -> /usr/lpp/ims/ims11/zsummer . Feel free to download/import it from there.

To call the window ftp client insert the following code in the getfiles.xml file (It might be required to click on the source tab of the editor window first, it is located on the left bottom of the editor window):

Save the file (e.g. using the File menu or <STRG>-S)

<?xml version="1.0"?> <project name="IMSJava" default="all" basedir="."> <target name="all"> <exec executable="ftp" dir="."> <arg line="-i -s:ftp_getfiles.in "/> </exec> </target> </project>

Page 14: LAB IMS zSummerUni 2010 Part 1-7 - uni-hamburg.de · Part 1: Prepare the Development Environment (required) This part describes how prepare the RDz environment to be able to create

© Copyright IBM Corporation 2009. All rights reserved.

9/15/2010 Summer University IMS

Page 14 of 87

Create a second simple file named ftp_getfiles.in in the com.ibm.zsummer.scripts package.

Insert the following code in the ftp_getfiles.in file:

Replace TEAMxx,PASSWORD and teamxx with your userid and your

password and replace 192.168.7.252 with the ip address of your z/OS host (if necessary). You might want to change the download directory (C:\temp in this sample) as well (it might not exist). This is the location where the imsjava.jar will be downloaded to and the directory to select when adding this file to the IMSJava project classpath.

Select the getfiles.xml file, click the right mouse button and select Run Ant Build.

open 192.168.7.252 TEAMxx ZSUMMER cd /usr/lpp/ims/ims11/zsummer/teamxx/scripts get ftp_restart.in get restart.xml get RESTART get ftp_sendjar.in get sendjar.xml lcd C:\temp cd /usr/lpp/ims/ims11/zsummer/material mget * bin cd /usr/lpp/ims/ims11/imsjava/classic get imsjavaBase.jar get imsjavaTM.jar get imsJDBC.jar quit

Page 15: LAB IMS zSummerUni 2010 Part 1-7 - uni-hamburg.de · Part 1: Prepare the Development Environment (required) This part describes how prepare the RDz environment to be able to create

© Copyright IBM Corporation 2009. All rights reserved.

9/15/2010 Summer University IMS

Page 15 of 87

Page 16: LAB IMS zSummerUni 2010 Part 1-7 - uni-hamburg.de · Part 1: Prepare the Development Environment (required) This part describes how prepare the RDz environment to be able to create

© Copyright IBM Corporation 2009. All rights reserved.

9/15/2010 Summer University IMS

Page 16 of 87

The ant script will be executed and the successful output looks like this:

You have now downloaded all necessary script files for the required

parts. In addition all code or ant script sources can be found in C:\temp or where the downloads from the getfiles.xml ant script where downloaded to.

Click on the scripts package right and click refresh so that the imported files will appear

Page 17: LAB IMS zSummerUni 2010 Part 1-7 - uni-hamburg.de · Part 1: Prepare the Development Environment (required) This part describes how prepare the RDz environment to be able to create

© Copyright IBM Corporation 2009. All rights reserved.

9/15/2010 Summer University IMS

Page 17 of 87

Now you have to add the downloaded jars to the java build path:

Select the IMSJava project, click the right mouse button and select Properties.

In the properties window select Java Build Path and click on the Libraries Tab.

Click on Add External JARs and select the files imsjavaBase.jar, imsjavaTM.jar and imsJDBC.jar in the directory where the file was just downloaded (e.g. C:\temp) and click Open. The file should now appear in the Libraries list.

Page 18: LAB IMS zSummerUni 2010 Part 1-7 - uni-hamburg.de · Part 1: Prepare the Development Environment (required) This part describes how prepare the RDz environment to be able to create

© Copyright IBM Corporation 2009. All rights reserved.

9/15/2010 Summer University IMS

Page 18 of 87

Click on Add Library Server Runtime and select WebSphere Application Server 7.0

Click OK to close the Properties Window. Now the project is prepared to write the IMS Java transaction. ___2. Create the input and output record definitions As mentioned to invoke an IMS transaction there are input messages sent to IMS and output messages received by the requestor. These messages are record based as a tribute to the times where memory was short. Therefore those messages always contain a length field (LL) for the total message length and a status field (ZZ). The input message also contains the transaction code. After that there are the parameters.

Select the com.ibm.zsummer.ims package in the IMSJava project, click the right mouse button and select New Class. Use Input as the class name. The LL, ZZ and trancode fields are not defined. We use a fixed 8 byte transaction code plus one blank character (TRANCODE_FIXED_9). The input message consists of an 4 byte integer that contains the Amount and the 10 byte item id. The DLITypeInfo entry have to contain the offset and the length as parameters. There will be a toll called DLIMODEL utility which will be used to assemble the messages later.

Page 19: LAB IMS zSummerUni 2010 Part 1-7 - uni-hamburg.de · Part 1: Prepare the Development Environment (required) This part describes how prepare the RDz environment to be able to create

© Copyright IBM Corporation 2009. All rights reserved.

9/15/2010 Summer University IMS

Page 19 of 87

Insert the following code for the Input message and save the changes.

Hint: The line setTransCodeRule is entered, this tells IMS that the transaction code is of length 8 bytes plus 1 blank and after that the data starts.

Create a new class in the com.ibm.zsummer.ims package called Output. The output message also contains LL and ZZ, but they are not defined. The record contains an 4 byte integer for the Return code of the web service and an 80 byte String message.

Insert the following code for the Output message and save the changes.

___3. Create the IMS transaction code

Create a new class in the com.ibm.zsummer.ims package called Backorder. The code for the Backorder is somewhat self-instructional.

Insert the following code for the Backorder class and save the changes.

package com.ibm.zsummer.ims; import com.ibm.ims.base.*; import com.ibm.ims.application.*; public class Input extends IMSFieldMessage { static DLITypeInfo[] fieldInfo = { new DLITypeInfo("Amount", DLITypeInfo.INTEGER,1,4), new DLITypeInfo("Item",DLITypeInfo.CHAR,5,10) }; public Input() { super(fieldInfo, 200, false); //constructor setTransCodeRule(IMSFieldMessage.TRANSCODE_FIXED_9); } static final long serialVersionUID = 1L; }

package com.ibm.zsummer.ims; import com.ibm.ims.base.*; import com.ibm.ims.application.*; public class Output extends IMSFieldMessage { static DLITypeInfo[] fieldInfo = { new DLITypeInfo("RC", DLITypeInfo.INTEGER,1,4), new DLITypeInfo("Message", DLITypeInfo.CHAR,5,80) }; public Output() { super(fieldInfo, 200, false); } static final long serialVersionUID = 1L; }

Page 20: LAB IMS zSummerUni 2010 Part 1-7 - uni-hamburg.de · Part 1: Prepare the Development Environment (required) This part describes how prepare the RDz environment to be able to create

© Copyright IBM Corporation 2009. All rights reserved.

9/15/2010 Summer University IMS

Page 20 of 87

Now the IMS Java transaction was successfully created. The package com.ibm.zsummer.ims should now contain 3 classes.

The definitions on the z/OS host are made that each user can upload a jar file called teamxx.jar to the users home directory (/u/teamxx) and it will be in class path. The transactions that are defined are called TEAMxxT1 and is mapped to class com.ibm.zsummer.ims.Backorder. Replace xx for the actual user. Each user will have a separate IMS region (TEAMxxMP) with a separate classpath and separate transaction class. This ensures that the actual code of TEAM11 will not interfere with code of other users. These are settings that are made in an z/OS dataset called IMS Proclib (actually IMS11A.PROCLIB). For ease of use the definitions are already finished and there is nothing to do on the z/OS side if the naming conventions are followed.

package com.ibm.zsummer.ims; import com.ibm.ims.application.*; public class Backorder { /** * @param args */ public static void main(String[] args) { // TODO Auto-generated method stub //instanciate Message Queue Object and Input/Output Messages IMSMessageQueue messageQueue = new IMSMessageQueue(); Input inputMessage = new Input(); Output outputMessage = new Output(); //catch any IMSExceptions try { //initial Get Unique messageQueue.getUniqueMessage(inputMessage); //for performance reasons and multiple schedules loop around processing do { try { //for the simplest case just send Hello World back outputMessage.setString("Message", "Hello World!"); } catch (Exception e) { //in case of exception print the stack trace and set message text e.printStackTrace(); outputMessage.setString("Message", "Exception occured! See IMS Region Log!"); } //send output message back to caller messageQueue.insertMessage(outputMessage); //loop as long as there are input messages } while (messageQueue.getNextMessage(inputMessage)); } catch (Exception e) { //something really bad happened outputmessage cannot be send to caller e.printStackTrace(); } } }

Page 21: LAB IMS zSummerUni 2010 Part 1-7 - uni-hamburg.de · Part 1: Prepare the Development Environment (required) This part describes how prepare the RDz environment to be able to create

© Copyright IBM Corporation 2009. All rights reserved.

9/15/2010 Summer University IMS

Page 21 of 87

___4. Upload the file to the host

sendjar.xml in the com.ibm.zsummer.scripts package

Edit the second file named ftp_sendjar.in in the

com.ibm.zsummer.scripts package.

Replace PASSWORD with your password and replace 192.168.7.252 with

the host name or ip address of your z/OS host and

Select the sendjar.xml file, click the right mouse button and select Run As Ant Build. The successful output will look similar like this:

___5. Restart the IMS Region

Now for the activation of the Java classes we just uploaded it is necessary to restart your IMS region. Hint: Normally you must issue a few commands each time the program is uploaded. The sequence in short is as follows: /DIS A to find out if it is already started /STO REG JOBNAME TEAMxxMP to stop the region /DIS A to check if the region is stopped /STA REG TEAMxxMP to start the region

<?xml version="1.0"?> <project name="IMSJava" default="all" basedir="."> <target name="all"> <delete file="teamxx.jar"/> <jar destfile="teamxx.jar" basedir="../../../../../bin" includes="com/ibm/zsummer/**" excludes="com/ibm/zsummer/scripts/*" /> <exec executable="ftp" dir="."> <arg line="-s:ftp_sendjar.in "/> </exec> </target> </project>

open 192.168.7.252 TEAMxx ZSUMMER bin cd /u/teamxx bin put teamxx.jar quit

Page 22: LAB IMS zSummerUni 2010 Part 1-7 - uni-hamburg.de · Part 1: Prepare the Development Environment (required) This part describes how prepare the RDz environment to be able to create

© Copyright IBM Corporation 2009. All rights reserved.

9/15/2010 Summer University IMS

Page 22 of 87

/DIS A to verify that the region was started

We use a script instead to speed up the development. Edit the restart.xml and replace your Host IP Address.

The Script uploads and executes a job (RESTART) which will restart your IMS

Region TEAMxxMP

Also edit the ftp_restart.in file and replace PASSWORD with your password and insert your Host IP

Every time you will run the sendjar.xml you also have to execute the

restart.xml by right-clicking Run as Ant Build.

If the package scripts is refreshed, the job.output file appears. Review the job output. For the STOP command it is possible that there is a Return code of 08 if there is no IMS region running.

<?xml version="1.0"?> <project name="IMSJava" default="all" basedir="."> <target name="all"> <exec executable="ftp" dir="."> <arg line="-s:ftp_restart.in"/> </exec> </target> </project>

open 192.168.7.252 TEAMxx PASSWORD put RESTART TEAMxxRS quote site filetype=jes quote site JESJOBNAME=TEAMxxRS get TEAMxxRS job.output

Page 23: LAB IMS zSummerUni 2010 Part 1-7 - uni-hamburg.de · Part 1: Prepare the Development Environment (required) This part describes how prepare the RDz environment to be able to create

© Copyright IBM Corporation 2009. All rights reserved.

9/15/2010 Summer University IMS

Page 23 of 87

___6. Test the IMS transaction

Open a new or existing 3270 session and instead of TSO for logging on to ISPF, enter IMS and send this selection to the host. On the IMS logon screen, enter Userid (TEAMxx) and password and send this selection to the host.

Enter the transaction code (TEAMxxT1) followed by at least one blank character and send this to the host.

You should see your Hello World Echo as result.

Page 24: LAB IMS zSummerUni 2010 Part 1-7 - uni-hamburg.de · Part 1: Prepare the Development Environment (required) This part describes how prepare the RDz environment to be able to create

© Copyright IBM Corporation 2009. All rights reserved.

9/15/2010 Summer University IMS

Page 24 of 87

Part 3: Create a Non Managed Test Client Now it is tested if the IMS transaction is working by building a plain java Test Client using IMS Connector for Java ___1. Generate the Input and Output Message Format Handlers for the J2EE

Client There is currently no generator for creating the Input and Output message format handlers for Java Input. There is only C and COBOL available. Therefore a COBOL Source file was prepared that contains the COBOL equivalents of the IMS Java transactions input and output messages. This file will be used to create the input and output message definitions.

The summeruni.cpy file should be placed to c:\temp Go to the IMSJava project and expand the com.ibm.zsummer.ims package. Select the com.ibm.zsummer.ims package, click the right mouse button and

select New Other.

Expand J2C, select CICS/IMS Data Binding and click Next.

Page 25: LAB IMS zSummerUni 2010 Part 1-7 - uni-hamburg.de · Part 1: Prepare the Development Environment (required) This part describes how prepare the RDz environment to be able to create

© Copyright IBM Corporation 2009. All rights reserved.

9/15/2010 Summer University IMS

Page 25 of 87

Click on Browse and select the file summeruni.cpy that was just downloaded

and click Next.

Change the platform to z/OS, Click Show Advanced, Scroll Down and change Compile Option Trunc to BIN. Click on Query and select INPUT01.

Click Next.

Page 26: LAB IMS zSummerUni 2010 Part 1-7 - uni-hamburg.de · Part 1: Prepare the Development Environment (required) This part describes how prepare the RDz environment to be able to create

© Copyright IBM Corporation 2009. All rights reserved.

9/15/2010 Summer University IMS

Page 26 of 87

In the next window check if IMSJava is selected as the project to import to

and change the package name to com.ibm.zsummer.ims.

Click Finish.

Repeat the Import for the OUTPUT01 Record (New J2C CICS/IMS Data Binding with the same settings as for INPUT01). The com.ibm.zsummer.ims package should now look like this:

The input and output message handlers for the IMS Java transactions were now created.

Page 27: LAB IMS zSummerUni 2010 Part 1-7 - uni-hamburg.de · Part 1: Prepare the Development Environment (required) This part describes how prepare the RDz environment to be able to create

© Copyright IBM Corporation 2009. All rights reserved.

9/15/2010 Summer University IMS

Page 27 of 87

___2. Create the J2C Bean

Select the com.ibm.zsummer.ims package, click the right mouse button and select New Other.

Under J2C Select J2C Java Bean and click Next.

Select the IMS Resource Adapter 10.3.2 under IMS TM

and click Next.

Let the default name and select WebSphere Application Server 7.0 as Runtime and Click Next

Select Outbound as we want to call the transaction and lick Next

Page 28: LAB IMS zSummerUni 2010 Part 1-7 - uni-hamburg.de · Part 1: Prepare the Development Environment (required) This part describes how prepare the RDz environment to be able to create

© Copyright IBM Corporation 2009. All rights reserved.

9/15/2010 Summer University IMS

Page 28 of 87

Let the default and click next.

Page 29: LAB IMS zSummerUni 2010 Part 1-7 - uni-hamburg.de · Part 1: Prepare the Development Environment (required) This part describes how prepare the RDz environment to be able to create

© Copyright IBM Corporation 2009. All rights reserved.

9/15/2010 Summer University IMS

Page 29 of 87

At the Connection Properties page select Non-managed Connection, uncheck Managed Connection. The non-managed connection will be used with a Java application to test the IMS transaction. Enter the host name or IP address, port number (9999) and datastore ID (IMSA)!!!.

Click on Show Advanced, scroll down and add the Userid and password. Otherwise the default userid of the IMS regions started task will be used, which usually does not have the privileges to run the transaction (e.g. ICH408 messages). Click Next.

In the next window enter com.ibm.zsummer.imsnonmanaged as the package name where the bean is to be created. For the Interface Name start typing IMSJ2CNonManaged, the Implementation name will be typed automatically.

Page 30: LAB IMS zSummerUni 2010 Part 1-7 - uni-hamburg.de · Part 1: Prepare the Development Environment (required) This part describes how prepare the RDz environment to be able to create

© Copyright IBM Corporation 2009. All rights reserved.

9/15/2010 Summer University IMS

Page 30 of 87

Click Next.

In the Java Methods window Click Add and for the Java Method Name Enter Backorder

Now the input message for the J2C Bean Method Backorder will be selected. In the Add Java Method window click browse under Input Type, start typing Input and select INPUT01 – com.ibm.zsummer.ims.

Page 31: LAB IMS zSummerUni 2010 Part 1-7 - uni-hamburg.de · Part 1: Prepare the Development Environment (required) This part describes how prepare the RDz environment to be able to create

© Copyright IBM Corporation 2009. All rights reserved.

9/15/2010 Summer University IMS

Page 31 of 87

Click OK. For the Output Type click Browse, select OUPUT01 and click OK.

The Add Java method window should look like this:

Click Finish.

Page 32: LAB IMS zSummerUni 2010 Part 1-7 - uni-hamburg.de · Part 1: Prepare the Development Environment (required) This part describes how prepare the RDz environment to be able to create

© Copyright IBM Corporation 2009. All rights reserved.

9/15/2010 Summer University IMS

Page 32 of 87

Now back on the Java Methods pane in the New J2C Java Bean Wizard it should look like this.

Click Advanced and uncheck Use Conversation ID

Click Finish. The J2C Bean is now being generated. ___3. Run the Non-managed J2C Bean

Expand and select the com.ibm.zsummer.ims.nonmanaged package, click the right mouse button and select New Class. For the class name Enter IMSJ2CTestApp, check public static void main(String [] args) and click OK.

Change the class to contain the following code which will invoke the J2C bean and display the output.

Page 33: LAB IMS zSummerUni 2010 Part 1-7 - uni-hamburg.de · Part 1: Prepare the Development Environment (required) This part describes how prepare the RDz environment to be able to create

© Copyright IBM Corporation 2009. All rights reserved.

9/15/2010 Summer University IMS

Page 33 of 87

Make sure to replace the xx in TEAMxxT1 according to your userid,

otherwise you will get an Exception stating that the DESTINATION COULD NOT BE FOUND OR CREATED or an Exception stating: IMS OTMA returned error: SENSECODE=[26], REASONCODE=[29]. [].

Save the changes, select the IMSJ2CTestApp, click the right mouse button and Select Run As Java Application. The output on successful invocation will look like this, depending on your Transaction output.

package com.ibm.zsummer.imsnonmanaged; import com.ibm.zsummer.ims.*; public class IMSJ2CTestApp { public static void main(String[] args) { try { //create the bean IMSJ2CNonManagedImpl bean = new IMSJ2CNonManagedImpl(); //instanciate the input and output messages INPUT01 input = new INPUT01(); OUTPUT01 output = new OUTPUT01(); //fill the input message input.setIn__ll((short)input.getSize()); input.setIn__trcd("TEAMxxT1"); input.setAmount(1); input.setItem("0010"); //execute the Backorder Method on the Bean output = bean.Backorder(input); //Display the output on STDOUT System.out.println("RC: " + output.getRc() + " Message: " + output.getOut__msg()); } catch (Exception e) { //Catch any exception and print the stack trace e.printStackTrace(); } } }

Page 34: LAB IMS zSummerUni 2010 Part 1-7 - uni-hamburg.de · Part 1: Prepare the Development Environment (required) This part describes how prepare the RDz environment to be able to create

© Copyright IBM Corporation 2009. All rights reserved.

9/15/2010 Summer University IMS

Page 34 of 87

Part 4: Enhance the simple IMS Java transaction to call DB2 This part enhances the simple IMS Java transaction to access DB2. A DB2 table is updated with the delivered parts. This is a free tutorial, so no step-by-step instructions.

Change the Backorder Transaction to have the DB2 code implemented: It is suggested to add two methods getConnection() and callDB2Update(int amount, String item). Required Variables:

SQL for using a prepared Statement:

In the prepared Statement the variable placeholder (?) for WS_IN_STOCK and WS_ON_ORDER is to be set with the amount and placeholder for WS_ITEM_REF is to be set with the String item.

Save the changes and execute the Ant Script sendjar.xml to upload the changed IMS transaction.

Stop and Start the IMS region to reload the changed application jar file by running restart.xml again. Hint: The complete sample (Backorder_with_DB2.java) should be placed in your local c:/temp directory. Be sure to change the name and class to Backorder if you import this file.

Test the changed Backorder transaction with the non Managed Test Client using the IMSJ2CTestApp which was created during the last Part. The reason for this is that the Input Message implements a binary value (Integer type for Amount) which cannot be entered at a 3270 screen.

// the DB2 connection url private static String url = "jdbc:db2os390sqlj:"; // DB2 JDBC/SBLJ driver name private static String driverName = "COM.ibm.db2os390.sqlj.jdbc.DB2SQLJDriver";

String sql = "UPDATE " + " ZUNI.EXMPCAT" + " SET" + " WS_IN_STOCK = WS_IN_STOCK + ?, " + " WS_ON_ORDER = WS_ON_ORDER - ? " + " WHERE" + " WS_ITEM_REF = ?";

Page 35: LAB IMS zSummerUni 2010 Part 1-7 - uni-hamburg.de · Part 1: Prepare the Development Environment (required) This part describes how prepare the RDz environment to be able to create

© Copyright IBM Corporation 2009. All rights reserved.

9/15/2010 Summer University IMS

Page 35 of 87

Part 5: Use IMS SOAP Gateway to call the IMS Transaction as a Web Service This Lab describes the necessary steps to create an IMS Web Service from a Cobol Copybook and deploy it into an IMS SOAP Gateway. The Web Service will call the IMS Transaction and will return the results to the requestor. IMS acts in this case as service provider (for CICS or RDz Web Service Explorer). IMS SOAP Gateway is a kind of a lightweight Web Server for Web Services which is connected to IMS via IMS Connect. In IMS Connect you can therefore install an XML Adapter, which maps your Incoming SOAP Message to the IMS traditional Message Format which the IMS Transaction is expecting. In this part you will develop a Web Service which maps to the Cobol Copybook, deploy the Web Service in the IMS SOAP Gateway and test it with the help of Rational Developer for System z. Instead of using IMS SOAP Gateway for the hosting of Web Services you can also use WebSphere Application Server, which offers much more possibilities but is therefore more complex to configure.

Lab Requirements IMS V11 or later (with Transaction) IMS Connect with installed XML Adapter Support IMS SOAP Gateway v10.1 Fix 3 Rational Developer for System z v7.5.4 with RAD 7.6 ATTENTION: Be aware of case sensitivity in this tutorial. This is important! XX or xx in all Inputs stands always for your User ID. (cnuserX for User01 = cnuser01)

Page 36: LAB IMS zSummerUni 2010 Part 1-7 - uni-hamburg.de · Part 1: Prepare the Development Environment (required) This part describes how prepare the RDz environment to be able to create

© Copyright IBM Corporation 2009. All rights reserved.

9/15/2010 Summer University IMS

Page 36 of 87

___1. IMS SOAP Gateway Introduction The following architectural picture shows an example how IMS SOAP Gateway can be used:

Components: IMS SOAP Gateway Lightweight Web & SOAP Server for IMS IMS Connect TCP/IP Gateway for IMS with XML Converter OTMA Open Transaction Manager for IMS IMS TM IMS Transaction Manager with dependent Region IMS DB IMS Database Manager with Database

1. A User queries a Phone Number for a person via the Web App. 2. The Web App calls the SOAP Gateway adapter via SOAP Web Service. 3. IMS SOAP Gateway offers a possibility to connect to IMS Connect via

TCP/IP XML Communication. It can also handle easy web applications because it is based on Apache Tomcat.

4. IMS Connect has a Converter installed which translates the incoming XML Message structure into IMS Message Format without the XML Tags and with the Length Field (LL) and a status Field (ZZ).

5. OTMA passes the Message to IMS TM. 6. The Application gets the message from the IMS Queue and checks the

database for the correct name and replies the answer on the output queue.

7. The Message follows the line back to the Web App where the SOAP Response Message is transformed into HTML Output.

Page 37: LAB IMS zSummerUni 2010 Part 1-7 - uni-hamburg.de · Part 1: Prepare the Development Environment (required) This part describes how prepare the RDz environment to be able to create

© Copyright IBM Corporation 2009. All rights reserved.

9/15/2010 Summer University IMS

Page 37 of 87

___2. Create the IMS SOAP Gateway Project Please perform the following steps:

Start the Rational Developer for System z. Switch to the Enterprise Service Tools Perspective

Click on the “Window with Plus” Icon on the right top side of the RD4z window as shown. Select Other. In the appearing window choose Enterprise Service Tools and click OK. The Project Explorer of the Enterprise Service Tools Perspective will appear on the left side.

Before you start the wizard, make sure the summeruni.cpy COBOL Copybook has been downloaded to a temporary directory on your system. The file defines the format which the IMS Transactions is expecting. The XML Adapter is responsible to create a mapping therefore.

Click the right mouse button in the Project Explorer and Select New IMS SOAP Gateway Project.

The IMS SOAP Gateway Project Wizard appears. Insert a Project Name (e.g. IMS_SOAP_WS) and Click Next.

Page 38: LAB IMS zSummerUni 2010 Part 1-7 - uni-hamburg.de · Part 1: Prepare the Development Environment (required) This part describes how prepare the RDz environment to be able to create

© Copyright IBM Corporation 2009. All rights reserved.

9/15/2010 Summer University IMS

Page 38 of 87

The Source Import Window appears.

Click on File System and put in the location of the Cobol Copybook (summeruni.cpy) you downloaded in previous tutorials and Click Open.

Page 39: LAB IMS zSummerUni 2010 Part 1-7 - uni-hamburg.de · Part 1: Prepare the Development Environment (required) This part describes how prepare the RDz environment to be able to create

© Copyright IBM Corporation 2009. All rights reserved.

9/15/2010 Summer University IMS

Page 39 of 87

Now you can Click Finish in the Import Dialog.

You should see in the Project Explorer the Cobol Copybook Source.

The next wizard will be automatically launched

Page 40: LAB IMS zSummerUni 2010 Part 1-7 - uni-hamburg.de · Part 1: Prepare the Development Environment (required) This part describes how prepare the RDz environment to be able to create

© Copyright IBM Corporation 2009. All rights reserved.

9/15/2010 Summer University IMS

Page 40 of 87

Select INPUT01 in the Inbound Language Structure Click on the Response Language Structure Tab and Select OUTPUT01.

Click Next

Page 41: LAB IMS zSummerUni 2010 Part 1-7 - uni-hamburg.de · Part 1: Prepare the Development Environment (required) This part describes how prepare the RDz environment to be able to create

© Copyright IBM Corporation 2009. All rights reserved.

9/15/2010 Summer University IMS

Page 41 of 87

Click Next again

Insert the following values as shown in the picture.

Converter Name: IMSWSxx (e.g. IMSWS01 for User01) Service Program name: IMSWSxxD (Be aware: The D at the End is important)

Page 42: LAB IMS zSummerUni 2010 Part 1-7 - uni-hamburg.de · Part 1: Prepare the Development Environment (required) This part describes how prepare the RDz environment to be able to create

© Copyright IBM Corporation 2009. All rights reserved.

9/15/2010 Summer University IMS

Page 42 of 87

Click on the WSDL and XSD tab and Change the values to your own System settings.

For Service Location: http://localhost:8080/imssoap/services/IMSWSxxPort (x for your userid) (Remove the D before the port) Service Name: IMSWSxxService Operation Name: IMSWSxxOperation

Page 43: LAB IMS zSummerUni 2010 Part 1-7 - uni-hamburg.de · Part 1: Prepare the Development Environment (required) This part describes how prepare the RDz environment to be able to create

© Copyright IBM Corporation 2009. All rights reserved.

9/15/2010 Summer University IMS

Page 43 of 87

Click Next and insert the Transaction Code and Inbound connection bundle.

SOAPAction: urn:IMSWSxx Transaction Code: TEAMxxT1 Inbound connection bundle: cnuserXX

Page 44: LAB IMS zSummerUni 2010 Part 1-7 - uni-hamburg.de · Part 1: Prepare the Development Environment (required) This part describes how prepare the RDz environment to be able to create

© Copyright IBM Corporation 2009. All rights reserved.

9/15/2010 Summer University IMS

Page 44 of 87

Click Next and check if the Converter driver file name ends with a D, generate all to driver is selected.

Click Finish. Now you should see the following files in the Project Explorer:

Page 45: LAB IMS zSummerUni 2010 Part 1-7 - uni-hamburg.de · Part 1: Prepare the Development Environment (required) This part describes how prepare the RDz environment to be able to create

© Copyright IBM Corporation 2009. All rights reserved.

9/15/2010 Summer University IMS

Page 45 of 87

___3. Copy & Prepare Files on System z Normally you have to copy the converter to the host and compile and link the program to the steplib of IMS Connect which is responsible for transforming the incoming and outgoing messages. After doing this, IMS Connect has to be restarted to take the changes into effect. For your comfort all these steps are already done for you. There are 20 converters generated in the IMS11A.WORKSHOP Dataset called IMSWS01D thru IMSWS20D. They are already compiled for ease of use and for your convenience. So no compile and link of the converter and restart of IMS Connect is required.

Page 46: LAB IMS zSummerUni 2010 Part 1-7 - uni-hamburg.de · Part 1: Prepare the Development Environment (required) This part describes how prepare the RDz environment to be able to create

© Copyright IBM Corporation 2009. All rights reserved.

9/15/2010 Summer University IMS

Page 46 of 87

___4. Configure the IMS SOAP Gateway Environment IMS SOAP Gateway is available for very much platforms because it is mainly Java based. This solution also works on z/OS UNIX System Services, but in this case we use Windows for easier handling with the file exchange. Therefore start in your Start Menu the IMS SOAP Gateway Deployment Utility

A screen should appear:

****************************************************************************** * * * Welcome to the IMS SOAP Gateway Deployment Utility * * * ****************************************************************************** The IMS SOAP Gateway Deployment Utility provides an interactive user interface with tasks to enable and maintain your IMS applications as a Web Service. It also lets you enable your IMS application to access an external Web service. To get help for a particular task, go to the IMS SOAP Gateway documentation. To return to the main menu, type "cancel" at any point. =============================================================================== Enable your IMS application as a Web service : Task 1: Enable your IMS application as a Web service provider from start to f inish Administrative tasks (Type "cancel" to return to the main menu): Task 2: Start IMS SOAP Gateway Task 3: Stop IMS SOAP Gateway Task 4: Update IMS SOAP Gateway properties Task 5: Create, Update or View correlator properties for Web Service Task 6: Create, Update, Delete or View connection bundle Task 7: Deploy the WSDL file Task 8: Generate Java client code Task 9: Undeploy Web service Task 10: Enable your IMS application to access an external Web Service Task 11: Exit deployment utility =============================================================================== > Enter your selection here:

Page 47: LAB IMS zSummerUni 2010 Part 1-7 - uni-hamburg.de · Part 1: Prepare the Development Environment (required) This part describes how prepare the RDz environment to be able to create

© Copyright IBM Corporation 2009. All rights reserved.

9/15/2010 Summer University IMS

Page 47 of 87

Make the following inputs followed with <RETURN> - Select 2 to start the SOAP Gateway first. ( A second screen should

appear)

- Select 1 - Insert the name and the location of your IMSWSxx.wsdl - Make sure to replace xx or XX according to your userid. Hint: You can check the location of the wsdl and xml file by right-clicking on your the file in the project explorer of RDz and select Properties

You can mark the location and use <Control>-C to copy and the Menu Edit -> Paste in the deployment utility window to copy the full file name. - Want to view all connection bundles: Insert N - Want to create a new connection bundle: Insert Y - Name for connection bundle: Insert cnuserXX - Host name: Insert 192.168.7.252 - Port Number: Insert 9999 - Datastore: Insert IMSA - Userid: Insert TEAMxx - Password: Insert <Your Password> - Group: Leave blank - SSL Properties : Insert N - Use exisiting correlator : Insert Y - Insert the name and the location of your IMSWSxx.xml - Want to view the correlator file : Insert Y - Want to deploy the WSDL File to SOAP Gateway : Insert Y - Want to generate Java Client Code : Insert N

Now you can check if the web service is deployed on your local running

SOAP Gateway by calling the following website http://localhost:8080/imssoap/ and view the deployed web services. Or you can access the wsdl directly by calling http://localhost:8080/imssoap/services/IMSWSxxPort?wsdl (make sure to replace xx with according to your userid)

Page 48: LAB IMS zSummerUni 2010 Part 1-7 - uni-hamburg.de · Part 1: Prepare the Development Environment (required) This part describes how prepare the RDz environment to be able to create

© Copyright IBM Corporation 2009. All rights reserved.

9/15/2010 Summer University IMS

Page 48 of 87

___5. Test the Web Service

Go back to RDz Switch to the Enterpise Service Tools Perspective and Right click on the WSDL file in the Project Explorer. Go to Web Services Section and there to Test with Web Service Explorer

Click in the Web Service Explorer on your “Operation”

Page 49: LAB IMS zSummerUni 2010 Part 1-7 - uni-hamburg.de · Part 1: Prepare the Development Environment (required) This part describes how prepare the RDz environment to be able to create

© Copyright IBM Corporation 2009. All rights reserved.

9/15/2010 Summer University IMS

Page 49 of 87

Insert your test values and Click on Go. (You can also play around with the values or use this Web Service to test your changes in the Transaction) Transaction code: TEAMxxT1 | LL: 59 | ZZ: 00 TRCD: TEAMxxT1 | AMOUNT: 1 | ITEM: 0010

See the results of your Web Service call in the Response window.

Page 50: LAB IMS zSummerUni 2010 Part 1-7 - uni-hamburg.de · Part 1: Prepare the Development Environment (required) This part describes how prepare the RDz environment to be able to create

© Copyright IBM Corporation 2009. All rights reserved.

9/15/2010 Summer University IMS

Page 50 of 87

Part 6: Create a Web Service for the IMS transaction with WAS In this lab a Web Service for calling this transaction will be generated and deployed to the local WebSphere Application Server Evironment ___1. Create a new Web Project

Click New Dynamic Web Project in the Project Explorer

Enter TEAMxxIMSWS as Project name and select Target Runtime WAS 7.0 Click Add Project to an EAR and enter TEAMxxIMSWSEar and click on

New..

Page 51: LAB IMS zSummerUni 2010 Part 1-7 - uni-hamburg.de · Part 1: Prepare the Development Environment (required) This part describes how prepare the RDz environment to be able to create

© Copyright IBM Corporation 2009. All rights reserved.

9/15/2010 Summer University IMS

Page 51 of 87

Select Runtime WAS 7.0 and click Finish Deny any appearing view switch requests. Click Finish

In your TEAMxxIMSWS Project create a new package called

com.ibm.zsummer.ims and click Finish

Page 52: LAB IMS zSummerUni 2010 Part 1-7 - uni-hamburg.de · Part 1: Prepare the Development Environment (required) This part describes how prepare the RDz environment to be able to create

© Copyright IBM Corporation 2009. All rights reserved.

9/15/2010 Summer University IMS

Page 52 of 87

Should look like this now

___2. Generate the Input and Output Message Format Handlers for the

J2EE Client

Wheter you do the same steps again like you did in the non managed Part for the Input and Output Message Format Handler Creation (see part 3 Step 1) or you can also just copy the Input01 and the Output01 from the IMSJava Project to your new project and your just created package. ___3. Generate the J2C Bean for the managed Environment Since the Web Service runs in an application server (so called managed environment) JNDI services will be used to lookup the IMS Connection Settings, so they can be changed using the WebSphere Admin console and without recompiling and redeploying the code. A J2C Bean for the managed Environment will be created.

Page 53: LAB IMS zSummerUni 2010 Part 1-7 - uni-hamburg.de · Part 1: Prepare the Development Environment (required) This part describes how prepare the RDz environment to be able to create

© Copyright IBM Corporation 2009. All rights reserved.

9/15/2010 Summer University IMS

Page 53 of 87

Select the com.ibm.zsummer.ims package, click the right mouse button

and select New Other.

Under J2C Select J2C Java Bean and click Next.

Page 54: LAB IMS zSummerUni 2010 Part 1-7 - uni-hamburg.de · Part 1: Prepare the Development Environment (required) This part describes how prepare the RDz environment to be able to create

© Copyright IBM Corporation 2009. All rights reserved.

9/15/2010 Summer University IMS

Page 54 of 87

Select the IMS Resource Adapter 10.3.0 under IMS TM

and click Next.

Let the default name and select WebSphere Application Server 7.0 as Runtime and Click Next

Select Outbound as we want to call the transaction and click Next.

Page 55: LAB IMS zSummerUni 2010 Part 1-7 - uni-hamburg.de · Part 1: Prepare the Development Environment (required) This part describes how prepare the RDz environment to be able to create

© Copyright IBM Corporation 2009. All rights reserved.

9/15/2010 Summer University IMS

Page 55 of 87

Let the default for IMS COBOL based applications and click next.

At the Connection Properties page select Managed Connection. Enter /eis/TEAMxxIMS1CF as the JNDI Lookup Name and replace the xx according to your userid.

Click New. The JNDI Lookup Wizard will Open.

Select WebSphere Application Server v7.1 and click Next.

Page 56: LAB IMS zSummerUni 2010 Part 1-7 - uni-hamburg.de · Part 1: Prepare the Development Environment (required) This part describes how prepare the RDz environment to be able to create

© Copyright IBM Corporation 2009. All rights reserved.

9/15/2010 Summer University IMS

Page 56 of 87

On the New Connection Factory Window check if eis/TEAMxxIMS1CF is the JNDI name, enter the host name or ip address of your host, the port number and scroll down. Enter the Datastore ID, click on Show Advanced and enter the userid and password.

Click Finish.

Back in the New J2C Java Bean wizard window click Next.

In the next window enter or select com.ibm.zsummer.ims as the package name where the bean is to be created. For the Interface Name start typing IMSJ2C, the Implementation name will be typed automatically.

Page 57: LAB IMS zSummerUni 2010 Part 1-7 - uni-hamburg.de · Part 1: Prepare the Development Environment (required) This part describes how prepare the RDz environment to be able to create

© Copyright IBM Corporation 2009. All rights reserved.

9/15/2010 Summer University IMS

Page 57 of 87

Click Next.

In the Java Methods window Click Add and for the Java Method Name Enter backorder

Now the input message for the J2C Bean Method Backorder will be selected. In the Add Java Method window click browse under Input Type, start typing Input and select INPUT01 – com.ibm.zsummer.ims.

Page 58: LAB IMS zSummerUni 2010 Part 1-7 - uni-hamburg.de · Part 1: Prepare the Development Environment (required) This part describes how prepare the RDz environment to be able to create

© Copyright IBM Corporation 2009. All rights reserved.

9/15/2010 Summer University IMS

Page 58 of 87

Click OK. For the Output Type click Browse, select OUPUT01 and click OK.

The Add Java method window should look like this:

Click Finish.

Page 59: LAB IMS zSummerUni 2010 Part 1-7 - uni-hamburg.de · Part 1: Prepare the Development Environment (required) This part describes how prepare the RDz environment to be able to create

© Copyright IBM Corporation 2009. All rights reserved.

9/15/2010 Summer University IMS

Page 59 of 87

Now back on the Java Methods pane in the New J2C Java Bean Wizard it should look like this.

Click Advanced and uncheck Use Conversation ID Leave the other defaults and click Next.

In the Deployment Information Window check Create a Web Page, Web Service, or EJB from J2C Bean

Page 60: LAB IMS zSummerUni 2010 Part 1-7 - uni-hamburg.de · Part 1: Prepare the Development Environment (required) This part describes how prepare the RDz environment to be able to create

© Copyright IBM Corporation 2009. All rights reserved.

9/15/2010 Summer University IMS

Page 60 of 87

Select Web Service as the J2EE Resource Type and click Next.

Click Advanced and insert TEAMxxIMS1CF_res as Resource Reference

Click Finish.

Expand the TEAMxxIMSWSWeb Project, expand the Java Resources, src folder and package com.ibm.zsummer.ims package. It should look like this:

Page 61: LAB IMS zSummerUni 2010 Part 1-7 - uni-hamburg.de · Part 1: Prepare the Development Environment (required) This part describes how prepare the RDz environment to be able to create

© Copyright IBM Corporation 2009. All rights reserved.

9/15/2010 Summer University IMS

Page 61 of 87

___4. Deploy the EAR on the local Application Server

Start your local WAS 7.0 by right Clicking WAS 7.0 –> Start if not already started.

Click on Add and Remove Projects.

Add UserXXIMSWSEar to your server and click Finish. The Resource

Adapter should be automatically deployed and a Connection Factory created. ___5. Test with Web Service Explorer

Expand your project to find the wsdl file.

Page 62: LAB IMS zSummerUni 2010 Part 1-7 - uni-hamburg.de · Part 1: Prepare the Development Environment (required) This part describes how prepare the RDz environment to be able to create

© Copyright IBM Corporation 2009. All rights reserved.

9/15/2010 Summer University IMS

Page 62 of 87

Right Click and select Web Services Test with Web Service Explorer Insert the test values

Page 63: LAB IMS zSummerUni 2010 Part 1-7 - uni-hamburg.de · Part 1: Prepare the Development Environment (required) This part describes how prepare the RDz environment to be able to create

© Copyright IBM Corporation 2009. All rights reserved.

9/15/2010 Summer University IMS

Page 63 of 87

Check the results.

Now creating the IMS Web Service is successfully finished. The optional step is to add some business logic accessing IMS databases to the IMS Java transaction. For adding the business logic there are no interface changes required, thus if the logic inside the IMS transaction is changed, the web service and the classes to call and test the IMS transaction will not change. The whole environment is now set up to add the IMS databases and to add the logic to access this hierarchical database to the Backorder class. ___6. Test the J2C Bean with other Options This step is optional if you have time to try some things for your own

- Try to manually deploy the EAR File with the WAS Admin Console …Right Click on Server Administration Admin Console.

- Try to build a JSP GUI for calling the Bean. Click on New Other Create a Web Service, JSP for a J2C Bean.

- Try to generate a Java Proxy Client to Invoke the WebService via a Java Class Right Click on the WSDL File – > Web Services Generate Client Code. And Add a Caller Class.

Page 64: LAB IMS zSummerUni 2010 Part 1-7 - uni-hamburg.de · Part 1: Prepare the Development Environment (required) This part describes how prepare the RDz environment to be able to create

© Copyright IBM Corporation 2009. All rights reserved.

9/15/2010 Summer University IMS

Page 64 of 87

Part 7: IMS DB Calls and business logic The whole infrastructure is set up. It is possible to call the DB2 Web Service and the IMS Java transaction is running. The interfaces will not change. It is now time to add some business logic to the IMS transaction. First, an IMS Database will be created. For the creation and setup of the IMS test database it is required to submit some jobs. For the ease of use the DDL for the 2 physical and 1 logical IMS databases is already written and the jobs are prepared and almost ready to run. ___1. Download the script files for your USER For the Jobs a new package will be created.

Select the IMS Java project under Other Projects, right click it and select New Package.

In the appearing New Java Package Wizard choose com.ibm.zsummer.imsdbscripts as the name for the new package. Click Finish. The package should now appear under the IMS Java project tree.

Next step is to import the Files.

Page 65: LAB IMS zSummerUni 2010 Part 1-7 - uni-hamburg.de · Part 1: Prepare the Development Environment (required) This part describes how prepare the RDz environment to be able to create

© Copyright IBM Corporation 2009. All rights reserved.

9/15/2010 Summer University IMS

Page 65 of 87

Therefore first create a file in the new package called getdbfiles.xml

Create a second file called ftp_getdbfiles.in

Replace TEAMxx, PASSWORD and userXX with your userid and your

password and replace your HOST IP.

Execute the getdbfiles.xml by right click Run as Ant build and refresh your project (F5)

The result will look like this:

<?xml version="1.0"?> <project name="IMSJava" default="all" basedir="."> <target name="all"> <exec executable="ftp" dir="."> <arg line="-i -s:ftp_getdbfiles.in "/> </exec> </target> </project>

open 192.168.7.252 TEAMxx PASSWORD cd /u/tliedlo/z/userXX/imsdbscripts mget * quit

Page 66: LAB IMS zSummerUni 2010 Part 1-7 - uni-hamburg.de · Part 1: Prepare the Development Environment (required) This part describes how prepare the RDz environment to be able to create

© Copyright IBM Corporation 2009. All rights reserved.

9/15/2010 Summer University IMS

Page 66 of 87

Edit each “.in” file in the package anr replace 192.168.7.252 with your host ip, check your USERID and replace your PASSWORD. Now we have all scripts imported and configured that are necessary for this part. ___2. Setup the project for sending JCL to the host, run it and receive

the output In this section, a portioned dataset containing the IMS DB DDL will be created. The refering job is called UPLOAD. There is also the ant script (execute_uploadddl.xml), the ftp input file (ftp_upload_ddl.in) and the output file (job.output).

execute_uploadddl.xml file:

ftp_upload_ddl.in file:

Check that the host ip address and the xx have been replaced according

to your userid. Also replace PASSWORD with your current password.

Select the upload_ddl.xml file, click the right mouse button and select Run Ant Build.

<?xml version="1.0"?> <project name="IMSJava" default="all" basedir="."> <target name="all"> <exec executable="ftp" dir="."> <arg line="-s:ftp_upload_ddl.in "/> </exec> </target> </project>

open 192.168.7.252 TEAMxx PASSWORD put UPLOAD TEAMxxUP quote site filetype=jes quote site JESJOBNAME=TEAMxxUP get TEAMxxUP job.output quit

Page 67: LAB IMS zSummerUni 2010 Part 1-7 - uni-hamburg.de · Part 1: Prepare the Development Environment (required) This part describes how prepare the RDz environment to be able to create

© Copyright IBM Corporation 2009. All rights reserved.

9/15/2010 Summer University IMS

Page 67 of 87

The execution will take some seconds, since the ftp job is waiting for the executed job to finish to receive its output.

Now double click on the job.output file to view the job output. It should look like this (please note, that in this sample the user was USER01):

Page 68: LAB IMS zSummerUni 2010 Part 1-7 - uni-hamburg.de · Part 1: Prepare the Development Environment (required) This part describes how prepare the RDz environment to be able to create

© Copyright IBM Corporation 2009. All rights reserved.

9/15/2010 Summer University IMS

Page 68 of 87

On successful execution the column RC should show 00 for all job steps.

Now the portioned dataset that holds the DDL for the IMS databases was successfully created. ___3. Create and Initial Load the IMS Databases The following steps are required to prepare an IMS database that it could be used by an application program:

• DBDGEN (assemble the DDL Source of the IMS databases) • PSBGEN (assemble the PSBs for the IMS transaction and for the Load

utility) • ACBGEN (compare DBD and PSB load modules for integrity e.g. naming

conventions, key lengths, segment names, etc.) • Create the dynamic allocation members. They contain the names of the

datasets (e.g. VSAM) that are allocated for the IMS databases. This is to be able to change the dataset names without reassembling the DBDs.

• Allocate the actual datasets. For VSAM files, which are used in this sample for both databases, this step is called DELETE/DEFINE. Actually any existing databases will be deleted.

• Initial Load. To be able to use an IMS Database, the datasets need to be formatted. Today, there are utilities to do that, but in former times this was

1 J E S 2 J O B L O G -- S Y S T E M S Y S 1 -- N O D E B O E B P C M 1 0 14.15.00 JOB07527 ---- MONDAY, 28 AUG 2006 ---- 14.15.00 JOB07527 IRR010I USERID GAEBLER IS ASSIGNED TO THIS JOB. 14.15.00 JOB07527 ICH70001I GAEBLER LAST ACCESS AT 14:14:58 ON MONDAY, AUGUST 28, 2006 14.15.00 JOB07527 $HASP373 USER01UP STARTED - INIT 1 - CLASS A - SYS SYS1 14.15.00 JOB07527 IEF403I USER01UP - STARTED - TIME=14.15.00 14.15.00 JOB07527 - --TIMINGS (MINS.)-- ----PAGING COUNTS--- 14.15.00 JOB07527 -JOBNAME STEPNAME PROCSTEP RC EXCP CPU SRB CLOCK SERV PG PAGE SWAP VIO SWAPS STEPNO 14.15.00 JOB07527 -USER01UP SCRATCH 00 40 .00 .00 .00 128 0 0 0 0 0 1 14.15.00 JOB07527 -USER01UP CREATE 00 0 .00 .00 .00 11 0 0 0 0 0 2 14.15.00 JOB07527 -USER01UP USER01D1 00 38 .00 .00 .00 167 0 0 0 0 0 3 14.15.00 JOB07527 -USER01UP USER01D2 00 22 .00 .00 .00 133 0 0 0 0 0 4 14.15.00 JOB07527 -USER01UP USER01D3 00 22 .00 .00 .00 134 0 0 0 0 0 5 14.15.00 JOB07527 -USER01UP USER01T1 00 22 .00 .00 .00 133 0 0 0 0 0 6 14.15.00 JOB07527 -USER01UP USER01T3 00 22 .00 .00 .00 129 0 0 0 0 0 7 14.15.00 JOB07527 -USER01UP DLIMODIN 00 22 .00 .00 .00 132 0 0 0 0 0 8 14.15.00 JOB07527 IEF404I USER01UP - ENDED - TIME=14.15.00 14.15.00 JOB07527 -USER01UP ENDED. NAME-MANUEL TOTAL CPU TIME= .00 TOTAL ELAPSED TIME= .00 14.15.00 JOB07527 $HASP395 USER01UP ENDED 0------ JES2 JOB STATISTICS ------ - 28 AUG 2006 JOB EXECUTION DATE - 181 CARDS READ - 322 SYSOUT PRINT RECORDS - 0 SYSOUT PUNCH RECORDS - 20 SYSOUT SPOOL KBYTES - 0.00 MINUTES EXECUTION TIME

Page 69: LAB IMS zSummerUni 2010 Part 1-7 - uni-hamburg.de · Part 1: Prepare the Development Environment (required) This part describes how prepare the RDz environment to be able to create

© Copyright IBM Corporation 2009. All rights reserved.

9/15/2010 Summer University IMS

Page 69 of 87

achieved by inserting a segment in the database using PSB PROCOPT=L and deleting it, resulting in an empty formatted IMS database. Since this samples use logical relationships, a pre-reorg utility will preceed the load job.

All the mentioned steps are collected in Job CREATEDB.

execute_dbcreate.xml

ftp_execute_dbcreate.in

Check that the host ip address and the xx have been replaced according

to your userid. Also replace PASSWORD with your current password.

Select the execute_dbcreate.xml file, click the right mouse button and select Run Ant Build. Successful execution will look like below:

Now double click on the job.output file to view the job output.

<?xml version="1.0"?> <project name="IMSJava" default="all" basedir="."> <target name="all"> <exec executable="ftp" dir="."> <arg line="-s:ftp_execute_dbcreate.in "/> </exec> </target> </project>

open 192.168.7.252 TEAMxx PASSWORD put CREATEDB TEAMxxCD quote site filetype=jes quote site JESJOBNAME=TEAMxxCD get TEAMxxCD job.output quit

Page 70: LAB IMS zSummerUni 2010 Part 1-7 - uni-hamburg.de · Part 1: Prepare the Development Environment (required) This part describes how prepare the RDz environment to be able to create

© Copyright IBM Corporation 2009. All rights reserved.

9/15/2010 Summer University IMS

Page 70 of 87

It should look like this (please note, that in this sample the user was USER01):

On successful execution the column RC should show 04 for the step

ACBGEN and 00 for all other job steps.

1 J E S 2 J O B L O G -- S Y S T E M S Y S 1 -- N O D E B O E B P C M 1 0 09.30.41 JOB07561 ---- TUESDAY, 29 AUG 2006 ---- 09.30.41 JOB07561 IRR010I USERID GAEBLER IS ASSIGNED TO THIS JOB. 09.30.41 JOB07561 ICH70001I GAEBLER LAST ACCESS AT 09:30:39 ON TUESDAY, AUGUST 29, 2006 09.30.41 JOB07561 $HASP373 USER01CD STARTED - INIT 1 - CLASS A - SYS SYS1 09.30.41 JOB07561 IEF403I USER01CD - STARTED - TIME=09.30.41 09.30.41 JOB07561 - --TIMINGS (MINS.)-- ----PAGING COUNTS--- 09.30.41 JOB07561 -JOBNAME STEPNAME PROCSTEP RC EXCP CPU SRB CLOCK SERV PG PAGE SWAP VIO SWAPS STEPNO 09.30.41 JOB07561 -USER01CD USER01D1 C 00 222 .00 .00 .00 1268 0 0 0 0 0 1 09.30.41 JOB07561 -USER01CD USER01D1 L 00 54 .00 .00 .00 182 0 0 0 0 0 2 09.30.41 JOB07561 -USER01CD USER01D2 C 00 195 .00 .00 .00 1065 0 0 0 0 0 3 09.30.42 JOB07561 -USER01CD USER01D2 L 00 43 .00 .00 .00 180 0 0 0 0 0 4 09.30.42 JOB07561 -USER01CD USER01D3 C 00 167 .00 .00 .00 835 0 0 0 0 0 5 09.30.42 JOB07561 -USER01CD USER01D3 L 00 42 .00 .00 .00 171 0 0 0 0 0 6 09.30.42 JOB07561 -USER01CD USER01T1 C 00 139 .00 .00 .00 500 0 0 0 0 0 7 09.30.42 JOB07561 -USER01CD USER01T1 L 00 47 .00 .00 .00 184 0 0 0 0 0 8 09.30.42 JOB07561 -USER01CD USER01T3 C 00 136 .00 .00 .00 450 0 0 0 0 0 9 09.30.42 JOB07561 -USER01CD USER01T3 L 00 41 .00 .00 .00 175 0 0 0 0 0 10 09.30.42 JOB07561 DFS627I IMS RTM CLEANUP ( EOT ) COMPLETE FOR JS USER01CD.ACBGEN .G ,RC=00 09.30.42 JOB07561 -USER01CD ACBGEN G 04 572 .00 .00 .00 1313 0 0 0 0 0 11 09.30.42 JOB07561 -USER01CD DYNALLOC ASSEM 00 136 .00 .00 .00 656 0 0 0 0 0 12 09.30.42 JOB07561 -USER01CD DYNALLOC BLDMBR 00 31 .00 .00 .00 80 0 0 0 0 0 13 09.30.42 JOB07561 -USER01CD DYNALLOC LNKEDT 00 77 .00 .00 .00 306 0 0 0 0 0 14 09.30.43 JOB07561 -USER01CD DELDEF 00 246 .00 .00 .00 1100 0 0 0 0 0 15 09.30.43 JOB07561 +DFS671I USER01CD.PREREORG. - FOR THIS EXECUTION, DBRC IS SET TO YES IMS9 09.30.43 JOB07561 +DFS035I BATCH INITIALIZATION COMPLETE IMS9 09.30.44 JOB07561 DFS627I IMS RTM CLEANUP ( EOT ) COMPLETE FOR JS USER01CD.PREREORG. ,RC=00 09.30.44 JOB07561 -USER01CD PREREORG 00 853 .00 .00 .01 2690 0 0 0 0 0 16 09.30.44 JOB07561 +DFS671I USER01CD.G.LOAD - FOR THIS EXECUTION, DBRC IS SET TO NO IMS9 09.30.44 JOB07561 DFS2500I DATABASE USER01D1 SUCCESSFULLY ALLOCATED IMS9 09.30.44 JOB07561 DFS2500I DATABASE USER01D2 SUCCESSFULLY ALLOCATED IMS9 09.30.44 JOB07561 +DFS035I BATCH INITIALIZATION COMPLETE IMS9 09.30.44 JOB07561 DFS627I IMS RTM CLEANUP ( EOT ) COMPLETE FOR JS USER01CD.LOAD .G ,RC=00 09.30.44 JOB07561 -USER01CD LOAD G 00 775 .00 .00 .01 2057 0 0 0 0 0 17 09.30.44 JOB07561 +DFS671I USER01CD.G.DELETE - FOR THIS EXECUTION, DBRC IS SET TO NO IMS9 09.30.45 JOB07561 DFS2500I DATABASE USER01D1 SUCCESSFULLY ALLOCATED IMS9 09.30.45 JOB07561 DFS2500I DATABASE USER01D2 SUCCESSFULLY ALLOCATED IMS9 09.30.45 JOB07561 +DFS035I BATCH INITIALIZATION COMPLETE IMS9 09.30.45 JOB07561 DFS627I IMS RTM CLEANUP ( EOT ) COMPLETE FOR JS USER01CD.DELETE .G ,RC=00 09.30.45 JOB07561 -USER01CD DELETE G 00 1371 .00 .00 .01 2614 0 0 0 0 0 18 09.30.45 JOB07561 IEF404I USER01CD - ENDED - TIME=09.30.45 09.30.45 JOB07561 -USER01CD ENDED. NAME- TOTAL CPU TIME= .00 TOTAL ELAPSED TIME= .06 09.30.45 JOB07561 $HASP395 USER01CD ENDED 0------ JES2 JOB STATISTICS ------

Page 71: LAB IMS zSummerUni 2010 Part 1-7 - uni-hamburg.de · Part 1: Prepare the Development Environment (required) This part describes how prepare the RDz environment to be able to create

© Copyright IBM Corporation 2009. All rights reserved.

9/15/2010 Summer University IMS

Page 71 of 87

___4. Load Item and customer data into created IMS databases Now that the databases are created they have to be populated with data that is useful by the application. Since the Backorder web service only allows to specify an item number and the amount, a default customer is created. In addition in order to be able to enter items to an order, the items have to be loaded. This step will load the two physical databases (TEAMxxD1, TEAMxxD2) and create a list of all segments using the logical database (TEAMxxD3).

execute_dbinsert.xml

ftp_execute_dbinsert.in

Check that the host ip address and the xx have been replaced according

to your userid. Also replace PASSWORD with your current password.

Select the execute_dbinsert.xml file, click the right mouse button and select Run Ant Build. Successful execution will look like below:

<?xml version="1.0"?> <project name="IMSJava" default="all" basedir="."> <target name="all"> <exec executable="ftp" dir="."> <arg line="-s:ftp_execute_dbinsert.in "/> </exec> </target> </project>

open 192.168.7.252 TEAMxx PASSWORD put INSERTDB TEAMxxIS quote site filetype=jes quote site JESJOBNAME=TEAMxxIS get TEAMxxIS job.output quit

Page 72: LAB IMS zSummerUni 2010 Part 1-7 - uni-hamburg.de · Part 1: Prepare the Development Environment (required) This part describes how prepare the RDz environment to be able to create

© Copyright IBM Corporation 2009. All rights reserved.

9/15/2010 Summer University IMS

Page 72 of 87

Now double click on the job.output file to view the job output. It should look like this (please note, that in this sample the user was USER01):

On successful execution the column RC should show 00 for all job steps.

If one scrolls further down in job.output, it can also be seen the segements that were listed from the database, here is the sample output from the execution

1 J E S 2 J O B L O G -- S Y S T E M S Y S 1 -- N O D E B O E B P C M 1 0 09.53.45 JOB07567 ---- TUESDAY, 29 AUG 2006 ---- 09.53.45 JOB07567 IRR010I USERID GAEBLER IS ASSIGNED TO THIS JOB. 09.53.45 JOB07567 ICH70001I GAEBLER LAST ACCESS AT 09:53:43 ON TUESDAY, AUGUST 29, 2006 09.53.45 JOB07567 $HASP373 USER01IS STARTED - INIT 1 - CLASS A - SYS SYS1 09.53.45 JOB07567 IEF403I USER01IS - STARTED - TIME=09.53.45 09.53.45 JOB07567 +DFS671I USER01IS.G.DLT0 - FOR THIS EXECUTION, DBRC IS SET TO NO IMS9 09.53.45 JOB07567 DFS2500I DATABASE USER01D1 SUCCESSFULLY ALLOCATED IMS9 09.53.45 JOB07567 DFS2500I DATABASE USER01D2 SUCCESSFULLY ALLOCATED IMS9 09.53.45 JOB07567 +DFS035I BATCH INITIALIZATION COMPLETE IMS9 09.53.45 JOB07567 DFS627I IMS RTM CLEANUP ( EOT ) COMPLETE FOR JS USER01IS.DLT0 .G ,RC=00 09.53.45 JOB07567 - --TIMINGS (MINS.)-- ----PAGING COUNTS--- 09.53.45 JOB07567 -JOBNAME STEPNAME PROCSTEP RC EXCP CPU SRB CLOCK SERV PG PAGE SWAP VIO SWAPS STEPNO 09.53.45 JOB07567 -USER01IS DLT0 G 00 570 .00 .00 .00 1307 0 0 0 0 0 1 09.53.46 JOB07567 +DFS671I USER01IS.G.DLT0 - FOR THIS EXECUTION, DBRC IS SET TO NO IMS9 09.53.46 JOB07567 DFS2500I DATABASE USER01D1 SUCCESSFULLY ALLOCATED IMS9 09.53.46 JOB07567 DFS2500I DATABASE USER01D2 SUCCESSFULLY ALLOCATED IMS9 09.53.46 JOB07567 +DFS035I BATCH INITIALIZATION COMPLETE IMS9 09.53.46 JOB07567 DFS627I IMS RTM CLEANUP ( EOT ) COMPLETE FOR JS USER01IS.DLT0 .G ,RC=00 09.53.46 JOB07567 -USER01IS DLT0 G 00 543 .00 .00 .00 1354 0 0 0 0 0 2 09.53.46 JOB07567 +DFS671I USER01IS.G.DLT0 - FOR THIS EXECUTION, DBRC IS SET TO NO IMS9 09.53.46 JOB07567 DFS2500I DATABASE USER01D1 SUCCESSFULLY ALLOCATED IMS9 09.53.46 JOB07567 DFS2500I DATABASE USER01D2 SUCCESSFULLY ALLOCATED IMS9 09.53.46 JOB07567 +DFS035I BATCH INITIALIZATION COMPLETE IMS9 09.53.46 JOB07567 DFS627I IMS RTM CLEANUP ( EOT ) COMPLETE FOR JS USER01IS.DLT0 .G ,RC=00 09.53.46 JOB07567 -USER01IS DLT0 G 00 635 .00 .00 .00 1476 0 0 0 0 0 3 09.53.46 JOB07567 IEF404I USER01IS - ENDED - TIME=09.53.46 09.53.46 JOB07567 -USER01IS ENDED. NAME-GAEBLER TOTAL CPU TIME= .00 TOTAL ELAPSED TIME= .02 09.53.46 JOB07567 $HASP395 USER01IS ENDED 0------ JES2 JOB STATISTICS ------

Page 73: LAB IMS zSummerUni 2010 Part 1-7 - uni-hamburg.de · Part 1: Prepare the Development Environment (required) This part describes how prepare the RDz environment to be able to create

© Copyright IBM Corporation 2009. All rights reserved.

9/15/2010 Summer University IMS

Page 73 of 87

above. The output shows a complete record from the root segment (CUSTOMER), two ADDRESS segments, an order segment with one ITEM, which DELIVERY was split since the request could not be fulfilled from one store.

.......................................................................................................... CALL=GN SEGMENT =(100002CICS INVENTORY - BEST SHOP OF WORLD |) DBPCB LEV=01 SEG=CUSTOMER RET CODE=GA KFDB LEN=0006 KEY FDB=(100002) .......................................................................................................... CALL=GN SEGMENT =(MAIN 0001IBM DEUTSCHLAND ENTWICKLUNG GMBH SCHOENEICHER STRASSE 220 ) ( BOEBLINGEN 0071032GERMANY |) DBPCB LEV=02 SEG=ADDRESS RET CODE= KFDB LEN=0006 KEY FDB=(100002) .......................................................................................................... CALL=GN SEGMENT =(MAIL 0001IBM DEUTSCHLAND ENTWICKLUNG GMBH POSTFACH 1380 ) 1 ( BOEBLINGEN 0071003GERMANY |) DBPCB LEV=02 SEG=ADDRESS RET CODE= KFDB LEN=0006 KEY FDB=(100002) .......................................................................................................... CALL=GN SEGMENT =(20060814000001DELIVERED 20060816) DBPCB LEV=02 SEG=ORDER RET CODE=GK KFDB LEN=0020 KEY FDB=(10000220060814000001) .......................................................................................................... CALL=GN SEGMENT =(00000010000020 00000010BALL PENS BLACK 24PK 000210) DBPCB LEV=03 SEG=ITEM RET CODE= KFDB LEN=0028 KEY FDB=(1000022006081400000100000010) .......................................................................................................... CALL=GN SEGMENT =(20060815000001000012) DBPCB LEV=04 SEG=DELIVERY RET CODE= KFDB LEN=0028 KEY FDB=(1000022006081400000100000010) .......................................................................................................... CALL=GN SEGMENT =(20060816000002000008) DBPCB LEV=04 SEG=DELIVERY RET CODE= KFDB LEN=0028 KEY FDB=(1000022006081400000100000010) .......................................................................................................... CALL=GN SEGMENT =(000010123456700001 ) DBPCB LEV=04 SEG=STOCK RET CODE=GK KFDB LEN=0028 KEY FDB=(1000022006081400000100000010) ...........................................................................................................

Page 74: LAB IMS zSummerUni 2010 Part 1-7 - uni-hamburg.de · Part 1: Prepare the Development Environment (required) This part describes how prepare the RDz environment to be able to create

© Copyright IBM Corporation 2009. All rights reserved.

9/15/2010 Summer University IMS

Page 74 of 87

___5. Create the IMSDLIDatabaseView For creating the IMSDLIDatabaseView the DLI Model Utility has to be run on the host and its output has to be downloaded and imported into our project.

execute_dlimodel.xml:

ftp_execute_dlimodel.in

Check correct Userid, Password and userid replacements. Select the

execute_dlimodel.xml file, click the right mouse button and select Run Ant Build.

Now double click on the job.output file to view the job output. It should look like this (please note, that in this sample the user was USER01):

<?xml version="1.0"?> <project name="IMSJava" default="all" basedir="."> <target name="all"> <exec executable="ftp" dir="."> <arg line="-s:ftp_execute_dlimodel.in "/> </exec> </target> </project>

open 192.168.7.252 TEAMxx PASSWORD put DLIMODEL TEAMxxDM quote site filetype=jes quote site JESJOBNAME=TEAMxxDM get TEAMxxDM job.output quote site filetype=seq lcd ../ims ascii get TEAMxxT1DatabaseView.java quit

1 J E S 2 J O B L O G -- S Y S T E M S Y S 1 -- N O D E B O E B P C M 1 0 11.02.14 JOB07577 ---- TUESDAY, 29 AUG 2006 ---- 11.02.14 JOB07577 IRR010I USERID GAEBLER IS ASSIGNED TO THIS JOB. 11.02.14 JOB07577 ICH70001I GAEBLER LAST ACCESS AT 11:02:13 ON TUESDAY, AUGUST 29, 2006 11.02.14 JOB07577 $HASP373 USER01DM STARTED - INIT 1 - CLASS A - SYS SYS1 11.02.14 JOB07577 IEF403I USER01DM - STARTED - TIME=11.02.14 11.02.14 JOB07577 - --TIMINGS (MINS.)-- ----PAGING COUNTS--- 11.02.14 JOB07577 -JOBNAME STEPNAME PROCSTEP RC EXCP CPU SRB CLOCK SERV PG PAGE SWAP VIO SWAPS STEPNO 11.02.14 JOB07577 -USER01DM DLIMODEL STEP1 00 55 .00 .00 .00 84 0 0 0 0 0 1 11.02.14 JOB07577 -USER01DM DLIMODEL *OMVSEX 00 26 .00 .00 .00 85 0 0 0 0 0 1 11.02.18 JOB07577 -USER01DM DLIMODEL *OMVSEX 00 222 .00 .00 .07 345 0 0 0 0 0 1 11.02.19 JOB07577 -USER01DM DLIMODEL STEP2 00 75 .00 .00 .00 299 0 0 0 0 0 2 11.02.19 JOB07577 IEF404I USER01DM - ENDED - TIME=11.02.19 11.02.19 JOB07577 -USER01DM ENDED. NAME- TOTAL CPU TIME= .00 TOTAL ELAPSED TIME= .07 11.02.19 JOB07577 $HASP395 USER01DM ENDED0------ JES2 JOB STATISTICS ------

Page 75: LAB IMS zSummerUni 2010 Part 1-7 - uni-hamburg.de · Part 1: Prepare the Development Environment (required) This part describes how prepare the RDz environment to be able to create

© Copyright IBM Corporation 2009. All rights reserved.

9/15/2010 Summer University IMS

Page 75 of 87

On successful execution the column RC should show 00 for all job steps.

The DLIDatabaseView should now appear in the com.ibm.zsummer.ims package.

The database view is now successfully imported. ___6. Activate the new Databases in IMS Before programming can be started, the new databases have to be made known to the online IMS System. Two things are required for that, copying the modules from the IMS staging libraries (e.g. ACBLIB) into the active libraries (e.g. ACBLIBA, ACBLIBB) and an IMS restart or Online Change. Since an IMS system should not be restarted without good reasons, the Online change will be used.

For the COPYACB job nothing needs to be changed. execute_copyacb.xml

ftp_execute_copyacb.in

Check that the host ip address and the xx have been replaced according

to your userid. Also replace PASSWORD with your current password.

<?xml version="1.0"?> <project name="IMSJava" default="all" basedir="."> <target name="all"> <exec executable="ftp" dir="."> <arg line="-s:ftp_execute_copyacb.in "/> </exec> </target> </project>

open 192.168.7.252 TEAMxx PASSWORD put COPYACB quote site filetype=jes quote site JESJOBNAME= COPYACB get COPYACB job.output quit

Page 76: LAB IMS zSummerUni 2010 Part 1-7 - uni-hamburg.de · Part 1: Prepare the Development Environment (required) This part describes how prepare the RDz environment to be able to create

© Copyright IBM Corporation 2009. All rights reserved.

9/15/2010 Summer University IMS

Page 76 of 87

Select the execute_copyacb.xml file, click the right mouse button and select Run Ant Build. Successful execution will look like below:

___7. Add the business logic to our IMS Java transaction The java code is prepared to be ready to run, but feel free to read the comments and make the code better. According to the Database Layout here:

Page 77: LAB IMS zSummerUni 2010 Part 1-7 - uni-hamburg.de · Part 1: Prepare the Development Environment (required) This part describes how prepare the RDz environment to be able to create

© Copyright IBM Corporation 2009. All rights reserved.

9/15/2010 Summer University IMS

Page 77 of 87

The following actions are required by the application:

1. Insert Ordersegment for new Order (method insertNewOrder()) 2. Insert Item in CustomerDB (TEAMxxD1) and check if Item is available

(method insertItem()) 3. Add all Stocks for the item from ItemDB and determine the maximum

stock that can be delivered by a single warehouse (method stocksForItem())

4. If ordered items > than items in stock -> deliver what we got in stock otherwise deliver the whole order and split order to multiple warehouses if necessary, while looping through the stock segments, update Stock, insert delivery segment for each warehouse, update the order status and return with delivered amount (method processWarehouseDelivery())

5. Call DB2 Web Service (method callDB2WebService()) So there is a huge amount of logic required to be added to the BackOrder transaction. The source can be found in C:\temp or where the downloads from the getfiles.xml ant script where downloaded to. Make sure to replace all occurrences of TEAMxx with the correct values.

Open the Backorder.java source from the IMSJava project, package com.ibm.zsummer.ims.

Page 78: LAB IMS zSummerUni 2010 Part 1-7 - uni-hamburg.de · Part 1: Prepare the Development Environment (required) This part describes how prepare the RDz environment to be able to create

© Copyright IBM Corporation 2009. All rights reserved.

9/15/2010 Summer University IMS

Page 78 of 87

Update the packages that are required to be imported and ignore the warnings.

Move the required global variables out of the main methods and make them

private. In addition some more global variables are added. The space between the class statement and the main method should now look like this:

import com.ibm.ims.base.*; import com.ibm.ims.application.*; import com.ibm.ims.db.*; import java.util.Date; import java.text.DateFormat; import java.text.DecimalFormat; import java.text.SimpleDateFormat; import java.sql.*;

public class Backorder { //Strings private static String currentDate = null; private static String newOrderNumber = null; //instanciate Message Queue Object and Input/Output Messages private static IMSMessageQueue messageQueue = new IMSMessageQueue(); private static Input inputMessage = new Input(); private static Output outputMessage = new Output(); //create Databaseview Object private static USERXXT1DatabaseView dbView = new USERXXT1DatabaseView(); private static DLIConnection connection = DLIConnection.createInstance(dbView); //create ssa private static SSA ssa = null; private static SSAList ssaList = null; //integers max and instock private int max=0; private int instock=0; // the DB2 connection url private static String url = "jdbc:db2os390sqlj:"; // DB2 JDBC/SBLJ driver url private static String driverName = "COM.ibm.db2os390.sqlj.jdbc.DB2SQLJDriver"; private static Connection DB2connection; private static PreparedStatement preparedStatement; private static Statement statement; static void getConnection() { try { // load the DB2 JDBC/SQLJ driver Class.forName(driverName); // establish JDBC Connection to specified DB2 server DB2connection = DriverManager.getConnection(url); } catch (ClassNotFoundException e) { System.out.println("Class not found Exception for DB2 JDBC Driver."); } catch (SQLException e) { e.printStackTrace(); System.out.println("SQL Exception for GetConnection."); } }

Page 79: LAB IMS zSummerUni 2010 Part 1-7 - uni-hamburg.de · Part 1: Prepare the Development Environment (required) This part describes how prepare the RDz environment to be able to create

© Copyright IBM Corporation 2009. All rights reserved.

9/15/2010 Summer University IMS

Page 79 of 87

Change the main Method to contain the following code:

A method to obtain the current date is required. Add the method getDate() to

the code. It will look like this:

public static void main(String[] args) { try { //initial Get Unique messageQueue.getUniqueMessage(inputMessage); //for performance reasons and multiple schedules loop do { if (inputMessage.getInt("Amount") > 0 && inputMessage.getInt("Amount") < 10000) { if (inputMessage.getString("Item").trim().length() > 0) { try { //Get the current Date getDate(); //insert new Order Segment newOrderNumber = insertNewOrder(); //insert the Item for the new Order insertItem(newOrderNumber, inputMessage.getInt("Amount"), inputMessage.getString("Item")); //search all Stocks for the Item and return max per single warehouse and total stock int [] stocks = stocksForItem(newOrderNumber, inputMessage.getInt("Amount"), inputMessage.getString("Item")); if (stocks[0]>0) { //if totalstock > ordered amount insertDelivery, change order status and call DB2 int delivered=0; //check if total stock gt ordered amount if (inputMessage.getInt("Amount")<=stocks[0]) { delivered = processWarehouseDelivery(newOrderNumber, inputMessage.getInt("Amount"), inputMessage.getString("Item")); //if not just deliver what we got } else { delivered = processWarehouseDelivery(newOrderNumber, stocks[0], inputMessage.getString("Item")); } //Update DB2 with Delivery callDB2Update(delivered, inputMessage.getString("Item")); } else { //Order not possible since total stock is zero outputMessage.setString("Message", "The item is not in stock."); } //Catch any exception and notice transaction caller } catch (Exception e) { //in case of exception print the stack trace and set message text System.out.println(e.getMessage()); e.printStackTrace(); outputMessage.setString("Message", "Exception occured! See IMS Region Log!"); }} else { outputMessage.setString("Message", "Please enter Item."); }} else { //Order not possible since total stock is zero outputMessage.setString("Message", "Amount not in Range (1-9999)."); } //send output message back to caller messageQueue.insertMessage(outputMessage); //commit the UOW IMSTransaction.getTransaction().commit(); //continue loop with next message } while (messageQueue.getNextMessage(inputMessage)); } catch (Exception e1) { System.out.println("Error setting Output Message."); e1.printStackTrace(); } }

public static void getDate() { //use 8 digit date format DateFormat dateFormat = new SimpleDateFormat("yyyyMMdd"); //get the date java.util.Date date = new java.util.Date(); //create the string using dateFormat currentDate = dateFormat.format(date); }

Page 80: LAB IMS zSummerUni 2010 Part 1-7 - uni-hamburg.de · Part 1: Prepare the Development Environment (required) This part describes how prepare the RDz environment to be able to create

© Copyright IBM Corporation 2009. All rights reserved.

9/15/2010 Summer University IMS

Page 80 of 87

Add the method insertNewOrder() that is required to create the new order:

//Insert a new order segment for the default customer 100002 public static String insertNewOrder () { String runningno = null; DLISegment orderSegment = null; try { //instanciate the segment orderSegment = dbView.cloneSegment("CustomerDB","ORDER"); //create an SSA List ssaList = SSAList.createInstance("CustomerDB"); //qualified SSA for getting all order segments for the current date for customer 100002 ssa = SSA.createInstance("CUSTOMER","CUSTID",SSA.EQUALS,"100002"); ssaList.addSSA(ssa); ssa = SSA.createInstance("ORDER","ORDERID",SSA.GREATER_OR_EQUAL,currentDate+"000000"); ssa.addQualificationStatement(SSA.AND,"ORDERID",SSA.LESS_OR_EQUAL,currentDate+"999999"); ssaList.addSSA(ssa); //first call if (!connection.getUniqueSegment(orderSegment,ssaList)) { //no segment returned from the first call //no order segment for current date -> insert new Order Segment with runningNo 000001 runningno = "000001"; } else { //get all order segments and determine highest runningno //this is because runningno has to be unique //store runningno in local variable Integer rno = new Integer(orderSegment.getString("RUNINGNO")); Integer calcrno = null; //repeat until no more orders for current date and customer 100002 while (connection.getNextSegment(orderSegment,ssaList)) { //store running no in local variabel calcrno = new Integer(orderSegment.getString("RUNINGNO")); //compare to previous call und update if found runningno is higher if (calcrno.intValue() > rno.intValue()) rno=calcrno; } //Add 1 to the highest runningNo found and format 6 byte string for number DecimalFormat newrno = new DecimalFormat("000000"); //-> insert new Order Segment for new runningNo runningno = newrno.format((rno.longValue()+1)); }

//insert the actual order segment orderSegment = dbView.cloneSegment("CustomerDB","ORDER"); //set orderid orderSegment.setString("ORDERID",currentDate+runningno); //make the order status received orderSegment.setString("ORTYPE","RECEIVED"); //the order date is the current date orderSegment.setString("ORDATE", currentDate); //create SSALIst for inserting the order segment ssaList = SSAList.createInstance("CustomerDB"); ssa = SSA.createInstance("CUSTOMER","CUSTID",SSA.EQUALS,"100002"); ssaList.addSSA(ssa); ssa = SSA.createInstance("ORDER"); ssaList.addSSA(ssa); //insert the segment and check for errors try { connection.insertSegment(orderSegment, ssaList); } catch (Exception e) { e.printStackTrace(); outputMessage.setString("Message", "Error inserting new Order"); } //catch any non DLI related exceptions } catch (Exception e) { e.printStackTrace(); try { outputMessage.setString("Message", e.getMessage()); } catch (Exception e2) { //If the previous catch is not gonna work theres something really wrong e2.printStackTrace(); } } //return the new ordernumber that is concatinated by currentdate and the new runningno return currentDate+runningno; }

Page 81: LAB IMS zSummerUni 2010 Part 1-7 - uni-hamburg.de · Part 1: Prepare the Development Environment (required) This part describes how prepare the RDz environment to be able to create

© Copyright IBM Corporation 2009. All rights reserved.

9/15/2010 Summer University IMS

Page 81 of 87

Add the method insertItem that will look like this: //this method inserts an item segment with the ordered item and amount public static void insertItem(String orderNo, int amount, String item) { try { //instanciate LITEM segment DLISegment itemSegment = dbView.cloneSegment("CustomerDB","LITEM"); ssaList = SSAList.createInstance("CustomerDB"); //unqualified SSA for inserting the item for the current orderNo and cust 100002 ssa = SSA.createInstance("CUSTOMER","CUSTID",SSA.EQUALS,"100002"); ssaList.addSSA(ssa); ssa = SSA.createInstance("ORDER","ORDERID",SSA.EQUALS,orderNo); ssaList.addSSA(ssa); ssa = SSA.createInstance("LITEM"); ssaList.addSSA(ssa); //filling item segment with ordered itemid and format it with leading zeros DecimalFormat itemid = new DecimalFormat("00000000"); itemSegment.setString("IDITEM", itemid.format((new Integer(item.trim())).longValue())); //filling item segment with ordered amount and format it with leading zeros DecimalFormat amountFormat = new DecimalFormat("000000"); itemSegment.setString("AMOUNT", amountFormat.format((new Integer(amount)).longValue())); //insert the item segment and check for errors try { connection.insertSegment(itemSegment, ssaList); } catch (Exception e) { e.printStackTrace(); outputMessage.setString("Message", "Error inserting Item or Item not orderable"); } //catch all other exceptions } catch (Exception e) { e.printStackTrace(); try { outputMessage.setString("Message", e.getMessage()); } catch (Exception e2) { //If the previous catch is not gonna work theres something really wrong e2.printStackTrace(); }}}

Page 82: LAB IMS zSummerUni 2010 Part 1-7 - uni-hamburg.de · Part 1: Prepare the Development Environment (required) This part describes how prepare the RDz environment to be able to create

© Copyright IBM Corporation 2009. All rights reserved.

9/15/2010 Summer University IMS

Page 82 of 87

Move the code to call the DB2 out to a new method called callDB2Update. This method will look like this:

//call DB2 to tell about the amount public static void callDB2Update(int amount, String item) { try { if (DB2connection == null || DB2connection.isClosed()) { getConnection(); } String sql = "UPDATE " + " ZUNI.EXMPCAT" + " SET" + " WS_IN_STOCK = WS_IN_STOCK + ?, " + " WS_ON_ORDER = WS_ON_ORDER - ? " + " WHERE" + " WS_ITEM_REF = ?"; preparedStatement = DB2connection.prepareStatement( sql ); preparedStatement.setInt( 1, amount ); preparedStatement.setInt( 2, amount ); preparedStatement.setString( 3, item ); int result = preparedStatement.executeUpdate(); // close the statments preparedStatement.close(); try { outputMessage.setString("Message", amount + " item(s) successfully delivered."); } catch (Exception e2) { //If the previous is not gonna work theres something really wrong e2.printStackTrace(); } } catch (SQLException e) { System.out.println("SQL Exception for Update."); System.out.println(e.getErrorCode()); e.printStackTrace(); try { outputMessage.setString("Message", "Updating DB2 failed."); } catch (Exception e2) { //If the previous is not gonna work theres something really wrong e2.printStackTrace(); } } }

Page 83: LAB IMS zSummerUni 2010 Part 1-7 - uni-hamburg.de · Part 1: Prepare the Development Environment (required) This part describes how prepare the RDz environment to be able to create

© Copyright IBM Corporation 2009. All rights reserved.

9/15/2010 Summer University IMS

Page 83 of 87

Add the method stocksForItem that will look like this:

//This method returns the total stock of all warehouses + the maximum single stock //amount that a single warehouse holds in an int array public static int [] stocksForItem(String orderNo, int amount, String item) { //working variable int dummy = 0; //array for returning total stock and max stock for a single warehouse int [] returnValues = new int[2]; //start DB Access try { //JDBC Driver Class.forName("com.ibm.ims.db.DLIDriver"); //Connection Connection connectionJDBC = DriverManager.getConnection("jdbc:dli:com.ibm.zsummer.ims.TEAMXXT1DatabaseView"); //Statement Statement statement = connectionJDBC.createStatement(); //Formatter for the 8 Byte Amount in the Stock Segment DecimalFormat itemid = new DecimalFormat("00000000"); //Execute Query and store result in ResultSet ResultSet results = statement.executeQuery("SELECT STOCK.IDSTORE, STOCK.AMOUNT FROM " + " LGCustomerDB.STOCK WHERE " + " ITEM.IDITEM = '" + itemid.format((new Integer(item.trim())).longValue()) + "'" + " AND ORDER1.ORDERID = '" + orderNo + "'" + " AND CUSTOMER.CUSTID = '100002' " ); //Loop through Stock Segment Resultset while (results.next()) { //Store the the Amount in a working variable dummy = (new Integer((results.getString(2)).trim())).intValue(); //Add Amount to total stock sum returnValues[0] += dummy; //If max amount of single warehouse lt amount update max amount if (returnValues[1] < dummy) returnValues[1]=dummy; } //Catch all SQL Related Exceptions } catch (SQLException e) { System.out.println("During connection creation: " + e.toString()); } catch (ClassNotFoundException e) { System.out.println("Could not load DLIDriver." + e.toString()); } //return the int array to caller return returnValues; }

Page 84: LAB IMS zSummerUni 2010 Part 1-7 - uni-hamburg.de · Part 1: Prepare the Development Environment (required) This part describes how prepare the RDz environment to be able to create

© Copyright IBM Corporation 2009. All rights reserved.

9/15/2010 Summer University IMS

Page 84 of 87

And last but not least add the method processWarehouseDelivery that will look like this:

//go through the stock segments and create delivery segments if order must be split //most complicated logic public static int processWarehouseDelivery(String orderNo, int amount, String item) { //var that returns the delivered amount int returnAmount = 0; //working var that contains the amount that was not delivered so far while looping //through the stock segments, initially starts with the complete order amount int todoAmount = amount; //working var that holds the value for the stock that is deducted from the current warehous int substractValue = 0; //working var that holds the stock before deducting for delivery //this is for performance reasons int oldStock = 0; try { //instanciate STOCK segment in logical databse DLISegment stockSegment = dbView.cloneSegment("LGCustomerDB","STOCK"); //create the ssa list ssaList = SSAList.createInstance("LGCustomerDB"); //format the itemid and store it to a String DecimalFormat itemid = new DecimalFormat("00000000"); String itemidformat = itemid.format((new Integer(item.trim())).longValue()); //unqualified SSA for updating a stock segment for the item for the current orderNo and cust 100002 ssa = SSA.createInstance("CUSTOMER","CUSTID",SSA.EQUALS,"100002"); ssaList.addSSA(ssa); ssa = SSA.createInstance("ORDER1","ORDERID",SSA.EQUALS,orderNo); ssaList.addSSA(ssa); ssa = SSA.createInstance("ITEM","ITEMID",SSA.EQUALS,itemidformat); ssaList.addSSA(ssa); ssa = SSA.createInstance("STOCK"); ssaList.addSSA(ssa); //searching for the first stock segment if (connection.getUniqueSegment(stockSegment,ssaList)) { do { //Type Casts are expensive, so the variable is saved in a simple type oldStock = (new Integer(stockSegment.getString("AMOUNT"))).intValue(); //if current warehouse can deliver the whole remaining order if ( oldStock >= todoAmount) { //fine, substract value will be set to amount substractValue = amount; //todoAmount back to zero and after updating the segment we leave the loop todoAmount =- amount; //if current stock is too small for order } else { //deliver what we got in stock substractValue = oldStock; //what is still done to complete the order is saved in todoAmount todoAmount =- oldStock; } //update Stock Segment with the formatted substracted value stockSegment.setString("AMOUNT", (new DecimalFormat("00000000")).format(oldStock-substractValue)); //update call to stock segment and check for errors try { connection.replaceSegment(stockSegment); } catch (Exception e) { e.printStackTrace(); outputMessage.setString("Message", "Error Updating Stock Segment"); } //insert Delivery Segment and update Stock Status

Page 85: LAB IMS zSummerUni 2010 Part 1-7 - uni-hamburg.de · Part 1: Prepare the Development Environment (required) This part describes how prepare the RDz environment to be able to create

© Copyright IBM Corporation 2009. All rights reserved.

9/15/2010 Summer University IMS

Page 85 of 87

And the second part:

After copy and paste or importing the file from the materials, replace all 4

occurences of TEAMXXT1DatabaseView according to your userid.

Save the changes. Now all errors should be gone by now. ___8. Upload the new jar file to the host and test the new transaction

Select the sendjar.xml file from the com.ibm.zsummer.scripts package in the IMSJava project, click the right mouse button and select Run Ant Build. The successful output for the upload will look like this:

try { Class.forName("com.ibm.ims.db.DLIDriver"); Connection connectionJDBC = DriverManager.getConnection("jdbc:dli:com.ibm.zsummer.ims.TEAMXXT1DatabaseView"); Statement statement = connectionJDBC.createStatement(); int result = statement.executeUpdate("INSERT INTO LGCustomerDB.DELIVERY "+ " (DELIVERY.DELDATE, DELIVERY.RUNINGNO, DELIVERY.AMOUNT) " + " VALUES('" + currentDate + "','000001','" + (new DecimalFormat("000000")).format(substractValue) + "') " + " WHERE ITEM.IDITEM = '" + itemid.format((new Integer(item.trim())).longValue()) + "'" + " AND ORDER1.ORDERID = '" + orderNo + "'" + " AND CUSTOMER.CUSTID = '100002' " ); //check if insert of delivery segment was successful if (result <=0) { outputMessage.setString("Message", "Error inserting Delivery Segment"); } //Update the status of the order and set it to DELIVERED result = statement.executeUpdate("UPDATE CustomerDB.ORDER1 SET ORDER1.ORTYPE = " + " 'DELIVERED' WHERE " + " ORDER1.ORDERID = '" + orderNo + "'" + " AND CUSTOMER.CUSTID = '100002' " ); //check if update of the Order segment was successful if (result <=0) { outputMessage.setString("Message", "Error updating Order Segment with Status."); } //update delivered count returnAmount += substractValue; //catch any SQL Exceptions } catch (SQLException e) { System.out.println("During connection creation: " + e.toString()); } catch (ClassNotFoundException e) { System.out.println("Could not load DLIDriver." + e.toString()); } //exit the loop if we are either out of stock or finished with the whole order } while (connection.getNextSegment(stockSegment,ssaList) && (todoAmount >0)); } //catch any other exceptions } catch (Exception e) { e.printStackTrace(); try { outputMessage.setString("Message", e.getMessage()); } catch (Exception e2) { //If the previous is not gonna work theres something really wrong e2.printStackTrace(); } } //return the delivered amount to caller return returnAmount; }

Page 86: LAB IMS zSummerUni 2010 Part 1-7 - uni-hamburg.de · Part 1: Prepare the Development Environment (required) This part describes how prepare the RDz environment to be able to create

© Copyright IBM Corporation 2009. All rights reserved.

9/15/2010 Summer University IMS

Page 86 of 87

Every time you will run the sendjar.xml you also have to execute the restart.xml by right-clicking Run as Ant Build.

Now its time to test the transaction including the new business logic. This can be done by using the unmanaged client that was created earlier.

Expand package com.ibm.zsummer.imsnonmanaged in the IMSJava project.

Select the IMSJ2CTestApp, click the right mouse button and Select Run Java Application. The output on successful invocation will look like this:

Now the IMS transaction including the business logic works.

Page 87: LAB IMS zSummerUni 2010 Part 1-7 - uni-hamburg.de · Part 1: Prepare the Development Environment (required) This part describes how prepare the RDz environment to be able to create

© Copyright IBM Corporation 2009. All rights reserved.

9/15/2010 Summer University IMS

Page 87 of 87

___9. Check your results There is a transaction already defined for you which will create a excel file for you with the contents of the IMS database. The Transaction is called TEAMxxT2 and has as parameter NEW to create a new sheet or ADD to add a new excel sheet to the current file. Try to invoke the transaction and download the excel file from your ftp user directory. /u/TEAMxx/output.xls To check the contents of the DB2 Table you can try the Data View of RDz or access it with DataStudio.