05.01.2013 Views

IMS Version 7 and Java Application Programming - IBM Redbooks

IMS Version 7 and Java Application Programming - IBM Redbooks

IMS Version 7 and Java Application Programming - IBM Redbooks

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

<strong>IMS</strong> <strong>Version</strong> 7 <strong>and</strong> <strong>Java</strong><br />

<strong>Application</strong> <strong>Programming</strong><br />

Learn to develop <strong>IMS</strong> <strong>Java</strong> applications<br />

by following examples<br />

Create <strong>Java</strong> control <strong>and</strong><br />

execution statements<br />

Gain practical experience<br />

in using <strong>Java</strong><br />

ibm.com/redbooks<br />

Bill Arkins<br />

Virgil Aguilar<br />

Daniel Bourque<br />

Giri Giritharan<br />

Nancy Stein


International Technical Support Organization<br />

<strong>IMS</strong> <strong>Version</strong> 7 <strong>and</strong> <strong>Java</strong><br />

<strong>Application</strong> <strong>Programming</strong><br />

February 2001<br />

SG24-6123-00


Take Note!<br />

Before using this information <strong>and</strong> the product it supports, be sure to read the general information in<br />

Appendix K, “Special notices” on page 393.<br />

First Edition (February 2001)<br />

This edition applies to <strong>Version</strong> 7 of <strong>IMS</strong>, Program Number 5655-B01 for use with the OS/390 Operating<br />

System.<br />

Comments may be addressed to:<br />

<strong>IBM</strong> Corporation, International Technical Support Organization<br />

Dept. QXXE Building 80-E2<br />

650 Harry Road<br />

San Jose, California 95120-6099<br />

When you send information to <strong>IBM</strong>, you grant <strong>IBM</strong> a non-exclusive right to use or distribute the<br />

information in any way it believes appropriate without incurring any obligation to you.<br />

© Copyright International Business Machines Corporation 2001. All rights reserved.<br />

Note to U.S Government Users – Documentation related to restricted rights – Use, duplication or disclosure is<br />

subject to restrictions set forth in GSA ADP Schedule Contract with <strong>IBM</strong> Corp.


Contents<br />

Figures. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .xi<br />

Tables. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xv<br />

Preface. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xvii<br />

The team that wrote this redbook. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xvii<br />

Comments welcome. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xix<br />

Part 1. <strong>IMS</strong> <strong>Java</strong> environment . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1<br />

Chapter 1. Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3<br />

1.1 ET/390 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5<br />

1.2 OS/390. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6<br />

1.3 <strong>IMS</strong> as an object server . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7<br />

1.3.1 Background . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7<br />

1.3.2 <strong>IMS</strong> client for <strong>Java</strong> . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8<br />

1.4 What is <strong>IMS</strong> <strong>Java</strong>? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9<br />

1.4.1 Other <strong>IMS</strong> <strong>Java</strong> considerations. . . . . . . . . . . . . . . . . . . . . . . . . . 10<br />

1.5 <strong>Java</strong> . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10<br />

1.5.1 <strong>Java</strong> environment . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12<br />

1.5.2 <strong>Java</strong> language . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13<br />

1.5.3 <strong>Java</strong> for OS/390 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16<br />

1.5.4 High Performance <strong>Java</strong> compiler . . . . . . . . . . . . . . . . . . . . . . . . 17<br />

1.5.5 <strong>Java</strong> tools. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17<br />

1.5.6 Class libraries <strong>and</strong> packages . . . . . . . . . . . . . . . . . . . . . . . . . . . 18<br />

1.5.7 VisualAge for <strong>Java</strong> . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19<br />

1.5.8 VisualAge for <strong>Java</strong> tools . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20<br />

1.5.9 <strong>Java</strong> application structures . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21<br />

1.5.10 Access to hardware . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22<br />

Chapter 2. Environment customization. . . . . . . . . . . . . . . . . . . . . . . . . 23<br />

2.1 Required software levels . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23<br />

2.1.1 NFS <strong>and</strong> FTP server tasks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23<br />

2.1.2 <strong>Java</strong> Development ToolKit (JDK) 1.1.8 . . . . . . . . . . . . . . . . . . . . 23<br />

2.1.3 Visual Age for <strong>Java</strong>, Enterprise Edition for OS/390. . . . . . . . . . . 25<br />

2.1.4 The HPJ compiler Installation on OS/390 . . . . . . . . . . . . . . . . . . 26<br />

2.1.5 OS/390 UNIX System Services environment . . . . . . . . . . . . . . . 26<br />

2.2 Workstation environment . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28<br />

2.2.1 Prerequisites . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28<br />

2.2.2 Required software . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28<br />

2.2.3 NFS client. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28<br />

© Copyright <strong>IBM</strong> Corp. 2001 iii


Chapter 3. Building an <strong>IMS</strong> <strong>Java</strong> application . . . . . . . . . . . . . . . . . . . . 31<br />

3.1 Overview of <strong>IMS</strong> application processing . . . . . . . . . . . . . . . . . . . . . . . 31<br />

3.1.1 Message processing programs (MPPs) . . . . . . . . . . . . . . . . . . . 31<br />

3.1.2 <strong>IMS</strong> Fast Path programs (IFPs) . . . . . . . . . . . . . . . . . . . . . . . . . 32<br />

3.1.3 Batch message processing programs (BMPs) . . . . . . . . . . . . . . 32<br />

3.2 Message processing applications . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32<br />

3.2.1 Message queuing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33<br />

3.2.2 Reading <strong>and</strong> writing messages to the message queue in <strong>Java</strong> . . 33<br />

3.3 Building an <strong>IMS</strong> <strong>Java</strong> application by example . . . . . . . . . . . . . . . . . . . 34<br />

3.3.1 Introduction to the example environment . . . . . . . . . . . . . . . . . . 34<br />

3.3.2 Building an <strong>IMS</strong> <strong>Java</strong> message processing application . . . . . . . . 35<br />

Chapter 4. Conversational transactions . . . . . . . . . . . . . . . . . . . . . . . . 39<br />

4.1 Defining an SPA message . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39<br />

4.2 Conversational transaction sequence of events . . . . . . . . . . . . . . . . . 41<br />

4.2.1 Defining subsequent input messages . . . . . . . . . . . . . . . . . . . . . 42<br />

4.3 Using DLIConnection to access a database . . . . . . . . . . . . . . . . . . . . 42<br />

4.3.1 DLIConnection . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42<br />

4.3.2 DLISegment . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 43<br />

4.3.3 DLITypeInfo . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 43<br />

4.3.4 SSA . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 43<br />

4.3.5 SSAList . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 43<br />

4.3.6 SSAQualificationStatement. . . . . . . . . . . . . . . . . . . . . . . . . . . . . 43<br />

4.3.7 DLIRecord . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 43<br />

4.3.8 DLISegmentInfo . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 43<br />

4.3.9 DLIDatabaseView. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 44<br />

4.4 <strong>Application</strong> programming using DLIConnection . . . . . . . . . . . . . . . . . 44<br />

4.5 Subclassing DLISegment . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 44<br />

4.5.1 Coding messages with repeating structures . . . . . . . . . . . . . . . . 44<br />

4.5.2 Accessing messages with repeating structures. . . . . . . . . . . . . . 46<br />

4.6 Subclassing DLIDatabaseView. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 46<br />

4.6.1 Creating a DLIConnection Object . . . . . . . . . . . . . . . . . . . . . . . . 46<br />

4.6.2 Using SSAs to access DL/I information. . . . . . . . . . . . . . . . . . . . 47<br />

Chapter 5. Accessing an <strong>IMS</strong> database. . . . . . . . . . . . . . . . . . . . . . . . . 49<br />

5.1 Mapping an <strong>IMS</strong> database in <strong>Java</strong> classes . . . . . . . . . . . . . . . . . . . . . 49<br />

5.1.1 <strong>IMS</strong> DB Database Definition (DBD). . . . . . . . . . . . . . . . . . . . . . . 49<br />

5.1.2 Mapping the DBD to DLIDatabaseView . . . . . . . . . . . . . . . . . . . 50<br />

5.1.3 Mapping the DBD to DLISegment . . . . . . . . . . . . . . . . . . . . . . . . 52<br />

5.2 Using JDBC to access an <strong>IMS</strong> database . . . . . . . . . . . . . . . . . . . . . . 53<br />

5.2.1 Classes <strong>and</strong> field names. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 53<br />

5.2.2 Writing a JDBC application . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 54<br />

5.3 Supported data types in <strong>IMS</strong> <strong>Java</strong> . . . . . . . . . . . . . . . . . . . . . . . . . . . 60<br />

iv <strong>IMS</strong> <strong>Version</strong> 7 <strong>and</strong> <strong>Java</strong> <strong>Application</strong> <strong>Programming</strong>


5.4 Supported SQL grammar . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 62<br />

5.4.1 SELECT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 62<br />

5.4.2 FROM. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 63<br />

5.4.3 UPDATE. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 64<br />

5.4.4 DELETE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 65<br />

5.4.5 INSERT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 65<br />

5.4.6 How <strong>IMS</strong> <strong>Java</strong> has extended SQL . . . . . . . . . . . . . . . . . . . . . . . 65<br />

5.4.7 Statement. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 66<br />

5.4.8 Prepared statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 66<br />

Part 2. Sample application . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 67<br />

Chapter 6. <strong>IMS</strong>Auto application build <strong>and</strong> execute . . . . . . . . . . . . . . . 69<br />

6.1 Testing <strong>IMS</strong> applications . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 70<br />

6.2 “Nonvisual” <strong>IMS</strong> application development . . . . . . . . . . . . . . . . . . . . . . 71<br />

6.2.1 Some TSO/E comm<strong>and</strong>s . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 71<br />

6.3 ISHELL: Invoking UNIX System Services . . . . . . . . . . . . . . . . . . . . . . 73<br />

6.4 OSHELL: Invoking BPXBATCH from TSO/E. . . . . . . . . . . . . . . . . . . . 79<br />

6.5 OMVS: Invoking the UNIX System Services shell . . . . . . . . . . . . . . . . 81<br />

6.6 BPXBATCH: Shell comm<strong>and</strong>s, shell scripts, or executable files . . . . . 83<br />

6.7 OBROWSE <strong>and</strong> OEDIT: browsing <strong>and</strong> editing an HFS file . . . . . . . . . 86<br />

6.8 OCOPY: Copying to another member or file . . . . . . . . . . . . . . . . . . . . 87<br />

6.9 OGET, OGETX, OPUT, <strong>and</strong> OPUTX: Copying files <strong>and</strong> members . . . 88<br />

6.10 <strong>Java</strong> Tools in UNIX System Services environment . . . . . . . . . . . . . . 88<br />

6.10.1 javac comm<strong>and</strong> . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 88<br />

6.10.2 The hpj comm<strong>and</strong> . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 104<br />

6.11 Example of “nonvisual” application development . . . . . . . . . . . . . . 107<br />

Chapter 7. VisualAge for <strong>Java</strong> <strong>IMS</strong> application development . . . . . . 119<br />

7.1 <strong>IMS</strong> JAVA classes in VisualAge for <strong>Java</strong> <strong>Version</strong> 3.02 . . . . . . . . . . . 119<br />

7.2 Writing, importing/exporting, <strong>and</strong> editing your program . . . . . . . . . . . 126<br />

7.3 Exporting your program for execution . . . . . . . . . . . . . . . . . . . . . . . . 136<br />

7.4 Preparing your program for execution . . . . . . . . . . . . . . . . . . . . . . . 142<br />

7.5 Executing your <strong>Java</strong> program in <strong>IMS</strong> . . . . . . . . . . . . . . . . . . . . . . . . 148<br />

Part 3. Debugging <strong>and</strong> problem determination. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 155<br />

Chapter 8. Diagnostic techniques . . . . . . . . . . . . . . . . . . . . . . . . . . . . 157<br />

8.1 <strong>IMS</strong>Trace . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 157<br />

8.1.1 Initiating <strong>IMS</strong>Tracing. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 157<br />

8.1.2 Setting up tracing for the <strong>IMS</strong> <strong>Java</strong> library routines. . . . . . . . . . 157<br />

8.1.3 Adding trace statements to your application . . . . . . . . . . . . . . . 158<br />

8.2 Writing your <strong>Java</strong> code with problem detection in mind. . . . . . . . . . . 160<br />

v


8.2.1 <strong>Java</strong> sample tracing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 160<br />

8.2.2 Trace started using a program argument . . . . . . . . . . . . . . . . . 160<br />

8.2.3 Debugging trace method in each class . . . . . . . . . . . . . . . . . . . 160<br />

8.2.4 H<strong>and</strong>ling exceptions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 161<br />

8.3 Diagnosing problems with <strong>Java</strong> on OS/390 . . . . . . . . . . . . . . . . . . . 163<br />

8.4 Diagnosing LE (Language Environment) messages <strong>and</strong> abends . . . 163<br />

Chapter 9. Development limitations . . . . . . . . . . . . . . . . . . . . . . . . . . 165<br />

Part 4. Appendices . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 167<br />

Appendix A. <strong>IMS</strong> <strong>Java</strong> package . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 169<br />

A.1 Contents of com.ibm.ims.application package . . . . . . . . . . . . . . . . . . . . 169<br />

A.2 Class com.ibm.ims.application.<strong>IMS</strong><strong>Application</strong>. . . . . . . . . . . . . . . . . . . . 170<br />

Constructors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 170<br />

Methods . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 170<br />

A.3 Class com.ibm.ims.application.<strong>IMS</strong>ErrorMessages . . . . . . . . . . . . . . . . 171<br />

Constructors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 171<br />

Methods . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 171<br />

A.4 Class com.ibm.ims.application.<strong>IMS</strong>FieldMessage . . . . . . . . . . . . . . . . . 172<br />

Variables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 173<br />

Constructors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 174<br />

Methods . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 176<br />

A.5 Class com.ibm.ims.application.<strong>IMS</strong>MessageQueue. . . . . . . . . . . . . . . . 178<br />

Constructors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 178<br />

Methods . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 179<br />

A.6 Class com.ibm.ims.application.<strong>IMS</strong>Transaction . . . . . . . . . . . . . . . . . . . 181<br />

Methods . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 182<br />

A.7 Contents of com.ibm.ims.base package . . . . . . . . . . . . . . . . . . . . . . . . . 182<br />

A.8 Class com.ibm.ims.base.AIB . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 183<br />

Constructors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 183<br />

Methods . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 184<br />

A.9 Class com.ibm.ims.base.AlternatePCB . . . . . . . . . . . . . . . . . . . . . . . . . 186<br />

Methods . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 186<br />

A.10 Class com.ibm.ims.base.DBPCB . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 187<br />

Methods . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 187<br />

A.11 Class com.ibm.ims.base.DLIBaseSegment . . . . . . . . . . . . . . . . . . . . . 189<br />

Variables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 189<br />

Constructors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 189<br />

Methods . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 189<br />

A.12 Class com.ibm.ims.base.DLITypeInfo . . . . . . . . . . . . . . . . . . . . . . . . . 211<br />

Variables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 212<br />

Constructors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 213<br />

vi <strong>IMS</strong> <strong>Version</strong> 7 <strong>and</strong> <strong>Java</strong> <strong>Application</strong> <strong>Programming</strong>


Methods . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 216<br />

A.13 Class com.ibm.ims.base.DLITypeInfoList. . . . . . . . . . . . . . . . . . . . . . . 217<br />

Constructors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 218<br />

Methods . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 219<br />

A.14 Class com.ibm.ims.base.<strong>IMS</strong>ErrorMessages . . . . . . . . . . . . . . . . . . . . 219<br />

Constructor . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 219<br />

Methods . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 219<br />

A.15 Class com.ibm.ims.base.<strong>IMS</strong>Info . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 220<br />

Methods . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 220<br />

A.16 Class com.ibm.ims.base.<strong>IMS</strong>Trace . . . . . . . . . . . . . . . . . . . . . . . . . . . 222<br />

Variables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 225<br />

Methods . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 227<br />

A.17 Class com.ibm.ims.base.IOPCB. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 232<br />

Methods . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 232<br />

A.18 Class com.ibm.ims.base.<strong>Java</strong>ToDLI. . . . . . . . . . . . . . . . . . . . . . . . . . . 233<br />

Variables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 234<br />

Methods . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 255<br />

A.19 Class com.ibm.ims.base.DLIJNICallbackException . . . . . . . . . . . . . . . 258<br />

Method . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 259<br />

A.20 Class com.ibm.ims.base.DLIWarning . . . . . . . . . . . . . . . . . . . . . . . . . . 259<br />

Constructor . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 259<br />

A.21 Class com.ibm.ims.base.<strong>IMS</strong>Exception . . . . . . . . . . . . . . . . . . . . . . . . 259<br />

Constructor . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 260<br />

Methods . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 260<br />

A.22 Contents of com.ibm.ims.db package. . . . . . . . . . . . . . . . . . . . . . . . . . 261<br />

A.23 Class com.ibm.ims.db.DLIConnection . . . . . . . . . . . . . . . . . . . . . . . . . 262<br />

Constructors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 262<br />

Methods . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 262<br />

A.24 Class com.ibm.ims.db.DLIDatabaseView . . . . . . . . . . . . . . . . . . . . . . . 267<br />

Variables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 268<br />

Methods . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 268<br />

A.25 Class com.ibm.ims.db.DLIRecord. . . . . . . . . . . . . . . . . . . . . . . . . . . . . 268<br />

Constructor . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 269<br />

Method . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 269<br />

A.26 Class com.ibm.ims.db.DLISegment . . . . . . . . . . . . . . . . . . . . . . . . . . . 269<br />

Constructor . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 270<br />

Methods . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 270<br />

A.27 Class com.ibm.ims.db.DLISegmentInfo . . . . . . . . . . . . . . . . . . . . . . . . 271<br />

Constructor . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 271<br />

A.28 Class com.ibm.ims.db.DLIStatement . . . . . . . . . . . . . . . . . . . . . . . . . . 271<br />

Methods . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 272<br />

A.29 Class com.ibm.ims.db.<strong>IMS</strong>ErrorMessages . . . . . . . . . . . . . . . . . . . . . . 279<br />

Constructor . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 279<br />

vii


Methods . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 279<br />

A.30 Class com.ibm.ims.db.SSA. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 280<br />

Variables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 280<br />

Constructors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 283<br />

Methods . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 284<br />

A.31 Class com.ibm.ims.db.SSAList . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 287<br />

Constructors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 287<br />

Methods . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 287<br />

A.32 Class com.ibm.ims.db.SSAQualificationStatement . . . . . . . . . . . . . . . 294<br />

Constructors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 294<br />

Methods . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 294<br />

A.33 Class com.ibm.ims.db.Token . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 297<br />

Variables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 297<br />

Constructors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 298<br />

Methods . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 298<br />

A.34 Class com.ibm.ims.db.DLIException . . . . . . . . . . . . . . . . . . . . . . . . . . 299<br />

Constructors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 299<br />

Method . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 299<br />

Appendix B. Debugging <strong>and</strong> problem determination . . . . . . . . . . . . . . 301<br />

B.1 Exceptions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 301<br />

B.2 How exceptions map to DL/I status codes . . . . . . . . . . . . . . . . . . . . . . . 301<br />

B.3 Sync point failure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 303<br />

B.4 “Try <strong>and</strong> catch” example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 304<br />

Appendix C. <strong>IMS</strong> abend codes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 305<br />

C.1 Abends <strong>and</strong> pseudoabends . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 305<br />

C.2 Abends issued from <strong>IMS</strong> <strong>Java</strong> applications . . . . . . . . . . . . . . . . . . . . . . 305<br />

C.2.1 ABENDU0118 - Commit failure . . . . . . . . . . . . . . . . . . . . . . . . . . . 305<br />

C.2.2 ABENDU0200 - Small I/O area defined . . . . . . . . . . . . . . . . . . . . . 305<br />

C.2.3 ABENDU0462 - Get Unique was not issued . . . . . . . . . . . . . . . . . 306<br />

C.2.4 ABENDU0475 - Batch run failure . . . . . . . . . . . . . . . . . . . . . . . . . . 306<br />

C.2.5 ABENDU0778 - Rollback failure. . . . . . . . . . . . . . . . . . . . . . . . . . . 306<br />

Appendix D. <strong>IMS</strong> <strong>Java</strong> tracing facilities . . . . . . . . . . . . . . . . . . . . . . . . . 307<br />

D.1 <strong>IMS</strong>Trace . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 307<br />

D.2 Initiating <strong>IMS</strong>Tracing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 307<br />

D.3 Setting up tracing for the <strong>IMS</strong> <strong>Java</strong> library routines . . . . . . . . . . . . . . . . 307<br />

D.4 Adding trace statements to your application. . . . . . . . . . . . . . . . . . . . . . 308<br />

Appendix E. IVP application — <strong>Java</strong> source (<strong>Java</strong> to DLI version) . . 311<br />

E.1 PhoneBookSegment class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 312<br />

E.2 IVPDatabaseView class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 312<br />

E.3 InputMessage class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 313<br />

viii <strong>IMS</strong> <strong>Version</strong> 7 <strong>and</strong> <strong>Java</strong> <strong>Application</strong> <strong>Programming</strong>


E.4 OutputMessage class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 314<br />

E.5 SPAMessage class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 315<br />

E.6 Installation Verification Program (IVP) application . . . . . . . . . . . . . . . . . 316<br />

Appendix F. IVP application — <strong>Java</strong> source (JDBC version) . . . . . . . 325<br />

F.1 PhoneBookSegment class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 326<br />

F.2 IVPDatabaseView class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 326<br />

F.3 InputMessage class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 327<br />

F.4 OutputMessage class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 328<br />

F.5 SPAMessage class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 329<br />

F.6 Installation Verification Program (IVP) application . . . . . . . . . . . . . . . . . 330<br />

Appendix G. IVP application — COBOL source . . . . . . . . . . . . . . . . . . 339<br />

G.1 IVP application . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 339<br />

Appendix H. Installing the IVP Phone application . . . . . . . . . . . . . . . . 351<br />

H.1 Installation verification process. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 351<br />

Appendix I. Dealership sample application . . . . . . . . . . . . . . . . . . . . . . 357<br />

I.1 Dealer class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 358<br />

I.2 Model class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 359<br />

I.3 Order class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 360<br />

I.4 Sales class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 360<br />

I.5 Stock class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 361<br />

I.6 DealerDatabaseView class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 362<br />

I.7 <strong>IMS</strong>Auto class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 363<br />

I.8 InputMessage class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 375<br />

I.9 OutputMessage class. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 375<br />

I.10 ErrorMessage class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 376<br />

I.11 AcceptOrderInput class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 377<br />

I.12 OrderAccepted class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 377<br />

I.13 CancelOrderInput class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 378<br />

I.14 Cancelled class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 378<br />

I.15 FindACarInput class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 379<br />

I.16 Carfound class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 380<br />

I.17 ListModelsInput class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 380<br />

I.18 ModelList class. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 381<br />

I.19 RecordASaleInput class. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 382<br />

I.20 SalesRecord class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 382<br />

I.21 ShowModelDetailsInput class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 383<br />

I.22 ModelDetails class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 383<br />

ix


Appendix J. Options for the hpj comm<strong>and</strong> . . . . . . . . . . . . . . . . . . . . . . 385<br />

Appendix K. Special notices . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 393<br />

Appendix L. Related publications . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 397<br />

L.1 <strong>IBM</strong> <strong>Redbooks</strong>. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 397<br />

L.2 <strong>IBM</strong> <strong>Redbooks</strong> collections . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 397<br />

L.3 Other resources. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 397<br />

L.4 Referenced Web sites . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 399<br />

How to get <strong>IBM</strong> <strong>Redbooks</strong> . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 401<br />

<strong>IBM</strong> <strong>Redbooks</strong> fax order form . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 402<br />

Glossary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 403<br />

Abbreviations <strong>and</strong> acronyms . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 409<br />

Index . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 411<br />

<strong>IBM</strong> <strong>Redbooks</strong> review . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 415<br />

x <strong>IMS</strong> <strong>Version</strong> 7 <strong>and</strong> <strong>Java</strong> <strong>Application</strong> <strong>Programming</strong>


Figures<br />

1. <strong>IMS</strong> <strong>Java</strong> development environment . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4<br />

2. <strong>IMS</strong> <strong>Java</strong> class library . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5<br />

3. A simple class model for <strong>Java</strong> . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14<br />

4. Sample <strong>Java</strong> source code . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15<br />

5. <strong>Java</strong> structure, components, <strong>and</strong> tools . . . . . . . . . . . . . . . . . . . . . . . . . . . 19<br />

6. Example of HPJ variables in /etc/.profile . . . . . . . . . . . . . . . . . . . . . . . . . . 27<br />

7. JDK.profile file . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27<br />

8. <strong>IMS</strong>JAVA.profile file . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27<br />

9. NFS Network Access Suite connection customization . . . . . . . . . . . . . . . 29<br />

10. Establishing NFS connections using net use in MS-DOS . . . . . . . . . . . . . 30<br />

11. Database view of all segments . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34<br />

12. Example to define Input messages . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36<br />

13. Example to define Output messages . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36<br />

14. Example to Implement Main <strong>and</strong> doBegin(). . . . . . . . . . . . . . . . . . . . . . . . 37<br />

15. SPA Message code (1) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 40<br />

16. SPA Message code (2) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 40<br />

17. SPA Message code (3) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41<br />

18. Subsequent Input Message code . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42<br />

19. Sample DLITypeInfo statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45<br />

20. The use of dotted notation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45<br />

21. The use of field indexes. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45<br />

22. Another example of dotted notation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 46<br />

23. Sample DLIConnection statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 46<br />

24. Creating an SSALIST. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 47<br />

25. Database view of all segments . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 49<br />

26. <strong>IMS</strong> Database Definition (DBD) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 50<br />

27. Sample DBD . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 51<br />

28. Sample DLIDatabaseView. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 51<br />

29. Dealer DBD extract . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 52<br />

30. Sample DLISegment . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 52<br />

31. JDBC <strong>Application</strong> code . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 56<br />

32. JDBC Connection code . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 57<br />

33. Example of a SELECT statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 63<br />

34. Example of a FROM statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 64<br />

35. FROM statement in Dealer code . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 64<br />

36. Example of an UPDATE statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 64<br />

37. Example of a DELETE statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 65<br />

38. Example of WHERE <strong>and</strong> INSERT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 66<br />

39. Example of an INSERT statement. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 66<br />

40. <strong>IMS</strong> <strong>Java</strong> application development scenario . . . . . . . . . . . . . . . . . . . . . . . 69<br />

© Copyright <strong>IBM</strong> Corp. 2001 xi


41. ISPF Comm<strong>and</strong> Shell panel. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 73<br />

42. ISHELL main screen . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 75<br />

43. ISHELL Directory List. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 76<br />

44. ISHELL Select an Action panel for files . . . . . . . . . . . . . . . . . . . . . . . . . . . 77<br />

45. ISHELL Select an Action panel for directories . . . . . . . . . . . . . . . . . . . . . . 77<br />

46. Display File Attributes option . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 78<br />

47. OSHELL ls -l input . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 79<br />

48. OSHELL ls -l output: Panel 1 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 80<br />

49. OSHELL ls -l output: Panel 2 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 80<br />

50. OMVS startup panel. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 81<br />

51. OMVS ls -l output: Panel 1. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 82<br />

52. OMVS ls -l output: Panel 2. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 83<br />

53. BPXBATCH JCL . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 85<br />

54. Auto Dealer shell script . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 86<br />

55. The profile, profile.imsjava. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 92<br />

56. The profile, profile.imsres4. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 93<br />

57. First sample of javac output. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 94<br />

58. Another sample of javac output (part 1 of 2) . . . . . . . . . . . . . . . . . . . . . . . 95<br />

59. Another sample of javac output (part 2 of 2) . . . . . . . . . . . . . . . . . . . . . . . 96<br />

60. BPXBATCH JCL that executes shell script . . . . . . . . . . . . . . . . . . . . . . . . 97<br />

61. Shell script to compile the auto dealer program. . . . . . . . . . . . . . . . . . . . . 98<br />

62. STDERRL DD SYSOUT from BPXBATCH job (part 1 of 6) . . . . . . . . . . . 99<br />

63. STDERRL DD SYSOUT from BPXBATCH job (part 2 of 6) . . . . . . . . . . 100<br />

64. STDERRL DD SYSOUT from BPXBATCH job (part 3 of 6) . . . . . . . . . . 101<br />

65. STDERRL DD SYSOUT from BPXBATCH job (part 4 of 6) . . . . . . . . . . 102<br />

66. STDERRL DD SYSOUT from BPXBATCH job (part 5 of 6) . . . . . . . . . . 103<br />

67. STDERRL DD SYSOUT from BPXBATCH job (part 6 of 6) . . . . . . . . . . 104<br />

68. Example of hpj comm<strong>and</strong> . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 105<br />

69. javac compile <strong>and</strong> link . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 108<br />

70. BPXBATCH job . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 109<br />

71. Shell Script to hpj compile <strong>and</strong> bind the IVP application . . . . . . . . . . . . . 110<br />

72. Sample .profile.imsjava file . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 111<br />

73. Sample .profile.imsres4 file . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 112<br />

74. Sample .profile.hpj file . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 113<br />

75. STDOUTL file. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 114<br />

76. STDERRL File . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 115<br />

77. <strong>IMS</strong> Message Region STEPLIB Concatenation. . . . . . . . . . . . . . . . . . . . 116<br />

78. IVP program input screen . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 116<br />

79. IVP program output screen . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 117<br />

80. VisualAge for <strong>Java</strong> startup screen . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 120<br />

81. SmartGuide Import dialog . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 121<br />

82. SmartGuide (Import from a directory) dialog — application. . . . . . . . . . . 122<br />

83. SmartGuide (Import from a directory) dialog — base . . . . . . . . . . . . . . . 123<br />

xii <strong>IMS</strong> <strong>Version</strong> 7 <strong>and</strong> <strong>Java</strong> <strong>Application</strong> <strong>Programming</strong>


84. SmartGuide (Import from a directory) dialog — db . . . . . . . . . . . . . . . . . 124<br />

85. <strong>IMS</strong>_<strong>Java</strong>_Class_Libraries listing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 125<br />

86. SmartGuide (Add Project dialog) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 126<br />

87. SmartGuide (Add Package dialog) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 127<br />

88. SmartGuide Create Class dialog . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 128<br />

89. The newly created class: <strong>IMS</strong><strong>Java</strong>PGM . . . . . . . . . . . . . . . . . . . . . . . . . 129<br />

90. SmartGuide Create Method dialog . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 130<br />

91. Workbench showing newly added method . . . . . . . . . . . . . . . . . . . . . . . 131<br />

92. Imported <strong>IMS</strong> <strong>Java</strong> classes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 132<br />

93. Workbench showing expansion of classes . . . . . . . . . . . . . . . . . . . . . . . 133<br />

94. Workbench showing modifiable source code. . . . . . . . . . . . . . . . . . . . . . 134<br />

95. Workbench showing a method with an error . . . . . . . . . . . . . . . . . . . . . . 135<br />

96. <strong>Java</strong>doc option screen . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 136<br />

97. ET/390 Properties for object Dealership . . . . . . . . . . . . . . . . . . . . . . . . . 137<br />

98. ET/390 Properties for object Dealership (Bind Options) . . . . . . . . . . . . . 138<br />

99. Workbench (Administrator) menu . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 139<br />

100.SmartGuide Export dialog . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 140<br />

101.SmartGuide Export to a directory dialog . . . . . . . . . . . . . . . . . . . . . . . . . 141<br />

102.Duplicate name error message . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 142<br />

103.BPXBATCH job to execute HPJ-only shell script . . . . . . . . . . . . . . . . . . 143<br />

104./u/imsres4/Dealerhpj.sh.st<strong>and</strong>alone -— HPJ-only shell script. . . . . . . . . 144<br />

105.u/imsres4/Dealerscript.ver3 — script to execute 2 other scripts . . . . . . . 145<br />

106.u/imsres4/Dealerjavac.sh.ver3 — javac compile script . . . . . . . . . . . . . . 146<br />

107.u/imsres4/Dealerhpj.sh.ver3 - HPJ binder script . . . . . . . . . . . . . . . . . . . 147<br />

108.Stage1 Gen input . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 148<br />

109.DB2 Gen input . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 149<br />

110.PSB Gen input. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 150<br />

111.<strong>IMS</strong> message region STEPLIB concatenation . . . . . . . . . . . . . . . . . . . . 151<br />

112.A typical <strong>IMS</strong>FieldMessage subclass . . . . . . . . . . . . . . . . . . . . . . . . . . . 173<br />

113.Example of how to access the fields in subclass InputMessage. . . . . . . 173<br />

114.Example of coding messages that have the same field in common . . 175<br />

115.Example of Message reading logic . . . . . . . . . . . . . . . . . . . . . . . . . . 176<br />

116.Example of retrieving messages using a while loop . . . . . . . . . . . . . . . . 178<br />

117.Example defining an OutputModel message. . . . . . . . . . . . . . . . . . . . . . 218<br />

118.Using System.out for trace output . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 224<br />

119.Example: A typical DLIDatabaseView subclass . . . . . . . . . . . . . . . . . . . 268<br />

120.Example: A typical DLISegment subclass. . . . . . . . . . . . . . . . . . . . . . . . 270<br />

121.DLIConnection list . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 302<br />

122.Status code call exception example . . . . . . . . . . . . . . . . . . . . . . . . . . . . 303<br />

123.Example of “try <strong>and</strong> catch” methods . . . . . . . . . . . . . . . . . . . . . . . . . . . . 304<br />

124.<strong>IMS</strong> <strong>Java</strong> profile sample . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 351<br />

125.HPJ comm<strong>and</strong> to create executable load . . . . . . . . . . . . . . . . . . . . . . . . 351<br />

126.Sample MVS BPXBATCH JCL . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 352<br />

xiii


127.Sample IVP BPXBATCH Script. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 353<br />

128.Sample <strong>IMS</strong> <strong>Java</strong> class library <strong>and</strong> HPJ class libraries. . . . . . . . . . . . . . 354<br />

129.IVTCC input screen . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 355<br />

130.IVTCC DISPLAY query . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 356<br />

131.IVTCC DISPLAY output query . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 356<br />

xiv <strong>IMS</strong> <strong>Version</strong> 7 <strong>and</strong> <strong>Java</strong> <strong>Application</strong> <strong>Programming</strong>


Tables<br />

1. Supported data types. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 60<br />

2. Available get methods for data types. . . . . . . . . . . . . . . . . . . . . . . . . . . . . 61<br />

3. Supported SQL keywords . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 62<br />

4. References to source code . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 70<br />

5. Status code, reason <strong>and</strong> return code. . . . . . . . . . . . . . . . . . . . . . . . . . . . 303<br />

6. Options for the hpj comm<strong>and</strong>. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 385<br />

© Copyright <strong>IBM</strong> Corp. 2001 xv


xvi <strong>IMS</strong> <strong>Version</strong> 7 <strong>and</strong> <strong>Java</strong> <strong>Application</strong> <strong>Programming</strong>


Preface<br />

This <strong>IBM</strong> Redbook is intended for customers who wish to exploit the <strong>Java</strong><br />

language support provided by <strong>IMS</strong> <strong>Version</strong> 7.1. Its prime audience are <strong>IMS</strong><br />

<strong>and</strong> <strong>Java</strong> application programmers, who can now use <strong>Java</strong> to develop <strong>IMS</strong><br />

application transactions, <strong>and</strong> <strong>IMS</strong> system programmers, who support <strong>IMS</strong><br />

applications development. This book will be helpful to any organization that is<br />

interested in user developed S/390 <strong>Java</strong> applications, especially to access<br />

<strong>IMS</strong> databases by using <strong>Java</strong> application programming.<br />

As <strong>Java</strong> coding skills have become more readily available in the IT<br />

employment marketplace, application development with <strong>Java</strong> has become<br />

more <strong>and</strong> more the de facto coding st<strong>and</strong>ard. This book exp<strong>and</strong>s upon the<br />

<strong>IMS</strong> <strong>Java</strong> User’s Guide, SC27-0832-00, <strong>and</strong> provides a practical reference for<br />

developing an <strong>IMS</strong> application transaction written in <strong>Java</strong>.<br />

This book assumes a certain level of knowledge of <strong>IMS</strong>, <strong>Java</strong>, <strong>and</strong> UNIX.<br />

We start by overviewing the base concepts of the <strong>Java</strong> environment <strong>and</strong><br />

introduce new terminology. We then provide information about the S/390<br />

software <strong>and</strong> hardware requirements which enable <strong>Java</strong> on the Enterprise<br />

platform, <strong>and</strong> we describe how to download, install, <strong>and</strong> configure the <strong>Java</strong><br />

related application development environment for your workstation, <strong>IMS</strong>/ESA,<br />

<strong>and</strong> OS/390.<br />

We discuss two <strong>IMS</strong> applications that were developed within <strong>IBM</strong>, using the<br />

<strong>Java</strong> API to <strong>IMS</strong>. The Telephone Directory IVP application uses the <strong>Java</strong><br />

Native DL/I interface, <strong>and</strong> the <strong>IMS</strong> Auto Dealership application employs the<br />

JDBC interface from <strong>Java</strong> to <strong>IMS</strong>. We also provide guidance on debugging,<br />

problem determination, <strong>and</strong> some of the development limitations.<br />

The team that wrote this redbook<br />

This redbook was produced by a team of specialists from around the world<br />

working at the International Technical Support Organization San Jose Center.<br />

Bill Arkins is an <strong>IMS</strong> Product Specialist with the International Technical<br />

Support Organization, San Jose Center. He writes extensively <strong>and</strong> teaches<br />

<strong>IBM</strong> classes worldwide in the areas of <strong>IMS</strong> performance, Parallel Sysplex,<br />

<strong>and</strong> S/390 large buffer pool performance. Before joining the ITSO in July<br />

2000, Bill worked in the <strong>IMS</strong> Technical Support, <strong>IMS</strong> QPP, <strong>and</strong> <strong>IMS</strong><br />

Performance groups. Bill also spent 5 years in Europe on assignment <strong>and</strong><br />

has been a regular presenter at SHARE, GUIDE, CMG, <strong>and</strong> <strong>IMS</strong> Technical<br />

conferences.<br />

© Copyright <strong>IBM</strong> Corp. 2001 xvii


Virgil Aguilar is a Staff Software Engineer with the <strong>IBM</strong> Silicon Valley<br />

Laboratory in San Jose, CA. He has been working as an <strong>IMS</strong> Transaction<br />

Manager Level 2 for the past 5 years. His areas of specialization are OTMA,<br />

APPC, security <strong>and</strong> <strong>IMS</strong> e-connectors. Before joining <strong>IBM</strong>, he worked as an<br />

<strong>IMS</strong> <strong>Application</strong>s Programmer, Systems Programmer, <strong>and</strong> Database<br />

Administrator in the banking, telephony, <strong>and</strong> electric utility industries for 10<br />

years. He holds a Bachelor’s degree in Mathematics from University of the<br />

Philippines.<br />

Daniel Bourque is an <strong>IMS</strong> Product Specialist with the <strong>IBM</strong> Silicon Valley<br />

Laboratory in San Jose, CA. He holds a degree in Management Information<br />

Science <strong>and</strong> Finance from the University of Florida. Daniel has 4 years of<br />

experience in the IT industry <strong>and</strong> specializes in System/390 database<br />

management <strong>and</strong> connectivity.<br />

Giri Giritharan is an <strong>IMS</strong> Systems Programmer with <strong>IBM</strong> Global Services,<br />

Australia. He has worked in financial institutions before joining <strong>IBM</strong> in 1989.<br />

He has over 13 years of experience in IT, of which 6 years have been with<br />

<strong>IMS</strong>. His areas of expertise include installation, maintenance, performance<br />

tuning, <strong>and</strong> problem diagnosis.<br />

Nancy Stein is a Senior Software Engineer with the <strong>IBM</strong> Silicon Valley<br />

Laboratory in San Jose, CA. Before joining the <strong>IBM</strong> Software Group’s <strong>IMS</strong><br />

Product Services/Advocacy team in 1998, she worked as an <strong>IMS</strong> <strong>Application</strong>s<br />

Developer, <strong>IMS</strong> Systems Programmer, MVS Systems Programmer, <strong>and</strong><br />

OS/390 Technical Support Principal for a major telecommunications<br />

company. She has over 23 years experience developing, architecting,<br />

debugging, <strong>and</strong> tuning <strong>IMS</strong> systems <strong>and</strong> applications.<br />

Thanks to the following people for their invaluable contributions to this<br />

project:<br />

Ken Blackman<br />

<strong>IBM</strong> <strong>IMS</strong> Advanced Technical Support, Dallas Systems Center, Dallas, TX<br />

Kyle Charlet<br />

<strong>IBM</strong> <strong>IMS</strong> Development, Silicon Valley Laboratory, San Jose, CA<br />

Rich Conway<br />

International Technical Support Organization, Poughkeepsie, NY<br />

Bach Doan<br />

<strong>IBM</strong> <strong>IMS</strong> Development, Silicon Valley Laboratory, San Jose, CA<br />

xviii <strong>IMS</strong> <strong>Version</strong> 7 <strong>and</strong> <strong>Java</strong> <strong>Application</strong> <strong>Programming</strong>


Comments welcome<br />

Eugene Dong<br />

<strong>IBM</strong> <strong>IMS</strong> Development, Silicon Valley Laboratory, San Jose, CA<br />

Scott Gieselman<br />

<strong>IBM</strong> <strong>IMS</strong> Development, Silicon Valley Laboratory, San Jose, CA<br />

Vasilis Karras<br />

International Technical Support Organization, Poughkeepsie, NY<br />

Yvonne Lyon<br />

International Technical Support Organization, San Jose, CA<br />

Bob Love<br />

<strong>IBM</strong> <strong>IMS</strong> Development, Silicon Valley Laboratory, San Jose, CA<br />

John Shelton<br />

<strong>IBM</strong> <strong>IMS</strong> Development, Silicon Valley Laboratory, San Jose, CA<br />

Your comments are important to us!<br />

We want our <strong>Redbooks</strong> to be as helpful as possible. Please send us your<br />

comments about this or other <strong>Redbooks</strong> in one of the following ways:<br />

Fax the evaluation form found in “<strong>IBM</strong> <strong>Redbooks</strong> review” on page 415 to<br />

the fax number shown on the form.<br />

Use the online evaluation form found at ibm.com/redbooks<br />

Send your comments in an Internet note to redbook@us.ibm.com<br />

xix


xx <strong>IMS</strong> <strong>Version</strong> 7 <strong>and</strong> <strong>Java</strong> <strong>Application</strong> <strong>Programming</strong>


Part 1. <strong>IMS</strong> <strong>Java</strong> environment<br />

This part of the book describes the <strong>IMS</strong> <strong>Java</strong> environment.<br />

It contains the following chapters:<br />

Chapter 1, “Introduction” on page 3.<br />

Chapter 2, “Environment customization” on page 23<br />

Chapter 3, “Building an <strong>IMS</strong> <strong>Java</strong> application” on page 31<br />

Chapter 4, “Conversational transactions” on page 39<br />

Chapter 5, “Accessing an <strong>IMS</strong> database” on page 49<br />

© Copyright <strong>IBM</strong> Corp. 2001 1


2 <strong>IMS</strong> <strong>Version</strong> 7 <strong>and</strong> <strong>Java</strong> <strong>Application</strong> <strong>Programming</strong>


Chapter 1. Introduction<br />

In this chapter we familiarize you with the basic concepts of <strong>and</strong><br />

developments in object-oriented (OO) technology in relation to the OS/390<br />

<strong>and</strong> <strong>IMS</strong>. The main topics covered are the positioning of OS/390, <strong>IMS</strong> <strong>and</strong><br />

<strong>Java</strong>, <strong>and</strong> the use of <strong>Java</strong> in an <strong>IMS</strong> environment.<br />

This book contains the following information on <strong>IMS</strong> <strong>Java</strong>:<br />

Information on user setup, with compile <strong>and</strong> run time options <strong>and</strong> an<br />

example shell script to set your classpath default.<br />

The basics of how an application works, with an overview of <strong>IMS</strong><br />

application processing, information on message queueing, <strong>and</strong> a car<br />

dealership application example that is used throughout this book.<br />

How to access an <strong>IMS</strong> database with information on mapping databases in<br />

<strong>Java</strong> classes, defining <strong>IMS</strong> databases <strong>and</strong> DBDs, JDBC access of <strong>IMS</strong><br />

databases, <strong>and</strong> supported SQL grammar.<br />

Advanced application topics, including:<br />

- Conversational transactions<br />

- Multi-segment messages<br />

- Installation verification<br />

- DLIConnection access of databases<br />

- <strong>Application</strong> programming with DLIConnection<br />

- Subclassing <strong>IMS</strong>Segment<br />

- Providing an array<br />

- Creating a DLIConnection object<br />

- SSA use to access DL/I information<br />

- DLIDatabaseView connection example<br />

- <strong>Java</strong>ToDLI example<br />

Debugging <strong>and</strong> determining problem causes, including information on:<br />

exceptions, sync point failure, abends <strong>and</strong> dumps, <strong>and</strong> <strong>IMS</strong>Trace.<br />

Appendixes containing a complete sample program, IVP database view<br />

samples, <strong>and</strong> an IVP.<br />

An index of terms.<br />

These concepts are illustrated in Figure 1 <strong>and</strong> Figure 2.<br />

© Copyright <strong>IBM</strong> Corp. 2000 3


VisualAge for <strong>Java</strong>,<br />

Enterprise Edition<br />

Edit/Compile<br />

Browse<br />

<strong>Version</strong> Control<br />

Error Feedback<br />

Local<br />

Debugger<br />

Remote<br />

Debugger<br />

Profiler<br />

J<br />

P<br />

O<br />

R<br />

T<br />

Figure 1. <strong>IMS</strong> <strong>Java</strong> development environment<br />

Export<br />

<strong>Java</strong><br />

Bytecode<br />

4 <strong>IMS</strong> <strong>Version</strong> 7 <strong>and</strong> <strong>Java</strong> <strong>Application</strong> <strong>Programming</strong><br />

<strong>IMS</strong><br />

<strong>Java</strong><br />

High<br />

Performance<br />

Compiler<br />

PC Server<br />

320<br />

Executable<br />

Run on<br />

OS/390<br />

Trace<br />

OS/390


SSAQualificationStatement<br />

SSAList<br />

SSA<br />

DLIConnection<br />

DLISegment<br />

DLISegmentInfo<br />

DLIDatabaseView<br />

DLIRecord<br />

Implementation of java.sql<br />

Figure 2. <strong>IMS</strong> <strong>Java</strong> class library<br />

1.1 ET/390<br />

Uses JNI (java<br />

native interface)<br />

to access C<br />

<strong>Java</strong> Class Library<br />

A java program uses the APIs that are provided<br />

application Package classes to<br />

- initialize <strong>and</strong> begin the program<br />

- get the input message from the message queue<br />

- put the output message on the message queue<br />

- commit<br />

JDBC interface or db Package classes to<br />

- access the <strong>IMS</strong> databases<br />

JDBC interface<br />

db Package<br />

application Package<br />

base Package<br />

CEETDLI Interface for C Language<br />

<strong>IMS</strong> DB <strong>IMS</strong> System <strong>IMS</strong> TM<br />

<strong>IMS</strong><strong>Application</strong><br />

<strong>IMS</strong>FieldMessage<br />

<strong>IMS</strong>MessageQueue<br />

<strong>IMS</strong>Transaction<br />

AIB<br />

AlternatePCB<br />

DBPCB<br />

DLIBaseSegment<br />

DLITypeInfo<br />

IOPCB<br />

<strong>IMS</strong>Exception<br />

<strong>IMS</strong>Info<br />

<strong>Java</strong>ToDLI<br />

VisualAge for <strong>Java</strong>, Enterprise Edition for OS/390 includes the Enterprise<br />

Toolkit for OS/390 (ET/390) which allows you to quickly <strong>and</strong> easily develop<br />

enterprise applications in <strong>Java</strong>. If you want to improve the performance of<br />

your <strong>Java</strong> code for the OS/390 environment, you can use ET/390 to bind your<br />

<strong>Java</strong> bytecode into optimized object code to run under OS/390 UNIX System<br />

Services. The fully bound object code runs as an executable or DLL in the<br />

OS/390 shell.<br />

ET/390 not only provides additional functionality, but it also supplies a<br />

comprehensive suite of development tools. ET/390 extends the VisualAge for<br />

<strong>Java</strong> tool set by including an interactive debugger <strong>and</strong> the Performance<br />

Chapter 1. Introduction 5


1.2 OS/390<br />

Analyzer. The debugger lets you debug your <strong>Java</strong> bytecode as it runs in<br />

OS/390.<br />

The Performance Analyzer complements the debugger by allowing you to<br />

take a trace of the <strong>Java</strong> object code as it runs in the OS/390 shell. You can<br />

use graphical <strong>and</strong> textual diagrams at the workstation to analyze the<br />

complete history of method calls captured in the trace file <strong>and</strong> identify parts of<br />

the <strong>Java</strong> code that you may want to tune.<br />

Today, OS/390 combines the robustness of historic MVS <strong>and</strong><br />

UNIX-95-compliant UNIX Systems Services in one operating system.<br />

Some of the unique classic strengths of S/390 are:<br />

Flexibility OS/390 is open <strong>and</strong> allows you to integrate data <strong>and</strong><br />

applications with its environment. Also, application porting<br />

to OS/390 is easy because of the presence of the UNIX<br />

Systems Services. This set of services was known as<br />

OpenEdition/MVS in releases of OS/390 prior to 2.5. The<br />

ability to use the processor to its maximum capability is<br />

designed into OS/390. Thus you can purchase systems to<br />

run your aggregate workload <strong>and</strong> manage the peaks with<br />

the same processor capacity, instead of buying capacity to<br />

match your peak workloads <strong>and</strong> having it under utilized the<br />

rest of the time. OS/390, through its Workload Manager<br />

(WLM), can manage both traditional work <strong>and</strong> new workload<br />

types such as <strong>Java</strong>, according to the business priorities you<br />

set.<br />

Data Approximately 70% of the data of mission-critical<br />

applications worldwide resides on S/390. A wide range of<br />

features <strong>and</strong> products support an absolutely secure<br />

environment for storing your data with integrity.<br />

Performance High-volume transaction processing <strong>and</strong> heavy batch<br />

processes are common on S/390. S/390 is very efficient in<br />

managing its use of hardware <strong>and</strong> software resources.<br />

Availability S/390 availability is the best in the industry. It can provide<br />

continuous availability so that your applications are<br />

available to your users <strong>and</strong> customers whenever they need<br />

them.<br />

6 <strong>IMS</strong> <strong>Version</strong> 7 <strong>and</strong> <strong>Java</strong> <strong>Application</strong> <strong>Programming</strong>


Manageability One S/390 server can serve thous<strong>and</strong>s of users anywhere<br />

in the world. One centrally located department of IS staff is<br />

sufficient to manage <strong>and</strong> supply information services<br />

throughout the world. Because changes in data or<br />

applications have to be made only once at one place, they<br />

become active at the same time for all users.<br />

Scalability It is possible to serve your data <strong>and</strong>/or applications on S/390<br />

to thous<strong>and</strong>s or, when serving the Internet, even millions of<br />

new users without necessarily having to replicate your<br />

servers.<br />

Security OS/390, <strong>and</strong> the S/390 hardware, have been architected for<br />

more than 25 years to isolate applications <strong>and</strong> subsystems<br />

from one another <strong>and</strong> to provide user authentication <strong>and</strong><br />

access control. <strong>Java</strong> programs <strong>and</strong> applications that run on<br />

S/390 benefit from this extended security model as well as<br />

the st<strong>and</strong>ard, built-in, security of the <strong>Java</strong> environment.<br />

OS/390 has evolved to a fully open operating system that supports:<br />

Internet Web serving<br />

High security <strong>and</strong> integrity required for electronic commerce<br />

Distributed object-oriented application architectures<br />

This support, combined with the classic strengths of OS/390, makes it an<br />

excellent operating system for your current <strong>and</strong> future mission-critical<br />

applications <strong>and</strong> data.<br />

1.3 <strong>IMS</strong> as an object server<br />

The transaction processing strengths of <strong>IMS</strong> in an enterprise computing<br />

environment are appreciated <strong>and</strong> exploited worldwide. <strong>IMS</strong> has always<br />

provided a robust transaction processing environment that:<br />

Allows creation of transactions with atomicity, consistency, isolation, <strong>and</strong><br />

durability (ACID) properties.<br />

Allows transactions to run under all sorts of conditions.<br />

Provides continuous operation <strong>and</strong> high availability with (more recently)<br />

sysplex support, data sharing, <strong>and</strong> the removal of single points of failure.<br />

1.3.1 Background<br />

<strong>IMS</strong> is unique in a number of ways, making this environment significantly<br />

easier for <strong>IMS</strong> to move into <strong>and</strong> thus rapidly provide solutions:<br />

Chapter 1. Introduction 7


1. <strong>IMS</strong> is proprietary to the S/390 <strong>and</strong> has been designed to easily exploit,<br />

integrate with, <strong>and</strong> utilize any new S/390 hardware or software function<br />

immediately. This includes the ability for <strong>IMS</strong> to take immediate<br />

advantage, not only of S/390 storage, communication, <strong>and</strong> data<br />

management facilities, provided by the operating system, but also of<br />

any Sysplex, OpenEdition, Recoverable Resource Management<br />

Services for distributed coordinated commit, <strong>and</strong> WebSphere<br />

<strong>Application</strong> Server functions, for example, as well.<br />

2. <strong>IMS</strong> has provided an extremely easy application model, structured to be<br />

device <strong>and</strong> environment independent. Thus, there are no hidden<br />

dependencies of <strong>IMS</strong> applications on the environment. For example,<br />

any address space <strong>and</strong> task structure changes would not affect the <strong>IMS</strong><br />

application as they might under other transaction systems.<br />

3. As a message-driven queued system, the <strong>IMS</strong> application is in most all<br />

cases structured to be independent of message delivery timing <strong>and</strong> of<br />

what has gone on before. This makes <strong>IMS</strong> more robust, reliable, <strong>and</strong><br />

easier to recover from problems. Because of the way the <strong>IMS</strong><br />

application has thus had to be written, concurrency issues of other<br />

transaction management systems do not arise in <strong>IMS</strong>. This stateless<br />

condition, common to most <strong>IMS</strong> applications, is also how <strong>Java</strong> <strong>and</strong> the<br />

Internet are structured, making <strong>IMS</strong> a natural application server for this<br />

environment.<br />

4. The <strong>IMS</strong> programming model in scheduling an application is very<br />

powerful, providing applications, for example, the ability to emulate both<br />

synchronous or asynchronous communication <strong>and</strong> make either work<br />

very well.<br />

5. <strong>IMS</strong> is, in fact, an object manager, with applications encapsulating data<br />

into <strong>IMS</strong> transaction objects <strong>and</strong> where data objects can be stored as<br />

<strong>IMS</strong> database segments. This makes object programming a natural<br />

transition for the <strong>IMS</strong> programming environment.<br />

6. <strong>IMS</strong> has been providing a broad base of connectivity interfaces, for both<br />

SNA <strong>and</strong> TCP/IP network access <strong>and</strong> for subsystem access. Recent<br />

subsystem access facilities are the <strong>IMS</strong> V7 Open Transaction Manager<br />

Access (OTMA) facility <strong>and</strong> the new <strong>IMS</strong> V7 Open Database Access<br />

(ODBA) facility.<br />

1.3.2 <strong>IMS</strong> client for <strong>Java</strong><br />

<strong>IMS</strong> is exploiting the latest programming technologies for the Internet. This<br />

includes <strong>Java</strong>, which enables interactive <strong>and</strong> multimedia applications in a<br />

simplified fashion. With <strong>Java</strong>, users can transparently download <strong>and</strong><br />

8 <strong>IMS</strong> <strong>Version</strong> 7 <strong>and</strong> <strong>Java</strong> <strong>Application</strong> <strong>Programming</strong>


1.4 What is <strong>IMS</strong> <strong>Java</strong>?<br />

seamlessly run applications. This may be something as simple as animating<br />

the title of the HTML file, or something more complex, such as automatically<br />

retrieving desired information from various sites around the Internet <strong>and</strong><br />

manipulating it.<br />

<strong>Java</strong> is multithreaded <strong>and</strong> interpreted. It can thus be widely used <strong>and</strong> is<br />

platform independent. Initially provided here for this environment is the <strong>IMS</strong><br />

Client for <strong>Java</strong>, which consists of application <strong>and</strong> applet code for preparing a<br />

<strong>Java</strong> program to access <strong>IMS</strong> applications <strong>and</strong> data, <strong>and</strong> a user exit to<br />

translate the message into the format required by the <strong>IMS</strong> <strong>Version</strong> 7 Open<br />

Transaction Manager Access (OTMA) interface. This code uses the <strong>IMS</strong><br />

Connect to access <strong>IMS</strong>.<br />

<strong>IBM</strong> has ported <strong>Java</strong> to the S/390, providing the popular <strong>Java</strong> run-time<br />

environment from PCs to S/390s. Today the <strong>IBM</strong> Domino Go Webserver for<br />

OS/390 is able to host <strong>Java</strong> applets for downloading to <strong>Java</strong>-enabled Web<br />

browsers. And the <strong>IMS</strong> Client for <strong>Java</strong> provides an applet for this purpose.<br />

Recent <strong>IMS</strong> Client for <strong>Java</strong> V2.1 enhancements provide conversational,<br />

security, <strong>and</strong> capacity/usability enhancements.<br />

<strong>IMS</strong> <strong>Java</strong> allows <strong>IMS</strong> shops to take advantage of the growing pool of <strong>Java</strong><br />

trained programmers. It extends existing <strong>IMS</strong> transactions to e-business,<br />

uses <strong>Java</strong> with high-performance server solutions, <strong>and</strong> reduces the<br />

complexity of <strong>IMS</strong> application development.<br />

<strong>IMS</strong> <strong>Java</strong> was developed to provide an application programming interface<br />

(API) that is usable by experienced <strong>Java</strong> programmers, <strong>and</strong> to provide an API<br />

that can later be supported with code generation tools, such as those found in<br />

VisualAge for <strong>Java</strong>. <strong>IMS</strong> <strong>Java</strong> provides you with the ability to develop new<br />

applications more easily. <strong>IMS</strong> <strong>Java</strong> also provides <strong>Java</strong> programmers with<br />

complete access to necessary <strong>IMS</strong> services.<br />

<strong>IMS</strong> <strong>Java</strong> is delivered in a layered set of class libraries providing high-level<br />

classes that focus strongly on ease-of-use, <strong>and</strong> lower-level classes that<br />

provide complete access to <strong>IMS</strong> services <strong>and</strong> serve as the implementation<br />

vehicle for the higher-level classes.<br />

<strong>IMS</strong> <strong>Java</strong> on the OS/390 platform supports:<br />

High Performance <strong>Java</strong> (HPJ) compiled <strong>Java</strong> applications executing in all<br />

<strong>IMS</strong> dependent regions (MPP, IFP, <strong>and</strong> BMP), but not in a JVM.<br />

Chapter 1. Introduction 9


<strong>Java</strong> class libraries that support the development of applications within<br />

visual development environments (like VisualAge for <strong>Java</strong>) to access the<br />

<strong>IMS</strong> message queue <strong>and</strong> to DL/I data on OS/390.<br />

Access to DB2 data on OS/390 through the use of JDBC <strong>and</strong> SQLJ within<br />

a <strong>Java</strong> application. See your DB2 documentation for further explanation.<br />

<strong>Java</strong> Database Connectivity (JDBC) access to DL/I data.<br />

Alternate PCB program switching. <strong>IMS</strong> <strong>Java</strong> allows programs to use the<br />

alternate PCB to send messages to another terminal or program, including<br />

a COBOL program.<br />

Conversational transactions <strong>and</strong> non-conversational transactions.<br />

Fast Path databases. There is no limitation on the use of DEDB<br />

databases.<br />

Full-Function databases.<br />

Multi-segment messages. There is no limitation to the use of<br />

multi-segment <strong>and</strong> single-segment messages.<br />

Message formatting services (MFS) are available by passing the MOD<br />

names to <strong>IMS</strong>.<br />

Secondary indexes.<br />

Logical relationships.<br />

High availability large databases (HALDBs).<br />

HIDAM.<br />

1.4.1 Other <strong>IMS</strong> <strong>Java</strong> considerations<br />

1.5 <strong>Java</strong><br />

<strong>IMS</strong> <strong>Java</strong> programs must be single-threaded. <strong>IMS</strong> <strong>Java</strong> only supports the AIB<br />

interface, therefore the database PCBs in your PSBGEN must be named.<br />

<strong>IMS</strong> <strong>Java</strong> applications can only call other language applications through <strong>Java</strong><br />

native interface (JNI) that are POSIX(ON), therefore you cannot call COBOL<br />

functions. In addition, you cannot currently invoke a <strong>Java</strong> program from a<br />

COBOL program.<br />

<strong>Java</strong> is an OO programming language <strong>and</strong> execution environment that offers<br />

significant new opportunities for software development, interoperability, <strong>and</strong><br />

portable execution. In this section we introduce the technology, explain the<br />

basics, <strong>and</strong> position <strong>Java</strong> <strong>and</strong> <strong>Java</strong> technology. <strong>Java</strong> started its life in 1991 as<br />

part of a Sun Microsystems project called OAK, a software environment<br />

10 <strong>IMS</strong> <strong>Version</strong> 7 <strong>and</strong> <strong>Java</strong> <strong>Application</strong> <strong>Programming</strong>


(“virtual machine”) <strong>and</strong> programming language aimed at cable television<br />

“set-top” boxes. For various reasons the name OAK was dropped, <strong>and</strong> the<br />

name <strong>Java</strong> was adopted before the first release of the resulting technology.<br />

To meet the objectives of this project, <strong>Java</strong> was designed from the outset to<br />

be small, portable, fast, <strong>and</strong> safe. These characteristics would later prove to<br />

be an essential part of <strong>Java</strong>'s success, as they made <strong>Java</strong> an ideal language<br />

for the explosion in growth of the Web <strong>and</strong> the Internet.<br />

As part of this explosive growth, Sun released a Web browser called Hot<strong>Java</strong>.<br />

To implement the browser, Sun licensed the source code for the Hot<strong>Java</strong><br />

environment, the <strong>Java</strong> Virtual Machine (JVM). This meant that the JVM <strong>and</strong><br />

<strong>Java</strong> language were soon available on other UNIX systems, <strong>and</strong> shortly<br />

afterward on OS/2 <strong>and</strong> Microsoft Windows.<br />

It did not take long for technologists to realize the potential advantages<br />

offered by the JVM <strong>and</strong> its portable bytecode: rapid takeup followed <strong>and</strong><br />

ushered in a new generation of Internet programming.<br />

Today, <strong>Java</strong> can be deployed in applications, in full executable programs that<br />

perform functions similar to applications written in traditional languages, <strong>and</strong><br />

in applets, which are small reusable extensions to a Web browser. The<br />

extensions are restricted in what they can do, <strong>and</strong> the environment they run in<br />

is completely secured by the Web browser. A <strong>Java</strong> program can also run in a<br />

Web server environment as a servlet, thus extending the function provided by<br />

a Web server. <strong>IBM</strong> provides a plug-in, WebSphere <strong>Application</strong> Server, that<br />

allows Web servers to run servlets. WebSphere <strong>Application</strong> Server is not a<br />

prerequisite for <strong>IMS</strong> support of the <strong>Java</strong> language or of a CORBA client.<br />

The full impact of <strong>Java</strong> will be seen over time. However, its impact to date<br />

should not be underestimated. <strong>Java</strong> has been <strong>and</strong> continues to be adopted<br />

by many businesses <strong>and</strong> technology companies both large <strong>and</strong> small.<br />

The <strong>Java</strong> platform is a way of computing, based on the idea that the same<br />

software should run on many different kinds of computers <strong>and</strong> devices. With<br />

the <strong>Java</strong> technology, you can use the same application from any kind of<br />

machine — a PC, a Macintosh computer, a network computer, or even new<br />

technologies like Internet screen phones.<br />

<strong>Java</strong> technology components do not care what kind of computer, device or<br />

operating system they run on. They just work on any kind of compatible<br />

device that supports the <strong>Java</strong> platform. <strong>Java</strong> technology is widely regarded as<br />

revolutionary, because it is designed to let computers <strong>and</strong> devices<br />

communicate with one another much more easily than ever before.<br />

Chapter 1. Introduction 11


<strong>Java</strong> is a simple, robust, object-oriented, platform-independent,<br />

multithreaded, dynamic, general-purpose programming environment for<br />

creating applications for the Internet <strong>and</strong> Intranet. The open,<br />

platform-independent, object-oriented nature of <strong>Java</strong> technology means<br />

developers can solve the problem of integrating with existing computers that<br />

previously would have seemed unthinkably complex.<br />

With <strong>Java</strong> technology, the Internet <strong>and</strong> private networks become your<br />

computing environment. For example, users can securely access their<br />

personal information <strong>and</strong> applications when they are far away from the office<br />

by using any computer that is connected to the Internet.<br />

1.5.1 <strong>Java</strong> environment<br />

<strong>Java</strong>, a programming language developed by Sun Microsystems, is<br />

object-oriented, distributed, interpreted, architecture-neutral, <strong>and</strong> portable.<br />

<strong>Java</strong> can be used to create downloadable program fragments, so-called<br />

applets, that augment the functionality of a <strong>Java</strong>-capable browser such as<br />

Netscape Navigator. Additionally, <strong>Java</strong> can be run as a st<strong>and</strong>-alone<br />

application, without the use of a Browser, in a <strong>Java</strong> virtual machine.<br />

<strong>Java</strong> originated as part of a research project to develop advanced software<br />

for a wide variety of network devices <strong>and</strong> embedded systems. The goal was<br />

to develop a small, reliable, portable, distributed, real-time operating<br />

platform. The result is a language platform that has proven ideal for<br />

developing secure, distributed, network-based end-user applications in<br />

environments ranging from network-embedded devices to the World-Wide<br />

Web <strong>and</strong> the desktop.<br />

The design requirements of <strong>Java</strong> are driven by the nature of the computing<br />

environments in which software must be deployed. The massive growth of the<br />

Internet <strong>and</strong> the World-Wide Web lead to a completely new way of looking at<br />

development <strong>and</strong> distribution of software. To live in the world of electronic<br />

commerce <strong>and</strong> distribution, <strong>Java</strong> must enable the development of secure,<br />

high performance, <strong>and</strong> highly robust applications on multiple platforms in<br />

heterogeneous, distributed networks.<br />

<strong>Java</strong> is designed to meet the challenges of application development in the<br />

context of heterogeneous, network-wide distributed environments.<br />

Paramount among these challenges is secure delivery of applications that<br />

consume the minimum of system resources, can run on any hardware <strong>and</strong><br />

software platform, <strong>and</strong> can be extended dynamically.<br />

12 <strong>IMS</strong> <strong>Version</strong> 7 <strong>and</strong> <strong>Java</strong> <strong>Application</strong> <strong>Programming</strong>


Operating on multiple platforms invalidates the traditional schemes of binary<br />

distribution, release, upgrade, patch, <strong>and</strong> so on. <strong>Java</strong> must be architecture<br />

neutral, portable, <strong>and</strong> dynamically adaptable. The <strong>Java</strong> system meets these<br />

needs. It can be easily programmed by most developers. Current developers<br />

can easily learn <strong>Java</strong>. It is object-oriented to take advantage of modern<br />

software development methodologies <strong>and</strong> it fits into distributed client-server<br />

applications. Multithreaded for high performance in applications that need to<br />

perform multiple concurrent activities, such as multimedia, <strong>Java</strong> also is<br />

interpreted for maximum portability <strong>and</strong> dynamic capabilities.<br />

1.5.2 <strong>Java</strong> language<br />

<strong>Java</strong> is a high-level language, similar to C <strong>and</strong> C++. <strong>Java</strong> is claimed to be<br />

(relatively) simple when compared to C++, as many of the more error-prone<br />

aspects of C++ have been eliminated. For example, <strong>Java</strong> has no<br />

preprocessor, pointers, or goto, only limited casting, <strong>and</strong> automatic garbage<br />

collection.<br />

<strong>Java</strong> is object-oriented, but without all the complications. It has a single<br />

inheritance model, simple data types, <strong>and</strong> code that is organized into classes.<br />

These classes provide an excellent way of packaging functions. It is<br />

object-oriented from the ground up <strong>and</strong> meshes well with the needs of<br />

client-server <strong>and</strong> distributed software. Benefits of object technology are<br />

rapidly becoming realized as more organizations move their applications to<br />

the distributed client-server model. An important characteristic that<br />

distinguishes objects from ordinary procedures or functions is that an object<br />

can have a lifetime greater than that of the object that created it. This aspect<br />

of objects is subtle <strong>and</strong> mostly overlooked.<br />

In the distributed client-server world, you now have the potential for objects to<br />

be created in one place, passed around networks, <strong>and</strong> stored elsewhere,<br />

possibly in databases, to be retrieved for future work. As an object-oriented<br />

language, <strong>Java</strong> draws on the best concepts <strong>and</strong> features of previous<br />

object-oriented languages, primarily Eiffel, SmallTalk, Objective C, <strong>and</strong> C++.<br />

<strong>Java</strong> goes beyond C++ in both extending the object model <strong>and</strong> removing the<br />

major complexities of C++. With the exception of its primitive data types,<br />

everything in <strong>Java</strong> is an object, <strong>and</strong> even the primitive types can be<br />

encapsulated within objects if the need arises.<br />

Interfaces to the objects are abstract classes. Classes can implement<br />

multiple interfaces. The interfaces are similar to CORBA interface definition<br />

language (IDL) interfaces. A number of products <strong>and</strong> tools are available,<br />

including <strong>IBM</strong>'s Component Broker, that can bridge between <strong>Java</strong> <strong>and</strong><br />

CORBA.<br />

Chapter 1. Introduction 13


As a language, <strong>Java</strong> is statically typed, <strong>and</strong> most type checking is done at<br />

compile time. However, run-time checks such as array bounds, are still<br />

required. A key function of <strong>Java</strong> is that numeric precision is defined with the<br />

IEEE floating point notation, which ensures the same results everywhere for<br />

mathematical calculations. Figure 3 illustrates a simple <strong>Java</strong> class model.<br />

<strong>Java</strong> has a simple class hierarchy, <strong>and</strong> a single inheritance model. This<br />

example shows two types of classes: Vehicle <strong>and</strong> Building. Both classes can<br />

inherit from the class above. Classes further down in the hierarchy can inherit<br />

from either the Vehicle or the Building class but not both. Other object-based<br />

technologies also have single inheritance, <strong>and</strong> some more complex<br />

technologies have multiple inheritance, where a class could inherit from both<br />

the Vehicle <strong>and</strong> Building class.<br />

Figure 3. A simple class model for <strong>Java</strong><br />

Figure 4 shows some <strong>Java</strong> source code (the typical "Hello World" program)<br />

<strong>and</strong> the basic structure <strong>and</strong> elements of a <strong>Java</strong> application. It begins with<br />

block documentation comments that are started with /** <strong>and</strong> end with */. If<br />

this program were processed by the <strong>Java</strong>-<strong>Java</strong>doc utility, a st<strong>and</strong>ard part of<br />

the <strong>Java</strong> Development Kit (JDK), these comments, along with the structure of<br />

the program, its methods, <strong>and</strong> other documentation comments, would be<br />

automatically included in a documentation file in HTML format.<br />

A second form of comment can also be seen in the program: // display<br />

string. This is a private comment <strong>and</strong> will not be included in the HTML file<br />

that <strong>Java</strong>doc produces. <strong>Java</strong> also supports a third style of comment: the<br />

classical C comment starting with /* <strong>and</strong> ending with */. These are also<br />

private <strong>and</strong> are not included in <strong>Java</strong>doc HTML files. Some sample <strong>Java</strong><br />

source code is shown in Figure 4.<br />

14 <strong>IMS</strong> <strong>Version</strong> 7 <strong>and</strong> <strong>Java</strong> <strong>Application</strong> <strong>Programming</strong>


**<br />

*HelloWorldApp class implements an application that simply<br />

*displays "Hello World" to the st<strong>and</strong>ard output device.<br />

*/<br />

public class HelloWorldApp {<br />

public static void main(String[] args) {<br />

System.out.println("Hello World!"); //display string<br />

}<br />

}<br />

Figure 4. Sample <strong>Java</strong> source code<br />

After the documentation comment you can see the name of the class defined:<br />

HelloWorldApp. This part of the program gives us important information, such<br />

as whether this is an application, an applet, or a servlet. In this case the<br />

sample program is an application — it has a main() construct in its source<br />

code — <strong>and</strong> it can be executed from a comm<strong>and</strong> line.<br />

The name of the class is case sensitive <strong>and</strong> must match the name of the file.<br />

The file type is .java, making the full file name HelloWorldApp.java. The file<br />

name, for example javac HelloWorldApp.java, is used when you compile the<br />

program. A <strong>Java</strong> program is compiled into a .class file. The class name<br />

without its file type of .class, for example java HelloWorldApp, is used when<br />

you run the program.<br />

The next part of the program defines the properties of the <strong>Java</strong> program or<br />

class. In this case it is a public class that can be called by any other class.<br />

Our sample program returns no data, <strong>and</strong> it takes as input a character string<br />

of comm<strong>and</strong> line arguments.<br />

Finally our sample program performs its function: in this case to print out<br />

"Hello World" by creating an instance of a <strong>Java</strong> class. If you are only familiar<br />

with procedural programming, you could think of this as a call to a<br />

system-provided function. In reality it is very different, but that is beyond the<br />

scope of this introduction.<br />

The source code shown in Figure 4 would be compiled into machine<br />

independent bytecode with the <strong>Java</strong> compiler, javac. The bytecode is<br />

conceptually similar to an object deck in S/390 terms. It is executable but still<br />

needs to be link-edited.<br />

<strong>Java</strong> bytecode is dynamically linked; that is, functions external to the program<br />

are located <strong>and</strong> loaded at runtime rather than being statically bound to the<br />

<strong>Java</strong> bytecode. Thus functions can be loaded on dem<strong>and</strong> over the network<br />

when needed, with unused code never loaded. If the <strong>Java</strong> program is an<br />

Chapter 1. Introduction 15


application or servlet, it can still be dynamically linked by loading classes over<br />

a network-based file system such as network file system (NFS), distributed<br />

file system (DFS), or Andrew file system (AFS). Typically, however all the<br />

required classes would be installed locally for applications <strong>and</strong> servlets.<br />

Once loaded <strong>and</strong> linked, <strong>Java</strong> bytecodes are ready for execution. Originally<br />

<strong>Java</strong> bytecode was always interpreted, that is, translated into native<br />

instructions. However, by default, almost all JVMs include a just-in-time (JIT)<br />

compiler. The JIT uses a number of techniques to precompile or cache <strong>and</strong><br />

reuse native instructions. A JIT provides significant performance advantages,<br />

as demonstrated by the improved JIT releases of the OS/390 JDK 1.1.4 in<br />

April 1998, <strong>and</strong> in the 1.1.6 JDK in October 1998.<br />

Because <strong>Java</strong> bytecode is in a machine-independent, architecture-neutral<br />

format, it can be run on any system with a st<strong>and</strong>ard <strong>Java</strong> implementation. An<br />

extensive library of underlying classes or functions can be used to do<br />

everything from graphics to network communication. Because these classes<br />

are <strong>Java</strong> bytecode, they too are machine-independent.<br />

1.5.3 <strong>Java</strong> for OS/390<br />

The implementation of <strong>Java</strong> on OS/39O started in 1996 with a port of the AIX<br />

JDK 1.0.2 to the OS/390 UNIX Systems Services. The AIX JDK is based on<br />

licensed source code from Sun Microsystems.<br />

The OS/390 JVM maps <strong>Java</strong> threads onto native OS/390 threads. All <strong>Java</strong><br />

threads are run on an OS/390 task control block (TCB). This makes all <strong>Java</strong><br />

threads truly multithreaded <strong>and</strong> preemptively multitasked <strong>and</strong><br />

multiprocessor-capable. <strong>Java</strong> components that implement multiple threads<br />

can exploit the S/390 architecture without knowledge of or programming for<br />

the underlying OS/390 operating system.<br />

In 1997, the JDK 1.1.1 for OS/390 was released <strong>and</strong> was the first fully<br />

supported implementation of <strong>Java</strong> on OS/390. JDK 1.1.1 included a JIT<br />

compiler <strong>and</strong> a number of other improvements. January 1998 saw the release<br />

of an updated JDK 1.1.1 with a number of defects fixed <strong>and</strong> an updated JIT<br />

with significantly improved performance.<br />

The next significant update was with OS/390 JDK 1.1.4, which included all<br />

the previous enhancements, plus a new <strong>Java</strong> garbage collection model. In<br />

<strong>Java</strong>, programmers do not allocate <strong>and</strong> free memory. Memory is allocated by<br />

the JVM when needed, <strong>and</strong> then, in the st<strong>and</strong>ard <strong>Java</strong> implementation, the<br />

JVM periodically suspends all running threads <strong>and</strong> reclaims memory that is<br />

no longer in use.<br />

16 <strong>IMS</strong> <strong>Version</strong> 7 <strong>and</strong> <strong>Java</strong> <strong>Application</strong> <strong>Programming</strong>


In a server environment, to make systems both scalable <strong>and</strong> efficient <strong>and</strong> to<br />

provide a predictable response time, the OS/390 JVM now reclaims memory<br />

in real time without the suspension of executing threads. From a<br />

programming perspective, this change remains completely compatible <strong>and</strong><br />

does not require any additional programming.<br />

1.5.4 High Performance <strong>Java</strong> compiler<br />

Most JVMs contain a JIT compiler to improve execution performance. JIT<br />

compilers turn <strong>Java</strong> bytecode into native object code "on-the-fly", as it is<br />

loaded into the JVM. The JVM then executes the generated object code<br />

directly, instead of interpreting bytecodes. Because this translation is done for<br />

each execution phase, the requirement for reasonable compilation speed<br />

constrains the amount of optimization that a JIT compiler can perform.<br />

VisualAge for <strong>Java</strong>, Enterprise Edition for OS/390 contains a new component,<br />

Enterprise Toolkit for OS/390 (ET/390). This component introduces an<br />

optimizing native code compiler that statically compiles <strong>Java</strong> bytecode<br />

directly into native object code. This compiler is called the High Performance<br />

<strong>Java</strong> (HPJ) compiler. Unlike with the JIT compilation, the ET/390 static<br />

compilation occurs only once, before execution time. The HPJ compiler also<br />

fully binds the code into an executable or dynamic link library (DLL) that can<br />

be run in the OS/390 shell or under <strong>IMS</strong>.<br />

1.5.5 <strong>Java</strong> tools<br />

One of the strengths of <strong>Java</strong> is the set of st<strong>and</strong>ard tools <strong>and</strong> class libraries<br />

that are included in every JDK. The tools include the following:<br />

javac The <strong>Java</strong> compiler. This is actually a <strong>Java</strong> program that<br />

translates <strong>Java</strong> source code programs into <strong>Java</strong> bytecode.<br />

jdb The <strong>Java</strong> debugger<br />

javah Generates header files for C or C++ programs to<br />

interoperate with <strong>and</strong> call <strong>Java</strong> programs or objects.<br />

javakey Can be used to generate security keys for use with <strong>Java</strong><br />

<strong>and</strong> <strong>Java</strong> programs.<br />

javap The <strong>Java</strong> disassembler. It takes <strong>Java</strong> bytecode <strong>and</strong><br />

produces pseudo <strong>Java</strong> source code. The source code<br />

contains enough information for a programmer to be able<br />

to underst<strong>and</strong> the structure, classes, <strong>and</strong> methods within<br />

the bytecode. However, the source code needs extensive<br />

reprogramming before it can be recompiled <strong>and</strong> used.<br />

Chapter 1. Introduction 17


javadoc Takes a <strong>Java</strong> source code program <strong>and</strong> produces<br />

documentation in the form of HTML files. The<br />

documentation contains class structures <strong>and</strong> methods.<br />

Where <strong>Java</strong> documentation comments are included in the<br />

source code they will be included in the HTML file at the<br />

correct point, class, or method definition.<br />

rmic/rmregistry A pair of tools to build <strong>and</strong> locate <strong>Java</strong> objects in a<br />

networked or st<strong>and</strong>-alone environment. These are a set of<br />

basic services that reduce the need to hard code locations<br />

in program source code.<br />

appletviewer Is used to test <strong>and</strong> display the output from <strong>Java</strong> applets. It<br />

can be used on OS/390 with an X-terminal or X-capable<br />

server to h<strong>and</strong>le the actual display.<br />

In addition to these there are a number of other st<strong>and</strong>ard tools <strong>and</strong> utilities.<br />

1.5.6 Class libraries <strong>and</strong> packages<br />

Like the st<strong>and</strong>ard set of tools available in every JDK, one of the big<br />

advantages of <strong>Java</strong> is the built-in, st<strong>and</strong>ard class or run-time libraries <strong>and</strong><br />

packages available in every JDK. These include:<br />

java.lang Essential <strong>Java</strong> classes, implicitly imported. Contains<br />

object, string, number, exception, error, <strong>and</strong> other<br />

java.io Stream-based input/output file system.<br />

java.util Utility classes, date, r<strong>and</strong>om, dictionary hashtable, vector,<br />

enumeration <strong>and</strong> other<br />

java.net Networking, sockets, addresses, uniform resource<br />

locators (URLs)<br />

java.awt Abstract Windowing Toolkit (AWT), cross-platform<br />

graphical user interface (GUI)<br />

java.applet Support for applets<br />

Packages often contain one or more classes. For example, java.lang<br />

contains java.lang.Thread <strong>and</strong> .System. These were the st<strong>and</strong>ard class<br />

packages in <strong>Java</strong> JDK 1.1. Others have been defined <strong>and</strong> architected for<br />

inclusion in <strong>Java</strong> JDK 1.2 including a replacement for the java.awt, java.jfc, a<br />

richer cross-platform GUI, <strong>and</strong> java.servlet, which is currently available only<br />

in the <strong>Java</strong> Servlet Development Toolkit, as well as many others.<br />

Figure 5 shows the structure, relationships, <strong>and</strong> interoperability of the various<br />

<strong>Java</strong> components, the operating system, <strong>and</strong> the hardware.<br />

18 <strong>IMS</strong> <strong>Version</strong> 7 <strong>and</strong> <strong>Java</strong> <strong>Application</strong> <strong>Programming</strong>


1.5.7 VisualAge for <strong>Java</strong><br />

Figure 5. <strong>Java</strong> structure, components, <strong>and</strong> tools<br />

In 1997, the focus of <strong>Java</strong> development changed somewhat to encompass<br />

enterprise computing. Today you need a robust development environment to<br />

create large <strong>and</strong> complex applications. You need an environment with code<br />

management, powerful searching <strong>and</strong> browsing, GUI building, <strong>and</strong> <strong>Java</strong>Bean<br />

creation <strong>and</strong> manipulation capabilities. You need an environment that helps<br />

you think in terms of objects.<br />

VisualAge for <strong>Java</strong> is an integrated, visual development environment that<br />

supports the complete cycle of <strong>Java</strong> program development. Using the rapid<br />

application development environment provided by VisualAge for <strong>Java</strong>, you<br />

can shorten the development cycle of your applications.<br />

The VisualAge for <strong>Java</strong> product family includes workstation <strong>and</strong> OS/390<br />

components. Some customers will prefer to do their <strong>Java</strong> application<br />

development for <strong>IMS</strong> using exclusively mainframe tools. Others will opt for a<br />

workstation application development environment. In this project we used<br />

both mainframe <strong>and</strong> workstation environments, which we describe in Chapter<br />

2, “Environment customization” on page 23.<br />

VisualAge for <strong>Java</strong> is available in three versions:<br />

Entry Edition<br />

Professional Edition<br />

Enterprise Edition<br />

Chapter 1. Introduction 19


If you choose VisualAge for <strong>Java</strong> as your workstation development<br />

environment for <strong>IMS</strong>, use the Enterprise Edition on your workstation. You can<br />

also use another <strong>Java</strong> integrated development environment (IDE) workbench<br />

or not use any workbench at all. In any case, you have to order VisualAge for<br />

<strong>Java</strong>, Enterprise Edition for OS/390, to support compilation <strong>and</strong> binding of<br />

<strong>Java</strong> programs for use in the <strong>IMS</strong> environment.<br />

1.5.8 VisualAge for <strong>Java</strong> tools<br />

Several tools in VisualAge for <strong>Java</strong>, Enterprise Edition, facilitate the<br />

application development process for OS/390 <strong>and</strong> <strong>IMS</strong>:<br />

1.5.8.1 Remote debugger<br />

You can remotely debug your fully compiled <strong>and</strong> bound <strong>Java</strong> programs<br />

running natively in the OS/390 UNIX environment or under <strong>IMS</strong>. The remote<br />

debugger has an intuitive GUI that you can use to debug your code at the<br />

source level. You can set breakpoints by line number, on method entry, or on<br />

a storage chain. You can display <strong>and</strong> monitor variables, registers, memory,<br />

<strong>and</strong> call stacks or display your variables. You can single-step through your<br />

code or step into or around methods. You can set frequency counts for line<br />

breakpoints to stop program execution at specific iterations.<br />

1.5.8.2 Performance analyzer<br />

You can use the ET/390 Performance Analyzer on your workstation to<br />

graphically display <strong>and</strong> analyze a trace of the execution of fully compiled <strong>and</strong><br />

bound programs running in your OS/390 UNIX environment. This tool does<br />

not support execution under <strong>IMS</strong>.<br />

1.5.8.3 jport utility<br />

The jport utility is used to identify code that cannot be optimized with the HPJ<br />

compiler, which targets natively compiled code for the OS/390 UNIX <strong>and</strong> <strong>IMS</strong><br />

environments; for example, the java.applet package <strong>and</strong> AWT are not<br />

supported. The jport utility reads <strong>Java</strong> bytecode files <strong>and</strong> generates a report<br />

that lists all unsupported packages, classes, methods, <strong>and</strong> fields for the<br />

OS/390 UNIX <strong>and</strong> <strong>IMS</strong> environments. The jport utility can be invoked<br />

automatically when you use VisualAge for <strong>Java</strong> to export <strong>and</strong> bind your<br />

program. Alternatively you can invoke the jport utility directly from the<br />

comm<strong>and</strong> prompt on your workstation to verify <strong>Java</strong> bytecode files that are on<br />

your local workstation, or from the OS/390 UNIX shell to verify <strong>Java</strong> code that<br />

is on your OS/390 Hierarchical File System (HFS).<br />

20 <strong>IMS</strong> <strong>Version</strong> 7 <strong>and</strong> <strong>Java</strong> <strong>Application</strong> <strong>Programming</strong>


1.5.9 <strong>Java</strong> application structures<br />

In the <strong>Java</strong> environment you deal with several types of application structures.<br />

1.5.9.1 <strong>Application</strong><br />

<strong>Java</strong> applications are real <strong>Java</strong> programs. They can process local files,<br />

contact other systems on the network, <strong>and</strong> do many other things <strong>Java</strong> applets<br />

cannot do. <strong>Java</strong> applications can create their own security manager, which<br />

can persist for the duration of the application <strong>and</strong> set the security rules for the<br />

application. An application would typically be preinstalled on the system on<br />

which it is to run in the same way as applications written in other languages.<br />

<strong>Java</strong> applications can be made available through a network <strong>and</strong> in fact are<br />

suited to this type of configuration. You can use NFS, WebNFS, DFS, or<br />

another network-based file system, rather than distributing the application to<br />

each individual system (PC or workstation) on which it will run. <strong>Java</strong><br />

applications have a main() construct in their source code; this defines the<br />

top-level class. Applets <strong>and</strong> servlets, by contrast, do not have a main()<br />

construct.<br />

1.5.9.2 Applets<br />

<strong>Java</strong> applets are mini-programs <strong>and</strong> must be run by either the <strong>Java</strong> JDK<br />

appletviewer or by a <strong>Java</strong>-enabled Web browser.The applet class, a special<br />

type of <strong>Java</strong> application, can only exist within another application that can<br />

create or initiate it. The JDK appletviewer or a <strong>Java</strong>-enabled Web browser are<br />

two such applications. Over time it is reasonable to expect that other<br />

applications, such as word processors, will be able to run <strong>Java</strong> applets.<br />

Typically, <strong>Java</strong> applets reside on a Web server. When a Web server returns a<br />

page that contains a pointer to a <strong>Java</strong> applet through an tag, the<br />

<strong>Java</strong>-enabled Web browser requests the applet from the server. Once<br />

received, either the browser starts the applet internally, or the external JVM<br />

executes it. <strong>Java</strong> applets do not require <strong>Java</strong> execution environment to be<br />

available on the server.<br />

During execution, the applet may require other classes that are not available.<br />

These classes will be brought over the network by the <strong>Java</strong> class loader. The<br />

classes are compiled <strong>Java</strong> bytecode, not source code.<br />

Applets have no access to operating system or hardware; this is a function of<br />

inheriting from the <strong>Java</strong> applet class <strong>and</strong> is restricted by the JVM. Applets can<br />

have no access, restricted access, or unrestricted access to the Internet or<br />

intranet. Software, hardware, <strong>and</strong> network access is controlled by built-in<br />

<strong>Java</strong> security.<br />

Chapter 1. Introduction 21


1.5.9.3 Servlets<br />

A servlet is to a Web server what an applet is to a Web browser. It is a way of<br />

extending the function of the Web server beyond the st<strong>and</strong>ard facilities<br />

offered by that server. Unlike other technologies that do this, such as<br />

Common Gateway Interface (CGI), Internet Connection <strong>Application</strong><br />

<strong>Programming</strong> Interface (ICAPI), Go Webserver <strong>Application</strong> <strong>Programming</strong><br />

Interface (GWAPI), servlets use <strong>Java</strong> <strong>and</strong> adhere to Sun's servlet model.<br />

WebSphere <strong>Application</strong> Server <strong>and</strong> other plug-ins make servlets portable not<br />

only between platforms but also between Web servers from different<br />

manufacturers.<br />

As with an applet, a servlet has no main() construct. It is initiated, serviced,<br />

<strong>and</strong> destroyed by the Web server.<br />

1.5.9.4 Beans<br />

<strong>Java</strong>Beans are the component technology for <strong>Java</strong>. They are both a<br />

mechanism for packaging <strong>Java</strong> components <strong>and</strong> an infrastructure for creating<br />

<strong>and</strong> instantiating the components. <strong>Java</strong>Beans can “describe” themselves to a<br />

development environment; that is, they can be imported in bytecode class file<br />

format <strong>and</strong> then disclose the public methods <strong>and</strong> properties they have <strong>and</strong><br />

that can be set, retrieved, <strong>and</strong> called at execution time.<br />

It is possible to download <strong>and</strong> use Beans from a network, <strong>and</strong> to devise test<br />

cases for each Bean to make sure it meets your requirements before you use<br />

it in an application.<br />

Although Beans are often graphical, representing visual components, they do<br />

not have to be. An IDE such as VisualAge for <strong>Java</strong> can import both visual <strong>and</strong><br />

nonvisual Beans, <strong>and</strong> these Beans can be "wired" together when building<br />

applications, applets, servlets, or other <strong>Java</strong>Beans.<br />

1.5.10 Access to hardware<br />

The set of APIs delivered with the st<strong>and</strong>ard JDK is very rich. Unfortunately, it<br />

cannot cover every situation. Most importantly, you cannot access specific<br />

hardware from <strong>Java</strong>, because that would hamper portability. However, if<br />

developers want to access specific hardware, they obviously do not care<br />

much about portability. For this purpose, <strong>Java</strong> offers the <strong>Java</strong> Native Interface<br />

(JNI), a set of APIs that can call native routines (written, for example, in C)<br />

<strong>and</strong> allow native programs to call <strong>Java</strong> methods.<br />

With JNI, a <strong>Java</strong> program running on OS/390 can call a native program<br />

written, for example, in C, <strong>and</strong> access S/390 resources. Data can be passed<br />

back <strong>and</strong> forth between the <strong>Java</strong> code <strong>and</strong> the C code.<br />

22 <strong>IMS</strong> <strong>Version</strong> 7 <strong>and</strong> <strong>Java</strong> <strong>Application</strong> <strong>Programming</strong>


Chapter 2. Environment customization<br />

In this chapter, we describe the tasks necessary to set up the environment for<br />

developing <strong>and</strong> running <strong>Java</strong> programs in <strong>IMS</strong>. <strong>Java</strong> programs can be<br />

developed on a workstation, using a GUI environment such as Visual Age for<br />

<strong>Java</strong> Enterprise Edition, or in the OS/390 UNIX System Services shell. The<br />

programs are then compiled with the OS/390 HPJ compiler to create a<br />

high-performance runtime module as either an HFS executable or a Data Link<br />

Library (DLL) member in a PDSE.<br />

<strong>IMS</strong> <strong>Version</strong> 7 supports <strong>Java</strong> in two ways:<br />

2.1 Required software levels<br />

It provides the facility that allows <strong>IMS</strong> transactions to be written in <strong>Java</strong><br />

language as a substitute for COBOL, PL/1, or C.<br />

External <strong>Java</strong> applications can communicate with an <strong>IMS</strong> transaction by<br />

means of a connector called <strong>IMS</strong> Connect.<br />

Major software prerequisites <strong>and</strong> minimum release levels for enabling <strong>IMS</strong><br />

<strong>Java</strong> are shown below. Detailed installation <strong>and</strong> setup information follows.<br />

<strong>IMS</strong> V7 Transaction Manager<br />

OS/390 R2.6 (or higher)<br />

OS/390 LE V1 R7<br />

Visual Age for <strong>Java</strong> Enterprise Edition for OS/390<br />

JDK 1.1.8<br />

DB2 V5 with APAR PQ19814 (if DB2 access will be required)<br />

2.1.1 NFS <strong>and</strong> FTP server tasks<br />

An NFS server <strong>and</strong> an FTP server are required on OS/390, <strong>and</strong> an NFS client<br />

<strong>and</strong> FTP client are required on the workstation for workstation-to-OS/390<br />

remote file access <strong>and</strong> file transfer operations.<br />

The FTP Server on OS/390 is part of the base TCP/IP facilities. These<br />

facilities are part of the OS/390 base support from OS/390 V2 R4 <strong>and</strong> later<br />

(in OS/390 V2 R7, the TCP/IP facilities will be known as eNetwork<br />

Communications Server facilities).<br />

2.1.2 <strong>Java</strong> Development ToolKit (JDK) 1.1.8<br />

Installation <strong>and</strong> setup details for the JDK are described next.<br />

© Copyright <strong>IBM</strong> Corp. 2001 23


2.1.2.1 JDK 1.1.8 installation <strong>and</strong> setup<br />

At the time of writing, the latest generally available version of the<br />

<strong>Java</strong>Development Toolkit for OS/390 is JDK 1.1.8 <strong>and</strong> is downloadable from<br />

the following URL:<br />

http://www.ibm.com/s390/java<br />

In addition, this URL outlines the latest prerequisites <strong>and</strong> instructions, <strong>and</strong><br />

you will be able to download the latest JDK available for OS/390. You can<br />

also order the latest version on tape, which includes a program directory<br />

containing the prerequisites <strong>and</strong> the instructions.<br />

For the latest information regarding prerequisites for <strong>Java</strong> on OS/390, you<br />

can refer to the URL:<br />

http://www.ibm.com/s390/java/javainst.html#prer<br />

For information regarding installation of <strong>Java</strong> for OS/390, refer to the URL:<br />

http://www.ibm.com/s390/java/javainst.htm<br />

2.1.2.2 Directory structure<br />

You should decide from the beginning about the directory structure in which<br />

the JDK <strong>and</strong> other <strong>Java</strong>-related products will be installed. A possible structure<br />

is to create the /usr/lpp/java/ directory. Then, in this directory, unpack the<br />

downloaded JDK install file.as explained in, ‘Installation method: Tar <strong>and</strong><br />

Tarball files’ The unpacking will create a subdirectory named J1.1 in the same<br />

/usr/lpp/java/ directory. You may also install JDBC <strong>and</strong> other <strong>Java</strong>-related<br />

packages in the same directory structure.<br />

2.1.2.3 Installation method: Tar <strong>and</strong> Tarball files<br />

There are two ways of installing the JDK:<br />

1. Download a Tar file <strong>and</strong> manually install it.<br />

2. Download a Tarball file <strong>and</strong> install it with SMP/E.<br />

If you choose the first solution, you will have to download a Tar file (a file<br />

made with the OS/390 UNIX System Services tar utility) <strong>and</strong> install it. You<br />

can either enter manual UNIX comm<strong>and</strong>s to “untar” the file, or run a utility<br />

called ajvinst.exec.<br />

This is a REXX installation script that is downloadable from the same place<br />

as the Tar or Tarball files.The second solution uses SMP/E. The Tarball file<br />

contains the SMP/E jobs <strong>and</strong> the program directory. Run the ajvinst.exec<br />

installation script to uncompress <strong>and</strong> install the Tarball.<br />

24 <strong>IMS</strong> <strong>Version</strong> 7 <strong>and</strong> <strong>Java</strong> <strong>Application</strong> <strong>Programming</strong>


2.1.2.4 Downloading the JDK<br />

Go to this URL for downloading the JDK onto your workstation:<br />

http://www.ibm.com/s390/java/register.html<br />

Then, after registration, follow the directions to transfer the JDK compressed<br />

file to your workstation. After having stored the JDK compressed file on your<br />

workstation, transfer it to your OS/390 server using FTP. Initiate the FTP<br />

session from the workstation, using the FTP server running in the OS/390<br />

machine.<br />

2.1.2.5 Verifying the installation<br />

Your path should contain the binary directory where java is located. Type:<br />

export PATH=/usr/lpp/java/J1.1/bin:$PATH<br />

Now, verify that <strong>Java</strong> is correctly installed by typing:<br />

java -fullversion<br />

<strong>Java</strong> should reply with the correct version <strong>and</strong> the build date of the JDK.<br />

2.1.3 Visual Age for <strong>Java</strong>, Enterprise Edition for OS/390<br />

VisualAge for <strong>Java</strong>, Enterprise Edition for OS/390 <strong>Version</strong> 2, product number<br />

5655-JAV, when ordered with OS/390 V2R7.0, is provided with an<br />

<strong>IBM</strong>-supplied IFAPRD00 member that contains the required PRODUCT<br />

statements to enable the VAJAVA/390-DEBUG feature. This feature provides<br />

the required Debug/Performance Analyzer functions.<br />

The NFS client on the workstation is not part of the base functions of<br />

Windows NT <strong>and</strong> you will need to install an NFS client such as Hummingbird<br />

NFS Maestro. The NFS Server on OS/390 is part of the base elements of<br />

OS/390 for OS/390 V2R4 <strong>and</strong> later releases. The NFS Server was known as<br />

DFSMS/MVS NFS until OS/390 V2R6, at which time it became exclusive to<br />

OS/390, had function added to it, <strong>and</strong> is now known as NFS.<br />

2.1.3.1 Installation of VisualAge for <strong>Java</strong>, Enterprise Edition OS/390<br />

The installation of the HPCJ Run Time Library <strong>and</strong> the HPCJ Compiler,<br />

Program Number 5655-JAV, is provided through two FMIDs:<br />

FMID H0A5201 — VisualAge for <strong>Java</strong> Compiler, priced<br />

FMID H0A5202 — VisualAge for <strong>Java</strong> Run Time Library, no charge<br />

The installation of these two FMIDs is detailed in the Program Directory for<br />

VisualAge for <strong>Java</strong>, Enterprise Edition for OS/390, Program Number<br />

5655-JAV, Document Number GI10-4949 (product documentation).<br />

Chapter 2. Environment customization 25


2.1.4 The HPJ compiler Installation on OS/390<br />

The installation of the HPJ Run Time <strong>and</strong> the HPJ Compiler are described in<br />

detail in the Program Directory for VisualAge for <strong>Java</strong>, Enterprise Edition for<br />

OS/390, Program Number 5655-JAV, Document Number GI10-4949 (product<br />

documentation). As part of the SMP/E installation for both FMIDs, sample<br />

jobs are provided that assist in the installation of VisualAge for <strong>Java</strong>. These<br />

jobs <strong>and</strong> the changes that must be made to them for the specific installation<br />

configuration,.as well as the steps that must be followed to perform the jobs,<br />

are described in the Program Directory product documentation.<br />

VisualAge for <strong>Java</strong>, Enterprise Edition for OS/390 <strong>Version</strong> 3, product number<br />

5655-JAV, when ordered with OS/390 V2R7.0, is provided with an<br />

<strong>IBM</strong>-supplied IFAPRD00 member that contains the required PRODUCT<br />

statements to enable the VAJAVA/390-DEBUG feature. This feature provides<br />

the required Debug/Performance Analyzer functions.<br />

2.1.5 OS/390 UNIX System Services environment<br />

This section covers the OS/390 UNIX System Services environment.<br />

2.1.5.1 Setup of directories on UNIX System Services<br />

The HFS directories are set up as a result of the HPOISMKD <strong>and</strong> the<br />

HPJISMKD jobs for the VisualAge for <strong>Java</strong>, Enterprise Edition for OS/390<br />

Run Time Library <strong>and</strong> the VisualAge for <strong>Java</strong>, Enterprise Edition for OS/390<br />

HPCJ Compiler respectively.<br />

When the installation of the Run Time Library <strong>and</strong> the HPCJ Compiler is<br />

complete, it is necessary to set the environment variables for <strong>IBM</strong>HPJ_HOME,<br />

CLASSPATH, LIBPATH, <strong>and</strong> STEPLIB to the appropriate values.STEPLIB should<br />

include HPJ.SHPOMOD, HPJ.SHPJMOD, <strong>and</strong> CEE.SCEERUN.<br />

When both the VisualAge for <strong>Java</strong> Run Time Library <strong>and</strong> the VisualAge for<br />

<strong>Java</strong> Compiler have been installed, the contents of the file with default name<br />

/usr/lpp/hpj/bin/profile.hpj as shown in Figure 6 should be appended to<br />

/etc/profile for use by everyone, or copied into $HOME.profile for individual<br />

use <strong>and</strong> updated to reflect the values used in your environment.<br />

26 <strong>IMS</strong> <strong>Version</strong> 7 <strong>and</strong> <strong>Java</strong> <strong>Application</strong> <strong>Programming</strong>


etc/profile for general use or to the<br />

/u//.profile for individual user use.<br />

export <strong>IBM</strong>HPJ_HOME=/usr/lpp/hpj 1<br />

export <strong>IBM</strong>HPJ_RTL="CEE.SCEELKED:CEE.SCEELKEX:CEE.SCEEOBJ:CEE.SCEECPP" 2<br />

export CLASSPATH=$<strong>IBM</strong>HPJ_HOME/lib:$CLASSPATH 3<br />

export PATH=$<strong>IBM</strong>HPJ_HOME/bin:$PATH 4<br />

export LIBPATH=$<strong>IBM</strong>HPJ_HOME/lib:$LIBPATH 5<br />

export STEPLIB=$STEPLIB:HPJ.SHPJMOD:HPJ.SHPOMOD:CEE.SCEERUN 6<br />

Figure 6. Example of HPJ variables in /etc/.profile<br />

The system programmer should append the updated profile.hpj file to<br />

/etc/profile for general use or to the /u/”username”/.profile for individual<br />

use (see Figure 7 <strong>and</strong> Figure 8):<br />

1. Set the home variable for the HPJ root.<br />

2. Required LE support for HPJ compiler; CEE was used as the high level<br />

qualifier.<br />

3. Append the CLASSPATH with the HPJ classes.<br />

4. Append the PATH with the HPJ executables.<br />

5. Append the LIBPATH with the executables.<br />

6. HPJ was used as the high level qualifier.<br />

#================================================<br />

#JDK<br />

#================================================<br />

export JAVA_HOME=/usr/lpp/java18i/J1.1<br />

export PATH=/usr/lpp/java18i/J1.1/bin:$PATH<br />

export CLASSPATH=/usr/lpp/java18i/J1.1/lib/classes.zip:$CLASSPATH<br />

export LD_LIBRARY_PATH=/usr/lpp/java18i/J1.1/lib/classes.zip:$LD_LIBRARY_PATH<br />

Figure 7. JDK.profile file<br />

export <strong>IBM</strong><strong>IMS</strong>J_HOME=/usr/lpp/ims/imsjava71/classes.zip<br />

export CLASSPATH=$CLASSPATH:$<strong>IBM</strong><strong>IMS</strong>J_HOME<br />

echo ‘*------------------------------------------------------------------------*’<br />

echo ‘profile.imsjava executed ------------------------------------------------*’<br />

echo ‘*------------------------------------------------------------------------*’<br />

Figure 8. <strong>IMS</strong>JAVA.profile file<br />

Chapter 2. Environment customization 27


2.1.5.2 TSO/E storage considerations<br />

If you experience memory shortage when you execute the hpj comm<strong>and</strong>, you<br />

might have to log on to TSO with a larger address space (SIZE field on the<br />

TSO/E logon panel). The maximum value for an address space size is set up<br />

by MAXASSIZE parameter in SYS1.PARMLIB(BPXPRM00). We set ours to<br />

MAXASSIZE(2147483647), which is the maximum.<br />

2.2 Workstation environment<br />

This section describes the requirements to set up your workstation<br />

environment.<br />

2.2.1 Prerequisites<br />

A 300 MZ or faster processor with a minimum of 256 MB RAM is<br />

recommended. Also, available free disk space of 1 GB is suggested.<br />

2.2.2 Required software<br />

2.2.3 NFS client<br />

We recommend Microsoft Windows NT Workstation V4.0 with SP4, SP5,<br />

or SP6+.<br />

TCP/IP Networking is required.<br />

JDK 1.1.8<br />

Visual Age for <strong>Java</strong> 3.0.2<br />

An NFS server <strong>and</strong> an FTP server are required on OS/390, <strong>and</strong> an NFS client<br />

<strong>and</strong> FTP client are required on the workstation for workstation-to-OS/390<br />

remote file access <strong>and</strong> file transfer operations.<br />

2.2.3.1 NFS connections<br />

An NFS connection between the NFS Client on your workstation <strong>and</strong> the NFS<br />

Server on OS/390 is required. The connection is used to import <strong>and</strong> export<br />

java source <strong>and</strong> bytecode to <strong>and</strong> from Visual Age for <strong>Java</strong> on the workstation.<br />

The OS/390 NFS Server must be installed on the OS/390 system. Refer to<br />

2.1.1, “NFS <strong>and</strong> FTP server tasks” on page 23 for more information.<br />

On the workstation, we are using Network Access Suite 3.0 for NT as our<br />

NFS Client. The setup box for the authentication server connection is shown<br />

in Figure 9.<br />

28 <strong>IMS</strong> <strong>Version</strong> 7 <strong>and</strong> <strong>Java</strong> <strong>Application</strong> <strong>Programming</strong>


Figure 9. NFS Network Access Suite connection customization<br />

Once the NFS client is installed on the development workstation, the network<br />

connections to the HFS on the OS/390 server have to be established. Figure<br />

10 shows how to make these connections from an MS-DOS prompt.<br />

The net use comm<strong>and</strong> comes as part of the Windows NT workstation<br />

software. It allows you to have an NFS connection to windows resources, but<br />

in order to connect to OS/390 resources, you will need to have an NFS client<br />

such as Network Access Suite 3.0 installed. The net use comm<strong>and</strong> usage is<br />

as follows:<br />

Chapter 2. Environment customization 29


For a binary connection to OS/390:<br />

NET USE devicename: \\domainname\/hfs/targetdirectory,binary password<br />

/USER:username<br />

For a text connection to OS/390:<br />

NET USE devicename: \\domainname\/hfs/targetdirectory,TEXT password<br />

/USER:username<br />

Once the net use comm<strong>and</strong> is submitted, you should receive a message<br />

“The comm<strong>and</strong> completed successfully.” To check the connections on the NT<br />

workstation, simply enter the net use comm<strong>and</strong> as seen in Figure 10.<br />

Figure 10. Establishing NFS connections using net use in MS-DOS<br />

2.2.3.2 FTP links<br />

The FTP client is part of the base functions of Windows NT <strong>and</strong> requires no<br />

special configuration for VisualAge for <strong>Java</strong>, Enterprise Edition for OS/390 to<br />

be able to use it.<br />

30 <strong>IMS</strong> <strong>Version</strong> 7 <strong>and</strong> <strong>Java</strong> <strong>Application</strong> <strong>Programming</strong>


Chapter 3. Building an <strong>IMS</strong> <strong>Java</strong> application<br />

The <strong>IMS</strong> <strong>Java</strong> class libraries allow you to write <strong>IMS</strong> applications in <strong>Java</strong>.<br />

Below is a description of how to write an application using the <strong>IMS</strong> <strong>Java</strong> class<br />

libraries with access to necessary <strong>IMS</strong> services.<br />

3.1 Overview of <strong>IMS</strong> application processing<br />

The <strong>IMS</strong> <strong>Java</strong> classes allow you to write the following types of applications:<br />

Message Processing Programs (MPPs)<br />

<strong>IMS</strong> Fast Path Programs (IFPs)<br />

Batch Message Processing Programs (BMPs)<br />

Ordinarily, in <strong>IMS</strong>, before deciding upon which types of programs to use, you<br />

need to determine the working environment, that is, DB/DC, batch, or DBCTL.<br />

However, <strong>IMS</strong> <strong>Java</strong> currently only supports the DB/DC environment.<br />

In <strong>IMS</strong>, your program type would also depend upon the type of database that<br />

you are connecting to, either:<br />

Full-Function<br />

DB2<br />

Fast Path<br />

Other database types<br />

However, all these database types (<strong>and</strong> others) can be processed by all the<br />

program types that <strong>IMS</strong> <strong>Java</strong> supports, as listed above, in the DB/DC working<br />

environment.<br />

3.1.1 Message processing programs (MPPs)<br />

MPPs are online programs that process <strong>and</strong> reply to messages quickly. MPPs<br />

are executed through transaction codes submitted by users at terminals <strong>and</strong><br />

from other application programs, where each transaction code represents a<br />

transaction that the MPP processes. A single program can also be started<br />

from multiple transaction codes.<br />

These programs are very flexible in how they process transactions <strong>and</strong> where<br />

they send the output. An MPP is started when there is a message in the<br />

queue for the MPP; <strong>and</strong> MPPs are designed to continue to run until there are<br />

no more messages. MPPs are:<br />

Small<br />

Able to produce output that is needed immediately<br />

© Copyright <strong>IBM</strong> Corp. 2001 31


3.1.2 <strong>IMS</strong> Fast Path programs (IFPs)<br />

IFPs are online programs similar to MPPs in that they are used for quick<br />

processing. However, IFPs provide faster response <strong>and</strong> allow higher volumes<br />

of processing because they:<br />

Take advantage of the Expedited Message H<strong>and</strong>ler (EMH)<br />

Process messages that consist of only one segment<br />

Process messages faster because they do not rely on queuing for<br />

processing<br />

Run in transaction response mode, where the terminal must wait for the<br />

IFP to respond before submitting any more requests<br />

Process only wait-for-input transactions where the program remains in<br />

virtual storage, even if there are no other messages available for<br />

processing<br />

Are the only program running in a region<br />

Do not end when there are no more messages, but must be explicitly<br />

stopped by an operator<br />

3.1.3 Batch message processing programs (BMPs)<br />

BMPs are flexible programs that perform batch-type processing online <strong>and</strong><br />

access the <strong>IMS</strong> message queues for their input <strong>and</strong> output. BMPs are started<br />

by submitting a batch job, for example by a user by way of TSO or with a job<br />

scheduler. Two types of BMPs are:<br />

Batch-oriented<br />

Transaction-oriented<br />

<strong>IBM</strong> recommends that you use BMPs to write batch programs instead of DL/I<br />

batch processing because BMPs better lend themselves to data sharing.<br />

3.2 Message processing applications<br />

After determining the appropriate program to use, you must give your<br />

program specific instructions from the terminal in order to use it. You can<br />

access programs from the terminal by providing one of these types of input:<br />

Comm<strong>and</strong>s These start with slash (/), for example: /START.<br />

Transaction message To be routed to an application program for<br />

processing. The program destination is defined by<br />

the 1 to 8-byte transaction code included as the<br />

first part if the input.<br />

32 <strong>IMS</strong> <strong>Version</strong> 7 <strong>and</strong> <strong>Java</strong> <strong>Application</strong> <strong>Programming</strong>


Message switch To be routed to another terminal.The terminal<br />

destination is defined by the 1 to 8-byte terminal<br />

name included as the first part if the input.<br />

Related reading<br />

See the <strong>IMS</strong> Operator’s Reference, SC26-9436-00 for more information<br />

on <strong>IMS</strong> comm<strong>and</strong>s.<br />

3.2.1 Message queuing<br />

Once the input has been issued, the message is either queued or sent<br />

directly to comm<strong>and</strong> process or modules.<br />

Specifically, all Full-Function database input <strong>and</strong> output messages are<br />

queued in message queues, waiting to be enqueued to their destinations —<br />

their points of completion. However, before getting to the points of<br />

completion, <strong>IMS</strong> message queues are held in buffers in main storage until<br />

they are either directed to their destination or until there is a backlog of<br />

messages arriving in the queue. If there are more messages entering the<br />

queue than exiting, <strong>IMS</strong> writes messages to the message queue data sets<br />

until they are directed to their final destination.<br />

However, for all Fast Path transactions, messages are h<strong>and</strong>led within the<br />

Transaction Manager by the Expedited Message H<strong>and</strong>ler (EMH).<br />

Related reading<br />

See the <strong>IMS</strong> <strong>Application</strong> <strong>Programming</strong>: Design Guide, SC26-9423-00 for<br />

more information on <strong>IMS</strong> program types.<br />

See the V7 <strong>IMS</strong> Primer, SG24-5352-00 for general information on <strong>IMS</strong><br />

message queues.<br />

3.2.2 Reading <strong>and</strong> writing messages to the message queue in <strong>Java</strong><br />

A basic <strong>IMS</strong> <strong>Java</strong> application involves input of <strong>and</strong> the receipt of multiple<br />

messages from the message queue much like applications in other<br />

languages. <strong>IMS</strong> <strong>Java</strong> applications are invoked by transactions, where a<br />

person at a terminal can communicate with the application program <strong>and</strong> <strong>IMS</strong>.<br />

The actual applications are built with the application package classes, using<br />

the <strong>IMS</strong> <strong>Java</strong> classes <strong>and</strong> methods.<br />

Chapter 3. Building an <strong>IMS</strong> <strong>Java</strong> application 33


3.3 Building an <strong>IMS</strong> <strong>Java</strong> application by example<br />

In this <strong>and</strong> the next chapter we are introducing a sample auto dealership<br />

program for illustration purposes.<br />

3.3.1 Introduction to the example environment<br />

The sample database contains 5 segment types as shown in Figure 11. The<br />

root segment is the Dealer segment. Its child segment is the Model segment.<br />

Under the Model segment are its children; the segments Order, Stock, <strong>and</strong><br />

Sales.<br />

Figure 11. Database view of all segments<br />

The Dealer segment identifies a dealer selling cars. The segment contains a<br />

unique dealer number, dealer name <strong>and</strong> address, <strong>and</strong> annual sales<br />

information. Dealers carry car types, each of which has a corresponding<br />

Model segment. A Model segment contains a unique type code, descriptive<br />

information about the car <strong>and</strong> its price.<br />

There is an Order segment for each car ordered for the dealership itself. The<br />

segment is sequenced by an order number that contains information about<br />

the options, pricing, order date, <strong>and</strong> the customer who ordered the car. When<br />

a car is delivered to fill a particular order, its serial number <strong>and</strong> delivery date<br />

are added to the segment. The segment is deleted when the customer (or<br />

dealer) accepts the car.<br />

34 <strong>IMS</strong> <strong>Version</strong> 7 <strong>and</strong> <strong>Java</strong> <strong>Application</strong> <strong>Programming</strong><br />

Dealer<br />

Model<br />

Order Sales Stock


A Stock segment is created for each car that is available for sale in the<br />

dealer’s inventory. The segment is sequenced by a serial number that is<br />

unique to a given model. It contains descriptive information about the car <strong>and</strong><br />

the date it was delivered to the dealer. The segment remains in the database<br />

until the car is sold from delivery.<br />

Finally, when the car is sold, a Sales segment is created. This segment is<br />

sequenced by sale date <strong>and</strong> contains information about the car sold <strong>and</strong> the<br />

purchaser.<br />

3.3.2 Building an <strong>IMS</strong> <strong>Java</strong> message processing application<br />

A model of an <strong>IMS</strong> <strong>Java</strong> message processing application consists of these<br />

steps:<br />

Subclassing <strong>IMS</strong><strong>Application</strong> <strong>and</strong> implementing your entire application in<br />

the doBegin method of your subclass. The doBegin method is an abstract<br />

method in the base class, <strong>IMS</strong><strong>Application</strong>. The main method of your<br />

subclass must call the begin method of the base class, <strong>IMS</strong><strong>Application</strong>.<br />

The begin method of the base class then performs initialization <strong>and</strong> calls<br />

the abstract doBegin method that was implemented in your subclass.<br />

Receiving <strong>and</strong> sending <strong>IMS</strong>FieldMessages<br />

Performing a commit before processing the next message or terminating<br />

the application by calling <strong>IMS</strong>Transaction.getTransaction().commit()-.<br />

3.3.2.1 Subclass <strong>IMS</strong>FieldMessage to define any input messages<br />

Subclass <strong>IMS</strong>FieldMessage to define your application’s input messages.<br />

1. Subclass <strong>IMS</strong>FieldMessage to make the fields in a message available to<br />

our <strong>Java</strong> program.<br />

2. Identify the field name, data type, position, <strong>and</strong> length of the individual<br />

fields within the byte array. This allows your application to use the<br />

accessor functions within <strong>IMS</strong>FieldMessage to automatically convert the<br />

data from its format in the message to a <strong>Java</strong> type that your application<br />

can process. In addition to the message-specific fields you define,<br />

<strong>IMS</strong>FieldMessage provides accessor functions that allow you to determine<br />

the transaction code <strong>and</strong> the length of the message.<br />

The example input code in Figure 12 accepts a two-byte car model type code<br />

to query a car dealership database for available car models.<br />

Chapter 3. Building an <strong>IMS</strong> <strong>Java</strong> application 35


package dealership.application;<br />

import com.ibm.ims.db.*;<br />

import com.ibm.ims.base.*;<br />

import com.ibm.ims.application.*;<br />

public class InputMessage extends <strong>IMS</strong>FieldMessage { a<br />

final static DLITypeInfo[]fieldInfo={<br />

new DLITypeInfo("ModelTypeCode", DLITypeInfo.CHAR, 1, 2)b<br />

};<br />

public InputMessage() {<br />

super(fieldInfo, 2, false);<br />

}<br />

}<br />

Figure 12. Example to define Input messages<br />

3.3.2.2 Subclass <strong>IMS</strong>FieldMessage to define any output messages<br />

Subclass <strong>IMS</strong>FieldMessage to define your application’s input messages.<br />

1. Subclass <strong>IMS</strong>FieldMessage.<br />

2. Identify the data type.<br />

3. Identify the field name.<br />

4. Identify the position.<br />

5. Identify the length in the byte array.<br />

The example output code in Figure 13 will output a match for the car model<br />

input type code.<br />

package dealership.application;<br />

import com.ibm.ims.db.*;<br />

import com.ibm.ims.base.*;<br />

import com.ibm.ims.application.*;<br />

public class ModelOutput extends <strong>IMS</strong>FieldMessage { a<br />

final static DLITypeInfo[] fieldInfo={<br />

new DLITypeInfo("Type", DLITypeInfo.CHAR, 1,2), b<br />

new DLITypeInfo("Make", DLITypeInfo.CHAR, 3, 10), c<br />

new DLITypeInfo("Model", DLITypeInfo.CHAR, 13,10), d<br />

new DLITypeInfo("Year", DLITypeInfo.DOUBLE,23,4), e<br />

new DLITypeInfo("CityMiles", DLITypeInfo.CHAR, 27,4),<br />

new DLITypeInfo("HighwayMiles", DLITypeInfo.CHAR, 31,4),<br />

new DLITypeInfo("Horsepower", DLITypeInfo.CHAR, 35,4)<br />

};<br />

public ModelOutput() {<br />

super(fieldInfo, 38,false);<br />

}<br />

Figure 13. Example to define Output messages<br />

36 <strong>IMS</strong> <strong>Version</strong> 7 <strong>and</strong> <strong>Java</strong> <strong>Application</strong> <strong>Programming</strong>


3.3.2.3 Subclass <strong>IMS</strong><strong>Application</strong> <strong>and</strong> implement main <strong>and</strong> doBegin()<br />

The example code in Figure 14 does the following things:<br />

1. Subclasses <strong>IMS</strong><strong>Application</strong>.<br />

2. Instantiates the subclass in the main method.<br />

3. Calls <strong>IMS</strong><strong>Application</strong>.begin.<br />

4. Implements the application within the overridden version of doBegin().<br />

5. Queries the database for a specific model that matches the input model<br />

type code. This method is not implemented yet <strong>and</strong> is explained more fully<br />

in Chapter 5, “Accessing an <strong>IMS</strong> database” on page 49.<br />

6. Returns detailed information as output about that specific model if it is<br />

available at the dealership.<br />

7. Returns an error message if the model is not available at the dealership.<br />

package dealership.application;<br />

import com.ibm.ims.application.*;<br />

public class <strong>IMS</strong>Auto extends <strong>IMS</strong><strong>Application</strong> { a<br />

<strong>IMS</strong>MessageQueue messageQueue = null;<br />

InputMessage inputMessage = null;<br />

ModelOutput modelOutput = null;<br />

public <strong>IMS</strong>Auto() {<br />

super();<br />

}<br />

public static void main(String args[]){<br />

<strong>IMS</strong>Auto imsauto = new <strong>IMS</strong>Auto(); b<br />

imsauto.begin(); c<br />

}<br />

public void doBegin() throws <strong>IMS</strong>Exception { d<br />

messageQueue = new <strong>IMS</strong>MessageQueue();<br />

inputMessage = new InputMessage();<br />

modelOutput = new ModelOutput();<br />

while(messageQueue.getUniqueMessage(inputMessage)) {<br />

if (!inputMessage.getString("ModelTypeCode").trim().equals("")) {<br />

if (getModelDetails(inputMessage, modelOutput)) e<br />

messageQueue.insertMessage(modelOutput); f<br />

}<br />

else {<br />

reply("Invalid Input"); g<br />

}<br />

<strong>IMS</strong>Transaction.getTransaction().commit();<br />

}<br />

}<br />

public void reply(String errmsg) throws <strong>IMS</strong>Exception{<br />

ErrorMessage errorMessage = new ErrorMessage();<br />

errorMessage.setString("MessageText",errmsg);<br />

messageQueue.insertMessage(errorMessage);<br />

}.<br />

Figure 14. Example to Implement Main <strong>and</strong> doBegin()<br />

Chapter 3. Building an <strong>IMS</strong> <strong>Java</strong> application 37


Notice that <strong>IMS</strong>MessageQueue.getUniqueMessage returns the boolean<br />

true if a message was read from the queue <strong>and</strong> false if one was not. Also,<br />

<strong>IMS</strong>Transaction.getTransaction().commit must be called prior to receiving<br />

subsequent messages from the queue.<br />

38 <strong>IMS</strong> <strong>Version</strong> 7 <strong>and</strong> <strong>Java</strong> <strong>Application</strong> <strong>Programming</strong>


Chapter 4. Conversational transactions<br />

A conversational program is an MPP that processes transactions made up of<br />

several steps. It does not process the entire transaction at the same time. A<br />

conversational program divides processing into a connected series of<br />

terminal-to-program-to-terminal interactions. You use conversational<br />

processing when one transaction contains several parts.<br />

A nonconversational program receives a message from a terminal, processes<br />

the request, <strong>and</strong> sends a message back to the terminal. A conversational<br />

program receives a message from a terminal, <strong>and</strong> replies to the terminal, but<br />

saves the data from the transaction in a scratch pad area (SPA). Then, when<br />

the person at the terminal enters more data, the program has the data it<br />

saved from the last message in the SPA, so it can continue processing the<br />

request without the person at the terminal having to enter the data again. The<br />

<strong>Application</strong> Package classes enable applications to be built using <strong>IMS</strong> <strong>Java</strong>.<br />

Related reading:<br />

For more information on conversational <strong>and</strong> nonconversational transaction<br />

processing, see the <strong>IMS</strong> V7 Administration Guide: Transaction Manager,<br />

SC26-9421-00.<br />

4.1 Defining an SPA message<br />

Here are the steps to define a SPA message in a conversational program:<br />

1. Define the SPA message (including the boolean isSPA parameter). By<br />

default, all messages going to (input) <strong>and</strong> from (output) an <strong>IMS</strong> <strong>Java</strong><br />

application are transmitted as EBCDIC character data. To use a different<br />

type of encoding, you must call the <strong>IMS</strong>FieldMessage inherited member<br />

setDefaultEncoding <strong>and</strong> provide the new encoding. The encoding can be<br />

any <strong>Java</strong> supported encoding. In Figure 15, the default encoding is<br />

specified as UTF-8.<br />

© Copyright <strong>IBM</strong> Corp. 2001 39


public class SPAMessage extends <strong>IMS</strong>FieldMessage {<br />

static DLITypeInfo[] fieldInfo = {<br />

new DLITypeInfo(“SessionNumber”,DLITypeInfo.SMALLINT,1, 2),<br />

new DLITypeInfo(“ProcessCode”, DLITypeInfo.CHAR, 3, 8),<br />

new DLITypeInfo(“LastName”, DLITypeInfo.CHAR, 11,10),<br />

new DLITypeInfo(“FirstName”, DLITypeInfo.CHAR, 21,10),<br />

new DLITypeInfo(“Extension”, DLITypeInfo.CHAR, 31,10),<br />

new DLITypeInfo(“ZipCode”, DLITypeInfo.CHAR, 41, 7),<br />

new DLITypeInfo(“Reserved”, DLITypeInfo.CHAR, 48,19)<br />

public SPAMessage() {<br />

super(fieldInfo, 66, true);<br />

setDefaultEncoding (UTF-8”);<br />

}<br />

}<br />

Figure 15. SPA Message code (1)<br />

2. Read the SPA message before reading the application messages<br />

(Figure 16).<br />

try {<br />

// Get the SPA data<br />

msgReceived = msgQ.getUniqueMessage(spaMessage);<br />

}<br />

catch (<strong>IMS</strong>Exception e)<br />

{<br />

if (e.getStatusCode() !=<br />

<strong>Java</strong>ToDLI.MESSAGE_QUEUED_PRIOR_TO_LAST_START)<br />

throw e;<br />

}<br />

if (!msgReceived)<br />

outputMessage.setString(“Message”,”UNABLE TO READ SPA”);<br />

else if (!msgQ.getNextMessage(inputMessage))<br />

// No input message received<br />

outputMessage.setString(“Message”,”NO INPUT MESSAGE”);<br />

else if ((spaMessage.getShort(“SessionNumber”)==0)<br />

&& (!inputMessage.getString(“ProcessCode”).trim().equals(“END”))<br />

&& (inputMessage.getString(“LastName”).trim().equals(“ “)))<br />

// New Conversation. User has to specify last name.<br />

outputMessage.setString(“Message”,”LAST NAME WAS NOT SPECIFIED”);<br />

else<br />

{<br />

Figure 16. SPA Message code (2)<br />

3. Write the SPA message before sending any output messages (Figure 17).<br />

40 <strong>IMS</strong> <strong>Version</strong> 7 <strong>and</strong> <strong>Java</strong> <strong>Application</strong> <strong>Programming</strong>


Set spa data fields<br />

spaMessage.setString("ProcessCode",<br />

inputMessage.getString("ProcessCode"));<br />

spaMessage.setString("LastName",<br />

inputMessage.getString("LastName"));<br />

spaMessage.setString("FirstName",<br />

inputMessage.getString("FirstName"));<br />

spaMessage.setString("Extension",<br />

inputMessage.getString("Extension"));<br />

spaMessage.setString("ZipCode",<br />

inputMessage.getString("ZipCode"));<br />

spaMessage.incrementSessionNumber();<br />

msgQ.insertMessage(spaMessage);<br />

Figure 17. SPA Message code (3)<br />

4. Terminate the conversation using the version of insertMessage containing<br />

a boolean isLast argument set to true:<br />

msgQ.insertMessage(spaMessage, true);<br />

4.2 Conversational transaction sequence of events<br />

When the message is a conversational transaction, the following sequence of<br />

events occurs:<br />

1. <strong>IMS</strong> removes the transaction code <strong>and</strong> places it at the beginning of a<br />

message segment. The message segment is equal in length to the SPA<br />

that was defined for this transaction during system definition. This is the<br />

first segment of the input message that is made available to the program.<br />

The second through the nth segments from the terminal, minus the<br />

transaction code, become the remainder of the message that is presented<br />

to the application program.<br />

2. When the conversational program has prepared its reply, it inserts the SPA<br />

to <strong>IMS</strong>. The program then inserts the actual text of the reply as segments<br />

of an output message.<br />

3. <strong>IMS</strong> saves the SPA <strong>and</strong> routes the message to the input LTERM (logical<br />

terminal).<br />

4. If the SPA insert specified that another program is to continue the same<br />

conversation, the total reply (including the SPA) is retained on the<br />

message queue as input to the next program. This program then receives<br />

the message in a similar form.<br />

Chapter 4. Conversational transactions 41


5. A conversational program must be scheduled for each input exchange.<br />

The other processing continues while the operator at the input terminal<br />

examines the reply <strong>and</strong> prepares new input messages.<br />

6. To terminate a conversation, the program places blanks in the transaction<br />

code field of the SPA, <strong>and</strong> inserts the SPA to <strong>IMS</strong>. In <strong>IMS</strong> <strong>Java</strong> this<br />

happens when you call <strong>IMS</strong>MessageQueue.insertMessage with the<br />

boolean parameter isLast set to true.<br />

7. The conversation can also be terminated if the transaction code in the<br />

SPA is replaced by any non conversational program’s transaction code,<br />

<strong>and</strong> the SPA is inserted to <strong>IMS</strong>. After the next terminal input, <strong>IMS</strong> routes<br />

that message to the other program’s queue in the normal way.<br />

4.2.1 Defining subsequent input messages<br />

In order to utilize multi-segment messages, you must map subsequent input<br />

messages. Figure 18 is an example of a class to map a second input<br />

message. The default encoding is UTF-8.<br />

public class InputMessage2 extends <strong>IMS</strong>FieldMessage {<br />

final static DLITypeInfo[] segmentInfo = {<br />

new DLITypeInfo(“Field1”, DLITypeInfo.CHAR, 1, 10),<br />

new DLITypeInfo(“Field2”, DLITypeInfo.INT, 11, 4)};<br />

public InputMessage2() {<br />

super(““, segmentInfo, 14);<br />

setDefaultEncoding (UTF-8”);<br />

}<br />

}<br />

Figure 18. Subsequent Input Message code<br />

4.3 Using DLIConnection to access a database<br />

While it is possible to use this lower level package to access <strong>IMS</strong> data, we<br />

recommend that you use the JDBC package. This package is included for<br />

experienced <strong>IMS</strong> application developers who need more access than the<br />

higher level package provides. This style of the database package contains<br />

the following objects <strong>and</strong> classes:<br />

4.3.1 DLIConnection<br />

A DLIConnection object represents a connection with a DL/I database. It<br />

provides the interface to read, update, insert, <strong>and</strong> delete segments in a DL/I<br />

database.<br />

42 <strong>IMS</strong> <strong>Version</strong> 7 <strong>and</strong> <strong>Java</strong> <strong>Application</strong> <strong>Programming</strong>


4.3.2 DLISegment<br />

DLISegment is the abstract base class for objects representing segments in a<br />

DL/I database. It allows a subclass to register the types of data stored in a<br />

segment by providing an array of DLITypeInfo objects. Setter <strong>and</strong> getter<br />

functions use the type information to automatically locate <strong>and</strong> convert data in<br />

the byte array to the requested format. These setter <strong>and</strong> getter functions can<br />

locate data based on both its offset in the DLITypeInfo array (fastest) or using<br />

the name of the field included in the type information.<br />

4.3.3 DLITypeInfo<br />

DLITypeInfo, contained in the base package, defines the type, offset, <strong>and</strong><br />

length of a field in the byte array of a DLISegment. It supports all DB2 for<br />

OS/390 data types, including packed decimal.<br />

4.3.4 SSA<br />

SSA represents a Segment Search Argument. It provides functions to add<br />

comm<strong>and</strong> codes <strong>and</strong> qualification statements.<br />

4.3.5 SSAList<br />

SSAList represents a collection of SSA objects <strong>and</strong> converts the list to the<br />

byte array necessary to invoke the <strong>Java</strong>ToDLI functions. The combination of<br />

SSAList, SSA, <strong>and</strong> SSAQualification statement allows an application to<br />

specify a Segment Search Argument list that fully supports all of its features.<br />

4.3.6 SSAQualificationStatement<br />

An SSAQualificationStatement represents logical qualification statements to<br />

a Segment Search Argument. Qualification statements support both key<br />

search fields <strong>and</strong> search fields.<br />

4.3.7 DLIRecord<br />

DLIRecord represents the set of segment occurrences from a root segment<br />

down the hierarchy to the leaf segment. The DLIConnection methods<br />

getUniqueRecord <strong>and</strong> getNextRecord update a DLIRecord object using a<br />

path call (“D” comm<strong>and</strong> code). DLIRecord primarily exists to support JDBC<br />

queries that return results from multiple segments in a segment path.<br />

4.3.8 DLISegmentInfo<br />

DLISegmentInfo is a “wrapper” class that links a DLISegment object to its<br />

parent in the DL/I database hierarchy.<br />

Chapter 4. Conversational transactions 43


4.3.9 DLIDatabaseView<br />

DLIDatabaseView represents an application’s view of the segments in a DL/I<br />

database. It is built as an array of DLISegmentInfo objects which bind a<br />

DLISegment object to its parent DLISegment object <strong>and</strong> therefore defines the<br />

segment hierarchy. DLIDatabaseView provides named lookup of the<br />

DLISegment objects, <strong>and</strong> this feature is used by the DL/I JDBC<br />

implementation to locate a DLISegment object from the name of a segment<br />

used in a query.<br />

4.4 <strong>Application</strong> programming using DLIConnection<br />

To use DLIConnection to read, update, insert, <strong>and</strong> delete segment instances,<br />

your application should:<br />

1. Provide a subclass of DLISegment for each segment accessed in the<br />

database that identifies the types of data stored in the segment<br />

2. Provide a subclass of DLIDatabaseView that defines the segment<br />

hierarchy accessed by the application<br />

3. Create a DLIConnection object to access the database<br />

4. Create an SSAList Object.<br />

5. Invoke the database access functions of DLIConnection to read, write, or<br />

delete segments from the database<br />

4.5 Subclassing DLISegment<br />

The method for subclassing DLISegment is the same as described in 5.1.3.1,<br />

“DLISegment example” on page 52.<br />

4.5.1 Coding messages with repeating structures<br />

Messages with repeating structures can be defined using a subclass of<br />

DLITypeInfo called DLITypeInfoList. DLITypeInfoList allows you to define an<br />

array of repeating structures in one object instead of multiple, individual<br />

DLITypeInfo objects. DLITypeInfoList is an object that stores an array of<br />

DLITypeInfo objects along with a count of its occurrences, thus allowing an<br />

input message to contain nested repeating structures.<br />

The code in Figure 19 is an example of an output message containing a set of<br />

Make, Mode <strong>and</strong> Color fields, along with a count field to identify how many<br />

occurrences were stored.<br />

44 <strong>IMS</strong> <strong>Version</strong> 7 <strong>and</strong> <strong>Java</strong> <strong>Application</strong> <strong>Programming</strong>


public class ModelOutput extends <strong>IMS</strong>FieldMessage {<br />

static DLITypeInfo[] modelTypeInfo = {<br />

new DLITypeInfo(“Make”, DLITypeInfo.CHAR, 1, 20),<br />

new DLITypeInfo(“Model”, DLITypeInfo.CHAR, 21, 20),<br />

new DLITypeInfo(“Color”, DLITypeInfo.CHAR, 41, 20), };<br />

static DLITypeInfo[] modelTypeInfo = {<br />

new DLITypeInfo(“ModelCount”, DLITypeInfo.INTEGER, 1, 4),<br />

new DLITypeInfoList(“Models”, modelTypeInfo 5, 60, 100),};<br />

public ModelOutput() { super(modelOutputTypeInfo, 6004, false);<br />

}}<br />

Figure 19. Sample DLITypeInfo statement<br />

Note<br />

The creation of the DLITypeInfoList object has no provision for specifying<br />

its type. DLITypeInfoList hard codes the type of the fiels to<br />

DLITypeInfo.TYPELIST. This design is not constrained to any specific level<br />

of nesting. Within the declaration of model TypeInfo above, any of the array<br />

members could be instances of DLITypeInfoList<br />

To access the nested structures defined in a DLITypeInfoList, use a dotted<br />

notation for specifying the fields <strong>and</strong> the index of the field within a repeating<br />

structure. This dotted notation can use either the field names or field indexes.<br />

For example, the Color field in the fourth Models definition in ModelOutput<br />

would be accessed as Models.4.Color within the Model Output message. The<br />

code in Figure 20 sets the fourth Color in the ModelOutput message to Red.<br />

ModelOutput output= new ModelOutput();<br />

output.setString(“Models.4.Color”, “Red”);<br />

Figure 20. The use of dotted notation<br />

The code in Figure 21 uses field indexes instead of field names to make the<br />

same change to the ModelOutput message.<br />

ModelOutput output= new ModelOutput();<br />

output.setString(“2.4.3”, “Red”);<br />

Figure 21. The use of field indexes<br />

Chapter 4. Conversational transactions 45


4.5.2 Accessing messages with repeating structures<br />

A dotted notation is used for specifying the fields <strong>and</strong> the index of the field<br />

within a repeating structure. For example, the Color field in the fourth Models<br />

definition in ModelOutput would be accessed as Models.4.Color within the<br />

ModelOutput message. The code in Figure 22 sets the fourth Color in the<br />

ModelOutput message to Red.<br />

ModelOutput output= new ModelOutput();<br />

output.setString(“Models.4.Color”, “Red”);.<br />

Figure 22. Another example of dotted notation<br />

Note<br />

JDBC 1.0 does not support the concept of nested or repeating structures,<br />

so <strong>IMS</strong> <strong>Java</strong> does not support access to nested structure fields from a<br />

JDBC query.<br />

4.6 Subclassing DLIDatabaseView<br />

The method for subclassing DLIDatabaseView is the same as described in<br />

5.1.2.1, “DLIDatabaseView example” on page 51.<br />

4.6.1 Creating a DLIConnection Object<br />

A DLIConnection object must be created in one of two ways. This can be<br />

done by providing a DLIDatabaseView object, or by providing the fully<br />

qualified name of the DLIDatabaseView. When providing the fully qualified<br />

name of the DLIDatabaseView, be sure to use the -include option when you<br />

compile your application. When coding directly to DLIConnection, it is faster<br />

to create <strong>and</strong> pass the DLIDatabaseView object as it saves the overhead of<br />

finding the class by its name. Figure 23 is an example of creating a<br />

DLIConnection object.<br />

DealerDatabaseView dealerView = new DealerDatabaseView();<br />

DLIConnection connection = DLIConnection.createInstance(dealerView);<br />

Figure 23. Sample DLIConnection statement<br />

46 <strong>IMS</strong> <strong>Version</strong> 7 <strong>and</strong> <strong>Java</strong> <strong>Application</strong> <strong>Programming</strong>


4.6.2 Using SSAs to access DL/I information<br />

SSAs are used to identify the segment to which a DL/I call applies. Due to the<br />

hierarchical structure DL/I uses, you often have to specify several levels of<br />

SSAs to access a segment at a low level in the hierarchy. An SSAList is an<br />

ordered list of the SSAs from the Root to the Leaf. The SSAList is what is<br />

used to make any DL/I call.<br />

Figure 24 shows an example of creating a SSAList that will find all “Alfa” cars<br />

made in 1989:<br />

// Create an SSAList<br />

SSAList modelSSAList = SSAList.createInstance();<br />

// Construct an unqualified SSA for the Dealer segment<br />

SSA dealerSSA = SSA.createInstance(“Dealer”);<br />

// Construct a qualified SSA for the Model segment<br />

SSA modelSSA = SSA.createInstance(“Model”, “CarMake”, SSA.EQUALS, “Alfa”); //<br />

// Add an additional qualification statement<br />

modelSSA.addQualification(SSA.AND, "CarYear", SSA.EQUALS, "1989");<br />

// Add the SSAs to the SSAList<br />

modelSSAList.addSSA(dealerSSA);<br />

modelSSAList.addSSA(modelSSA);<br />

Figure 24. Creating an SSALIST<br />

Chapter 4. Conversational transactions 47


48 <strong>IMS</strong> <strong>Version</strong> 7 <strong>and</strong> <strong>Java</strong> <strong>Application</strong> <strong>Programming</strong>


Chapter 5. Accessing an <strong>IMS</strong> database<br />

Before accessing an <strong>IMS</strong> database, you should have a basic underst<strong>and</strong>ing<br />

of hierarchical databases. See the <strong>IMS</strong> V7 <strong>Application</strong> <strong>Programming</strong>: Design<br />

Guide, SC26-9423-00 for more information on hierarchical databases.<br />

In order to access information from an <strong>IMS</strong> database, you must first map the<br />

database information in <strong>Java</strong> <strong>and</strong> then access it through a set of supported<br />

SQL queries. This chapter explains the process of accessing <strong>IMS</strong> database<br />

information.<br />

5.1 Mapping an <strong>IMS</strong> database in <strong>Java</strong> classes<br />

Mapping an <strong>IMS</strong> database in <strong>Java</strong> classes involves using the segments <strong>and</strong><br />

fields in the Database Definition (DBD) to create DLIDatabaseView classes<br />

<strong>and</strong> DLISegment. The examples below use the hierarchical database found in<br />

Figure 25. Note that the DLIDatabaseView also includes the PCB name from<br />

the PSB generation.<br />

Figure 25. Database view of all segments<br />

Dealer<br />

Model<br />

Order Sales Stock<br />

5.1.1 <strong>IMS</strong> DB Database Definition (DBD)<br />

The Database Definition (DBD) is set up by the database administrator. It<br />

defines the segments (SEGM NAME) <strong>and</strong> key fields <strong>and</strong> search fields (FIELD NAME)<br />

of the database. Figure 26 shows the DBD for the above hierarchical<br />

database.<br />

© Copyright <strong>IBM</strong> Corp. 2001 49


DBD NAME=DEALERDB,ACCESS=(HDAM,OSAM),RMNAME=(DFSHDC40.1.10)<br />

SEGM NAME=DEALER,PARENT=0,BYTES=94,<br />

FIELD NAME=(DLRNO,SEQ,U),BYTES=4,START=1,TYPE=C<br />

FIELD NAME=DLRNAME,BYTES=30,START=5,TYPE=C<br />

SEGM NAME=MODEL,PARENT=DEALER,BYTES=43<br />

FIELD NAME=(MODTYPE,SEQ,U),BYTES=2,START=1,TYPE=C<br />

FIELD NAME=MAKE,BYTES=10,START=3,TYPE=C<br />

FIELD NAME=MODEL,BYTES=10,START=13,TYPE=C<br />

FIELD NAME=YEAR,BYTES=4,START=23,TYPE=C<br />

FIELD NAME=MSRP,BYTES=5,START=27,TYPE=P<br />

SEGM NAME=ORDER,PARENT=MODEL,BYTES=127<br />

FIELD NAME=(ORDNBR,SEQ,U),BYTES=6,START=1,TYPE=C<br />

FIELD NAME=LASTNME,BYTES=25,START=50,TYPE=C<br />

FIELD NAME=FIRSTNME,BYTES=25,START=75,TYPE=C<br />

SEGM NAME=SALES,PARENT=MODEL,BYTES=113<br />

FIELD NAME=(SALDATE,SEQ,U),BYTES=8,START=1,TYPE=C<br />

FIELD NAME=LASTNME,BYTES=25,START=9,TYPE=C<br />

FIELD NAME=FIRSTNME,BYTES=25,START=34,TYPE=C<br />

FIELD NAME=STKVIN,BYTES=20,START=94,TYPE=C<br />

SEGM NAME=STOCK,PARENT=MODEL,BYTES=62<br />

FIELD NAME=(STKVIN,SEQ,U),BYTES=20,START=1,TYPE=C<br />

FIELD NAME=COLOR,BYTES=10,START=37,TYPE=C<br />

FIELD NAME=PRICE,BYTES=5,START=47,TYPE=C<br />

FIELD NAME=LOT,BYTES=10,START=53,TYPE=C<br />

DBDGEN<br />

FINISH<br />

END<br />

Figure 26. <strong>IMS</strong> Database Definition (DBD)<br />

5.1.2 Mapping the DBD to DLIDatabaseView<br />

The DLIDatabaseView class is how we define the information needed to<br />

connect to the database. In <strong>IMS</strong> <strong>Java</strong>, the DLIDatabaseView class contains<br />

metadata, or information about your application’s view of the database<br />

(segments <strong>and</strong> fields) as well as the name of the database as it is known to<br />

<strong>IMS</strong>. The database name is sufficient to make a connection, but this<br />

metadata is also needed for processing queries.<br />

DLIDatabaseView contains the PCBNAME= field from the PCB definition.<br />

Following is the database name (DEALERDB) <strong>and</strong> the segment names (DEALER,<br />

MODEL, ORDER, SALES, STOCK) extracted from the DBD in Figure 26.<br />

50 <strong>IMS</strong> <strong>Version</strong> 7 <strong>and</strong> <strong>Java</strong> <strong>Application</strong> <strong>Programming</strong>


DBD NAME=DEALERDB,ACCESS=(HDAM,OSAM),RMNAME=(DFSHDC40.1.10)<br />

SEGM NAME=DEALER,PARENT=0,BYTES=94,<br />

SEGM NAME=MODEL,PARENT=DEALER,BYTES=43<br />

SEGM NAME=ORDER,PARENT=MODEL,BYTES=127<br />

SEGM NAME=SALES,PARENT=MODEL,BYTES=113<br />

SEGM NAME=STOCK,PARENT=MODEL,BYTES=62<br />

Figure 27. Sample DBD<br />

5.1.2.1 DLIDatabaseView example<br />

Using the extracted database name <strong>and</strong> segment names from above, we<br />

create a DLIDatabaseView subclass called DealerDatabaseView found in<br />

Figure 28. Notice the following:<br />

1. Within the subclass we create an array of DLISegmentInfo objects, one<br />

entry for each DLISegment object (see 5.1.3, “Mapping the DBD to<br />

DLISegment” on page 52) used by the application. As you will see in the<br />

following section about DLISegment, a DLISegment object defines the<br />

fields in a database segment, similar to the way an <strong>IMS</strong>FieldMessage<br />

object defines the fields in a message segment.<br />

2. Each DLISegmentInfo object is a wrapper that associates a DLISegment<br />

object to its parent. The parent is specified as a zero-based index in the<br />

array.Notice that the entry for the Order segment specifies an index of 1,<br />

which is the index in the array for the Model segment.<br />

3. The parent of the root segment, Dealer is specified by the constant<br />

DLIDatabaseView.ROOT to indicate that it has no parent.<br />

4. The database name, DEALERDB, is passed in the DealerDatabaseView<br />

constructor to the super class constructor along with the array of<br />

DLISegmentInfo objects. Note that DEALERDB was obtained from the<br />

PCBNAME= field from the PCB definition.<br />

public class DealerDatabaseView extends DLIDatabaseView {<br />

static DLISegmentInfo[] segments = { a<br />

new DLISegmentInfo(new Dealer(), DLIDatabaseView.ROOT), c<br />

new DLISegmentInfo(new Model(), 0),<br />

new DLISegmentInfo(new Order(), 1), b<br />

new DLISegmentInfo(new Sales(), 1),<br />

new DLISegmentInfo(new Stock(), 1),<br />

};<br />

public DealerDatabaseView(){<br />

super(“DEALERDB”, segments); d<br />

}<br />

}<br />

Figure 28. Sample DLIDatabaseView<br />

Chapter 5. Accessing an <strong>IMS</strong> database 51


5.1.3 Mapping the DBD to DLISegment<br />

DLISegment is the abstract base class for objects representing segments in a<br />

DL/I database. It allows a subclass to register the types of data stored in a<br />

segment by providing an array of DLITypeInfo objects.<br />

DLISegment must contain the segment name <strong>and</strong> the field names from the<br />

DBD. Figure 29 shows the segment name <strong>and</strong> the field names extracted from<br />

the DBD above for the DEALER segment.<br />

SEGM NAME=DEALER,PARENT=0,BYTES=94,<br />

FIELD NAME=(DLRNO,SEQ,U),BYTES=4,START=1,TYPE=C<br />

FIELD NAME=DLRNAME,BYTES=30,START=5,TYPE=C<br />

Figure 29. Dealer DBD extract<br />

5.1.3.1 DLISegment example<br />

Using the extracted database name <strong>and</strong> segment names from above, we<br />

create a DLISegment subclass called Dealer (Figure 30).<br />

public class Dealer extends DLISegment {<br />

static DLITypeInfo[] typeInfo = { a<br />

new DLITypeInfo(“DealerNumber”, DLITypeInfo.CHAR,1, 4,”DLRNO”),<br />

new DLITypeInfo(“DealerName”, DLITypeInfo.CHAR,5, 30,”DLRNAME”),<br />

new DLITypeInfo(“DealerAddress”,DLITypeInfo.CHAR,35, 50), b<br />

new DLITypeInfo(“YTDSales”, DLITypeInfo.PACKEDDECIMAL,85, 10),<br />

};<br />

public Dealer() {<br />

super(“DEALER”, typeInfo, 94); c<br />

}<br />

Figure 30. Sample DLISegment<br />

In Figure 30, notice the following:<br />

1. Within the subclass we create an array of DLITypeInfo objects, one entry<br />

for each field used by the application.<br />

2. Each DLITypeInfo object defines the name, type, starting offset, length,<br />

<strong>and</strong> optionally the name of the field in the DBD. To search on a field in a<br />

DLITypeInfo object, add the name of the field as specified in the DBD. You<br />

can have more fields than those named in the DBD. For example the field<br />

DealerAddress is a character field that starts at offset 35 for a length of 50<br />

bytes <strong>and</strong> is not defined in the DBD. In order to be able to search on a<br />

field, the field name must both be defined in the DBD file <strong>and</strong> the field<br />

name as listed in the DBD must be provided to the DLITypeInfo object.<br />

52 <strong>IMS</strong> <strong>Version</strong> 7 <strong>and</strong> <strong>Java</strong> <strong>Application</strong> <strong>Programming</strong>


3. The segment name, DEALER is passed in the Dealer constructor to the<br />

super class constructor along with the array of DLITypeInfo objects <strong>and</strong><br />

the length of the entire array. The easiest way to calculate that length is to<br />

add the starting offset of the last field in the array with its length <strong>and</strong><br />

subtract 1. In Figure 30, the length is calculated as: 85 + 10 -1 = 94.<br />

5.2 Using JDBC to access an <strong>IMS</strong> database<br />

The design of the database package is intended to support two styles of<br />

database programming. The first style utilizes JDBC <strong>and</strong> provides<br />

higher-level access designed for <strong>Java</strong> programmers who may not be familiar<br />

with <strong>IMS</strong>. The second style is more closely associated with current <strong>IMS</strong><br />

application programming <strong>and</strong> provides lower-level access to most <strong>IMS</strong><br />

functions. Both of these mechanisms are built upon classes that the<br />

application developer provides for defining the segments <strong>and</strong> segment<br />

hierarchies available to the application. It is recommended to use the<br />

higher-level style.<br />

The lower-level access builds segment search arguments (SSAs) <strong>and</strong> calls<br />

the functions of the DLIConnection object to read, insert, update, or delete<br />

segments. Using this style, the application has full control to navigate the<br />

segment hierarchy. For more details, see 4.3, “Using DLIConnection to<br />

access a database” on page 42.<br />

The higher-level approach utilizes a limited subset of the SQL92 query<br />

language <strong>and</strong> JDBC 1.0, the st<strong>and</strong>ard <strong>Java</strong> APIs for accessing relational<br />

databases currently supported on OS/390.<br />

The JDBC layer is implemented using the SSA layer. That is, it parses the<br />

SQL queries <strong>and</strong> builds SSALists to execute DL/I calls using DLIConnection.<br />

5.2.1 Classes <strong>and</strong> field names<br />

A database segment definition defines the fields for a set of segment<br />

instances similar to the way a relational table defines columns for a set of<br />

rows in a table. In this regard, segments relate to tables, <strong>and</strong> fields in a<br />

segment relate to columns in a table.<br />

As segments are defined in <strong>IMS</strong> <strong>Java</strong> by subclassing DLISegment, it is the<br />

name of this DLISegment subclass that becomes the table name in an SQL<br />

query. Similarly, as fields are defined in <strong>IMS</strong> <strong>Java</strong> using DLITypeInfo objects,<br />

it is the name of the field passed on the DLITypeInfo constructor that is used<br />

as the column name in an SQL query.<br />

Chapter 5. Accessing an <strong>IMS</strong> database 53


Therefore, you can take advantage of having to name the DLISegment<br />

subclass <strong>and</strong> DLITypeInfo object, yourself, by providing names that are<br />

representative of the data, not necessarily the name of the segment <strong>and</strong><br />

fields as they exist in the database definition. In other words, by assigning<br />

your data segment <strong>and</strong> field names aliases, you can make data retrieval more<br />

intuitive. For example, in the query below, Model is a DLISegment subclass<br />

that is used as a table name in the query:<br />

SELECT * FROM Model<br />

Note that DLISegment can contain fields not in the DBD. Searches cannot be<br />

done unless the field is defined in the DBD.<br />

In the following example, ModelTypeCode is the name of a DLITypeInfo<br />

object contained in the Model segment <strong>and</strong> is used in the SQL query as a<br />

column name:<br />

SELECT * FROM Model WHERE ModelTypeCode = ’K1’<br />

In both of the preceding examples, Model <strong>and</strong> ModelTypeCode are defined<br />

by the <strong>IMS</strong> <strong>Java</strong> programmer. They might not necessarily be the same names<br />

used in the database definition in <strong>IMS</strong>; they just reference them.<br />

5.2.2 Writing a JDBC application<br />

To use JDBC to read, update, insert, <strong>and</strong> delete segment instances, an<br />

application must:<br />

1. Provide a subclass of DLISegment for each segment accessed in the<br />

database that identifies the types of data stored in the segment. For an<br />

example, see 5.1.3.1, “DLISegment example” on page 52.<br />

2. Provide a subclass of DLIDatabaseView to identify the segments used by<br />

an application in a database. For an example, see 5.1.2.1,<br />

“DLIDatabaseView example” on page 51.<br />

3. Load the DLIDriver, <strong>and</strong> retrieve a Connection object from the<br />

DriverManager. This step is in boldface in the sample code in Figure 31.<br />

4. Retrieve a Statement or PreparedStatement object from the Connection<br />

<strong>and</strong> execute it. For an example, see 5.4.1, “SELECT” on page 62.<br />

5. Iterate the ResultSet returned from the Statement or PreparedStatement<br />

object to retrieve specific field results. For an example, see 5.4.1,<br />

“SELECT” on page 62.<br />

54 <strong>IMS</strong> <strong>Version</strong> 7 <strong>and</strong> <strong>Java</strong> <strong>Application</strong> <strong>Programming</strong>


The code sample in Figure 31 builds somewhat on the sample program<br />

started in 3.3.2.3, “Subclass <strong>IMS</strong><strong>Application</strong> <strong>and</strong> implement main <strong>and</strong><br />

doBegin()” on page 37 by showing Step 3. from the list above. For examples<br />

of each individual step, see the sample code indicated above.<br />

Chapter 5. Accessing an <strong>IMS</strong> database 55


package dealership.application;<br />

import com.ibm.ims.base.*;<br />

import com.ibm.ims.application.*;<br />

import com.ibm.ims.db.*;<br />

import java.sql.*;<br />

public class <strong>IMS</strong>Auto extends <strong>IMS</strong><strong>Application</strong><br />

{<br />

<strong>IMS</strong>MessageQueue messageQueue = null;<br />

InputMessage inputMessage = null;<br />

ModelOutput modelOutput = null;<br />

Connection connection = null;<br />

public <strong>IMS</strong>Auto()<br />

{<br />

super();<br />

}<br />

public static void main(String args[])<br />

{<br />

<strong>IMS</strong>Auto imsauto = new <strong>IMS</strong>Auto();<br />

imsauto.begin();<br />

}<br />

public void doBegin() throws <strong>IMS</strong>Exception<br />

{<br />

messageQueue = new <strong>IMS</strong>MessageQueue();<br />

inputMessage = new InputMessage();<br />

modelOutput = new ModelOutput();<br />

try<br />

{<br />

Class.forName(“com.ibm.ims.db.DLIDriver”);<br />

connection = DriverManager.getConnection<br />

(“jdbc:dli:dealership.application.DealerDatabaseView”);<br />

}<br />

catch (Exception e)<br />

{<br />

reply(“Connection not established”);<br />

}<br />

while(messageQueue.getUniqueMessage(inputMessage))<br />

{<br />

if (!inputMessage.getString(“ModelTypeCode”).trim().equals(““))<br />

{<br />

if (getModelDetails(inputMessage, modelOutput))<br />

messageQueue.insertMessage(modelOutput);<br />

}<br />

else<br />

{<br />

reply(“Invalid Input”);<br />

}<br />

<strong>IMS</strong>Transaction.getTransaction().commit();<br />

}<br />

}<br />

public void reply(String errmsg) throws <strong>IMS</strong>Exception{<br />

ErrorMessage errorMessage = new ErrorMessage();<br />

errorMessage.setString(“MessageText”,errmsg);<br />

messageQueue.insertMessage(errorMessage); }}<br />

Figure 31. JDBC <strong>Application</strong> code<br />

56 <strong>IMS</strong> <strong>Version</strong> 7 <strong>and</strong> <strong>Java</strong> <strong>Application</strong> <strong>Programming</strong>


You need imports so that the methods can be recognized by your application.<br />

In order to access a DL/I database, use this import statement:<br />

import com.ibm.ims.db.*;<br />

In order to access JDBC, use this import statement:<br />

import java.sql.*;<br />

When using JDBC to access DL/I, an application programmer provides the<br />

fully qualified name of the DLIDatabaseView subclass when getting a JDBC<br />

Connection object.<br />

When the line with Class.forName in Figure 31 above example in bold text is<br />

executed, DLIDriver, a class in com.ibm.ims.db registers itself with the JDBC<br />

DriverManager. When the line with DiverManager.getConnection above in bold<br />

text is executed, the JDBC DriverManager determines which of the<br />

registered drivers supports the supplied string. In this case, because it begins<br />

with jdbc.dli, it locates our DLIDriver instance <strong>and</strong> requests that it create a<br />

connection.<br />

The following describes the JDBC 1.0 required interfaces that are<br />

implemented in the database package. It also details limitations in the DL/I<br />

implementation of these interfaces.<br />

5.2.2.1 java.sql.Connection<br />

An object that represents the connection to the database. A Connection<br />

reference is retrieved from the DriverManager object implemented in the<br />

java.sql package. The DriverManager obtains a Connection reference by<br />

querying its list of registered Driver instances until it finds one that supports<br />

the universal resource locator (URL) passed to<br />

DriverManager.getConnection.<br />

<strong>IMS</strong> does not support the local, connection-based commit scope defined in<br />

the JDBC model. Therefore, the DL/I implementation of Connection.commit,<br />

Connection.rollback, <strong>and</strong> Connection.setAutoCommit result in an<br />

SQLException when called from a client program.<br />

Figure 32 is the code needed to make a connection to the database.<br />

connection = DriverManager.getConnection<br />

(“jdbc:dli:dealership.application.DealerDatabaseView”);<br />

Figure 32. JDBC Connection code<br />

Chapter 5. Accessing an <strong>IMS</strong> database 57


5.2.2.2 java.sql.DatabaseMetaData<br />

DatabaseMetaData defines a set of methods to query information about the<br />

database, including capabilities the database might or might not support. The<br />

class is provided for tool developers <strong>and</strong> is normally not used in client<br />

programs. Much of the functionality is specific to relational databases <strong>and</strong> is<br />

not implemented for DL/I databases.<br />

5.2.2.3 java.sql.Driver<br />

The Driver interface itself is not normally used in client programs, although<br />

today an application needs to dynamically load a particular Driver<br />

implementation by name. One of the first lines in a <strong>IMS</strong> JDBC program for<br />

DL/I access must be:<br />

Class.forName("com.ibm.ims.db.DLIDriver");<br />

This code loads the Driver <strong>and</strong> causes the Driver implementation to register<br />

itself with the DriverManager so that it can later be found by<br />

DriverManager.getConnection. It is the Driver implementation that creates<br />

<strong>and</strong> returns a Connection object to the DriverManager. The DL/I<br />

implementation of JDBC is not fully JDBC compliant <strong>and</strong> the Driver member<br />

jdbcCompliant returns false.<br />

5.2.2.4 java.sql.Statement<br />

A Statement interface is returned from Connection.createStatement. The<br />

Statement <strong>and</strong> its subclasses PreparedStatement <strong>and</strong> CallableStatement,<br />

define the interfaces that accept SQL statements <strong>and</strong> return tables as<br />

ResultSet objects. The code needed to create a statement is as follows:<br />

Statement statement = connection.createStatement();<br />

The DL/I implementation of Statement does not support:<br />

Named cursors, therefore the method Statement.setCursorName throws<br />

an SQLException.<br />

Aborting a DL/I operation, therefore Statement.cancel throws an<br />

SQLException.<br />

Setting a time-out for DL/I operations, therefore<br />

Statement.setQueryTimeout <strong>and</strong> Statement.getQueryTimeout throw an<br />

SQLException.<br />

5.2.2.5 java.sql.ResultSet<br />

The ResultSet interface defines an iteration mechanism for retrieving the data<br />

in rows of a table, <strong>and</strong> for converting the data from the type defined in the<br />

database to the type required in the application. For example,<br />

58 <strong>IMS</strong> <strong>Version</strong> 7 <strong>and</strong> <strong>Java</strong> <strong>Application</strong> <strong>Programming</strong>


ResultSet.getString will convert an integer or decimal data type to an<br />

instance of a <strong>Java</strong> String. The code needed to invoke ResultSet is as follows:<br />

ResultSet results = statement.executeQuery(queryString);<br />

Rather than building a complete set of results upon execution of a query, the<br />

DL/I implementation of ResultSet retrieves a new segment occurrence each<br />

time ResultSet.next is called. Further, the DL/I implementation of ResultSet<br />

does not support:<br />

Returning data as an ASCII stream, therefore ResultSet.getAsciiStream<br />

throws an SQLException.<br />

Named cursors, therefore ResultSet.getCursorName throws an<br />

SQLException.<br />

The method ResultSet.getUnicodeStream which is deprecated in JDBC 2.0.<br />

5.2.2.6 java.sql.ResultSetMetaData<br />

The interface defines methods to provide information about the types <strong>and</strong><br />

properties in a ResultSet object. It includes methods such as getColumnCount,<br />

isSigned, getPrecision, <strong>and</strong> getColumnName.<br />

5.2.2.7 java.sql.PreparedStatement<br />

The PreparedStatement interface extends the Statement interface, adding<br />

support for pre-compiling an SQL statement (the SQL statement is provided<br />

at construction instead of execution) <strong>and</strong> for substituting values in the SQL<br />

statement (“UPDATE Suppliers SET Status = ? WHERE City = ?”).<br />

5.2.2.8 java.sql.CallableStatement<br />

The CallableStatement interface extends the Statement interface <strong>and</strong><br />

supports calling stored procedures in a database. DL/I does not currently<br />

support stored procedures, therefore the DLIDatabaseMetaData method<br />

supportsStoredProcedures returns false <strong>and</strong> the Connection method<br />

prepareCall throws an SQLException. Therefore there currently is no way for a<br />

DL/I JDBC application to create a CallableStatement object. All exceptions<br />

thrown from the JDBC APIs are of type SQLException, or a class derived<br />

from SQLException. An SQLException thrown by the DLI JDBC driver contains:<br />

An NLS-enabled text string describing the error.<br />

An “SQLState” string identifying the exception that conforms to the<br />

X/Open SQLState conventions.<br />

An error code containing the failing DLI status code if one is available. If a<br />

status code is not available or the error is unrelated to a DLI call, the error<br />

code is zero.<br />

Chapter 5. Accessing an <strong>IMS</strong> database 59


5.3 Supported data types in <strong>IMS</strong> <strong>Java</strong><br />

<strong>IMS</strong> <strong>Java</strong> supports the JDBC types specified in Table 1.<br />

Table 1. Supported data types<br />

JDBC type <strong>Java</strong> type<br />

CHAR string<br />

VARCHAR string<br />

BIT byte<br />

TINYINT byte<br />

SMALLINT short<br />

INTEGER int<br />

BIGINT long<br />

FLOAT float<br />

DOUBLE double<br />

BINARY byte[]<br />

PACKEDDECIMAL java.math.BigDecimal<br />

ZONEDECIMAL java.math.BigDecimal<br />

DATE java.sql.Date<br />

TIME java.sql.Time<br />

TIMESTAMP java.sql.Timestamp<br />

60 <strong>IMS</strong> <strong>Version</strong> 7 <strong>and</strong> <strong>Java</strong> <strong>Application</strong> <strong>Programming</strong>


Table 2 shows the available get methods for accessing data of a certain JDBC<br />

type.<br />

Table 2. Available get methods for data types<br />

JDBC Type<br />

TINYINT<br />

SMALLINT<br />

INTEGER<br />

BIGINT<br />

getByte X O O O O O O O O O O<br />

getShort O X O O O O O O O O O<br />

getInt O O X O O O O O O O O<br />

getLong O O O X O O O O O O O<br />

getFloat O O O O X O O O O O O<br />

getDouble O O O O O X O O O O O<br />

getBoolean O O O O O O X O O O O<br />

FLOAT<br />

DOUBLE<br />

getString O O O O O O O X X O O O O O O<br />

getBigDecimal O O O O O O O O O X X<br />

getBytes X<br />

getDate O O X O<br />

getTime O O X O<br />

getTimestamp O O O O X<br />

Those marked with “X” indicate methods designed for accessing the given<br />

data type. No truncation or data loss will occur using those methods. Those<br />

marked with “O” indicate all other legal calls; however, data integrity cannot<br />

be ensured using those methods. If the box is empty (it neither contains an<br />

“X” or an “O”), using that method for a data type will result in an exception.<br />

BIT<br />

CHAR<br />

VARCHAR<br />

PACKEDDECIMAL<br />

ZONEDECIMAL<br />

BINARY<br />

DATE<br />

TIME<br />

TIMESTAMP<br />

Chapter 5. Accessing an <strong>IMS</strong> database 61


Note<br />

At this time PackedDecimal <strong>and</strong> ZoneDecimal data types DO NOT support<br />

the Sign Leading or Sign Seperate modes. Sign information is always<br />

stored with the Sign Trailing method.<br />

5.4 Supported SQL grammar<br />

<strong>IMS</strong> <strong>Java</strong> does not support aggregate keywords. The SQL keywords in Table<br />

3 are the only keywords currently supported in <strong>IMS</strong> <strong>Java</strong>:<br />

Table 3. Supported SQL keywords<br />

ALL AND DELETE DISTINCT<br />

FROM INSERT INTO OR<br />

SELECT SET UPDATE VALUE<br />

VALUES WHERE<br />

5.4.1 SELECT<br />

A SELECT statement is a query used as a top-level SQL statement. Figure 33<br />

shows an example that uses the results of a SELECT query to update<br />

modelOutput with the model information. It requires an inputMessage with the<br />

ModelTypeCode.<br />

62 <strong>IMS</strong> <strong>Version</strong> 7 <strong>and</strong> <strong>Java</strong> <strong>Application</strong> <strong>Programming</strong>


5.4.2 FROM<br />

public boolean getModelDetails(InputMessage inputMessage,<br />

ModelOutput modelOutput) throws <strong>IMS</strong>Exception {<br />

}<br />

}<br />

// Parse the input message for ModelTypeCode<br />

String queryString = “SELECT * from Model where ModelTypeCode = “<br />

+ “‘” + inputMessage.getString(“ModelTypeCode”).trim() + “‘”;<br />

// Create a statment <strong>and</strong> execute it to get a ResultSet<br />

try {<br />

Statement statement = connection.createStatement();<br />

ResultSet results = statement.executeQuery(queryString);<br />

// Send back the result of the query<br />

// Note: since "ModelTypeCode" is unique - only 1 row<br />

// is returned<br />

if (results.next()) {<br />

modelOutput.setString(“ModelTypeCode”,<br />

results.getString(“Type”).trim());<br />

modelOutput.setString("Make",<br />

results.getString(“Make”).trim());<br />

modelOutput.setString(“Model”,<br />

results.getString(“Model”));<br />

modelOutput.setString(“Year”,<br />

results.getString(“Year”));<br />

modelOutput.setString(“CityMiles”,<br />

results.getString(“EPACityMileage”));<br />

modelOutput.setString(“HighwayMiles”,<br />

results.getString(“EPAHighwayMileage”));<br />

modelOutput.setString(“Price”,<br />

results.getString(“Price”));<br />

modelOutput.setString(“Horsepower”,<br />

results.getString(“Horsepower”));<br />

return true;<br />

}<br />

else {<br />

reply(“Unknown Type”);<br />

return false;<br />

}<br />

}<br />

catch (SQLException e) {<br />

reply(“Query Failed:”+ e.toString());<br />

return false;<br />

}<br />

Figure 33. Example of a SELECT statement<br />

In st<strong>and</strong>ard SQL, the FROM clause can contain a list of table names separated<br />

by commas. This will result in a “join” of the tables in the list based on the<br />

equality of specified column values of the joined tables. An <strong>IMS</strong> DL/I<br />

database is hierarchical, so a join is implied, <strong>and</strong> only the segment furthest<br />

down the hierarchy needs to be specified in the FROM clause, even though<br />

Chapter 5. Accessing an <strong>IMS</strong> database 63


fields in all segments in the path can be named in the WHERE or SELECT clause.<br />

In Figure 34, the two queries are equivalent.<br />

SELECT CarModel<br />

FROM Model<br />

WHERE CarYear=’2000’<br />

SELECT Model.CarModel<br />

FROM Model<br />

WHERE Model.CarYear=’2000’.<br />

Figure 34. Example of a FROM statement<br />

In <strong>IMS</strong> <strong>Java</strong>, you only specify the segment furthest down the hierarchy in the<br />

FROM clause. You can query different segments by preceding the field name<br />

with the segment name, as in Figure 35.<br />

SELECT Dealer.DealerName,CarModel<br />

FROM Model<br />

WHERE CarMake=’Ford’<br />

Figure 35. FROM statement in Dealer code<br />

5.4.3 UPDATE<br />

An UPDATE statement modifies the value of at least one segment occurrence.<br />

An UPDATE statement applies its SET clause to each row in the specified table<br />

with a WHERE clause set for TRUE. If the UPDATE statement does not have a WHERE<br />

clause, the SET clause is applied to all rows in the specified table.<br />

A SET clause contains at least one assignment. In each assignment, the<br />

values to the right of the equal sign are computed <strong>and</strong> assigned to columns to<br />

the left of the equal sign. For example, the UPDATE statement in Figure 36 is<br />

called to accept an order. When a customer accepts an order, the car’s<br />

SerialNo <strong>and</strong> delivery dates are filled in.<br />

String updateString = “UPDATE Order “<br />

+ “SET SerialNo = ‘”<br />

+ inputMessage.getString(“StockVINumber”).trim()<br />

+ “‘, “<br />

+ “DeliverDate = ‘”<br />

+ inputMessage.getString(“Date”).trim()<br />

+ “© WHERE OrderNumber = ‘”<br />

+ inputMessage.getString(“OrderNumber”).trim()<br />

+ “‘”;<br />

Figure 36. Example of an UPDATE statement<br />

64 <strong>IMS</strong> <strong>Version</strong> 7 <strong>and</strong> <strong>Java</strong> <strong>Application</strong> <strong>Programming</strong>


It is possible for an update to violate some constraint, such as a check<br />

constraint or a foreign key constraint. If this or any other error occurs during<br />

the execution of an UPDATE statement, the statement is rolled back <strong>and</strong> no<br />

update is performed.<br />

5.4.4 DELETE<br />

The DELETE statement in <strong>IMS</strong> <strong>Java</strong> deletes at least one segment occurrence.<br />

The DELETE statement removes the segment occurrences specified in the<br />

WHERE clause. If no WHERE clause is specified, all of the segment occurrences<br />

are deleted. It is possible that deleting some of the occurrences that are<br />

specified in the DELETE statement may violate some constraint. In that case,<br />

the statement is rolled back <strong>and</strong> no occurrences are deleted. Figure 37 shows<br />

an example of a DELETE statement.<br />

String updateString = “DELETE from Order where “<br />

+ “Dealer.DealerNumber = ’”<br />

+ dealerDesired+ “‘ AND “<br />

+ “OrderNumber = ‘” + orderDesired + “‘”;<br />

try {<br />

Statement statement = connection.createStatement();<br />

int results = statement.executeUpdate(updateString);<br />

...<br />

}<br />

catch (SQLException e) {<br />

...<br />

}<br />

Figure 37. Example of a DELETE statement<br />

5.4.5 INSERT<br />

The INSERT statement inserts at least one row into a table. All column names<br />

must be in the statement; there are no default values in this release. Figure<br />

39 is an example of an INSERT statement which inserts a field in the<br />

database:<br />

5.4.6 How <strong>IMS</strong> <strong>Java</strong> has extended SQL<br />

St<strong>and</strong>ard SQL does not have a WHERE clause in an INSERT statement, as<br />

tuples are just being inserted into the table specified after the INTO keyword.<br />

In an <strong>IMS</strong> DL/I database, we are actually inserting a new instance of the<br />

specified segment, so we need to know where in the database this segment<br />

occurrence needs to be placed. In the case of an INSERT statement, the<br />

WHERE clause is necessary in all cases except when inserting a root<br />

segment. In the case of a prepared statement, the list of values can have a ?<br />

Chapter 5. Accessing an <strong>IMS</strong> database 65


5.4.7 Statement<br />

as the value, that can be substituted before the statement is executed.<br />

Examples are shown in Figure 38 <strong>and</strong> Figure 39.<br />

INSERT INTO Model(ModelTypeCode, CarMake, CarModel, CarYear,<br />

Price, EPACityMileage, EPAHighwayMileage, Horsepower)<br />

VALUES (?,?,?,?,?,?,?,?)<br />

WHERE Dealer.DealerNumber=?.<br />

Figure 38. Example of WHERE <strong>and</strong> INSERT<br />

String insertString = “INSERT INTO Sales “<br />

+ “(DateSold, PurchaserLastName, PurchaserFirstName, “<br />

+ “PurchaserAddress, SoldBy, StockVINumber)”<br />

+ “ VALUES (‘07032000’, ‘Beier’, ‘Otto’, “<br />

+ “’101 W. 1st Street, Smalltown, CA’, “<br />

+ “’S123’’1ABCD23E4F5678901234’) “<br />

+ “WHERE Dealer.DealerNumber = ’A123’”<br />

+ “‘ AND ModelTypeCode = ‘K1’)”;<br />

Figure 39. Example of an INSERT statement<br />

A JDBC statement object represents one SQL statement. A statement can be<br />

run immediately or it can be prepared once <strong>and</strong> then run several times with<br />

different parameters.<br />

5.4.8 Prepared statement<br />

A prepared statement is a statement that is written once with variable<br />

parameters to be run multiple times. Before a prepared statement can be run,<br />

values must be provided for all of the parameter markers in the statement.<br />

66 <strong>IMS</strong> <strong>Version</strong> 7 <strong>and</strong> <strong>Java</strong> <strong>Application</strong> <strong>Programming</strong>


Part 2. Sample application<br />

This part of the book describes a sample <strong>IMS</strong> <strong>Java</strong> application.<br />

It contains the following chapters:<br />

Chapter 6, “<strong>IMS</strong>Auto application build <strong>and</strong> execute” on page 69<br />

Chapter 7, “VisualAge for <strong>Java</strong> <strong>IMS</strong> application development” on page 119<br />

© Copyright <strong>IBM</strong> Corp. 2001 67


68 <strong>IMS</strong> <strong>Version</strong> 7 <strong>and</strong> <strong>Java</strong> <strong>Application</strong> <strong>Programming</strong>


Chapter 6. <strong>IMS</strong>Auto application build <strong>and</strong> execute<br />

To run your <strong>Java</strong> programs under <strong>IMS</strong> V7, first you have to code or generate<br />

the <strong>Java</strong> code for your application, compile the <strong>Java</strong> source code into <strong>Java</strong><br />

bytecode, <strong>and</strong> bind the <strong>Java</strong> bytecode into an <strong>IMS</strong> executable program using<br />

the ET/390 HPJ compiler. You can use an editor to code your <strong>Java</strong> programs,<br />

or you can generate your <strong>Java</strong> source code using a GUI <strong>Java</strong> development<br />

tool such as VisualAge for <strong>Java</strong>.<br />

Figure 40 illustrates the <strong>IMS</strong> <strong>Java</strong> application development scenario for <strong>IMS</strong>.<br />

VisualAge for <strong>Java</strong>,<br />

Enterprise Enterprise Edition<br />

Edit/Compile<br />

Edit/Compile<br />

Browse Browse<br />

<strong>Version</strong> <strong>Version</strong> Control<br />

Error Error Feedback Feedback<br />

Local<br />

Debugger<br />

Remote Remote<br />

Debugger Debugger<br />

Profiler Profiler<br />

J<br />

P<br />

O<br />

R<br />

T<br />

Export Export<br />

<strong>Java</strong> <strong>Java</strong><br />

Bytecode<br />

<strong>IMS</strong><br />

<strong>Java</strong><br />

Figure 40. <strong>IMS</strong> <strong>Java</strong> application development scenario<br />

High<br />

Performance<br />

Compiler<br />

Executable<br />

Run on<br />

OS/390<br />

Trace Trace<br />

OS/390<br />

The HPJ compiler runs on the OS/390 mainframe <strong>and</strong> can be invoked by<br />

running JCL under MVS or by using the UNIX System Services hpj comm<strong>and</strong><br />

on an ET/390 workstation. Typically, whether using a batch JOB or working<br />

interactively, you will run from a makefile or a script.<br />

© Copyright <strong>IBM</strong> Corp. 2001 69<br />

PC Se rver<br />

320


6.1 Testing <strong>IMS</strong> applications<br />

Initially we used one of the <strong>IMS</strong> IVP programs to familiarize ourselves with<br />

the UNIX System Services environment, the JDK javac compiler, the ET/390<br />

HPJ compiler, <strong>and</strong> the <strong>IMS</strong> <strong>Java</strong> <strong>Application</strong> <strong>Programming</strong> Interfaces<br />

(<strong>Java</strong>ToDLI <strong>and</strong> JDBC <strong>IMS</strong>). For comparison purposes, we had three<br />

versions of source code for the IVP program: original COBOL code, <strong>Java</strong><br />

code using the SSAs <strong>and</strong> DLIConnection interface, <strong>and</strong> <strong>Java</strong> code using<br />

JDBC <strong>IMS</strong>. Throughout the remainder of the project we worked with a more<br />

involved <strong>Java</strong> application, called Auto Dealership, to test <strong>and</strong> illustrate our<br />

findings. This application accesses the <strong>IMS</strong> message queue <strong>and</strong> <strong>IMS</strong><br />

databases using the JDBC <strong>IMS</strong> interface.<br />

Source code for the sample applications referenced in this redbook can be<br />

found in the appendices referenced in Table 4.<br />

Table 4. References to source code<br />

<strong>Application</strong> Tran Code <strong>Java</strong> To DLI JDBC COBOL<br />

IVP Telephone IVTCC Appendix E,<br />

“IVP<br />

application —<br />

<strong>Java</strong> source<br />

(<strong>Java</strong> to DLI<br />

version)” on<br />

page 311<br />

IVP Telephone IVTCC Appendix F,<br />

“IVP<br />

application —<br />

<strong>Java</strong> source<br />

(JDBC<br />

version)” on<br />

page 325<br />

IVP Telephone IVTCC Appendix G,<br />

“IVP<br />

application —<br />

COBOL<br />

source” on<br />

page 339<br />

Auto Dealership <strong>IMS</strong>AUTO Appendix I,<br />

“Dealership<br />

sample<br />

application”<br />

on page 357<br />

70 <strong>IMS</strong> <strong>Version</strong> 7 <strong>and</strong> <strong>Java</strong> <strong>Application</strong> <strong>Programming</strong>


6.2 “Nonvisual” <strong>IMS</strong> application development<br />

Your manually coded <strong>Java</strong> programs can reside on either the mainframe or<br />

the workstation. Your <strong>IMS</strong> <strong>Java</strong> programs can make use of both the JDK<br />

Class Libraries (see reference) <strong>and</strong> the <strong>IMS</strong> <strong>Java</strong> Class Libraries (see<br />

Appendix A <strong>IMS</strong> JAVA Packages). They can be compiled into bytecode using<br />

the JDK javac compiler on the workstation or the mainframe. The HPJ<br />

compiler resides on the mainframe, so when you use the workstation you<br />

have to transfer the bytecode to the mainframe. In this section, we focus on<br />

doing as much as possible under MVS, either in TSO or with batch jobs. This<br />

will enable you to integrate <strong>Java</strong> program development into your existing<br />

change control system in use on the mainframe host system. It is also useful<br />

to simply set up some batch jobs for often repeated tasks such as compiling,<br />

linking, <strong>and</strong> copying to an <strong>IMS</strong> PDSE PGMLIB.<br />

6.2.1 Some TSO/E comm<strong>and</strong>s<br />

In this section, we describe the Time Sharing Option Extensions (TSO/E)<br />

comm<strong>and</strong>s that you use to invoke the UNIX System Services shell <strong>and</strong> the<br />

TSO/E comm<strong>and</strong>s that you can use to work with the HFS file system.<br />

The comm<strong>and</strong>s for working with the HFS file system are:<br />

Start a shell<br />

– ISHELL Invokes the UNIX System Services ISPF shell.<br />

– OSHELL Invokes BPXBATCH from TSO/E.<br />

– OMVS Invokes the UNIX System Services shell.<br />

– BPXBATCH Runs shell comm<strong>and</strong>s, shell scripts, or<br />

executable files.<br />

Edit or browse an HFS file<br />

– OBROWSE Browses an HFS file.<br />

– OEDIT Edits an HFS file.<br />

Copy a file<br />

– OCOPY Copies an MVS data set member or HFS file to<br />

another member or file<br />

– OGET <strong>and</strong> OGETX Copy HFS files from a directory to an MVS PDS<br />

or PDSE<br />

– OPUT <strong>and</strong> OPUTX Copy members from an MVS PDS or PDSE to<br />

an HFS directory<br />

Chapter 6. <strong>IMS</strong>Auto application build <strong>and</strong> execute 71


You can enter the above TSO/E comm<strong>and</strong>s from:<br />

TSO/E<br />

ISPF option 6 (Interactive System Productivity Facility comm<strong>and</strong><br />

processor panel)<br />

The shell<br />

Note<br />

Enter TSO/E comm<strong>and</strong>s from an ISPF panel that does not convert all<br />

the parameters into upper case; some panels, such as the main ISPF<br />

panel, convert your input into upper case. Using ISPF Option 6 is<br />

preferable, because it does not convert into upper case the comm<strong>and</strong>s<br />

that you enter, (remember: the UNIX System Services environment is<br />

case-sensitive).<br />

The path name is relative to the working directory (usually the HOME<br />

directory) of the TSO/E session, not the shell session.<br />

Use absolute path names when entering any TSO/E comm<strong>and</strong>s.<br />

Avoid using spaces or single quotes within path names.<br />

In the sections that follow, we assume that you are using the ISPF Comm<strong>and</strong><br />

Shell (option 6 on the ISPF menu) as shown in Figure 41.<br />

72 <strong>IMS</strong> <strong>Version</strong> 7 <strong>and</strong> <strong>Java</strong> <strong>Application</strong> <strong>Programming</strong>


Menu List Mode Functions Utilities Help<br />

------------------------------------------------------------------------------------<br />

ISPF Comm<strong>and</strong> Shell<br />

Enter TSO or Workstation comm<strong>and</strong>s below:<br />

===><br />

Place cursor on choice <strong>and</strong> press enter to Retrieve comm<strong>and</strong><br />

=> ishell<br />

=> listenq<br />

=> ftp 9.112.127.108<br />

=> receive<br />

=> xmit stlmvs1.H044381 dsn(ITSO.SMPE.SYSOUT)<br />

=> omvs<br />

=> omvsd<br />

=> omvds<br />

=> oshell<br />

=> ommvs<br />

Figure 41. ISPF Comm<strong>and</strong> Shell panel<br />

On this panel you can enter the comm<strong>and</strong>s on the first line. The 10 most<br />

recent comm<strong>and</strong>s are stored on the lower 10 lines. To retrieve a stored<br />

comm<strong>and</strong>, move the cursor to the line <strong>and</strong> press Enter. The comm<strong>and</strong> is<br />

moved to the first line <strong>and</strong> can be edited if necessary. Press Enter again to<br />

execute the comm<strong>and</strong>.<br />

6.3 ISHELL: Invoking UNIX System Services<br />

We found ISHELL to be the most useful comm<strong>and</strong> for working with HFS files.<br />

ISHELL invokes the UNIX System Services ISPF shell, a panel interface that<br />

helps you set up <strong>and</strong> manage UNIX System Services functions. You can use<br />

the ISHELL comm<strong>and</strong> to:<br />

List the contents of a directory.<br />

Display the attributes of a file.<br />

Display the attributes <strong>and</strong> contents of a symbolic link (syml).<br />

Delete directory, a file, a symbolic link or a special file.<br />

Rename a directory, a file, a symbolic link or a special file.<br />

Edit a file.<br />

Browse a file as text or records.<br />

Copy a file or an entire directory.<br />

Chapter 6. <strong>IMS</strong>Auto application build <strong>and</strong> execute 73


Replace a file.<br />

Print a file or an entire directory.<br />

Compare two files or directories.<br />

Find search string(s) in a file or a directory.<br />

Run an executable file.<br />

Display the file system attributes.<br />

Create an HFS.<br />

Mount <strong>and</strong> unmount an HFS.<br />

Set the working directory.<br />

Set up character-special files.<br />

Set up st<strong>and</strong>ard directories for a root file system.<br />

Set up existing users <strong>and</strong> groups for UNIX System Services access.<br />

Tasks such as mounting, unmounting, setting up character-special files, <strong>and</strong><br />

setting up existing users <strong>and</strong> groups for UNIX System Services access<br />

require either superuser authority or the RACF SPECIAL attribute.<br />

Field level <strong>and</strong> panel help are available throughout the dialog via PF1. For<br />

additional information on ISHELL, see the OS/390 UNIX System Services<br />

User’s Guide, SC28-1891, <strong>and</strong> the online help panels.<br />

Your HOME directory as defined in your RACF profile OMVS segment is used<br />

as the default path name when the shell starts up (see Figure 42). You can<br />

specify any path name or comm<strong>and</strong> on this panel. We also found the tool bar<br />

at the top of the this panel to be very useful.<br />

74 <strong>IMS</strong> <strong>Version</strong> 7 <strong>and</strong> <strong>Java</strong> <strong>Application</strong> <strong>Programming</strong>


File Directory Special_file Tools File_systems Options Setup Help<br />

-------------------------------------------------------------------------------------<br />

OpenMVS ISPF Shell<br />

Enter a pathname <strong>and</strong> do one of these:<br />

- Press Enter.<br />

- Select an action bar choice.<br />

- Specify an action code or comm<strong>and</strong> on the comm<strong>and</strong> line.<br />

Return to this panel to work with a different pathname.<br />

More: +<br />

/u/imsres4<br />

_____________________________________________________________________<br />

_____________________________________________________________________<br />

_____________________________________________________________________<br />

Comm<strong>and</strong> ===> ____________________________________________________________________<br />

Figure 42. ISHELL main screen<br />

Press Enter to get the file list of the directory you entered (see Figure 43).<br />

Chapter 6. <strong>IMS</strong>Auto application build <strong>and</strong> execute 75


Figure 43. ISHELL Directory List<br />

Here you can issue your comm<strong>and</strong>s by entering the specific action code. Or<br />

you can issue comm<strong>and</strong>s using the general action character ‘/’ <strong>and</strong> then from<br />

the following Select an Action panel, entering the number that corresponds to<br />

the desired action (see Figure 44 for files <strong>and</strong> Figure 45 for directories).<br />

76 <strong>IMS</strong> <strong>Version</strong> 7 <strong>and</strong> <strong>Java</strong> <strong>Application</strong> <strong>Programming</strong><br />

Directory List<br />

/u/imsres4/<br />

Select one or more files with / or action codes.<br />

Type Filename Row 1 of 59<br />

_Dir .<br />

_Dir ..<br />

_ File .profile<br />

_ Dir ceedumps<br />

_Dir com<br />

_ File Dealerhpj.sh.st<strong>and</strong>alone<br />

_ File Dealerhpj.sh.ver1<br />

_ File Dealerhpj.sh.ver3<br />

_ File Dealerjavac.sh.ver1<br />

_ File Dealerjavac.sh.ver2<br />

_ File Dealerjavac.sh.ver3<br />

_ File Dealerscript.ver1<br />

_ File Dealerscript.ver3<br />

_ Dir dealership<br />

_ File Dealertest.sh.ver1<br />

_ File exechpj.sh.ver1<br />

_ File execjavac.sh.ver1<br />

Comm<strong>and</strong> ===> ________________________________________________________________________


Select an Action<br />

Enter a number to select an action for the file:<br />

/u/imsres4/Dealerscript.ver3<br />

__ 1. Not available<br />

2. Attributes(A)...<br />

3. Delete(D)...<br />

4. Rename(R)...<br />

5. Edit(E)...<br />

6. Browse text(B)...<br />

7. View records(V)...<br />

8. Copy to(C)...<br />

9. Replace From(I)...<br />

10. Print(P)<br />

11. Compare(M)...<br />

12. Find(F)...<br />

13. Run(X)...<br />

14. Not available<br />

15. File system(U)<br />

Figure 44. ISHELL Select an Action panel for files<br />

Select an Action<br />

Enter a number to select an action for the directory:<br />

/u/imsres4/dealership<br />

__ 1. List Directory(L)...<br />

2. Not available<br />

3. Attributes(A)...<br />

4. Delete(D)...<br />

5. Rename(R)...<br />

6. Copy to PDS(C)...<br />

7. Copy from PDS(I)...<br />

8. Print(P)<br />

9. Compare(M)...<br />

10. Find(F)...<br />

11. Set working directory(W)<br />

12. File system(U)<br />

Figure 45. ISHELL Select an Action panel for directories<br />

To move to another directory, use the ‘L’ or ‘/’ <strong>and</strong> option 1 on the entry field<br />

next to the directory to which you want to move. To move up one directory<br />

level, use the ‘..’ directory entry.<br />

Chapter 6. <strong>IMS</strong>Auto application build <strong>and</strong> execute 77


To copy a file, use ‘C’ or ‘/’ <strong>and</strong> option 8 on the entry field next to the file you<br />

want to copy. A panel on which you can specify the destination of the file then<br />

pops up.<br />

To browse or edit a file, use ‘B’ or ‘E’ respectively. The browser/editor is the<br />

same as that which is invoked by ISPF option 1, 2, 3, 4, OBROWSE, or<br />

OEDIT.<br />

To display the attributes of a file, use ‘A’ or ‘/’ <strong>and</strong> option 2 on the entry field<br />

next to the file. The display will contain file permissions, size, various dates<br />

<strong>and</strong> other information as seen in Figure 46.<br />

Edit Help<br />

------------------------------------------------<br />

Display File Attributes<br />

Pathname : /u/imsres4/Dealerhpj.sh.st<strong>and</strong>alone<br />

More: +<br />

Filetype ....:Regularfile<br />

Permissions . . . : 700<br />

Filesize ....:1192<br />

Fileowner....:RCONWAY(0)<br />

Group owner . . . : SYS1(0)<br />

Last modified . . : 08/14/2000 18:44 GMT<br />

Lastchanged...:08/14/200018:44GMT<br />

Last accessed . . : 08/29/2000 17:26 GMT<br />

Created .....:08/10/200016:50GMT<br />

Linkcount....:1<br />

Set UID bit . . . : 0<br />

Figure 46. Display File Attributes option<br />

78 <strong>IMS</strong> <strong>Version</strong> 7 <strong>and</strong> <strong>Java</strong> <strong>Application</strong> <strong>Programming</strong>


6.4 OSHELL: Invoking BPXBATCH from TSO/E<br />

The OSHELL comm<strong>and</strong> uses BPXBATCH to run a single shell comm<strong>and</strong> or<br />

shell script. For example, to display all files in your HOME directory, enter<br />

oshell ls -l<br />

The result is shown on one or more TSO panels, separated by three asterisks<br />

(***) in Figure 47, Figure 48, <strong>and</strong> Figure 49).<br />

Menu List Mode Functions Utilities Help<br />

-------------------------------------------------------------------------<br />

Enter TSO or Workstation comm<strong>and</strong>s below:<br />

===> oshell ls -l<br />

Place cursor on choice <strong>and</strong> press enter to Retrieve comm<strong>and</strong><br />

=> oshell ls -l<br />

=> ishell<br />

=> listc<br />

=> omvs<br />

=> receive<br />

=> oshell<br />

=> listenq<br />

=> ftp 9.112.127.108<br />

=> xmit stlmvs1.H044381 dsn(ITSO.SMPE.SYSOUT)<br />

LIBPATH reset to /lib:/usr/lib:/usr/lpp/db2/db2610/lib:<br />

----------------------------------------------------<br />

Set up environment variables for <strong>Java</strong> for MVS<br />

***<br />

Figure 47. OSHELL ls -l input<br />

Chapter 6. <strong>IMS</strong>Auto application build <strong>and</strong> execute 79


----------------------------------------------------<br />

----------------------------------------------------<br />

Previous environment for <strong>Java</strong> unset<br />

Previous JAVA_HOMEenvironment set to /usr/lpp/java18/J1.1<br />

for <strong>Java</strong> unset<br />

JAVA_HOME PATH reset set to to /usr/lpp/java18/J1.1/bin:/usr/lpp/db2/db2610/bin:/bin:.<br />

/usr/lpp/java18/J1.1<br />

PATH ----------------------------------------------------<br />

reset to /usr/lpp/java18/J1.1/bin:/usr/lpp/db2/db2610/bin:/bin:.<br />

----------------------------------------------------<br />

CLASSPATH set to .:/usr/lpp/internet/server_root/cgi-bin/icsclass.zip:/usr/lpp/<br />

internet/server_root/servlets/public:/usr/lpp/java18/J1.1/lib/RACF.jar:/usr/lpp/<br />

CLASSPATH set to .:/usr/lpp/internet/server_root/cgi-bin/icsclass.zip:/usr/lpp/<br />

internet/server_root/servlets/public:/usr/lpp/java18/J1.1/lib/RACF.jar:/usr/lpp/<br />

db2/db2610/classes/db2sqljclasses.zip:/usr/lpp/java18/J1.1/lib/classes.zip:/usr/<br />

db2/db2610/classes/db2sqljclasses.zip:/usr/lpp/java18/J1.1/lib/classes.zip:/usr/<br />

lpp/db2/db2610/c<br />

lpp/db2/db2610/c<br />

LD_LIBRARY_PATH reset to .:/usr/lpp/db2/db2610/bin:/usr/lpp/db2/db2610/lib:/usr<br />

/lpp/java18/J1.1/lib/mvs/native_threads<br />

LD_LIBRARY_PATH reset to .:/usr/lpp/db2/db2610/bin:/usr/lpp/db2/db2610/lib:/usr<br />

/lpp/java18/J1.1/lib/mvs/native_threads<br />

STEPLIB set to DB2V610J.SDSNEXIT:DSN610.SDSNEXIT:DSN610.SDSNLOAD:HPJ390.SHPJMOD<br />

:HPJ390.SHPOMOD:CEE.SCEERUN:EQAW.V1R2M0.SEQAMOD<br />

STEPLIB set to DB2V610J.SDSNEXIT:DSN610.SDSNEXIT:DSN610.SDSNLOAD:HPJ390.SHPJMOD<br />

:HPJ390.SHPOMOD:CEE.SCEERUN:EQAW.V1R2M0.SEQAMOD<br />

DB2SQLJPROPERTIES set to /usr/lpp/db2/db2610/classes/db2sqljjdbc.properties<br />

DB2SQLJPROPERTIES DB2SQLJDBRMLIB set set to to DB2V610J.DBRMLIB.DATA<br />

/usr/lpp/db2/db2610/classes/db2sqljjdbc.properties<br />

DB2SQLJDBRMLIB java version “1.1.8” set to DB2V610J.DBRMLIB.DATA<br />

java hpjava version version “1.1.8” “VisualAge 2.0 CL4.1 - May 26 2000”<br />

hpjava *---------------------------------------------------------------<br />

version “VisualAge 2.0 CL4.1 - May 26 2000”<br />

*--------------------------------------------------------------profile<br />

executed for HPJ, JAVA <strong>and</strong> SQLJ<br />

*--------------------------------------------------------------profile<br />

executed for HPJ, JAVA <strong>and</strong> SQLJ<br />

*--------------------------------------------------------------total<br />

336<br />

total drw------- 336 2 AAAAAAA DB2RES 8192 Jul 20 19:15 <strong>IBM</strong>V<strong>Java</strong><br />

drw------- drwxr-xr-x 26 AAAAAAA DB2RES 8192 Jul Dec 206 19:15 1999 <strong>IBM</strong>V<strong>Java</strong> SYSTEM<br />

drwxr-xr-x *** 6 AAAAAAA DB2RES 8192 Dec 6 1999 SYSTEM<br />

***<br />

Figure 48. OSHELL ls -l output: Panel 1<br />

drwxr-xr-x 4 AAAAAAA DB2RES 32768 Jun 14 05:37 bin<br />

lrwxrwxrwx 1 AAAAAAA DB2RES 12 Feb 3 2000 dev -> $SYSNAME/dev<br />

drwxr-xr-x 13 AAAAAAA DB2RES 8192 Aug 25 14:16 etc<br />

drw------- 2 AAAAAAA DB2RES 8192 Jul 20 18:33 extras<br />

drw------- 2 AAAAAAA DB2RES 8192 Jul 20 18:34 ibmvjava<br />

drwxr-xr-x 2 AAAAAAA DB2RES 8192 May 22 11:01 imsjava<br />

lrwxrwxrwx 1 AAAAAAA DB2RES 16 Feb 3 2000 krb5 -> etc/dce/var/krb5<br />

drwxr-xr-x 2 AAAAAAA DB2RES 8192 Jun 14 05:37 lib<br />

drwxr-xr-x 2 AAAAAAA DB2RES 8192 Jun 14 05:37 opt<br />

-rwx------ 1 AAAAAAA DB2RES 288 Jul 19 18:52 profile.imsjava<br />

-rwx------ 1 AAAAAAA DB2RES 1132 Jul 21 14:08 profile.imsres1<br />

drwxr-xr-x 4 AAAAAAA DB2RES 8192 Jun 14 05:37 samples<br />

drwxr-xr-x 11 AAAAAAA SYS1 8192 Aug 1 06:28 servils1<br />

drwxr-xr-x 3 AAAAAAA DB2RES 8192 Aug 28 12:41 servils1_db2v6<br />

drwxr-xr-x 2 AAAAAAA DB2RES 8192 Aug 28 13:32 servils1_r9<br />

lrwxrwxrwx 1 AAAAAAA DB2RES 12 Feb 3 2000 tmp -> $SYSNAME/tmp<br />

drwxr-xr-x 29 AAAAAAA SYS1 8192 Aug 30 17:50 u<br />

drwxr-xr-x 10 AAAAAAA DB2RES 8192 Jun 14 05:37 usr<br />

lrwxrwxrwx 1 AAAAAAA DB2RES 12 Feb 3 2000 var -> $SYSNAME/var<br />

drwxr-xr-x 4 AAAAAAA DB2RES 8192 Jun 28 12:47 was<br />

drwxr-xr-x 4 AAAAAAA DB2RES 8192 Jun 28 12:47 web<br />

THE RECORD SIZE IN THE OUTPUT DATA SET IS SMALLER THAN A LINE IN THE INPUT FILE<br />

. SOME RECORDS HAVE BEEN TRUNCATED.<br />

***<br />

Figure 49. OSHELL ls -l output: Panel 2<br />

80 <strong>IMS</strong> <strong>Version</strong> 7 <strong>and</strong> <strong>Java</strong> <strong>Application</strong> <strong>Programming</strong>


When you use OSHELL, do not use an ampers<strong>and</strong> (&) to run a shell<br />

comm<strong>and</strong> in the background. You can use the OSHELL comm<strong>and</strong> to:<br />

List files in a directory<br />

Create, delete, or rename a directory, file, or special file<br />

Display contents of a file<br />

Copy a file<br />

Display a files attributes<br />

Search files for text strings<br />

Compare files or directories<br />

Run an executable file<br />

Display the attributes <strong>and</strong> contents of a symbolic link (syml)<br />

Set up character-special files<br />

Set up st<strong>and</strong>ard directories for a root file system<br />

Some of these tasks may require superuser authority.<br />

6.5 OMVS: Invoking the UNIX System Services shell<br />

If you want to issue several UNIX System Services shell comm<strong>and</strong>s, you can<br />

invoke OMVS. The shell starts up in your HOME directory (see Figure 50).<br />

<strong>IBM</strong><br />

Licensed Material - Property of <strong>IBM</strong><br />

5647-A01 (C) Copyright <strong>IBM</strong> Corp. 1993, 2000<br />

(C) Copyright Mortice Kern Systems, Inc., 1985, 1996.<br />

(C) Copyright Software Development Group, University of Waterloo, 1989.<br />

All Rights Reserved.<br />

U.S. Government users - RESTRICTED RIGHTS - Use, Duplication, or<br />

Disclosure restricted by GSA-ADP schedule contract with <strong>IBM</strong> Corp.<br />

<strong>IBM</strong> is a registered trademark of the <strong>IBM</strong> Corp.<br />

LIBPATH reset to /lib:/usr/lib:/usr/lpp/db2/db2610/lib:<br />

----------------------------------------------------<br />

Set up environment variables for <strong>Java</strong> for MVS<br />

----------------------------------------------------<br />

Previous environment for <strong>Java</strong> unset<br />

JAVA_HOME set to /usr/lpp/java18/J1.1<br />

PATH reset to /usr/lpp/java18/J1.1/bin:/usr/lpp/db2/db2610/bin:/bin:.<br />

===><br />

MORE...<br />

ESC=¢ 1=Help 2=SubCmd 3=HlpRetrn 4=Top 5=Bottom 6=TSO<br />

7=BackScr 8=Scroll 9=NextSess 10=Refresh 11=FwdRetr 12=Retrieve<br />

Figure 50. OMVS startup panel<br />

Chapter 6. <strong>IMS</strong>Auto application build <strong>and</strong> execute 81


You can then issue UNIX System Services comm<strong>and</strong>s, for example, ls -l,<br />

to list your directory. In contrast to the OSHELL comm<strong>and</strong>, everything is<br />

displayed at once when you use the OMVS comm<strong>and</strong>. Therefore, after the<br />

comm<strong>and</strong> completes, you see the panel in Figure 51 first. You can then use<br />

PF7 to browse backwards, to get to the panel in Figure 52. Using PF8 you<br />

can browse forward again. Unlike the OSHELL comm<strong>and</strong>, where the output<br />

disappears after you press the Enter key, the output of OMVS is kept for<br />

browsing. OMVS can be customized. See the OS/390 UNIX System Services<br />

Comm<strong>and</strong> Reference, SC28-1892, for further details.<br />

-rw-r--r-- 1 RCONWAY SYS1 5172 Aug 14 13:10 JAVADUMP.20000814.131025.8<br />

3887243<br />

-rw-r--r-- 1 RCONWAY SYS1 5718 Aug 14 14:35 JAVADUMP.20000814.143505.8<br />

3887247<br />

-rwx------ 1 RCONWAY SYS1 1186 Jul 27 21:08 TPCChpj.sh.ver1<br />

-rwx------ 1 RCONWAY SYS1 316 Jul 27 21:07 TPCCjavac.sh.ver1<br />

-rwx------ 1 RCONWAY SYS1 414 Jul 27 21:07 TPCCscript.ver1<br />

-rwx------ 1 RCONWAY SYS1 413 Aug 8 18:04 Testscript.ver1<br />

drw------- 2 RCONWAY SYS1 8192 Aug 30 18:39 ceedumps<br />

drwxr-x--x 3 RCONWAY SYS1 8192 Aug 10 18:56 com<br />

drwxrwxr-x 11 RCONWAY SYS1 8192 Aug 25 12:45 dealership<br />

-rwx------ 1 RCONWAY SYS1 972 Jul 25 12:23 exechpj.sh.ver1<br />

-rwx------ 1 RCONWAY SYS1 320 Jul 25 12:22 execjavac.sh.ver1<br />

-rwx------ 1 RCONWAY SYS1 1282 Jul 24 12:28 profile<br />

-rwx------ 1 RCONWAY SYS1 308 Jul 24 12:20 profile.imsjava<br />

-rwx------ 1 RCONWAY SYS1 1517 Aug 29 17:07 profile.imsres4<br />

-rwx------ 1 RCONWAY SYS1 633 Jul 25 17:42 runit.sh.new<br />

-rwx------ 1 RCONWAY SYS1 633 Jul 24 18:09 runit.sh.v1<br />

drwxrwxr-x 3 RCONWAY SYS1 8192 Aug 25 21:30 samples<br />

<strong>IMS</strong>RES4 @ SC47:/u/imsres4><br />

===><br />

INPUT<br />

ESC=¢ 1=Help 2=SubCmd 3=HlpRetrn 4=Top 5=Bottom 6=TSO<br />

7=BackScr 8=Scroll 9=NextSess 10=Refresh 11=FwdRetr 12=Retrieve<br />

Figure 51. OMVS ls -l output: Panel 1<br />

82 <strong>IMS</strong> <strong>Version</strong> 7 <strong>and</strong> <strong>Java</strong> <strong>Application</strong> <strong>Programming</strong>


<strong>IMS</strong>RES4 @ SC47:/u/imsres4>ls -l<br />

total 976<br />

-rwx------ 1 RCONWAY SYS1 1192 Aug 14 14:44 Dealerhpj.sh.st<strong>and</strong>alone<br />

-rwx------ 1 RCONWAY SYS1 1198 Aug 9 18:02 Dealerhpj.sh.ver1<br />

-rwx------ 1 RCONWAY SYS1 1195 Aug 14 12:50 Dealerhpj.sh.ver3<br />

-rwx------ 1 RCONWAY SYS1 1348 Aug 8 19:14 Dealerjavac.sh.ver1<br />

-rwx------ 1 RCONWAY SYS1 1743 Aug 9 19:21 Dealerjavac.sh.ver2<br />

-rwx------ 1 RCONWAY SYS1 1707 Aug 10 16:07 Dealerjavac.sh.ver3<br />

-rwx------ 1 RCONWAY SYS1 542 Aug 9 17:10 Dealerscript.ver1<br />

-rwx------ 1 RCONWAY SYS1 597 Aug 10 20:58 Dealerscript.ver3<br />

-rwx------ 1 RCONWAY SYS1 926 Aug 8 18:12 Dealertest.sh.ver1<br />

-rw-r--r-- 1 RCONWAY SYS1 28914 Aug 25 15:14 <strong>IMS</strong>AUTO.map<br />

-rw-r--r-- 1 RCONWAY SYS1 2025 Aug 25 15:14 <strong>IMS</strong>AUTO.syslin<br />

===><br />

MORE...<br />

ESC=¢ 1=Help 2=SubCmd 3=HlpRetrn 4=Top 5=Bottom 6=TSO<br />

7=BackScr 8=Scroll 9=NextSess 10=Refresh 11=FwdRetr 12=Retrieve<br />

Figure 52. OMVS ls -l output: Panel 2<br />

6.6 BPXBATCH: Shell comm<strong>and</strong>s, shell scripts, or executable files<br />

BPXBATCH makes it easy for you to run shell scripts or OS/390 executable<br />

files that reside in HFS files. You can run from your TSO/E session or from<br />

batch. You can allocate MVS st<strong>and</strong>ard files stdin, stdout, stderr as HFS files<br />

for passing any input to be processed with shell comm<strong>and</strong>s, for writing<br />

output, <strong>and</strong> for error messages. Always allocate stdin as READ; always<br />

allocate stdout <strong>and</strong> stderr as WRITE. Such st<strong>and</strong>ard files must be HFS files.<br />

You allocate them by specifying the PATH keyword option on the ALLOCATE<br />

comm<strong>and</strong>. If you do not allocate them, they default to /dev/null, the output is<br />

discarded, <strong>and</strong> you get end of file on input files. A program run by<br />

BPXBATCH cannot use allocations for any files other than stdin, stdout, or<br />

stderr.<br />

BPXBATCH takes the following parameters: SH or PGM. These parameters<br />

specify whether BPXBATCH is to run a shell script or comm<strong>and</strong> versus an<br />

OS/390 executable file located in an HFS file. If neither SH nor PGM is<br />

specified, BPXBATCH assumes that the shell is to be started to run the shell<br />

script allocated by stdin.<br />

SH specifies the shell that is to be started to run shell comm<strong>and</strong>s or scripts<br />

provided from stdin. If SH is specified without a script, comm<strong>and</strong> or<br />

program_name, BPXBATCH attempts to run anything read in from stdin.<br />

SH is the default.<br />

Chapter 6. <strong>IMS</strong>Auto application build <strong>and</strong> execute 83


PGM specifies the program_name that is to be run as a called program from<br />

a shell environment. If you specify PGM, you must also specify<br />

program_name. BPXBATCH creates a process for the program to run in <strong>and</strong><br />

then calls the program. If possible, the HOME <strong>and</strong> LOGNAME environment<br />

variables are set when the program is run.<br />

program_name specifies the shell comm<strong>and</strong> name or the HFS pathname for<br />

the shell script or OS/390 executable file that you want to run. program_name<br />

can also contain option information. program_name is in upper case <strong>and</strong><br />

lower case letters. When PGM <strong>and</strong> program_name are specified <strong>and</strong> the<br />

specified program name does not begin with a slash character (/),<br />

BPXBATCH prefixes the user’s initial working directory information to the<br />

program path name.<br />

For example, from TSO/E:<br />

If you want to run the shell script you specify with stdin, you have to enter<br />

the following two lines:<br />

ALLOCATE FILE(STDIN) PATH(‘/u/imsres4/Dealerscript.ver3’)PATHOPTS(ORDONLY)<br />

BPXBATCH SH<br />

If you want to run the program test_program, you have to enter the<br />

following line:<br />

BPXBATCH PGM /u/imsres4/test_program<br />

If you want to run the shell Dealerscript.ver3 script <strong>and</strong> put its output in the<br />

test.out file in a temporary directory, you have to enter the following line:<br />

BPXBATCH SH /u/imsres4/Dealerscript.ver3’> /tmp/test.out<br />

BPXBATCH can also be called in a batch job where the same restrictions as<br />

those given above for TSO/E apply. Figure 53 shows the batch job JCL that<br />

we used.<br />

84 <strong>IMS</strong> <strong>Version</strong> 7 <strong>and</strong> <strong>Java</strong> <strong>Application</strong> <strong>Programming</strong>


AUTOHPJ JOB (999,POK),’ITSO <strong>IMS</strong> TEAM’,MSGCLASS=U,CLASS=A,<br />

// NOTIFY=&SYSUID,TIME=1440,REGION=0M<br />

//* ------------------------------------------------------------------<br />

//* EXECUTE SCRIPT<br />

//* ------------------------------------------------------------------<br />

//UXCALL EXEC PGM=BPXBATCH,REGION=0M,<br />

// PARM=’SH /u/imsres4/Dealerscript.ver3’<br />

//STEPLIB DD DISP=SHR,DSN=CEE.SCEERUN<br />

//STDENV DD DUMMY<br />

//STDIN DD DUMMY<br />

//************************************* THE OUTPUT *********<br />

//STDOUT DD PATH=’/u/imsres4/&SYSUID..autohpj.a082500.eout’,<br />

// PATHOPTS=(OWRONLY,OCREAT,OTRUNC),PATHMODE=SIRWXU<br />

//************************************* THE ERRORS *********<br />

//STDERR DD PATH=’/u/imsres4/&SYSUID..autohpj.a082500.eerr’,<br />

// PATHOPTS=(OWRONLY,OCREAT,OTRUNC),PATHMODE=SIRWXU<br />

//************************************* THE SYSOUT *********<br />

//SYSPRINT DD SYSOUT=*<br />

//* ------------------------------------------------------------------<br />

//* COPY RESULT(HFS) TO SYSOUT<br />

//* ------------------------------------------------------------------<br />

//HFS2PRT EXEC PGM=IKJEFT01,DYNAMNBR=300,COND=EVEN<br />

//SYSTSPRT DD SYSOUT=*<br />

//HFSOUT DD PATH=’/u/imsres4/&SYSUID..autohpj.a082500.eout’<br />

//HFSERR DD PATH=’/u/imsres4/&SYSUID..autohpj.a082500.eerr’<br />

//STDOUTL DD SYSOUT=*,DCB=(RECFM=VB,LRECL=6140,BLKSIZE=0)<br />

//STDERRL DD SYSOUT=*,DCB=(RECFM=VB,LRECL=6140,BLKSIZE=0)<br />

//SYSPRINT DD SYSOUT=*<br />

//SYSTSIN DD *<br />

OCOPY INDD(HFSOUT) OUTDD(STDOUTL)<br />

OCOPY INDD(HFSERR) OUTDD(STDERRL)<br />

/*<br />

//<br />

Figure 53. BPXBATCH JCL<br />

Executing PGM=BPXBATCH with PARM=’SH /u/imsres4/Dealerscript.ver3’<br />

indicates that we want to execute a shell script. In our case we executed the<br />

Dealerscript.ver3 script (see Figure 54) from the /u/imsres4 directory. (Notice<br />

that this script actually executes two other scripts.) When the shell starts up,<br />

you are in the HOME directory for the user that submitted the job. If you want<br />

to make sure that you execute the correct script no matter who submits the<br />

job, use absolute path names.<br />

Chapter 6. <strong>IMS</strong>Auto application build <strong>and</strong> execute 85


# ###############################################################<br />

# CREATED:<br />

# ITSO 8/10/00 - SCRIPT SHELL TO COMPILE AND BIND JAVA CODE<br />

# FOR THE ITSO AUTO DEALER APPLICATION<br />

# resides on /u/imsres4/<br />

# ###############################################################<br />

echo START Dealerscript.ver3 TO COMPILE AND BIND AUTO DEALER APPL<br />

date<br />

cd<br />

cd u/imsres4<br />

. profile.imsjava<br />

. profile.imsres4<br />

cd<br />

cd usr/lpp/hpj/bin<br />

. profile.hpj<br />

cd<br />

cd u/imsres4<br />

Dealerjavac.sh.ver3<br />

Dealerhpj.sh.ver3<br />

Date<br />

echo END Dealerscript.ver3 TO COMPILE AND BIND AUTO/DEALER APPL<br />

Figure 54. Auto Dealer shell script<br />

All the std files you use must be on HFS. stdenv file allows you to define an<br />

environment variable such as HOME or PATH if you want to run a program. It<br />

does not work with shell scripts. The stdin file is an alternative way of getting<br />

input to the shell. If you do not want to use PARM on the EXEC statement,<br />

define stdin like this:<br />

//STDIN DD PATHOPTS=(ORDONLY),PATH=’/u/imsres4/Dealerscript.ver3’<br />

If you run BPXBATCH, you do not see much in the job sysout. The return<br />

code (RC) is 00 if the shell could execute the script or 12 if there was a<br />

serious error. All other output is hidden on HFS within the files defined as<br />

stdout <strong>and</strong> stderr.<br />

Because it is our objective in this section to do as much as possible in MVS,<br />

we added a step to our BPXBATCH job which will copy the output from the<br />

HFS files to the job sysout.<br />

6.7 OBROWSE <strong>and</strong> OEDIT: browsing <strong>and</strong> editing an HFS file<br />

OBROWSE <strong>and</strong> OEDIT are straightforward. You can call OBROWSE <strong>and</strong><br />

OEDIT with or without a path name. If you do not give a path name, an Entry<br />

Panel is displayed, where you can enter the directory name <strong>and</strong> file name of a<br />

file you want to browse or edit.<br />

86 <strong>IMS</strong> <strong>Version</strong> 7 <strong>and</strong> <strong>Java</strong> <strong>Application</strong> <strong>Programming</strong>


6.8 OCOPY: Copying to another member or file<br />

You can use the OCOPY comm<strong>and</strong> to copy data between an MVS data set<br />

<strong>and</strong> the HFS, between two data sets, or between two files. For OCOPY, you<br />

would want to use the CONVERT option for these two situations:<br />

Conversion between code pages <strong>IBM</strong>-037 <strong>and</strong> <strong>IBM</strong>-1047<br />

Conversion between ASCII <strong>and</strong> code page <strong>IBM</strong>-1047<br />

The UNIX System Services shell uses code page 1047, <strong>and</strong> MVS uses a<br />

country extended code page. You can convert data to or from code page<br />

1047 while it is being copied. If you are copying a file with doublebyte data,<br />

do not use the CONVERT option. Before using the OCOPY comm<strong>and</strong>, you<br />

must allocate the data set with which you are working. When using the TSO/E<br />

ALLOCATE comm<strong>and</strong> or a JCL DD statement to allocate a file or data set,<br />

you can specify the PATHMODE <strong>and</strong> PATHOPTS parameters along with the<br />

PATH parameter. For information about the use of these parameters with the<br />

JCL statement, see the OS/390 MVS JCL Reference. For information about<br />

the TSO/E ALLOCATE comm<strong>and</strong>, see the TSO/E Comm<strong>and</strong> Reference.<br />

You can use OCOPY to copy:<br />

1. A member of an MVS PDS or PDSE to a file<br />

2. An MVS sequential data set to a file<br />

3. A file to a member of an MVS PDS or PDSE<br />

4. A file to an MVS sequential data set<br />

5. A file to a file<br />

6. A member of an MVS PDS or PDSE to another member of an MVS PDS or<br />

PDSE<br />

7. A member of an MVS PDS or PDSE to an MVS sequential data set<br />

8. An MVS sequential data set to another MVS sequential data set<br />

9. An MVS sequential data set to a member of an MVS PDS or PDSE<br />

Both the source <strong>and</strong> the target can be an MVS data set, a member of a PDS,<br />

or an HFS file. If the source (INDD) is an MVS data set <strong>and</strong> the target<br />

(OUTDD) is an HFS file, OCOPY copies an MVS data set to a file; the<br />

operation is the same as the OPUT comm<strong>and</strong>. If the source (INDD) is an HFS<br />

file <strong>and</strong> the target (OUTDD) is an MVS data set, then OCOPY copies a file to<br />

an MVS data set; the operation is the same as the OGET comm<strong>and</strong>.<br />

Chapter 6. <strong>IMS</strong>Auto application build <strong>and</strong> execute 87


If PATHMODE, which sets the permission bits for a new file, is specified<br />

during allocation, it is used when creating a new file. If PATHMODE is not<br />

specified during the allocation of a new file, the allocation creates a file with<br />

the default permission of 000, which means the user has no access to it. We<br />

used OCOPY to put the output of a job written into HFS files into the job<br />

sysout stream.<br />

6.9 OGET, OGETX, OPUT, <strong>and</strong> OPUTX: Copying files <strong>and</strong> members<br />

OGET <strong>and</strong> OGETX copy files from HFS directory to an MVS PDS, or PDSE,<br />

or a sequential file.<br />

OPUT <strong>and</strong> OPUTX copy members from an MVS PDS or PDSE to an HFS<br />

directory. The only difference between these comm<strong>and</strong>s <strong>and</strong> OCOPY is that<br />

you do not have to specify the file names within the JCL, rather you specify<br />

the file name within the comm<strong>and</strong>. Therefore these comm<strong>and</strong>s are more<br />

suited for use as TSO/E comm<strong>and</strong>s than for use in a job, as you do not have<br />

to ALLOCATE the files. Here is an example of copying from HFS to an MVS<br />

PDS member:<br />

OGET ‘/u/imsres4/auto.trace’ PDS.DEALERSHIP(TRACE) CONVERT(YES)<br />

For more details on OGET, OGETX, OPUT, OPUTX, <strong>and</strong> OCOPY, see the<br />

OS/390 UNIX System Services User’s Guide, SC28-1891 <strong>and</strong> OS/390 UNIX<br />

System Services Comm<strong>and</strong> Reference, SC28-1892.<br />

6.10 <strong>Java</strong> Tools in UNIX System Services environment<br />

In this section we explain how to use the javac <strong>and</strong> hpj comm<strong>and</strong>s in a UNIX<br />

System Services environment. Both tools can be run interactively from the<br />

OMVS comm<strong>and</strong> shell or in the background via a BPXBATCH shell script job.<br />

6.10.1 javac comm<strong>and</strong><br />

The javac comm<strong>and</strong> compiles <strong>Java</strong> source code into <strong>Java</strong> bytecodes. The<br />

java comm<strong>and</strong> is used to interpret <strong>and</strong> run the <strong>Java</strong> bytecodes.<br />

<strong>Java</strong> source code must be in files whose names end with the .java extension.<br />

The file name must be constructed from the class name (classname.java) if<br />

the class is public or is referenced from another source file.<br />

88 <strong>IMS</strong> <strong>Version</strong> 7 <strong>and</strong> <strong>Java</strong> <strong>Application</strong> <strong>Programming</strong>


For each class defined in a source file compiled by javac, the compiler stores<br />

the resulting bytecodes in a class file with a name of the form<br />

classname.class. The compiler places each class file in the same directory as<br />

the corresponding source file, unless you specify the -d option.<br />

When the compiler must refer to your own classes you need to specify their<br />

location. Use the -classpath option or CLASSPATH environment variable to<br />

do this. The class path is a sequence of directories (or zip files) which javac<br />

searches for classes not already defined in any of the files specified directly<br />

as comm<strong>and</strong> arguments. The compiler looks in the class path for both a<br />

source file <strong>and</strong> a class file, recompiling the source (<strong>and</strong> regenerating the<br />

class file) if it is newer.<br />

Set the property javac.pipe.output to true to send output messages to<br />

System.out. Set javac.pipe.output to false, to send output messages to<br />

System.err. Refer to the OS/390 UNIX documentation for more details on the<br />

use of the javac comm<strong>and</strong>.<br />

Here are some of the options for the javac comm<strong>and</strong>:<br />

-classpath path<br />

Specifies the path javac uses to look up classes needed to run javac or<br />

being referenced by other classes you are compiling. It overrides the<br />

default or the CLASSPATH environment variable if it is set. Use this option<br />

when you want to compile without modifying the CLASSPATH<br />

environment variable. Directories are separated by semi-colons. It is often<br />

useful for the directory containing the source files to be on the class path.<br />

You should always include the system classes at the end of the path. For<br />

example:<br />

javac -classpath .;C:\usr\lpp\ims\imsjava71\classes ...<br />

-d directory<br />

Specifies the root directory of the class file hierarchy where compiled<br />

classes are stored. In other words, this is essentially a destination<br />

directory for your compiled classes. This parameter is useful because<br />

classes are often organized in a hierarchical directory structure.<br />

With this parameter, the directories are created below the directory<br />

specified by . For example, the following comm<strong>and</strong> causes the class<br />

files for the classes in the <strong>IMS</strong>Auto.java source file to be saved in the<br />

directory C:\u\imsres4\dealership\application\classes:<br />

javac -d C:\u\imsres4\dealership\application\classes <strong>IMS</strong>Auto.java<br />

Chapter 6. <strong>IMS</strong>Auto application build <strong>and</strong> execute 89


Note<br />

Note that the -classpath <strong>and</strong> -d options have independent effects. The<br />

compiler reads only from the class path, <strong>and</strong> writes only to the destination<br />

directory. It is often useful for the destination directory to be on the class<br />

path. If the -d option is not specified, the source files should be stored in a<br />

directory hierarchy which reflects the package structure, so that the<br />

resulting class files can be easily located.<br />

-encoding encoding name<br />

Specify the source file encoding name, such as EUCJIS\SJIS. If this<br />

option is not specified, then the platform default converter is used.<br />

-deprecation<br />

Generate a warning for every use or override of a deprecated member or<br />

class. A member or class is deprecated if its documentation comment<br />

contains the @deprecated tag. The compiler will emit a warning at the end<br />

of compilation whether or not -deprecation is used; this option causes the<br />

location of each individual use or override to be noted.<br />

Deprecated members or classes are deliberately not mentioned if the<br />

source file containing the deprecation is being recompiled. This can<br />

happen because the file is on the comm<strong>and</strong> line or because -depend is<br />

used <strong>and</strong> the source file was out of date.<br />

-nowarn<br />

Turns off warnings. If used, the compiler does not print out any warnings.<br />

-g<br />

Compiles your code with debug information. Enables generation of<br />

information about local variables for use by <strong>Java</strong> debugging tools. Use this<br />

option if you want to examine the contents of local variables when<br />

debugging your classes. You can still set breakpoints. Step through your<br />

code if you do not compile your classes with this option. By default, only<br />

line number information is generated.<br />

With JDK 1.1.8, the -g <strong>and</strong> -O options are mutually exclusive.<br />

-g:nodebug<br />

Do not generate line number or local variable debugging information.<br />

90 <strong>IMS</strong> <strong>Version</strong> 7 <strong>and</strong> <strong>Java</strong> <strong>Application</strong> <strong>Programming</strong>


-O<br />

Directs the compiler to try to generate faster code. This may slow down<br />

compilation, make larger class files, <strong>and</strong>/or make it difficult to debug.<br />

With JDK 1.1.8, the -O option tries to inline methods across classes. This<br />

creates compatibility problems <strong>and</strong> sometimes generates illegal bytecode.<br />

-O also implicitly turns on -depend <strong>and</strong> implicitly turns off -g.<br />

-O:interclass<br />

This option optimizes your code by informing the compiler that all<br />

generated class files are guaranteed to be delivered <strong>and</strong> upgraded as a<br />

unit, enabling interclass optimizations that may otherwise break binary<br />

compatibility. Use this option with discretion.<br />

There are situations in which it is legal to use a <strong>Java</strong> compiler to inline<br />

methods. The compiler will only optimize code for which source is<br />

available during the compilation, so the only .java files discoverable by the<br />

compiler should be for classes intended to be delivered or upgraded as a<br />

unit. In particular, ensure that no sources for other classes are accessible<br />

on CLASSPATH, keeping in mind that the present working directory, ‘.’, is<br />

appended to CLASSPATH.<br />

Line number debugging information in class files compiled with<br />

-O:interclass may refer to lines of a different source file. This is a limitation<br />

of the class file format, which does not allow the originating file to be<br />

encoded along with the line number.<br />

This option implicitly turns on -depend.<br />

-verbose<br />

Causes the compiler <strong>and</strong> linker to print out messages about what source<br />

files are being compiled <strong>and</strong> what class files are being loaded.<br />

-depend<br />

Causes recompilation of class files on which the source files given as<br />

comm<strong>and</strong> line arguments recursively depend. Without this option, only<br />

files that are directly depended on <strong>and</strong> missing or out-of-date will be<br />

recompiled. Recompilation does not extend to missing or out-of-date files<br />

only depended on by already up-to-date class files.<br />

Chapter 6. <strong>IMS</strong>Auto application build <strong>and</strong> execute 91


-Jjavaoption<br />

Passes through the string javaoption as a single argument to the <strong>Java</strong><br />

interpreter which runs the compiler. The argument should not contain<br />

spaces. Multiple argument words must all begin with the prefix -J, which is<br />

stripped. This is useful for adjusting the compiler’s execution environment<br />

or memory usage.<br />

Refer to the OS/390 UNIX documentation for more details on the use of the<br />

javac comm<strong>and</strong>.<br />

In our testing we executed javac in the foreground <strong>and</strong> the backgound <strong>and</strong><br />

compiled a single class <strong>and</strong> multiple classes at one time. Here are the<br />

foreground comm<strong>and</strong>s we used to compile the Classes for the Auto<br />

Dealership application.<br />

First, we execute the necessary profile comm<strong>and</strong>s; second, we change to the<br />

directory holding the class(es) we want to compile; third, we run javac,<br />

supplying one or more class names <strong>and</strong> options.:<br />

. profile.imsjava<br />

. Profile.imsres4<br />

cd /u/imsres4/dealership/database<br />

javac *.java -verbose<br />

92 <strong>IMS</strong> <strong>Version</strong> 7 <strong>and</strong> <strong>Java</strong> <strong>Application</strong> <strong>Programming</strong><br />

cd /u/imsres4/dealership/application<br />

javac *.java -verbose<br />

javac <strong>IMS</strong>Auto.java -verbose<br />

Figure 55 <strong>and</strong> Figure 56 list the profiles we used to initialize the variables<br />

needed during the compile.<br />

export <strong>IBM</strong><strong>IMS</strong>J_HOME=/usr/lpp/ims/imsjava71/classes.zip<br />

export CLASSPATH=$CLASSPATH:$<strong>IBM</strong><strong>IMS</strong>J_HOME<br />

#<br />

# COMMENT HOLDER<br />

#<br />

echo ‘*------------------------------------------------------*<br />

echo ‘ profile.imsjava executed ‘<br />

echo ‘*------------------------------------------------------*<br />

Figure 55. The profile, profile.imsjava


# ====================================================<br />

#JDK<br />

# ====================================================<br />

export JAVA_HOME=/usr/lpp/java18i/J1.1<br />

export PATH=/usr/lpp/java18i/J1.1/bin:$PATH<br />

export CLASSPATH=/usr/lpp/java18i/J1.1/lib/classes.zip:$CLASSPATH<br />

export LD_LIBRARY_PATH=/usr/lpp/java18i/J1.1/lib/classes.zip:$LD_LIBRARY_PATH<br />

# ===================================================================<br />

#HPJ<br />

# ===================================================================<br />

export <strong>IMS</strong>RES4_HOME=”/u/imsres4”<br />

export <strong>IBM</strong>HPJ_HOME=”/usr/lpp/hpj”<br />

export <strong>IBM</strong>HPJ_RTL=”CEE.SCEELKED:CEE.SCEELKEX:CEE.SCEEOBJ:CEE.SCEECPP”<br />

export CLASSPATH=$CLASSPATH:$<strong>IBM</strong>HPJ_HOME/lib<br />

export CLASSPATH=$CLASSPATH:$<strong>IMS</strong>RES4_HOME<br />

export PATH=$PATH:$<strong>IBM</strong>HPJ_HOME/bin<br />

export LIBPATH=$LIBPATH:$<strong>IBM</strong>HPJ_HOME/lib<br />

export STEPLIB=$STEPLIB:HPJ390.SHPJMOD:HPJ390.SHPOMOD:CEE.SCEERUN<br />

# ===================================================================<br />

echo ********************************<br />

echo ***** profile.imsres4 **********<br />

echo ***** profile.imsres4 **********<br />

echo JAVA_HOME : $JAVA_HOME<br />

echo<br />

echo PATH : $PATH<br />

echo<br />

echo LIBPATH : $LIBPATH<br />

echo<br />

echo CLASSPATH : $CLASSPATH<br />

echo<br />

echo LD_LIBRARY_PATH : $LD_LIBRARY_PATH<br />

echo<br />

echo STEPLIB : $STEPLIB<br />

echo<br />

echo <strong>IBM</strong>HPJ_HOME : $<strong>IBM</strong>HPJ_HOME<br />

echo<br />

echo <strong>IBM</strong>HPJ_RTL : $<strong>IBM</strong>HPJ_RTL<br />

echo ***** profile.imsres4 **********<br />

echo ***** profile.imsres4 **********<br />

echo ********************************<br />

Figure 56. The profile, profile.imsres4<br />

Figure 57, Figure 58, <strong>and</strong> Figure 59 contain sample javac output when<br />

executed from an interactive OMVS session.<br />

Chapter 6. <strong>IMS</strong>Auto application build <strong>and</strong> execute 93


<strong>IMS</strong>RES4 @ SC47:/u/imsres4/dealership/database>javac *.java -verbose<br />

parsed Dealer.java in 370 ms¨<br />

parsed Model.java in 36 ms¨<br />

parsed Order.java in 30 ms¨<br />

parsed Sales.java in 21 ms¨<br />

parsed Salesperson.java in 13 ms¨<br />

parsed Stock.java in 32 ms¨<br />

loaded /usr/lpp/ims/imsjava71/classes.zip(com/ibm/ims/db/DLISegment.class) in 46 ms¨<br />

loaded /usr/lpp/ims/imsjava71/classes.zip(com/ibm/ims/base/DLIBaseSegment.class) in 124 ms¨<br />

loaded /usr/lpp/java18i/J1.1/lib/classes.zip(java/lang/Object.class) in 11 ms¨<br />

checking class dealership.database.Dealer¨<br />

loaded /usr/lpp/java18i/J1.1/lib/classes.zip(java/lang/Cloneable.class) in 4 ms¨<br />

loaded /usr/lpp/ims/imsjava71/classes.zip(com/ibm/ims/base/DLITypeInfo.class) in 21 ms¨<br />

wrote Dealer.class¨<br />

checking class dealership.database.Model¨<br />

wrote Model.class¨<br />

checking class dealership.database.Order¨<br />

wrote Order.class¨<br />

checking class dealership.database.Sales¨<br />

wrote Sales.class¨<br />

checking class dealership.database.Salesperson¨<br />

wrote Salesperson.class¨<br />

checking class dealership.database.Stock¨<br />

wrote Stock.class¨<br />

done in 2779 ms¨<br />

<strong>IMS</strong>RES4 @ SC47:/u/imsres4/dealership/database><br />

Figure 57. First sample of javac output<br />

94 <strong>IMS</strong> <strong>Version</strong> 7 <strong>and</strong> <strong>Java</strong> <strong>Application</strong> <strong>Programming</strong>


<strong>IMS</strong>RES4 @ SC47:/u/imsres4/dealership/application>javac *.java -verbose<br />

parsed AcceptOrderInput.java in 234 ms¨<br />

parsed CancelOrderInput.java in 26 ms¨<br />

parsed Cancelled.java in 21 ms¨<br />

parsed CarFound.java in 63 ms¨<br />

parsed DealerDatabaseView.java in 28 ms¨<br />

parsed ErrorMessage.java in 14 ms¨<br />

parsed FindACarInput.java in 29 ms¨<br />

parsed <strong>IMS</strong>Auto.java in 484 ms¨<br />

parsed InputMessage.java in 31 ms¨<br />

parsed ListModelsInput.java in 43 ms¨<br />

parsed ModelDetails.java in 35 ms¨<br />

parsed ModelList.java in 20 ms¨<br />

parsed OrderAccepted.java in 10 ms¨<br />

parsed OutputMessage.java in 41 ms¨<br />

parsed RecordASaleInput.java in 66 ms¨<br />

parsed SalesRecord.java in 36 ms¨<br />

parsed ShowModelDetailsInput.java in 31 ms¨<br />

loaded /usr/lpp/ims/imsjava71/classes.zip(com/ibm/ims/application/<strong>IMS</strong>FieldMessage.class) in 49 ms¨<br />

loaded /usr/lpp/ims/imsjava71/classes.zip(com/ibm/ims/base/DLIBaseSegment.class) in 121 ms¨<br />

loaded /usr/lpp/java18i/J1.1/lib/classes.zip(java/lang/Object.class) in 11 ms¨<br />

loaded /usr/lpp/ims/imsjava71/classes.zip(com/ibm/ims/db/DLIDatabaseView.class) in 16 ms¨<br />

loaded /usr/lpp/ims/imsjava71/classes.zip(com/ibm/ims/application/<strong>IMS</strong><strong>Application</strong>.class) in 18 ms¨<br />

checking class dealership.application.AcceptOrderInput¨<br />

loaded /usr/lpp/java18i/J1.1/lib/classes.zip(java/lang/Cloneable.class) in 3 ms¨<br />

loaded /usr/lpp/ims/imsjava71/classes.zip(com/ibm/ims/base/DLITypeInfo.class) in 19 ms¨<br />

wrote AcceptOrderInput.class¨<br />

checking class dealership.application.CancelOrderInput¨<br />

wrote CancelOrderInput.class¨<br />

checking class dealership.application.Cancelled¨<br />

loaded /usr/lpp/java18i/J1.1/lib/classes.zip(java/lang/IllegalArgumentException.class) in 5 ms¨<br />

loaded /usr/lpp/java18i/J1.1/lib/classes.zip(java/lang/RuntimeException.class) in 4 ms¨<br />

loaded /usr/lpp/java18i/J1.1/lib/classes.zip(java/lang/Exception.class) in 6 ms¨<br />

loaded /usr/lpp/java18i/J1.1/lib/classes.zip(java/lang/Throwable.class) in 11 ms¨<br />

wrote Cancelled.class¨<br />

checking class dealership.application.CarFound¨<br />

loaded /usr/lpp/ims/imsjava71/classes.zip(com/ibm/ims/base/DLITypeInfoList.class) in 3 ms¨<br />

wrote CarFound.class¨<br />

checking class dealership.application.DealerDatabaseView¨<br />

loaded /usr/lpp/ims/imsjava71/classes.zip(com/ibm/ims/db/DLISegmentInfo.class) in 5 ms¨<br />

loaded /u/imsres4/dealership/database/Dealer.class in 10 ms¨<br />

loaded /usr/lpp/ims/imsjava71/classes.zip(com/ibm/ims/db/DLISegment.class) in 1 9 ms¨<br />

loaded /u/imsres4/dealership/database/Model.class in 5 ms¨<br />

loaded /u/imsres4/dealership/database/Order.class in 13 ms¨<br />

loaded /u/imsres4/dealership/database/Sales.class in 25 ms¨<br />

loaded /u/imsres4/dealership/database/Stock.class in 14 ms¨<br />

wrote DealerDatabaseView.class¨<br />

checking class dealership.application.ErrorMessage¨<br />

wrote ErrorMessage.class¨<br />

checking class dealership.application.FindACarInput¨<br />

wrote FindACarInput.class¨<br />

Figure 58. Another sample of javac output (part 1 of 2)<br />

Chapter 6. <strong>IMS</strong>Auto application build <strong>and</strong> execute 95


checking class dealership.application.<strong>IMS</strong>Auto¨<br />

loaded /usr/lpp/ims/imsjava71/classes.zip(com/ibm/ims/base/<strong>IMS</strong>Exception.class) in 13 ms¨<br />

loaded /usr/lpp/java18i/J1.1/lib/classes.zip(java/io/FileWriter.class) in 7 ms¨<br />

loaded /usr/lpp/java18i/J1.1/lib/classes.zip(java/io/OutputStreamWriter.class) in 16 ms¨<br />

loaded /usr/lpp/java18i/J1.1/lib/classes.zip(java/io/Writer.class) in 6 ms¨<br />

loaded /usr/lpp/java18i/J1.1/lib/classes.zip(java/lang/String.class) in 35 ms¨<br />

loaded /usr/lpp/java18i/J1.1/lib/classes.zip(java/io/FileDescriptor.class) in 7 ms¨<br />

loaded /usr/lpp/java18i/J1.1/lib/classes.zip(java/io/Serializable.class) in 3 ms¨<br />

loaded /usr/lpp/java18i/J1.1/lib/classes.zip(java/io/File.class) in 28 ms¨<br />

loaded /usr/lpp/ims/imsjava71/classes.zip(com/ibm/ims/base/<strong>IMS</strong>Trace.class) in 34 ms¨<br />

loaded /usr/lpp/java18i/J1.1/lib/classes.zip(java/lang/System.class) in 25 ms¨<br />

loaded /usr/lpp/java18i/J1.1/lib/classes.zip(java/lang/Error.class) in 4 ms¨<br />

loaded /usr/lpp/java18i/J1.1/lib/classes.zip(java/io/IOException.class) in 4 ms¨<br />

loaded /usr/lpp/java18i/J1.1/lib/classes.zip(java/sql/Connection.class) in 12 ms¨<br />

loaded /usr/lpp/java18i/J1.1/lib/classes.zip(java/io/PrintStream.class) in 16 ms¨<br />

loaded /usr/lpp/java18i/J1.1/lib/classes.zip(java/io/FilterOutputStream.class) in 6 ms¨<br />

loaded /usr/lpp/java18i/J1.1/lib/classes.zip(java/io/OutputStream.class) in 4 ms¨<br />

loaded /usr/lpp/java18i/J1.1/lib/classes.zip(java/sql/Statement.class) in 8 ms¨<br />

loaded /usr/lpp/ims/imsjava71/classes.zip(com/ibm/ims/application/<strong>IMS</strong>Transaction.class) in 19 ms¨<br />

loaded /usr/lpp/java18i/J1.1/lib/classes.zip(java/sql/SQLException.class) in 14 ms¨<br />

loaded /usr/lpp/ims/imsjava71/classes.zip(com/ibm/ims/base/DLIException.class) in 6 ms¨<br />

loaded /usr/lpp/java18i/J1.1/lib/classes.zip(java/lang/StringBuffer.class) in 22 ms¨<br />

loaded /usr/lpp/java18i/J1.1/lib/classes.zip(java/lang/Integer.class) in 19 ms¨<br />

loaded /usr/lpp/java18i/J1.1/lib/classes.zip(java/lang/Number.class) in 5 ms¨<br />

Loaded /usr/lpp/ims/imsjava71/classes.zip(com/ibm/ims/application/<strong>IMS</strong>MessageQueue.class) in 23 ms¨<br />

loaded /usr/lpp/java18i/J1.1/lib/classes.zip(java/lang/Class.class) in 32 ms¨<br />

loaded /usr/lpp/java18i/J1.1/lib/classes.zip(java/sql/DriverManager.class) in 26 ms¨<br />

loaded /usr/lpp/java18i/J1.1/lib/classes.zip(java/lang/ExceptionInInitializerError.class) in 5 ms¨<br />

loaded /usr/lpp/java18i/J1.1/lib/classes.zip(java/lang/LinkageError.class) in 4 ms¨<br />

loaded /usr/lpp/java18i/J1.1/lib/classes.zip(java/lang/ClassNotFoundException.class) in 4 ms¨<br />

loaded /usr/lpp/java18i/J1.1/lib/classes.zip(java/sql/ResultSet.class) in 18 ms¨<br />

wrote <strong>IMS</strong>Auto.class¨<br />

checking class dealership.application.InputMessage¨<br />

wrote InputMessage.class¨<br />

checking class dealership.application.ListModelsInput¨<br />

wrote ListModelsInput.class¨<br />

checking class dealership.application.ModelDetails¨<br />

wrote ModelDetails.class¨<br />

checking class dealership.application.ModelList¨<br />

wrote ModelList.class¨<br />

checking class dealership.application.OrderAccepted¨<br />

wrote OrderAccepted.class¨<br />

checking class dealership.application.OutputMessage¨<br />

wrote OutputMessage.class¨<br />

checking class dealership.application.RecordASaleInput¨<br />

wrote RecordASaleInput.class¨<br />

checking class dealership.application.SalesRecord¨<br />

wrote SalesRecord.class¨<br />

checking class dealership.application.ShowModelDetailsInput¨<br />

wrote ShowModelDetailsInput.class¨<br />

done in 6813 ms¨<br />

<strong>IMS</strong>RES4 @ SC47:/u/imsres4/dealership/application><br />

Figure 59. Another sample of javac output (part 2 of 2)<br />

96 <strong>IMS</strong> <strong>Version</strong> 7 <strong>and</strong> <strong>Java</strong> <strong>Application</strong> <strong>Programming</strong>


Here is the the BPXBATCH JCL (Figure 60) <strong>and</strong> the shell script (Figure 61),<br />

which we used to compile all the Classes for the Auto Dealership application<br />

individually, as well as the STDERRL DD from the BPXBATCH job sysout<br />

(Figure 62 through Figure 67).<br />

//AUTOJAVA JOB (999,POK),’ITSO <strong>IMS</strong> TEAM’,MSGCLASS=U,CLASS=A,<br />

// NOTIFY=&SYSUID,TIME=1440,REGION=0M<br />

//* ------------------------------------------------------------------<br />

//* EXECUTE SCRIPT<br />

//* ------------------------------------------------------------------<br />

//UXCALL EXEC PGM=BPXBATCH,REGION=0M,<br />

// PARM=’SH /u/imsres4/Dealerjavac.sh.ver3’<br />

//STEPLIB DD DISP=SHR,DSN=CEE.SCEERUN<br />

//STDENV DD DUMMY<br />

//STDIN DD DUMMY<br />

//************************************* THE OUTPUT *********<br />

//STDOUT DD PATH=’/u/imsres4/&SYSUID..autohpj.d080800.eout’,<br />

// PATHOPTS=(OWRONLY,OCREAT,OTRUNC),PATHMODE=SIRWXU<br />

//************************************* THE ERRORS *********<br />

//STDERR DD PATH=’/u/imsres4/&SYSUID..autohpj.d080800.eerr’,<br />

// PATHOPTS=(OWRONLY,OCREAT,OTRUNC),PATHMODE=SIRWXU<br />

//************************************* THE SYSOUT *********<br />

//SYSPRINT DD SYSOUT=*<br />

//* ------------------------------------------------------------------<br />

//* COPY RESULT(HFS) TO SYSOUT<br />

//* ------------------------------------------------------------------<br />

//HFS2PRT EXEC PGM=IKJEFT01,DYNAMNBR=300,COND=EVEN<br />

//SYSTSPRT DD SYSOUT=*<br />

//HFSOUT DD PATH=’/u/imsres4/&SYSUID..autohpj.d080800.eout’<br />

//HFSERR DD PATH=’/u/imsres4/&SYSUID..autohpj.d080800.eerr’<br />

//STDOUTL DD SYSOUT=*,DCB=(RECFM=VB,LRECL=6140,BLKSIZE=0)<br />

//STDERRL DD SYSOUT=*,DCB=(RECFM=VB,LRECL=6140,BLKSIZE=0)<br />

//SYSPRINT DD SYSOUT=*<br />

//SYSTSIN DD *<br />

OCOPY INDD(HFSOUT) OUTDD(STDOUTL)<br />

OCOPY INDD(HFSERR) OUTDD(STDERRL)<br />

/*<br />

//<br />

Figure 60. BPXBATCH JCL that executes shell script<br />

Chapter 6. <strong>IMS</strong>Auto application build <strong>and</strong> execute 97


# ###############################################################<br />

# CREATED:<br />

# ITSO 08/10/00 - javac compile of ITSO AUTO DEALER APPL<br />

# ###############################################################<br />

echo BEGIN Dealerjavac.sh.ver3<br />

cd<br />

cd /u/imsres4<br />

javac dealership/database/*.java -verbose<br />

javac dealership/application/AcceptOrderInput.java -verbose<br />

javac dealership/application/Cancelled.java -verbose<br />

javac dealership/application/CancelOrderInput.java -verbose<br />

javac dealership/application/CarFound.java -verbose<br />

javac dealership/application/DealerDatabaseView.java -verbose<br />

javac dealership/application/ErrorMessage.java -verbose<br />

javac dealership/application/FindACarInput.java -verbose<br />

javac dealership/application/InputMessage.java -verbose<br />

javac dealership/application/ListModelsInput.java -verbose<br />

javac dealership/application/ModelDetails.java -verbose<br />

javac dealership/application/ModelList.java -verbose<br />

javac dealership/application/OrderAccepted.java -verbose<br />

javac dealership/application/OutputMessage.java -verbose<br />

javac dealership/application/RecordASaleInput.java -verbose<br />

javac dealership/application/SalesRecord.java -verbose<br />

javac dealership/application/ShowModelDetailsInput.java -verbose<br />

javac dealership/application/<strong>IMS</strong>Auto.java -verbose<br />

echo END Dealerjavac.sh.ver3<br />

# ##########################################################<br />

# #### FOLLOWING javac COMPILE ORDER WILL NOT WORK<br />

# #### database/*.java MUST BE COMPILED FIRST<br />

# #### application/*.java MUST BE COMPILED SECOND<br />

# #### <strong>IMS</strong>Auto.java HAS TO BE COMPILED LAST TO WORK<br />

# ##########################################################<br />

# javac dealership/database/*.java -verbose<br />

# javac dealership/application/*.java -verbose<br />

Figure 61. Shell script to compile the auto dealer program<br />

98 <strong>IMS</strong> <strong>Version</strong> 7 <strong>and</strong> <strong>Java</strong> <strong>Application</strong> <strong>Programming</strong>


java version “1.1.8”<br />

hpjava version “VisualAge 2.0 CL4.1 - May 26 2000”<br />

parsed dealership/database/Dealer.java in 221 ms<br />

parsed dealership/database/Model.java in 18 ms<br />

parsed dealership/database/Order.java in 18 ms<br />

parsed dealership/database/Sales.java in 15 ms<br />

parsed dealership/database/Salesperson.java in 12 ms<br />

parsed dealership/database/Stock.java in 14 ms<br />

loaded /usr/lpp/ims/imsjava71/classes.zip(com/ibm/ims/db/DLISegment.class) in 43 ms<br />

loaded /usr/lpp/ims/imsjava71/classes.zip(com/ibm/ims/base/DLIBaseSegment.class) in 121 ms<br />

loaded /usr/lpp/java18i/J1.1/lib/classes.zip(java/lang/Object.class) in 11 ms<br />

checking class dealership.database.Dealer<br />

loaded /usr/lpp/java18i/J1.1/lib/classes.zip(java/lang/Cloneable.class) in 3 ms<br />

loaded /usr/lpp/ims/imsjava71/classes.zip(com/ibm/ims/base/DLITypeInfo.class) in 21 ms<br />

wrote dealership/database/Dealer.class<br />

checking class dealership.database.Model<br />

wrote dealership/database/Model.class<br />

checking class dealership.database.Order<br />

wrote dealership/database/Order.class<br />

checking class dealership.database.Sales<br />

wrote dealership/database/Sales.class<br />

checking class dealership.database.Salesperson<br />

wrote dealership/database/Salesperson.class<br />

checking class dealership.database.Stock<br />

wrote dealership/database/Stock.class<br />

done in 2952 ms<br />

parsed dealership/application/AcceptOrderInput.java in 216 ms<br />

loaded /usr/lpp/ims/imsjava71/classes.zip(com/ibm/ims/application/<strong>IMS</strong>FieldMessage.class) in 48 ms<br />

loaded /usr/lpp/ims/imsjava71/classes.zip(com/ibm/ims/base/DLIBaseSegment.class) in 129 ms<br />

loaded /usr/lpp/java18i/J1.1/lib/classes.zip(java/lang/Object.class) in 11 ms<br />

checking class dealership.application.AcceptOrderInput<br />

loaded /usr/lpp/java18i/J1.1/lib/classes.zip(java/lang/Cloneable.class) in 4 ms<br />

loaded /usr/lpp/ims/imsjava71/classes.zip(com/ibm/ims/base/DLITypeInfo.class) in 19 ms<br />

loaded ./dealership/application/InputMessage.class in 14 ms<br />

wrote dealership/application/AcceptOrderInput.class<br />

done in 2041 ms<br />

parsed dealership/application/Cancelled.java in 224 ms<br />

loaded /usr/lpp/ims/imsjava71/classes.zip(com/ibm/ims/application/<strong>IMS</strong>FieldMessage.class) in 46 ms<br />

loaded /usr/lpp/ims/imsjava71/classes.zip(com/ibm/ims/base/DLIBaseSegment.class) in 139 ms<br />

loaded /usr/lpp/java18i/J1.1/lib/classes.zip(java/lang/Object.class) in 11 ms<br />

checking class dealership.application.Cancelled<br />

loaded /usr/lpp/java18i/J1.1/lib/classes.zip(java/lang/Cloneable.class) in 3 ms<br />

loaded /usr/lpp/ims/imsjava71/classes.zip(com/ibm/ims/base/DLITypeInfo.class) in 58 ms<br />

loaded /usr/lpp/java18i/J1.1/lib/classes.zip(java/lang/IllegalArgumentException.class) in 4 ms<br />

loaded /usr/lpp/java18i/J1.1/lib/classes.zip(java/lang/RuntimeException.class) in 3 ms<br />

loaded /usr/lpp/java18i/J1.1/lib/classes.zip(java/lang/Exception.class) in 5 ms<br />

loaded /usr/lpp/java18i/J1.1/lib/classes.zip(java/lang/Throwable.class) in 11 ms<br />

wrote dealership/application/Cancelled.class<br />

done in 2178 ms<br />

parsed dealership/application/CancelOrderInput.java in 231 ms<br />

loaded /usr/lpp/ims/imsjava71/classes.zip(com/ibm/ims/application/<strong>IMS</strong>FieldMessage.class) in 47 ms<br />

Figure 62. STDERRL DD SYSOUT from BPXBATCH job (part 1 of 6)<br />

Chapter 6. <strong>IMS</strong>Auto application build <strong>and</strong> execute 99


loaded /usr/lpp/ims/imsjava71/classes.zip(com/ibm/ims/base/DLIBaseSegment.class) in 123 ms<br />

loaded /usr/lpp/java18i/J1.1/lib/classes.zip(java/lang/Object.class) in 11 ms<br />

checking class dealership.application.CancelOrderInput<br />

loaded /usr/lpp/java18i/J1.1/lib/classes.zip(java/lang/Cloneable.class) in 37 ms<br />

loaded /usr/lpp/ims/imsjava71/classes.zip(com/ibm/ims/base/DLITypeInfo.class) in 23 ms<br />

loaded ./dealership/application/InputMessage.class in 3 ms<br />

wrote dealership/application/CancelOrderInput.class<br />

done in 2024 ms<br />

parsed dealership/application/CarFound.java in 227 ms<br />

loaded /usr/lpp/ims/imsjava71/classes.zip(com/ibm/ims/application/<strong>IMS</strong>FieldMessage.class) in 52 ms<br />

loaded /usr/lpp/ims/imsjava71/classes.zip(com/ibm/ims/base/DLIBaseSegment.class) in 133 ms<br />

loaded /usr/lpp/java18i/J1.1/lib/classes.zip(java/lang/Object.class) in 11 ms<br />

checking class dealership.application.CarFound<br />

loaded /usr/lpp/java18i/J1.1/lib/classes.zip(java/lang/Cloneable.class) in 4 ms<br />

loaded /usr/lpp/ims/imsjava71/classes.zip(com/ibm/ims/base/DLITypeInfo.class) in 21 ms<br />

loaded /usr/lpp/ims/imsjava71/classes.zip(com/ibm/ims/base/DLITypeInfoList.class) in 4 ms<br />

loaded /usr/lpp/java18i/J1.1/lib/classes.zip(java/lang/IllegalArgumentException.class) in 4 ms<br />

loaded /usr/lpp/java18i/J1.1/lib/classes.zip(java/lang/RuntimeException.class) in 3 ms<br />

loaded /usr/lpp/java18i/J1.1/lib/classes.zip(java/lang/Exception.class) in 5 ms<br />

loaded /usr/lpp/java18i/J1.1/lib/classes.zip(java/lang/Throwable.class) in 10 ms<br />

wrote dealership/application/CarFound.class<br />

done in 2076 ms<br />

parsed dealership/application/DealerDatabaseView.java in 223 ms<br />

loaded /usr/lpp/ims/imsjava71/classes.zip(com/ibm/ims/db/DLIDatabaseView.class) in 42 ms<br />

loaded /usr/lpp/java18i/J1.1/lib/classes.zip(java/lang/Object.class) in 11 ms<br />

checking class dealership.application.DealerDatabaseView<br />

loaded /usr/lpp/ims/imsjava71/classes.zip(com/ibm/ims/db/DLISegmentInfo.class) in 5 ms<br />

loaded ./dealership/database/Dealer.class in 5 ms<br />

loaded /usr/lpp/ims/imsjava71/classes.zip(com/ibm/ims/db/DLISegment.class) in 19 ms<br />

loaded /usr/lpp/ims/imsjava71/classes.zip(com/ibm/ims/base/DLIBaseSegment.class) in 161 ms<br />

loaded ./dealership/database/Model.class in 4 ms<br />

loaded ./dealership/database/Order.class in 4 ms<br />

loaded ./dealership/database/Sales.class in 4 ms<br />

loaded ./dealership/database/Stock.class in 5 ms<br />

wrote dealership/application/DealerDatabaseView.class<br />

done in 2081 ms<br />

parsed dealership/application/ErrorMessage.java in 216 ms<br />

loaded /usr/lpp/ims/imsjava71/classes.zip(com/ibm/ims/application/<strong>IMS</strong>FieldMessage.class) in 47 ms<br />

loaded /usr/lpp/ims/imsjava71/classes.zip(com/ibm/ims/base/DLIBaseSegment.class) in 176 ms<br />

loaded /usr/lpp/java18i/J1.1/lib/classes.zip(java/lang/Object.class) in 11 ms<br />

checking class dealership.application.ErrorMessage<br />

loaded /usr/lpp/java18i/J1.1/lib/classes.zip(java/lang/Cloneable.class) in 4 ms<br />

loaded /usr/lpp/ims/imsjava71/classes.zip(com/ibm/ims/base/DLITypeInfo.class) in 21 ms<br />

loaded /usr/lpp/java18i/J1.1/lib/classes.zip(java/lang/IllegalArgumentException.class) in 4 ms<br />

loaded /usr/lpp/java18i/J1.1/lib/classes.zip(java/lang/RuntimeException.class) in 5 ms<br />

loaded /usr/lpp/java18i/J1.1/lib/classes.zip(java/lang/Exception.class) in 5 ms<br />

loaded /usr/lpp/java18i/J1.1/lib/classes.zip(java/lang/Throwable.class) in 11 ms<br />

wrote dealership/application/ErrorMessage.class<br />

done in 2028 ms<br />

parsed dealership/application/FindACarInput.java in 228 ms<br />

loaded /usr/lpp/ims/imsjava71/classes.zip(com/ibm/ims/application/<strong>IMS</strong>FieldMessage.class) in 48 ms<br />

loaded /usr/lpp/ims/imsjava71/classes.zip(com/ibm/ims/base/DLIBaseSegment.class) in 155 ms<br />

loaded /usr/lpp/java18i/J1.1/lib/classes.zip(java/lang/Object.class) in 10 ms<br />

checking class dealership.application.FindACarInput<br />

Figure 63. STDERRL DD SYSOUT from BPXBATCH job (part 2 of 6)<br />

100 <strong>IMS</strong> <strong>Version</strong> 7 <strong>and</strong> <strong>Java</strong> <strong>Application</strong> <strong>Programming</strong>


checking class dealership.application.FindACarInput<br />

loaded /usr/lpp/java18i/J1.1/lib/classes.zip(java/lang/Cloneable.class) in 3 ms<br />

loaded /usr/lpp/ims/imsjava71/classes.zip(com/ibm/ims/base/DLITypeInfo.class) in 20 ms<br />

loaded ./dealership/application/InputMessage.class in 4 ms<br />

wrote dealership/application/FindACarInput.class<br />

done in 2022 ms<br />

parsed dealership/application/InputMessage.java in 221 ms<br />

loaded /usr/lpp/ims/imsjava71/classes.zip(com/ibm/ims/application/<strong>IMS</strong>FieldMessage.class) in 47 ms<br />

loaded /usr/lpp/ims/imsjava71/classes.zip(com/ibm/ims/base/DLIBaseSegment.class) in 161 ms<br />

loaded /usr/lpp/java18i/J1.1/lib/classes.zip(java/lang/Object.class) in 10 ms<br />

checking class dealership.application.InputMessage<br />

loaded /usr/lpp/java18i/J1.1/lib/classes.zip(java/lang/Cloneable.class) in 3 ms<br />

loaded /usr/lpp/ims/imsjava71/classes.zip(com/ibm/ims/base/DLITypeInfo.class) in 20 ms<br />

loaded /usr/lpp/java18i/J1.1/lib/classes.zip(java/lang/IllegalArgumentException.class) in 3 ms<br />

loaded /usr/lpp/java18i/J1.1/lib/classes.zip(java/lang/RuntimeException.class) in 4 ms<br />

loaded /usr/lpp/java18i/J1.1/lib/classes.zip(java/lang/Exception.class) in 5 ms<br />

loaded /usr/lpp/java18i/J1.1/lib/classes.zip(java/lang/Throwable.class) in 10 ms<br />

wrote dealership/application/InputMessage.class]<br />

done in 2029 ms<br />

parsed dealership/application/ListModelsInput.java in 217 ms<br />

loaded /usr/lpp/ims/imsjava71/classes.zip(com/ibm/ims/application/<strong>IMS</strong>FieldMessage.class) in 47 ms<br />

loaded /usr/lpp/ims/imsjava71/classes.zip(com/ibm/ims/base/DLIBaseSegment.class) in 195 ms<br />

loaded /usr/lpp/java18i/J1.1/lib/classes.zip(java/lang/Object.class) in 11 ms<br />

checking class dealership.application.ListModelsInput<br />

loaded /usr/lpp/java18i/J1.1/lib/classes.zip(java/lang/Cloneable.class) in 3 ms<br />

loaded /usr/lpp/ims/imsjava71/classes.zip(com/ibm/ims/base/DLITypeInfo.class) in 20 ms<br />

loaded ./dealership/application/InputMessage.class in 4 ms<br />

wrote dealership/application/ListModelsInput.class<br />

done in 2072 ms<br />

parsed dealership/application/ModelDetails.java in 224 ms<br />

loaded /usr/lpp/ims/imsjava71/classes.zip(com/ibm/ims/application/<strong>IMS</strong>FieldMessage.class) in 47 ms<br />

loaded /usr/lpp/ims/imsjava71/classes.zip(com/ibm/ims/base/DLIBaseSegment.class) in 172 ms<br />

loaded /usr/lpp/java18i/J1.1/lib/classes.zip(java/lang/Object.class) in 11 ms<br />

checking class dealership.application.ModelDetails<br />

loaded /usr/lpp/java18i/J1.1/lib/classes.zip(java/lang/Cloneable.class) in 5 ms<br />

loaded /usr/lpp/ims/imsjava71/classes.zip(com/ibm/ims/base/DLITypeInfo.class) in 20 ms<br />

loaded /usr/lpp/java18i/J1.1/lib/classes.zip(java/lang/IllegalArgumentException.class) in 4 ms<br />

loaded /usr/lpp/java18i/J1.1/lib/classes.zip(java/lang/RuntimeException.class) in 3 ms<br />

loaded /usr/lpp/java18i/J1.1/lib/classes.zip(java/lang/Exception.class) in 5 ms<br />

loaded /usr/lpp/java18i/J1.1/lib/classes.zip(java/lang/Throwable.class) in 10 ms<br />

wrote dealership/application/ModelDetails.class<br />

done in 2059 ms<br />

parsed dealership/application/ModelList.java in 293 ms<br />

loaded /usr/lpp/ims/imsjava71/classes.zip(com/ibm/ims/application/<strong>IMS</strong>FieldMessage.class) in 72 ms<br />

loaded /usr/lpp/ims/imsjava71/classes.zip(com/ibm/ims/base/DLIBaseSegment.class) in 151 ms<br />

loaded /usr/lpp/java18i/J1.1/lib/classes.zip(java/lang/Object.class) in 13 ms<br />

checking class dealership.application.ModelList<br />

loaded /usr/lpp/java18i/J1.1/lib/classes.zip(java/lang/Cloneable.class) in 4 ms<br />

loaded /usr/lpp/ims/imsjava71/classes.zip(com/ibm/ims/base/DLITypeInfo.class) in 27 ms<br />

loaded /usr/lpp/ims/imsjava71/classes.zip(com/ibm/ims/base/DLITypeInfoList.class) in 7 ms<br />

loaded /usr/lpp/java18i/J1.1/lib/classes.zip(java/lang/IllegalArgumentException.class) in 5 ms<br />

Figure 64. STDERRL DD SYSOUT from BPXBATCH job (part 3 of 6)<br />

Chapter 6. <strong>IMS</strong>Auto application build <strong>and</strong> execute 101


loaded /usr/lpp/java18i/J1.1/lib/classes.zip(java/lang/RuntimeException.class) in 7 ms<br />

loaded /usr/lpp/java18i/J1.1/lib/classes.zip(java/lang/Exception.class) in 6 ms<br />

loaded /usr/lpp/java18i/J1.1/lib/classes.zip(java/lang/Throwable.class) in 14 ms<br />

wrote dealership/application/ModelList.class<br />

done in 3120 ms<br />

parsed dealership/application/OrderAccepted.java in 214 ms<br />

loaded /usr/lpp/ims/imsjava71/classes.zip(com/ibm/ims/application/<strong>IMS</strong>FieldMessage.class) in 86 ms<br />

loaded /usr/lpp/ims/imsjava71/classes.zip(com/ibm/ims/base/DLIBaseSegment.class) in 125 ms<br />

loaded /usr/lpp/java18i/J1.1/lib/classes.zip(java/lang/Object.class) in 12 ms<br />

checking class dealership.application.OrderAccepted<br />

loaded /usr/lpp/java18i/J1.1/lib/classes.zip(java/lang/Cloneable.class) in 4 ms<br />

loaded /usr/lpp/ims/imsjava71/classes.zip(com/ibm/ims/base/DLITypeInfo.class) in 20 ms<br />

loaded /usr/lpp/java18i/J1.1/lib/classes.zip(java/lang/IllegalArgumentException.class) in 4 ms<br />

loaded /usr/lpp/java18i/J1.1/lib/classes.zip(java/lang/RuntimeException.class) in 4 ms<br />

loaded /usr/lpp/java18i/J1.1/lib/classes.zip(java/lang/Exception.class) in 5 ms<br />

loaded /usr/lpp/java18i/J1.1/lib/classes.zip(java/lang/Throwable.class) in 9 ms<br />

wrote dealership/application/OrderAccepted.class<br />

done in 2027 ms<br />

parsed dealership/application/OutputMessage.java in 239 ms<br />

loaded /usr/lpp/ims/imsjava71/classes.zip(com/ibm/ims/application/<strong>IMS</strong>FieldMessage.class) in 100 ms<br />

loaded /usr/lpp/ims/imsjava71/classes.zip(com/ibm/ims/base/DLIBaseSegment.class) in 130 ms<br />

loaded /usr/lpp/java18i/J1.1/lib/classes.zip(java/lang/Object.class) in 11 ms<br />

checking class dealership.application.OutputMessage<br />

loaded /usr/lpp/java18i/J1.1/lib/classes.zip(java/lang/Cloneable.class) in 3 ms<br />

loaded /usr/lpp/ims/imsjava71/classes.zip(com/ibm/ims/base/DLITypeInfo.class) in 20 ms<br />

loaded /usr/lpp/java18i/J1.1/lib/classes.zip(java/lang/IllegalArgumentException.class) in 4 ms<br />

loaded /usr/lpp/java18i/J1.1/lib/classes.zip(java/lang/RuntimeException.class) in 4 ms<br />

loaded /usr/lpp/java18i/J1.1/lib/classes.zip(java/lang/Exception.class) in 4 ms<br />

loaded /usr/lpp/java18i/J1.1/lib/classes.zip(java/lang/Throwable.class) in 10 ms<br />

wrote dealership/application/OutputMessage.class<br />

done in 2135 ms<br />

parsed dealership/application/RecordASaleInput.java in 232 ms<br />

loaded /usr/lpp/ims/imsjava71/classes.zip(com/ibm/ims/application/<strong>IMS</strong>FieldMessage.class) in 50 ms<br />

loaded /usr/lpp/ims/imsjava71/classes.zip(com/ibm/ims/base/DLIBaseSegment.class) in 124 ms<br />

loaded /usr/lpp/java18i/J1.1/lib/classes.zip(java/lang/Object.class) in 13 ms<br />

checking class dealership.application.RecordASaleInput<br />

loaded /usr/lpp/java18i/J1.1/lib/classes.zip(java/lang/Cloneable.class) in 3 ms<br />

loaded /usr/lpp/ims/imsjava71/classes.zip(com/ibm/ims/base/DLITypeInfo.class) in 20 ms<br />

loaded ./dealership/application/InputMessage.class in 4 ms<br />

wrote dealership/application/RecordASaleInput.class<br />

done in 2096 ms<br />

parsed dealership/application/SalesRecord.java in 216 ms<br />

loaded /usr/lpp/ims/imsjava71/classes.zip(com/ibm/ims/application/<strong>IMS</strong>FieldMessage.class) in 47 ms<br />

loaded /usr/lpp/ims/imsjava71/classes.zip(com/ibm/ims/base/DLIBaseSegment.class) in 125 ms<br />

loaded /usr/lpp/java18i/J1.1/lib/classes.zip(java/lang/Object.class) in 11 ms<br />

checking class dealership.application.SalesRecord<br />

loaded /usr/lpp/java18i/J1.1/lib/classes.zip(java/lang/Cloneable.class) in 4 ms<br />

loaded /usr/lpp/ims/imsjava71/classes.zip(com/ibm/ims/base/DLITypeInfo.class) in 20 ms<br />

loaded /usr/lpp/java18i/J1.1/lib/classes.zip(java/lang/IllegalArgumentException.class) in 4 ms<br />

loaded /usr/lpp/java18i/J1.1/lib/classes.zip(java/lang/RuntimeException.class) in 4 ms<br />

loaded /usr/lpp/java18i/J1.1/lib/classes.zip(java/lang/Exception.class) in 5 ms<br />

loaded /usr/lpp/java18i/J1.1/lib/classes.zip(java/lang/Throwable.class) in 11 ms<br />

Figure 65. STDERRL DD SYSOUT from BPXBATCH job (part 4 of 6)<br />

102 <strong>IMS</strong> <strong>Version</strong> 7 <strong>and</strong> <strong>Java</strong> <strong>Application</strong> <strong>Programming</strong>


wrote dealership/application/SalesRecord.class<br />

done in 2104 ms<br />

parsed dealership/application/ShowModelDetailsInput.java in 229 ms<br />

loaded /usr/lpp/ims/imsjava71/classes.zip(com/ibm/ims/application/<strong>IMS</strong>FieldMessage.class) in 48 ms<br />

loaded /usr/lpp/ims/imsjava71/classes.zip(com/ibm/ims/base/DLIBaseSegment.class) in 125 ms<br />

loaded /usr/lpp/java18i/J1.1/lib/classes.zip(java/lang/Object.class) in 11 ms<br />

checking class dealership.application.ShowModelDetailsInput<br />

loaded /usr/lpp/java18i/J1.1/lib/classes.zip(java/lang/Cloneable.class) in 3 ms<br />

loaded /usr/lpp/ims/imsjava71/classes.zip(com/ibm/ims/base/DLITypeInfo.class) in 22 ms<br />

loaded ./dealership/application/InputMessage.class in 4 ms<br />

wrote dealership/application/ShowModelDetailsInput.class<br />

done in 2021 ms<br />

parsed dealership/application/<strong>IMS</strong>Auto.java in 696 ms<br />

loaded /usr/lpp/ims/imsjava71/classes.zip(com/ibm/ims/application/<strong>IMS</strong><strong>Application</strong>.class) in 45 ms<br />

loaded /usr/lpp/java18i/J1.1/lib/classes.zip(java/lang/Object.class) in 11 ms<br />

checking class dealership.application.<strong>IMS</strong>Auto<br />

loaded /usr/lpp/ims/imsjava71/classes.zip(com/ibm/ims/base/<strong>IMS</strong>Exception.class) in 11 ms<br />

loaded /usr/lpp/java18i/J1.1/lib/classes.zip(java/io/FileWriter.class) in 7 ms<br />

loaded /usr/lpp/java18i/J1.1/lib/classes.zip(java/io/OutputStreamWriter.class) in 20 ms<br />

loaded /usr/lpp/java18i/J1.1/lib/classes.zip(java/io/Writer.class) in 6 ms<br />

loaded /usr/lpp/java18i/J1.1/lib/classes.zip(java/lang/String.class) in 73 ms<br />

loaded /usr/lpp/java18i/J1.1/lib/classes.zip(java/io/FileDescriptor.class) in 7 ms<br />

loaded /usr/lpp/java18i/J1.1/lib/classes.zip(java/io/Serializable.class) in 3 ms<br />

loaded /usr/lpp/java18i/J1.1/lib/classes.zip(java/io/File.class) in 25 ms<br />

loaded /usr/lpp/ims/imsjava71/classes.zip(com/ibm/ims/base/<strong>IMS</strong>Trace.class) in 32 ms<br />

loaded /usr/lpp/java18i/J1.1/lib/classes.zip(java/lang/Exception.class) in 5 ms<br />

loaded /usr/lpp/java18i/J1.1/lib/classes.zip(java/lang/System.class) in 25 ms<br />

loaded /usr/lpp/java18i/J1.1/lib/classes.zip(java/lang/Throwable.class) in 9 ms<br />

loaded /usr/lpp/java18i/J1.1/lib/classes.zip(java/lang/Error.class) in 3 ms<br />

loaded /usr/lpp/java18i/J1.1/lib/classes.zip(java/lang/RuntimeException.class) in 3 ms<br />

loaded /usr/lpp/java18i/J1.1/lib/classes.zip(java/io/IOException.class) in 4 ms<br />

loaded /usr/lpp/java18i/J1.1/lib/classes.zip(java/sql/Connection.class) in 12 ms<br />

loaded /usr/lpp/ims/imsjava71/classes.zip(com/ibm/ims/application/<strong>IMS</strong>FieldMessage.class) in 20 ms<br />

loaded ./dealership/application/AcceptOrderInput.class in 4 ms<br />

loaded /usr/lpp/java18i/J1.1/lib/classes.zip(java/io/PrintStream.class) in 17 ms<br />

loaded /usr/lpp/java18i/J1.1/lib/classes.zip(java/io/FilterOutputStream.class) in 6 ms<br />

loaded /usr/lpp/java18i/J1.1/lib/classes.zip(java/io/OutputStream.class) in 5 ms<br />

loaded ./dealership/application/OrderAccepted.class in 4 ms<br />

loaded /usr/lpp/ims/imsjava71/classes.zip(com/ibm/ims/base/DLIBaseSegment.class) in 123 ms]<br />

loaded /usr/lpp/ims/imsjava71/classes.zip(com/ibm/ims/base/DLITypeInfo.class) in 20 ms<br />

loaded /usr/lpp/java18i/J1.1/lib/classes.zip(java/sql/Statement.class) in 9 ms<br />

loaded /usr/lpp/ims/imsjava71/classes.zip(com/ibm/ims/application/<strong>IMS</strong>Transaction.class) in 19 ms<br />

loaded /usr/lpp/java18i/J1.1/lib/classes.zip(java/sql/SQLException.class) in 11 ms<br />

loaded /usr/lpp/ims/imsjava71/classes.zip(com/ibm/ims/base/DLIException.class) in 6 ms<br />

loaded ./dealership/application/CancelOrderInput.class in 5 ms<br />

loaded ./dealership/application/Cancelled.class in 3 ms<br />

loaded /usr/lpp/java18i/J1.1/lib/classes.zip(java/lang/StringBuffer.class) in 23 ms<br />

loaded /usr/lpp/java18i/J1.1/lib/classes.zip(java/lang/Integer.class) in 20 ms<br />

loaded /usr/lpp/java18i/J1.1/lib/classes.zip(java/lang/Number.class) in 6 ms<br />

loaded /usr/lpp/ims/imsjava71/classes.zip(com/ibm/ims/application/<strong>IMS</strong>MessageQueue.class) in 27 ms<br />

loaded ./dealership/application/InputMessage.class in 3 ms<br />

loaded /usr/lpp/java18i/J1.1/lib/classes.zip(java/lang/Class.class) in 32 ms<br />

Figure 66. STDERRL DD SYSOUT from BPXBATCH job (part 5 of 6)<br />

Chapter 6. <strong>IMS</strong>Auto application build <strong>and</strong> execute 103


loaded /usr/lpp/java18i/J1.1/lib/classes.zip(java/sql/DriverManager.class) in 25 ms<br />

loaded /usr/lpp/java18i/J1.1/lib/classes.zip(java/lang/ExceptionInInitializerError.class) in 5 ms<br />

loaded /usr/lpp/java18i/J1.1/lib/classes.zip(java/lang/LinkageError.class) in 4 ms<br />

loaded /usr/lpp/java18i/J1.1/lib/classes.zip(java/lang/ClassNotFoundException.class) in 4 ms<br />

loaded ./dealership/application/FindACarInput.class in 5 ms<br />

loaded ./dealership/application/ShowModelDetailsInput.class in 4 ms<br />

loaded ./dealership/application/RecordASaleInput.class in 4 ms<br />

loaded ./dealership/application/CarFound.class in 5 ms<br />

loaded /usr/lpp/java18i/J1.1/lib/classes.zip(java/sql/ResultSet.class) in 16 ms<br />

loaded ./dealership/application/ModelList.class in 5 ms<br />

loaded ./dealership/application/SalesRecord.class in 3 ms<br />

loaded ./dealership/application/ErrorMessage.class in 4 ms<br />

loaded ./dealership/application/ModelDetails.class in 4 ms<br />

loaded /usr/lpp/java18i/J1.1/lib/classes.zip(java/lang/Cloneable.class) in 3 ms<br />

wrote dealership/application/<strong>IMS</strong>Auto.class<br />

done in 4598 ms<br />

Figure 67. STDERRL DD SYSOUT from BPXBATCH job (part 6 of 6)<br />

6.10.2 The hpj comm<strong>and</strong><br />

The Enterprise ToolKit for OS/390 provides a High Performance <strong>Java</strong><br />

compiler which enables you to build platform-specific <strong>Java</strong> executables <strong>and</strong><br />

DLLs. You can use the hpj comm<strong>and</strong> to bind <strong>Java</strong> bytecode files into a <strong>Java</strong><br />

executable or DLL that runs in the OS/390 UNIX or <strong>IMS</strong>/ESA environment.<br />

The hpj comm<strong>and</strong> has the following syntax:<br />

hpj {[options] inputfiles [options]}...<br />

All comm<strong>and</strong> options begin with a dash (-) <strong>and</strong> can be entered sequentially.<br />

With the exception of the -B option, they must be separated from associated<br />

arguments by a space. The options can appear before, after, or between<br />

input file names. All of the options apply to all input files. If the same option<br />

appears more than once, the last occurrence of the option is used. Appendix<br />

J, “Options for the hpj comm<strong>and</strong>” on page 385 lists the valid options for the<br />

hpj comm<strong>and</strong>:<br />

For a complete list of the hpj comm<strong>and</strong> options, refer to ET/390<br />

documentation.<br />

Note<br />

A new parameter, -target=<strong>IMS</strong> | -target=LE, must be specified to build an<br />

<strong>IMS</strong> <strong>Java</strong> executable or DLL.<br />

Figure 68 illustrates the hpj comm<strong>and</strong> we used to create the Auto Dealership<br />

<strong>IMS</strong>AUTO executable in a PDSE PGMLIB. Note that we specified -target=<strong>IMS</strong><br />

104 <strong>IMS</strong> <strong>Version</strong> 7 <strong>and</strong> <strong>Java</strong> <strong>Application</strong> <strong>Programming</strong>


<strong>and</strong> that the PGMLIB must be a PDSE. The -include was necessary to<br />

resolve the DealerDatabaseView Class, <strong>and</strong> -exclude was used so that the<br />

<strong>IMS</strong> <strong>Java</strong> Library Classes would be dynamically resolved at runtime.<br />

hpj dealership.application.<strong>IMS</strong>Auto \<br />

-main=dealership.application.<strong>IMS</strong>Auto \<br />

-o=”//’<strong>IMS</strong>.SJ<strong>IMS</strong>R.IVP.PGMLIB(<strong>IMS</strong>AUTO)’” -alias=<strong>IMS</strong>AUTO \<br />

-target=<strong>IMS</strong> \<br />

-lerunopts=”ENVAR(CLASSPATH=$<strong>IMS</strong>JAVA:$<strong>IMS</strong>JDLL:$<strong>IMS</strong>CLIB:$<strong>IMS</strong>HPJ”) \<br />

-verbose \<br />

-include=dealership.application.DealerDatabaseView \<br />

-exclude=com.ibm.ims.db.* \<br />

-exclude=com.ibm.ims.application.* \<br />

-exclude=com.ibm.ims.base.*<br />

Figure 68. Example of hpj comm<strong>and</strong><br />

The following types of files are processed by the hpj comm<strong>and</strong>:<br />

6.10.2.1 Input files<br />

All input files must be on HFS except <strong>Java</strong> executables <strong>and</strong> <strong>Java</strong> DLLs. The<br />

executables <strong>and</strong> DLLs can either be on HFS or in a PDSE.<br />

The hpj comm<strong>and</strong> recognizes these types of input files:<br />

Class names (CLASSPATH is used to find the files). For example: hpj<br />

-o=queryEmp Abc.staff.queryDB.queryMain<br />

Partially bound program objects (.o files). For example: hpj -o=queryEmp<br />

abc.staff.queryDB.queryMain.mo abc.staff.queryDB.readDB.o<br />

A <strong>Java</strong> DLL or a <strong>Java</strong> executable specified with the -o option. For<br />

example: hpj -o=queryEmp -classpath=/home/ts123456/app.zip \<br />

-include=abc.staff.queryDB.* \ -partial=abc.staff.queryDB.readDB<br />

JAR files (.jar) containing packages or classes. For example: hpj<br />

-o=queryEmp abcstaff.jar<br />

ZIP files (.zip) containing packages or classes. For example: hpj<br />

-o=queryEmp abcstaff.zip<br />

6.10.2.2 Output files<br />

The hpj comm<strong>and</strong> generates the following output files:<br />

A <strong>Java</strong> executable or <strong>Java</strong> DLL on HFS or in a PDSE member<br />

- A <strong>Java</strong> executable when the -exe option is specified or when neither -jll<br />

nor -exe is specified<br />

- A <strong>Java</strong> DLL when the -jll option is specified<br />

Chapter 6. <strong>IMS</strong>Auto application build <strong>and</strong> execute 105


Note<br />

<strong>Java</strong> executables or DLLs running under <strong>IMS</strong> must reside in PDSE<br />

PGMLIBs. To specify a PDSE data set <strong>and</strong> member name, you must<br />

use the -o option. For <strong>Java</strong> DLLs residing in PDSE members, you must<br />

also use the -alias option to give the member an HFS-like DLL name.<br />

Partially bound program objects (.o, .mo, .ro, .po files) on HFS<br />

- The hpj comm<strong>and</strong> automatically generates .o files. One .o file is<br />

created for each class. The name of the .o file is the class name. These<br />

.o files must be written to HFS. The -collapse <strong>and</strong> -d options can be<br />

used to control the placement of .o Files.<br />

- The .mo file is also automatically generated by the hpj comm<strong>and</strong>. If -jll<br />

is specified, the .mo file is not generated. When the -main option is<br />

specified, a .mo file is generated (in addition to the .o file) for the<br />

specified main class. If -main is not specified <strong>and</strong> the -c option is<br />

specified, a .mo file is generated (in addition to the .o file) for the first<br />

class that contains a main method. The name <strong>and</strong> placement of the<br />

.mo files are the same as those of the .o file for the main class.<br />

- The .ro file is automatically generated by the hpj comm<strong>and</strong> when the<br />

-lerunopts option is specified. One .ro file is generated. You can bind<br />

the .ro file only to a <strong>Java</strong> executable. The name <strong>and</strong> placement of the<br />

.ro file are the same as those of the .o file for the main class.<br />

- The .po file is automatically generated by the hpj comm<strong>and</strong> when the<br />

-resource option is specified. One .po file is generated for all resource<br />

files in the specified ZIP <strong>and</strong> jar files. You can bind the .po file only to a<br />

<strong>Java</strong> executable or DLL that is written to a PDSE member. The .po file<br />

is written to the -d directory (if it is specified) or the current directory.<br />

Listing files (.lst files) on HFS. the hpj comm<strong>and</strong> generates .lst files<br />

when the -list <strong>and</strong>/or -inlrpt options are specified. One file is generated for<br />

each class. The name of the .lst file is the class name. These .lst files are<br />

written to the same HFS directories as the corresponding .o files.<br />

A binder map (.map file) on HFS. A map file is always generated unless<br />

both -BNOLIST <strong>and</strong> -BXREF(NO) are specified. The file is written to the<br />

same location as the <strong>Java</strong> executable or DLL. However, if the <strong>Java</strong><br />

executable or DLL is written to a PDSE member, the .map file is written to<br />

the current directory.<br />

.syslin file. The .syslin file contains the list of program objects that are<br />

bound in <strong>Java</strong> executable or DLL. It is generated when the -verbose option<br />

106 <strong>IMS</strong> <strong>Version</strong> 7 <strong>and</strong> <strong>Java</strong> <strong>Application</strong> <strong>Programming</strong>


is specified. The file is written to the same location as the <strong>Java</strong> executable<br />

or DLL. However, if the <strong>Java</strong> executable or DLL is written to a PDSE<br />

member, the .syslin file is written to the current directory.<br />

Error messages. The error messages are sent to stderr.<br />

6.11 Example of “nonvisual” application development<br />

In this section we explain the steps to follow to modify an <strong>IMS</strong> <strong>Java</strong> program<br />

<strong>and</strong> get it running.<br />

1. Edit the source file on the HFS<br />

We started with a sample IVP application distributed in HFS directory<br />

/usr/lpp/ims/imsjava71/sample/ivp. (See Appendix E to view the source<br />

code for the programs.) We used the ISHELL “C” action code to copy each<br />

of the <strong>Java</strong> programs to our own HFS directory, /u/imsres4/samples/ivp/.<br />

Then we edited the source code using the ISHELL “E” action code. We<br />

added several System.out.println display instructions <strong>and</strong> nothing more.<br />

Note<br />

Note that you can import <strong>Java</strong> code from a workstation to an HFS<br />

directory using FTP. Be aware that the source <strong>Java</strong> file names are case<br />

sensitive!<br />

2. Compile <strong>and</strong> link<br />

To quickly compile the <strong>Java</strong> programs, we executed the javac comm<strong>and</strong><br />

under the OMVS shell (see Figure 69).<br />

Chapter 6. <strong>IMS</strong>Auto application build <strong>and</strong> execute 107


<strong>IMS</strong>RES4 @ SC47:/u/imsres4/samples/ivp>javac *.java -verbose<br />

parsed IVP.java in 483 ms¨<br />

parsed IVPDatabaseView.java in 22 ms¨<br />

parsed InputMessage.java in 63 ms¨<br />

parsed OutputMessage.java in 20 ms¨<br />

parsed PhoneBookSegment.java in 25 ms¨<br />

parsed SPAMessage.java in 29 ms¨<br />

loaded /usr/lpp/ims/imsjava71/classes.zip(com/ibm/ims/application/<strong>IMS</strong><strong>Application</strong>.class) in 46 ms¨<br />

loaded /usr/lpp/java18i/J1.1/lib/classes.zip(java/lang/Object.class) in 13 ms¨<br />

loaded /usr/lpp/ims/imsjava71/classes.zip(com/ibm/ims/db/DLIDatabaseView.class) in 16 ms¨ loaded<br />

/usr/lpp/ims/imsjava71/classes.zip(com/ibm/ims/application/<strong>IMS</strong>FieldMessage.class) in 22 ms¨<br />

loaded /usr/lpp/ims/imsjava71/classes.zip(com/ibm/ims/base/DLIBaseSegment.class) in 119 ms¨ loaded<br />

/usr/lpp/ims/imsjava71/classes.zip(com/ibm/ims/db/DLISegment.class)in16ms¨ checkingclasssamples.ivp.IVP¨<br />

loaded /usr/lpp/ims/imsjava71/classes.zip(com/ibm/ims/base/<strong>IMS</strong>Exception.class) in 10 ms¨ loaded<br />

/usr/lpp/ims/imsjava71/classes.zip(com/ibm/ims/application/<strong>IMS</strong>MessageQueue.class) in 22 ms¨<br />

loaded /usr/lpp/ims/imsjava71/classes.zip(com/ibm/ims/db/DLIConnection.class) in 25 ms¨ loaded<br />

/usr/lpp/java18i/J1.1/lib/classes.zip(java/lang/Exception.class) in 5 ms¨ loaded<br />

/usr/lpp/ims/imsjava71/classes.zip(com/ibm/ims/db/SSA.class) in 38 ms¨<br />

loaded /usr/lpp/ims/imsjava71/classes.zip(com/ibm/ims/db/SSAList.class) in 24 ms¨ loaded<br />

/usr/lpp/java18i/J1.1/lib/classes.zip(java/lang/String.class) in 73 ms¨<br />

loaded /usr/lpp/ims/imsjava71/classes.zip(com/ibm/ims/base/DLITypeInfo.class) in 20 ms¨ loaded<br />

/usr/lpp/java18i/J1.1/lib/classes.zip(java/io/Serializable.class) in 3 ms¨ loaded<br />

/usr/lpp/java18i/J1.1/lib/classes.zip(java/lang/Throwable.class) in 10 ms¨ loaded<br />

/usr/lpp/java18i/J1.1/lib/classes.zip(java/lang/Error.class) in 4 ms¨<br />

loaded /usr/lpp/java18i/J1.1/lib/classes.zip(java/lang/RuntimeException.class) in 6 ms¨ loaded<br />

/usr/lpp/ims/imsjava71/classes.zip(com/ibm/ims/base/DLIException.class) in 5 ms¨ loaded<br />

/usr/lpp/java18i/J1.1/lib/classes.zip(java/lang/Cloneable.class) in 3 ms¨ loaded<br />

/usr/lpp/ims/imsjava71/classes.zip(com/ibm/ims/base/<strong>Java</strong>ToDLI.class) in 124 ms¨ loaded<br />

/usr/lpp/ims/imsjava71/classes.zip(com/ibm/ims/application/<strong>IMS</strong>Transaction.class) in 19 ms¨<br />

loaded/usr/lpp/java18i/J1.1/lib/classes.zip(java/lang/StringBuffer.class)in23ms¨ wroteIVP.class¨<br />

checking class samples.ivp.IVPDatabaseView¨<br />

loaded /usr/lpp/ims/imsjava71/classes.zip(com/ibm/ims/db/DLISegmentInfo.class) in 4 ms¨ wrote<br />

IVPDatabaseView.class¨<br />

checking class samples.ivp.InputMessage¨<br />

loaded /usr/lpp/java18i/J1.1/lib/classes.zip(java/lang/IllegalArgumentException.class) in 4 ms¨<br />

wrote InputMessage.class¨<br />

checking class samples.ivp.OutputMessage¨<br />

wrote OutputMessage.class¨<br />

checking class samples.ivp.PhoneBookSegment¨<br />

wrote PhoneBookSegment.class¨<br />

checking class samples.ivp.SPAMessage¨<br />

wrote SPAMessage.class¨<br />

done in 3733 ms¨<br />

<strong>IMS</strong>RES4 @ SC47:/u/imsres4/samples/ivp><br />

Figure 69. javac compile <strong>and</strong> link<br />

108 <strong>IMS</strong> <strong>Version</strong> 7 <strong>and</strong> <strong>Java</strong> <strong>Application</strong> <strong>Programming</strong>


To bind the programs, we used a BPXBATCH job (see Figure 70) to<br />

execute a shell script (see Figure 71). The shell script does the hpj<br />

compile <strong>and</strong> bind for the IVP application.<br />

//IVPHPJ JOB (999,POK),’ITSO <strong>IMS</strong> TEAM’,MSGCLASS=U,CLASS=A,<br />

// NOTIFY=&SYSUID,TIME=1440,REGION=0M<br />

//* ------------------------------------------------------------------<br />

//* EXECUTE SCRIPT<br />

//* ------------------------------------------------------------------<br />

//UXCALL EXEC PGM=BPXBATCH,REGION=0M,<br />

// PARM=’SH /u/imsres4/IVPhpj.sh.ver1’<br />

//STEPLIB DD DISP=SHR,DSN=CEE.SCEERUN<br />

//STDENV DD DUMMY<br />

//STDIN DD DUMMY<br />

//************************************* THE OUTPUT *********<br />

//STDOUT DD PATH=’/u/imsres4/&SYSUID..IVPhpj.a090100.eout’,<br />

// PATHOPTS=(OWRONLY,OCREAT,OTRUNC),PATHMODE=SIRWXU<br />

//************************************* THE ERRORS *********<br />

//STDERR DD PATH=’/u/imsres4/&SYSUID..IVPhpj.a090100.eerr’,<br />

// PATHOPTS=(OWRONLY,OCREAT,OTRUNC),PATHMODE=SIRWXU<br />

//************************************* THE SYSOUT *********<br />

//SYSPRINT DD SYSOUT=*<br />

//* ------------------------------------------------------------------<br />

//* COPY RESULT(HFS) TO SYSOUT<br />

//* ------------------------------------------------------------------<br />

//HFS2PRT EXEC PGM=IKJEFT01,DYNAMNBR=300,COND=EVEN<br />

//SYSTSPRT DD SYSOUT=*<br />

//HFSOUT DD PATH=’/u/imsres4/&SYSUID..IVPhpj.a090100.eout’<br />

//HFSERR DD PATH=’/u/imsres4/&SYSUID..IVPhpj.a090100.eerr’<br />

//STDOUTL DD SYSOUT=*,DCB=(RECFM=VB,LRECL=6140,BLKSIZE=0)<br />

//STDERRL DD SYSOUT=*,DCB=(RECFM=VB,LRECL=6140,BLKSIZE=0)<br />

//SYSPRINT DD SYSOUT=*<br />

//SYSTSIN DD *<br />

OCOPY INDD(HFSOUT) OUTDD(STDOUTL)<br />

OCOPY INDD(HFSERR) OUTDD(STDERRL)<br />

/*<br />

//<br />

Figure 70. BPXBATCH job<br />

Chapter 6. <strong>IMS</strong>Auto application build <strong>and</strong> execute 109


# ##################################################################<br />

# CREATED:<br />

# ITSO 8/20/00 - execute the HPJ binder for the IVP APPL<br />

# ##################################################################<br />

echo BEGIN IVPhpj.sh.ver1<br />

date<br />

cd<br />

cd u/imsres4<br />

. profile.imsjava<br />

. profile.imsres4<br />

cd<br />

cd usr/lpp/hpj/bin<br />

. profile.hpj<br />

#<br />

export <strong>IMS</strong>JAVA=/usr/lpp/ims/imsjava71<br />

export <strong>IMS</strong>JDLL=/usr/lpp/ims/imsjava71/imsjava.jll<br />

export <strong>IMS</strong>CLIB=/usr/lpp/ims/imsjava71/libJavTDLI.dll<br />

export <strong>IMS</strong>HPJ=/usr/lpp/hpj/lib<br />

export PATH=$PATH:/usr/lpp/hpj/bin<br />

echo <strong>IMS</strong>JAVA : $<strong>IMS</strong>JAVA<br />

echo <strong>IMS</strong>JDLL : $<strong>IMS</strong>JDLL<br />

echo <strong>IMS</strong>CLIB : $<strong>IMS</strong>CLIB<br />

echo <strong>IMS</strong>HPJ : $<strong>IMS</strong>HPJ<br />

echo PATH : $PATH<br />

#<br />

cd<br />

cd /u/imsres4/<br />

hpj samples.ivp.IVP \<br />

-main=samples.ivp.IVP \<br />

-o=”//’<strong>IMS</strong>.SJ<strong>IMS</strong>R.IVP.PGMLIB(DFSIVP32)’” -alias=DFSIVP32 \<br />

-target=<strong>IMS</strong> \<br />

-lerunopts=”ENVAR(CLASSPATH=$<strong>IMS</strong>JAVA:$<strong>IMS</strong>JDLL:$<strong>IMS</strong>CLIB:$<strong>IMS</strong>HPJ)” \<br />

-verbose \<br />

-exclude=com.ibm.ims.db.* \<br />

-exclude=com.ibm.ims.application.* \<br />

-exclude=com.ibm.ims.base.*<br />

#<br />

date<br />

echo END IVPhpj.sh.ver1<br />

Figure 71. Shell Script to hpj compile <strong>and</strong> bind the IVP application<br />

Note that before the hpj comm<strong>and</strong> we must position at a directory where<br />

both the <strong>Application</strong> Class Library <strong>and</strong> the <strong>IMS</strong> <strong>Java</strong> Class Libraries can<br />

be accessed. So, we change the directory to /u/imsres4/. The hpj<br />

comm<strong>and</strong> must indicate the specific directories required to access the<br />

input <strong>Java</strong> main method without the .class extention - samples.ivp.IVP.<br />

The hpj comm<strong>and</strong> is continued over many lines with backslashes (‘\’)<br />

used to indicate continuation.<br />

110 <strong>IMS</strong> <strong>Version</strong> 7 <strong>and</strong> <strong>Java</strong> <strong>Application</strong> <strong>Programming</strong>


The following parameters can be used:<br />

- -main indicates the class that contains the main startup. If -main is<br />

omitted, the first class with a main method found is assumed to be the<br />

main startup. This can produce some interesting errors if the program<br />

is changed <strong>and</strong> your main is no longer the first main. So be sure to<br />

specify -main.<br />

- -alias specifies an alias (HFS-like) name for a <strong>Java</strong> executable or DLL<br />

that is being written to a PDSE member. -alias must be specified for all<br />

<strong>Java</strong> DLLs that reside in PDSE members. It is not necessary to specify<br />

-alias for a <strong>Java</strong> executable, but it does not hurt either.<br />

- -o specifies where to put the executable so <strong>IMS</strong> can find <strong>and</strong> access it.<br />

It must be a member of a PDSE, which is included in the Dependent<br />

Region STEPLIB concatenation. Note the double <strong>and</strong> single quotes<br />

required!<br />

- -target tells hpj to compile <strong>and</strong> bind <strong>Java</strong> bytecode files into a <strong>Java</strong><br />

executable that runs in the <strong>IMS</strong> environment.<br />

- -exclude indicates that the classes in the specified Class Libraries are<br />

not to be included in the executable<br />

For more information on the hpj comm<strong>and</strong> options available, see<br />

Appendix J, “Options for the hpj comm<strong>and</strong>” on page 385.<br />

Figure 72, Figure 73, <strong>and</strong> Figure 74 show the .profile files that we used.<br />

They set up the <strong>Java</strong> <strong>and</strong> hpj paths.<br />

export <strong>IBM</strong><strong>IMS</strong>J_HOME=/usr/lpp/ims/imsjava71/classes.zip<br />

export CLASSPATH=$CLASSPATH:$<strong>IBM</strong><strong>IMS</strong>J_HOME<br />

#<br />

# COMMENT HOLDER<br />

#<br />

echo ‘*------------------------------------------------------*<br />

echo ‘ profile.imsjava executed ‘<br />

echo ‘*------------------------------------------------------*<br />

Figure 72. Sample .profile.imsjava file<br />

Chapter 6. <strong>IMS</strong>Auto application build <strong>and</strong> execute 111


#====================================================<br />

#JDK<br />

# ====================================================<br />

export JAVA_HOME=/usr/lpp/java18i/J1.1<br />

export PATH=/usr/lpp/java18i/J1.1/bin:$PATH<br />

export CLASSPATH=/usr/lpp/java18i/J1.1/lib/classes.zip:$CLASSPATH<br />

export LD_LIBRARY_PATH=/usr/lpp/java18i/J1.1/lib/classes.zip:$LD_LIBRARY_PATH<br />

# ===================================================================<br />

#HPJ<br />

# ===================================================================<br />

export <strong>IMS</strong>RES4_HOME=”/u/imsres4”<br />

export <strong>IBM</strong>HPJ_HOME=”/usr/lpp/hpj”<br />

export <strong>IBM</strong>HPJ_RTL=”CEE.SCEELKED:CEE.SCEELKEX:CEE.SCEEOBJ:CEE.SCEECPP”<br />

export CLASSPATH=$CLASSPATH:$<strong>IBM</strong>HPJ_HOME/lib<br />

export CLASSPATH=$CLASSPATH:$<strong>IMS</strong>RES4_HOME<br />

export PATH=$PATH:$<strong>IBM</strong>HPJ_HOME/bin<br />

export LIBPATH=$LIBPATH:$<strong>IBM</strong>HPJ_HOME/lib<br />

export STEPLIB=$STEPLIB:HPJ390.SHPJMOD:HPJ390.SHPOMOD:CEE.SCEERUN<br />

# ===================================================================<br />

#<br />

# ====================================================<br />

echo ********************************<br />

echo ***** profile.imsres4 **********<br />

echo ***** profile.imsres4 **********<br />

echo JAVA_HOME : $JAVA_HOME<br />

echo<br />

echo PATH : $PATH<br />

echo<br />

echo LIBPATH : $LIBPATH<br />

echo<br />

echo CLASSPATH : $CLASSPATH<br />

echo<br />

echo LD_LIBRARY_PATH : $LD_LIBRARY_PATH<br />

echo<br />

echo STEPLIB : $STEPLIB<br />

echo<br />

echo <strong>IBM</strong>HPJ_HOME : $<strong>IBM</strong>HPJ_HOME<br />

echo<br />

echo <strong>IBM</strong>HPJ_RTL : $<strong>IBM</strong>HPJ_RTL<br />

echo ***** profile.imsres4 **********<br />

echo ***** profile.imsres4 **********<br />

Figure 73. Sample .profile.imsres4 file<br />

112 <strong>IMS</strong> <strong>Version</strong> 7 <strong>and</strong> <strong>Java</strong> <strong>Application</strong> <strong>Programming</strong>


#----------------------------------------------------------------------<br />

# Licensed Materials - Property of <strong>IBM</strong>.<br />

# 5655-JAV<br />

# (C) Copyright <strong>IBM</strong> Corp. 1998, 1999<br />

#<br />

# Exports environment variables for VisualAge for <strong>Java</strong>, Enterprise<br />

# Edition for OS/390<br />

#<br />

# Before using this profile, you have to make the following<br />

# modifications:<br />

#<br />

# 1) Change HPJ <strong>and</strong> CEE to the appropriate high-level qualifier for<br />

# VisualAge for <strong>Java</strong>, Enterprise Edition for OS/390 <strong>and</strong> Language<br />

# Environment.<br />

#<br />

# 2) Change <strong>IBM</strong>HPJ_HOME to your install directory.<br />

#<br />

#----------------------------------------------------------------------<br />

#<br />

export <strong>IBM</strong>HPJ_HOME=”/usr/lpp/hpj”<br />

export <strong>IBM</strong>HPJ_RTL=”CEE.SCEELKED:CEE.SCEELKEX:CEE.SCEEOBJ:CEE.SCEECPP”<br />

export CLASSPATH=$CLASSPATH:.:$<strong>IBM</strong>HPJ_HOME/lib<br />

export CLASSPATH=$CLASSPATH:$<strong>IBM</strong>HPJ_HOME/lib/eablib.jar<br />

export CLASSPATH=$CLASSPATH:$<strong>IBM</strong>HPJ_HOME/lib/recjava.jar<br />

export CLASSPATH=$CLASSPATH:$<strong>IBM</strong>HPJ_HOME/lib/jdebug.jar<br />

export PATH=$PATH:$<strong>IBM</strong>HPJ_HOME/bin<br />

export LIBPATH=$LIBPATH:$<strong>IBM</strong>HPJ_HOME/lib<br />

export STEPLIB=$STEPLIB:HPJ.SHPJMOD:HPJ.SHPOMOD:CEE.SCEERUN<br />

#<br />

echo ‘*---------------------------------------------------------------’<br />

echo ‘ profile.java was executed ‘<br />

echo ‘*---------------------------------------------------------------’<br />

Figure 74. Sample .profile.hpj file<br />

The second step of the BPXBATCH job copied the information about our<br />

batch run to stdout <strong>and</strong> stderr files. Figure 75 shows the contents of the<br />

STDOUTL file. It contains messages generated when the .profile file was<br />

processed, the names of our input, <strong>and</strong> output files.<br />

Chapter 6. <strong>IMS</strong>Auto application build <strong>and</strong> execute 113


LIBPATH reset to /lib:/usr/lib:/usr/lpp/db2/db2610/lib:<br />

----------------------------------------------------<br />

Set up environment variables for <strong>Java</strong> for MVS<br />

----------------------------------------------------<br />

Previous environment for <strong>Java</strong> unset<br />

JAVA_HOME set to /usr/lpp/java18/J1.1<br />

PATH reset to /usr/lpp/java18/J1.1/bin:/usr/lpp/db2/db2610/bin:/bin:.<br />

----------------------------------------------------<br />

CLASSPATH set to .:/usr/lpp/internet/server_root/cgi-bin/icsclass.zip:/usr/lpp/i<br />

LD_LIBRARY_PATH reset to .:/usr/lpp/db2/db2610/bin:/usr/lpp/db2/db2610/lib:/usr/<br />

STEPLIB set to DB2V610J.SDSNEXIT:DSN610.SDSNEXIT:DSN610.SDSNLOAD:HPJ390.SHPJMOD:<br />

DB2SQLJPROPERTIES set to /usr/lpp/db2/db2610/classes/db2sqljjdbc.properties<br />

DB2SQLJDBRMLIB set to DB2V610J.DBRMLIB.DATA<br />

*--------------------------------------------------------------profile<br />

executed for HPJ, JAVA <strong>and</strong> SQLJ<br />

*---------------------------------------------------------------<br />

BEGIN IVPhpj.sh.ver1<br />

Thu Aug 31 23:43:00 EDT 2000<br />

*------------------------------------------------------*<br />

echo profile.imsjava executed<br />

JAVA_HOME : /usr/lpp/java18i/J1.1<br />

PATH : /usr/lpp/java18i/J1.1/bin:/usr/lpp/java18/J1.1/bin:/usr/lpp/db2/db2610/bi<br />

LIBPATH : /usr/lpp/db2/db2610/lib:/usr/lpp/db2/db2610/lib:/usr/lpp/java18/J1.1/l<br />

CLASSPATH : /usr/lpp/java18i/J1.1/lib/classes.zip:.:/usr/lpp/internet/server_roo<br />

LD_LIBRARY_PATH : /usr/lpp/java18i/J1.1/lib/classes.zip:.:/usr/lpp/db2/db2610/bi<br />

STEPLIB : DB2V610J.SDSNEXIT:DSN610.SDSNEXIT:DSN610.SDSNLOAD:HPJ390.SHPJMOD:HPJ39<br />

<strong>IBM</strong>HPJ_HOME : /usr/lpp/hpj<br />

<strong>IBM</strong>HPJ_RTL : CEE.SCEELKED:CEE.SCEELKEX:CEE.SCEEOBJ:CEE.SCEECPP<br />

*--------------------------------------------------------------profile.java<br />

was executed<br />

*---------------------------------------------------------------<br />

<strong>IMS</strong>JAVA : /usr/lpp/ims/imsjava71<br />

<strong>IMS</strong>JDLL : /usr/lpp/ims/imsjava71/imsjava.jll<br />

<strong>IMS</strong>CLIB : /usr/lpp/ims/imsjava71/libJavTDLI.dll<br />

<strong>IMS</strong>HPJ : /usr/lpp/hpj/lib<br />

PATH : /usr/lpp/java18i/J1.1/bin:/usr/lpp/java18/J1.1/bin:/usr/lpp/db2/db2610/bi<br />

samples.ivp.IVP<br />

samples.ivp.IVPDatabaseView<br />

samples.ivp.InputMessage<br />

samples.ivp.OutputMessage<br />

samples.ivp.PhoneBookSegment<br />

samples.ivp.SPAMessage<br />

//’<strong>IMS</strong>.SJ<strong>IMS</strong>R.IVP.PGMLIB(DFSIVP32)’<br />

Thu Aug 31 23:43:13 EDT 2000<br />

END IVPhpj.sh.ver1<br />

Figure 75. STDOUTL file<br />

114 <strong>IMS</strong> <strong>Version</strong> 7 <strong>and</strong> <strong>Java</strong> <strong>Application</strong> <strong>Programming</strong>


The STDERRL file (Figure 76) contains the binder messages.<br />

java version “1.1.8”<br />

hpjava version “VisualAge 2.0 CL4.1 - May 26 2000”<br />

IEW2278I B352 INVOCATION PARAMETERS -<br />

TERM,AMODE=31,RENT,DYNAM=DLL,CASE=MIXED,COMPAT=CURR,MSGLEVEL=4<br />

Figure 76. STDERRL File<br />

In the first line you see what file javac was working on. No error messages<br />

were generated. The last part of the output is the output of the binder.<br />

There were no problems here either.<br />

Now we have the following readable files:<br />

- .map file with the binder listing<br />

- .syslin with the input to the binder that was used<br />

We also have the following binary files:<br />

- .class containing the <strong>Java</strong> byte code<br />

- .mo containing the partly bound main class<br />

(this file is not generated if you use the -jll option)<br />

- .o containing the other partly bound classes<br />

- .ro containing the run-time options<br />

- The executable DFSIVP32 in the PDSE <strong>IMS</strong>.SJ<strong>IMS</strong>R.IVP.PGMLIB<br />

Sometimes when we invoked hpj from a shell within a TSO/E session<br />

there was not enough memory left to do the binding. In these cases, we<br />

resorted to running an hpj shell script under BPXBATCH <strong>and</strong> we were<br />

always successful.<br />

The <strong>Java</strong> program is now ready for execution under <strong>IMS</strong>.<br />

3. Define resources to <strong>IMS</strong><br />

If the IVP is not already defined to the <strong>IMS</strong> system, you have to define the<br />

DFSIVP32 program, the IVTCC transaction, <strong>and</strong> the IVPDB2 database to<br />

the <strong>IMS</strong> GEN before invoking the program through an <strong>IMS</strong> message<br />

region. (See <strong>IMS</strong> Installation Volume 1: Installation <strong>and</strong> Verification,<br />

GC26-9429.)<br />

Chapter 6. <strong>IMS</strong>Auto application build <strong>and</strong> execute 115


4. <strong>IMS</strong> message region preparation<br />

Next you have to include the PDSE PGMLIB which contains the hpj<br />

bound executables for the application, in the STEPLIB concatenation.<br />

Also include the <strong>IMS</strong> <strong>Java</strong> Class Library <strong>and</strong> HPJ Class Libraries in the<br />

STEPLIB (see Figure 77).<br />

//STEPLIB DD DSN=<strong>IMS</strong>.SJ<strong>IMS</strong>R.SDFSJLIB,DISP=SHR <strong>IMS</strong> CLASS LIBRARY<br />

// DD DSN=HPJ390.SHPJMOD,DISP=SHR HPJ CLASS LIBRARY<br />

// DD DSN=HPJ390.SHPOMOD,DISP=SHR HPJ CLASS LIBRARY<br />

// DD DSN=<strong>IMS</strong>.SJ<strong>IMS</strong>R.IVP.PGMLIB,DISP=SHRPDSE PGMLIB<br />

// DD DSN=<strong>IMS</strong>.SJ<strong>IMS</strong>R.PGMLIB,DISP=SHR PDS PGMLIB<br />

// DD DSN=<strong>IMS</strong>.SJ<strong>IMS</strong>R.SDFSRESL,DISP=SHR<strong>IMS</strong> RESLIB<br />

Figure 77. <strong>IMS</strong> Message Region STEPLIB Concatenation<br />

5. Run the IVP program<br />

Logon onto your <strong>IMS</strong> system <strong>and</strong> enter “/FOR IVTCC”. Your input screen<br />

for the IVTCC transaction should look like that in Figure 78.<br />

Figure 78. IVP program input screen<br />

116 <strong>IMS</strong> <strong>Version</strong> 7 <strong>and</strong> <strong>Java</strong> <strong>Application</strong> <strong>Programming</strong><br />

**************************************************<br />

* <strong>IMS</strong> INSTALLATION VERIFICATION PROCEDURE *<br />

**************************************************<br />

TRANSACTION TYPE : CONVERSATIONAL<br />

DATE : 09/01/00<br />

PROCESS CODE (*1) : display<br />

LAST NAME : last1<br />

(*1) PROCESS CODE<br />

ADD<br />

DELETE<br />

FIRST NAME : UPDATE<br />

DISPLAY<br />

EXTENSION NUMBER : TADD<br />

END<br />

INTERNAL ZIP CODE :<br />

SEGMENT# :


If you run the transaction, your output screen should look like that in<br />

Figure 79.<br />

**************************************************<br />

* <strong>IMS</strong> INSTALLATION VERIFICATION PROCEDURE *<br />

**************************************************<br />

Figure 79. IVP program output screen<br />

TRANSACTION TYPE : CONVERSATIONAL<br />

DATE : 09/01/00<br />

PROCESS CODE (*1) :<br />

LAST NAME : LAST1<br />

(*1) PROCESS CODE<br />

ADD<br />

DELETE<br />

FIRST NAME : FIRST1 UPDATE<br />

DISPLAY<br />

EXTENSION NUMBER : 8-111-1111 TADD<br />

END<br />

INTERNAL ZIP CODE : D01/R01<br />

ENTRY WAS DISPLAYED SEGMENT# :<br />

Chapter 6. <strong>IMS</strong>Auto application build <strong>and</strong> execute 117


118 <strong>IMS</strong> <strong>Version</strong> 7 <strong>and</strong> <strong>Java</strong> <strong>Application</strong> <strong>Programming</strong>


Chapter 7. VisualAge for <strong>Java</strong> <strong>IMS</strong> application development<br />

In this section, we discuss the mechanics of using VisualAge for <strong>Java</strong> to<br />

develop <strong>IMS</strong> <strong>Java</strong> programs. Although this section covers a step-by-step<br />

approach to working with an application project in VisualAge for <strong>Java</strong>, it is not<br />

intended to be a primer on using VisualAge for <strong>Java</strong>. The <strong>IMS</strong> customization<br />

to support the <strong>Java</strong> environment is covered in Chapter 2, “Environment<br />

customization” on page 23. Also, you can refer to <strong>Programming</strong> with<br />

VisualAge for <strong>Java</strong> Enterprise <strong>Version</strong> 2, SG24-5264, for basic information.<br />

7.1 <strong>IMS</strong> JAVA classes in VisualAge for <strong>Java</strong> <strong>Version</strong> 3.02<br />

In addition to installing VisualAge for <strong>Java</strong> on your workstation, you also have<br />

to install ET/390. You then need to customize the ET/390 component on your<br />

workstation as described in Chapter 2, “Environment customization” on page<br />

23. This customization allows your <strong>Java</strong> programs to be transferred to the<br />

OS/390 mainframe <strong>and</strong> bound by the HPJ compiler so that you can run your<br />

programs under <strong>IMS</strong>.<br />

VisualAge for <strong>Java</strong> <strong>Version</strong> 3 for Windows NT was made available in October<br />

1999. This release does not ship with the <strong>IMS</strong> <strong>Java</strong> Class Libraries. Because<br />

you will compile your programs on the workstation in VisualAge for <strong>Java</strong><br />

environment, you have to import the <strong>IMS</strong> JAVA classes from the OS/390<br />

system where <strong>IMS</strong> <strong>Java</strong> has been installed into VisualAge for <strong>Java</strong>. If you use<br />

VisualAge for <strong>Java</strong> <strong>Version</strong> 3, follow the steps below to make the <strong>IMS</strong> <strong>Java</strong><br />

classes available on your workstation.<br />

These classes are contained in the MVS Unix System Services file<br />

/usr/lpp/ims/imsjava71/classes.zip.<br />

Use the following procedure to import the classes:<br />

1. Transfer the /usr/lpp/ims/imsjava71/classes.zip file to your workstation in<br />

binary format. This file was installed into the MVS UNIX System Services<br />

environment when you installed <strong>IMS</strong> V7.1 <strong>Java</strong>. You can perform the<br />

transfer using NFS or FTP.<br />

2. Unzip the classes.zip file into a workstation directory. We used a directory<br />

called c:\<strong>IMS</strong>_<strong>Java</strong>_Classes. When unzipped, this zip file will create<br />

classes in the following three sub-directories:<br />

- c:\<strong>IMS</strong>_<strong>Java</strong>_Classes\com\ibm\ims\application<br />

- c:\<strong>IMS</strong>_<strong>Java</strong>_Classes\com\ibm\ims\base<br />

- c:\<strong>IMS</strong>_<strong>Java</strong>_Classes\com\ibm\ims\db<br />

© Copyright <strong>IBM</strong> Corp. 2001 119


3. Start VisualAge for <strong>Java</strong> <strong>and</strong> go to the workbench (see Figure 80).<br />

Figure 80. VisualAge for <strong>Java</strong> startup screen<br />

4. Select Import from the File menu.<br />

5. Select the Directory radio button in the SmartGuide Import dialog (see<br />

Figure 81) <strong>and</strong> click the Next button.<br />

120 <strong>IMS</strong> <strong>Version</strong> 7 <strong>and</strong> <strong>Java</strong> <strong>Application</strong> <strong>Programming</strong>


Figure 81. SmartGuide Import dialog<br />

6. In the SmartGuide Import from a directory dialog, click the Directory<br />

Browse button <strong>and</strong> navigate to the directory containing the unzipped class<br />

files.<br />

7. Select the directory c:\<strong>IMS</strong>_<strong>Java</strong>_Classes\com\ibm\ims\application <strong>and</strong><br />

click OK to return to the SmartGuide Import from a directory dialog (see<br />

Figure 82).<br />

8. Be sure that the boxes for class <strong>and</strong> resource are checked.<br />

9. In the Project field, type <strong>IMS</strong>_<strong>Java</strong>_Class_Libraries.<br />

Chapter 7. VisualAge for <strong>Java</strong> <strong>IMS</strong> application development 121


Figure 82. SmartGuide (Import from a directory) dialog — application<br />

10.Click the Finish button. At this point the <strong>IMS</strong> application <strong>Java</strong> classes<br />

have been imported into the <strong>IMS</strong>_<strong>Java</strong>_Class_Libraries Project.<br />

11.Repeat steps 4 through 10 to import the <strong>IMS</strong> base <strong>and</strong> db classes (see<br />

Figure 83 <strong>and</strong> Figure 84).<br />

122 <strong>IMS</strong> <strong>Version</strong> 7 <strong>and</strong> <strong>Java</strong> <strong>Application</strong> <strong>Programming</strong>


Figure 83. SmartGuide (Import from a directory) dialog — base<br />

Chapter 7. VisualAge for <strong>Java</strong> <strong>IMS</strong> application development 123


Figure 84. SmartGuide (Import from a directory) dialog — db<br />

Once processing is complete, the Workbench can be used to view all of the<br />

packages <strong>and</strong> classes within the <strong>IMS</strong>_<strong>Java</strong>_Class_Libraries (Figure 85).<br />

124 <strong>IMS</strong> <strong>Version</strong> 7 <strong>and</strong> <strong>Java</strong> <strong>Application</strong> <strong>Programming</strong>


Figure 85. <strong>IMS</strong>_<strong>Java</strong>_Class_Libraries listing<br />

Note: At this point, you have just finished importing <strong>IMS</strong> <strong>Java</strong> Class libraries<br />

into VisualAge for <strong>Java</strong>.<br />

Chapter 7. VisualAge for <strong>Java</strong> <strong>IMS</strong> application development 125


7.2 Writing, importing/exporting, <strong>and</strong> editing your program<br />

This section covers the steps for writing, importing/exporting, <strong>and</strong> editing an<br />

<strong>IMS</strong> <strong>Java</strong> program using VisualAge for <strong>Java</strong>.<br />

In VisualAge for <strong>Java</strong>, your code <strong>and</strong> variables are placed in classes <strong>and</strong><br />

methods. Classes are grouped into packages <strong>and</strong> packages are grouped into<br />

projects.<br />

You can follow these steps if you want to create a new Project with new <strong>IMS</strong><br />

<strong>Java</strong> classes:<br />

1. From the menu bar, click Selected -> Add -> Project.<br />

Supply a new project name (you could use <strong>IMS</strong>_<strong>Java</strong>_Project), then click<br />

Finish (see Figure 86).<br />

Figure 86. SmartGuide (Add Project dialog)<br />

126 <strong>IMS</strong> <strong>Version</strong> 7 <strong>and</strong> <strong>Java</strong> <strong>Application</strong> <strong>Programming</strong>


2. With the project name highlighted, click Selected -> Add -> Package.<br />

Supply a new package name (you could use <strong>IMS</strong><strong>Java</strong>PGM), <strong>and</strong> click<br />

Finish (see Figure 87). You will get a message warning you that <strong>Java</strong><br />

classes are usually in lower case, click Proceed.<br />

Figure 87. SmartGuide (Add Package dialog)<br />

Chapter 7. VisualAge for <strong>Java</strong> <strong>IMS</strong> application development 127


3. To add the <strong>IMS</strong><strong>Java</strong>PGM program, with the package name highlighted,<br />

click Selected -> Add -> Class (see Figure 88).<br />

Figure 88. SmartGuide Create Class dialog<br />

4. On the SmartGuide Create Class dialog (see Figure 88), indicate that the<br />

name of the new class is <strong>IMS</strong><strong>Java</strong>PGM. Make sure that Compose the<br />

class visually is not checked. Then click Finish (see Figure 89).<br />

128 <strong>IMS</strong> <strong>Version</strong> 7 <strong>and</strong> <strong>Java</strong> <strong>Application</strong> <strong>Programming</strong>


Figure 89. The newly created class: <strong>IMS</strong><strong>Java</strong>PGM<br />

5. Be sure to add the following import statements to your class:<br />

- import com.ibm.ims.application.*;<br />

- import com.ibm.ims.base.*;<br />

- import com.ibm.ims.db.*;<br />

Chapter 7. VisualAge for <strong>Java</strong> <strong>IMS</strong> application development 129


6. Add a method called main (see Figure 90) with contents similar to those<br />

shown in Figure 91, then add other application specific <strong>Java</strong> classes <strong>and</strong><br />

methods as appropriate.<br />

Figure 90. SmartGuide Create Method dialog<br />

130 <strong>IMS</strong> <strong>Version</strong> 7 <strong>and</strong> <strong>Java</strong> <strong>Application</strong> <strong>Programming</strong>


Figure 91. Workbench showing newly added method<br />

For our testing we did not create any new <strong>IMS</strong> <strong>Java</strong> programs. The programs<br />

we used for testing are part of the <strong>IMS</strong> Auto Dealership application (see<br />

Appendix I, “Dealership sample application” on page 357). This is an <strong>IMS</strong><br />

online transaction, <strong>IMS</strong>Auto, that can be used to perform six different<br />

functions against a full function DEALER database.<br />

We imported the <strong>Java</strong> source code for the Auto Dealership, <strong>IMS</strong>Auto, from<br />

our workstation into the VA-JAVA Dealership Project using the methodology<br />

employed earlier to import the distributed <strong>IMS</strong> <strong>Java</strong> Classes.<br />

Chapter 7. VisualAge for <strong>Java</strong> <strong>IMS</strong> application development 131


The Dealership Project consists of 2 packages: dealership.application, <strong>and</strong><br />

dealership.database. (See Figure 92).<br />

Figure 92. Imported <strong>IMS</strong> <strong>Java</strong> classes<br />

132 <strong>IMS</strong> <strong>Version</strong> 7 <strong>and</strong> <strong>Java</strong> <strong>Application</strong> <strong>Programming</strong>


To exp<strong>and</strong> a package or a class, click the “+” sign in front of a specific class.<br />

(See Figure 93 <strong>and</strong> Figure 94.)<br />

Figure 93. Workbench showing expansion of classes<br />

Chapter 7. VisualAge for <strong>Java</strong> <strong>IMS</strong> application development 133


Figure 94. Workbench showing modifiable source code<br />

Click a field or a method of any class to edit the <strong>Java</strong> source code.<br />

Note<br />

Notice in Figure 94 the use of the System.out.println instruction which we<br />

used during debugging of the application. (These displays are sent to a<br />

dynamically allocated sysout DD in the <strong>IMS</strong> message processing region.<br />

The datasets are named SYS00001, SYS00002 etc.)<br />

When you are finished editing one object, click the next object to be edited<br />

<strong>and</strong> a popup box will ask “Text has been modified - save changes?” You can<br />

reply Yes, No, or Cancel. Another way to save an edited object is to select<br />

Save from the Edit Menu.<br />

134 <strong>IMS</strong> <strong>Version</strong> 7 <strong>and</strong> <strong>Java</strong> <strong>Application</strong> <strong>Programming</strong>


When you save, VA-JAVA will automatically compile the object <strong>and</strong> indicate if<br />

there are errors. If you Save with errors, a red “X” will appear just to the left of<br />

the object name (see Figure 95).<br />

Figure 95. Workbench showing a method with an error<br />

<strong>Java</strong>doc can be produced for a project, a package, or a class within VA-JAVA<br />

by highlighting the object <strong>and</strong> from the menu bar clicking Selected -><br />

Document -> Generate<strong>Java</strong>doc. You will be asked to provide a Directory for<br />

<strong>Java</strong>doc output which is in HTML format <strong>and</strong> can easily be viewed or printed<br />

(see Figure 96).<br />

Chapter 7. VisualAge for <strong>Java</strong> <strong>IMS</strong> application development 135


Figure 96. <strong>Java</strong>doc option screen<br />

7.3 Exporting your program for execution<br />

To export your program for execution under <strong>IMS</strong> V7.1, you have to set up<br />

ET/390. Additionally, you have to set up the environment for the project by<br />

following these steps:<br />

1. With the Dealership Project highlighted, click Selected -> Tools -> ET/390<br />

-> Properties.<br />

136 <strong>IMS</strong> <strong>Version</strong> 7 <strong>and</strong> <strong>Java</strong> <strong>Application</strong> <strong>Programming</strong>


2. In the ET/390 Properties SmartGuide for object Dealership, you initially<br />

see the properties you set up for the VA-JAVA workspace. You could<br />

override some of them here if there were some attributes that were<br />

specific to this project.<br />

We used Host SC47. O: (TEXT access) <strong>and</strong> P: (binary access) were<br />

connected to the /u/imsres4 directory under the MVS USS HFS, the HFS<br />

mount point on the SC47 Host was /u/imsres4, <strong>and</strong> the directory for class<br />

files was established as O:\dealership (/u/imsre4/dealership).<br />

Figure 97. ET/390 Properties for object Dealership<br />

3. In the left part of the window (see Figure 97), click the plus sign next to<br />

Export <strong>and</strong> Bind Session.<br />

4. Click Bind Options to view the bind options for this project.<br />

5. You can have a development <strong>and</strong> a production set of bind options (see<br />

Figure 98)for the project. Click the radio button next to the environment for<br />

which you are compiling (we used Development).<br />

Chapter 7. VisualAge for <strong>Java</strong> <strong>IMS</strong> application development 137


Figure 98. ET/390 Properties for object Dealership (Bind Options)<br />

Once the ET/390 setup is complete, the NFS connections are defined <strong>and</strong><br />

working properly, <strong>and</strong> your coding is completed, you can begin to export <strong>Java</strong><br />

source or <strong>Java</strong> class files from the workstation to the MVS USS HFS.<br />

1. From the workbench, with the project, package, or class name highlighted<br />

(see Figure 99), click Export from the File Menu.<br />

138 <strong>IMS</strong> <strong>Version</strong> 7 <strong>and</strong> <strong>Java</strong> <strong>Application</strong> <strong>Programming</strong>


Figure 99. Workbench (Administrator) menu<br />

2. Select the Directory radio button in the SmartGuide Export dialog (see<br />

Figure 100) <strong>and</strong> click the Next button.<br />

Chapter 7. VisualAge for <strong>Java</strong> <strong>IMS</strong> application development 139


Figure 100. SmartGuide Export dialog<br />

3. In the SmartGuide Export to a directory dialog (see Figure 101), click the<br />

Directory Browse button <strong>and</strong> navigate to the directory to which the <strong>Java</strong><br />

object should be exported.<br />

140 <strong>IMS</strong> <strong>Version</strong> 7 <strong>and</strong> <strong>Java</strong> <strong>Application</strong> <strong>Programming</strong>


Figure 101. SmartGuide Export to a directory dialog<br />

4. Click the appropriate boxes under What do you want to export? Using<br />

.class will export only the <strong>Java</strong> bytecode, <strong>and</strong> .java will export only the<br />

<strong>Java</strong> source code. We found that clicking resource to export<br />

application-external class files (resources) took an extremely long time<br />

<strong>and</strong> was not necessary. You can also click the desired Options boxes. We<br />

used the Include debug attributes in .class files option. Occasionally we<br />

used the Overwrite existing files without warning option but preferred to<br />

get a notification.<br />

Chapter 7. VisualAge for <strong>Java</strong> <strong>IMS</strong> application development 141


Note<br />

Note that you must pay attention to <strong>and</strong> remember that .class <strong>and</strong> resource<br />

files must be exported/imported as binary; <strong>and</strong> .java files must be<br />

exported/imported as TEXT files. Be sure to use the appropriate network<br />

drive.<br />

5. Click Finish <strong>and</strong> the exporting starts. If you did not click the Overwrite<br />

existing files without warning option, you will get a pop-up box asking Do<br />

you want to overwrite it? You can reply Yes, Yes To All, No, or Cancel. If<br />

you choose one of the Yes replies, you will see a message at the bottom of<br />

the window indicating the object currently being exported (Figure 102).<br />

Figure 102. Duplicate name error message<br />

6. Repeat steps 1 through 5 to export individual classes, whole packages, or<br />

entire projects.<br />

7.4 Preparing your program for execution<br />

To bind the exported VA-JAVA program bytecode, you must use the High<br />

Performance <strong>Java</strong> (HPJ) compiler. The hpj comm<strong>and</strong> can be executed<br />

interactively under the OMVS shell or inside a shell script executed from a<br />

BPXBATCH job. Because of TSO storage limitations, we were forced to use a<br />

batch BPXBATCH job (see Figure 103) to bind the <strong>IMS</strong>Auto bytecode into<br />

executable code.<br />

142 <strong>IMS</strong> <strong>Version</strong> 7 <strong>and</strong> <strong>Java</strong> <strong>Application</strong> <strong>Programming</strong>


We used the shell script in Figure 104 on page 144 to do the HPJ compile<br />

<strong>and</strong> bind only. For illustration purposes, we also created <strong>and</strong> ran the shell<br />

script in Figure 105 on page 145, which executes one script to do the<br />

<strong>IMS</strong>Auto <strong>Java</strong> class compiles (Figure 106 on page 146); <strong>and</strong> we used another<br />

script to do the HPJ compile <strong>and</strong> bind (Figure 107 on page 147).<br />

//AUTOHPJ JOB (999,POK),’ITSO <strong>IMS</strong> TEAM’,MSGCLASS=U,CLASS=A,<br />

// NOTIFY=&SYSUID,TIME=1440,REGION=0M<br />

//* ------------------------------------------------------------------<br />

//* EXECUTE SCRIPT<br />

//* ------------------------------------------------------------------<br />

//UXCALL EXEC PGM=BPXBATCH,REGION=0M,<br />

// PARM=’SH /u/imsres4/Dealerhpj.sh.st<strong>and</strong>alone’<br />

//STEPLIB DD DISP=SHR,DSN=CEE.SCEERUN<br />

//STDENV DD DUMMY<br />

//STDIN DD DUMMY<br />

//************************************* THE OUTPUT *********<br />

//STDOUT DD PATH=’/u/imsres4/&SYSUID..autohpj.a082500.eout’,<br />

// PATHOPTS=(OWRONLY,OCREAT,OTRUNC),PATHMODE=SIRWXU<br />

//************************************* THE ERRORS *********<br />

//STDERR DD PATH=’/u/imsres4/&SYSUID..autohpj.a082500.eerr’,<br />

// PATHOPTS=(OWRONLY,OCREAT,OTRUNC),PATHMODE=SIRWXU<br />

//************************************* THE SYSOUT *********<br />

//SYSPRINT DD SYSOUT=*<br />

//* ------------------------------------------------------------------<br />

//* COPY RESULT(HFS) TO SYSOUT<br />

//* ------------------------------------------------------------------<br />

//HFS2PRT EXEC PGM=IKJEFT01,DYNAMNBR=300,COND=EVEN<br />

//SYSTSPRT DD SYSOUT=*<br />

//HFSOUT DD PATH=’/u/imsres4/&SYSUID..autohpj.a082500.eout’<br />

//HFSERR DD PATH=’/u/imsres4/&SYSUID..autohpj.a082500.eerr’<br />

//STDOUTL DD SYSOUT=*,DCB=(RECFM=VB,LRECL=6140,BLKSIZE=0)<br />

//STDERRL DD SYSOUT=*,DCB=(RECFM=VB,LRECL=6140,BLKSIZE=0)<br />

//SYSPRINT DD SYSOUT=*<br />

//SYSTSIN DD *<br />

OCOPY INDD(HFSOUT) OUTDD(STDOUTL)<br />

OCOPY INDD(HFSERR) OUTDD(STDERRL)<br />

/*<br />

//<br />

Figure 103. BPXBATCH job to execute HPJ-only shell script<br />

Chapter 7. VisualAge for <strong>Java</strong> <strong>IMS</strong> application development 143


# ##################################################################<br />

# CREATED:<br />

# ITSO 7/28/00 - execute only HPJ binder for ITSO DEALER APPL<br />

# ##################################################################<br />

echo BEGIN Dealerhpj.sh.st<strong>and</strong>alone<br />

date<br />

cd<br />

cd u/imsres4<br />

. profile.imsjava<br />

. profile.imsres4<br />

cd<br />

cd usr/lpp/hpj/bin<br />

. profile.hpj<br />

#<br />

export <strong>IMS</strong>JAVA=/usr/lpp/ims/imsjava71<br />

export <strong>IMS</strong>JDLL=/usr/lpp/ims/imsjava71/imsjava.jll<br />

export <strong>IMS</strong>CLIB=/usr/lpp/ims/imsjava71/libJavTDLI.dll<br />

export <strong>IMS</strong>HPJ=/usr/lpp/hpj/lib<br />

export PATH=$PATH:/usr/lpp/hpj/bin<br />

echo <strong>IMS</strong>JAVA : $<strong>IMS</strong>JAVA<br />

echo <strong>IMS</strong>JDLL : $<strong>IMS</strong>JDLL<br />

echo <strong>IMS</strong>CLIB : $<strong>IMS</strong>CLIB<br />

echo <strong>IMS</strong>HPJ : $<strong>IMS</strong>HPJ<br />

echo PATH : $PATH<br />

#<br />

cd<br />

cd /u/imsres4<br />

#<br />

hpj dealership.application.<strong>IMS</strong>Auto \<br />

-main=dealership.application.<strong>IMS</strong>Auto \<br />

-o=”//’<strong>IMS</strong>.SJ<strong>IMS</strong>R.IVP.PGMLIB(<strong>IMS</strong>AUTO)’” -alias=<strong>IMS</strong>AUTO \<br />

-target=<strong>IMS</strong> \<br />

-lerunopts=”ENVAR(CLASSPATH=$<strong>IMS</strong>JAVA:$<strong>IMS</strong>JDLL:$<strong>IMS</strong>CLIB:$<strong>IMS</strong>HPJ)” \<br />

-verbose \<br />

-include=dealership.application.DealerDatabaseView \<br />

-exclude=com.ibm.ims.db.* \<br />

-exclude=com.ibm.ims.application.* \<br />

-exclude=com.ibm.ims.base.*<br />

#<br />

date<br />

echo END Dealerhpj.sh.st<strong>and</strong>alone<br />

Figure 104. /u/imsres4/Dealerhpj.sh.st<strong>and</strong>alone -— HPJ-only shell script<br />

144 <strong>IMS</strong> <strong>Version</strong> 7 <strong>and</strong> <strong>Java</strong> <strong>Application</strong> <strong>Programming</strong>


# ###############################################################<br />

# CREATED:<br />

# ITSO 8/10/00 - SCRIPT SHELL TO javac THE JAVA CODE AND<br />

# hpj BIND THE BYTECODE INTO AN EXECUTABLE<br />

# FOR THE ITSO AUTO DEALER APPLICATION<br />

# ###############################################################<br />

echo START Dealerscript.ver3 TO COMPILE AND BIND AUTO/DEALER APPL<br />

date<br />

cd<br />

cd u/imsres4<br />

. profile.imsjava<br />

. profile.imsres4<br />

cd<br />

cd usr/lpp/hpj/bin<br />

. profile.hpj<br />

cd<br />

cd u/imsres4<br />

Dealerjavac.sh.ver3<br />

Dealerhpj.sh.ver3<br />

Date<br />

echo END Dealerscript.ver3 TO COMPILE AND BIND AUTO/DEALER APPL<br />

Figure 105. u/imsres4/Dealerscript.ver3 — script to execute 2 other scripts<br />

Chapter 7. VisualAge for <strong>Java</strong> <strong>IMS</strong> application development 145


# ###############################################################<br />

# CREATED:<br />

# NGS 08/10/00 - javac compile of ITSO DEALER APPL<br />

# ###############################################################<br />

echo BEGIN Dealerjavac.sh.ver3<br />

cd<br />

cd u/imsres4<br />

. profile.imsjava<br />

. profile.imsres4<br />

cd<br />

cd /u/imsres4<br />

javac dealership/database/*.java -verbose<br />

javac dealership/application/AcceptOrderInput.java -verbose<br />

javac dealership/application/Cancelled.java -verbose<br />

javac dealership/application/CancelOrderInput.java -verbose<br />

javac dealership/application/CarFound.java -verbose<br />

javac dealership/application/DealerDatabaseView.java -verbose<br />

javac dealership/application/ErrorMessage.java -verbose<br />

javac dealership/application/FindACarInput.java -verbose<br />

javac dealership/application/InputMessage.java -verbose<br />

javac dealership/application/ListModelsInput.java -verbose<br />

javac dealership/application/ModelDetails.java -verbose<br />

javac dealership/application/ModelList.java -verbose<br />

javac dealership/application/OrderAccepted.java -verbose<br />

javac dealership/application/OutputMessage.java -verbose<br />

javac dealership/application/RecordASaleInput.java -verbose<br />

javac dealership/application/SalesRecord.java -verbose<br />

javac dealership/application/ShowModelDetailsInput.java -verbose<br />

javac dealership/application/<strong>IMS</strong>Auto.java -verbose<br />

echo END Dealerjavac.sh.ver3<br />

# ##########################################################<br />

# #### FOLLOWING javac COMPILE ORDER WILL NOT WORK<br />

# #### database/*.java MUST BE COMPILED FIRST<br />

# #### application/*.java MUST BE COMPILED SECOND<br />

# #### <strong>IMS</strong>Auto.java HAS TO BE COMPILED LAST TO WORK<br />

# ##########################################################<br />

# javac dealership/database/*.java -verbose<br />

# javac dealership/application/*.java -verbose<br />

Figure 106. u/imsres4/Dealerjavac.sh.ver3 — javac compile script<br />

146 <strong>IMS</strong> <strong>Version</strong> 7 <strong>and</strong> <strong>Java</strong> <strong>Application</strong> <strong>Programming</strong>


# ##################################################################<br />

# CREATED:<br />

# ITSO 8/10/00 - hpj binder for the ITSO DEALER APPL<br />

#<br />

# ##################################################################<br />

echo BEGIN Dealerhpj.sh.ver3<br />

export <strong>IMS</strong>JAVA=/usr/lpp/ims/imsjava71<br />

export <strong>IMS</strong>JDLL=/usr/lpp/ims/imsjava71/imsjava.jll<br />

export <strong>IMS</strong>CLIB=/usr/lpp/ims/imsjava71/libJavTDLI.dll<br />

export <strong>IMS</strong>HPJ=/usr/lpp/hpj/lib<br />

export PATH=$PATH:/usr/lpp/hpj/bin<br />

echo <strong>IMS</strong>JAVA : $<strong>IMS</strong>JAVA<br />

echo <strong>IMS</strong>JDLL : $<strong>IMS</strong>JDLL<br />

echo <strong>IMS</strong>CLIB : $<strong>IMS</strong>CLIB<br />

echo <strong>IMS</strong>HPJ : $<strong>IMS</strong>HPJ<br />

echo PATH : $PATH<br />

#<br />

cd<br />

cd u/imsres4<br />

#<br />

hpj dealership.application.<strong>IMS</strong>Auto \<br />

-main=dealership.application.<strong>IMS</strong>Auto \<br />

-o=”//’<strong>IMS</strong>.SJ<strong>IMS</strong>R.IVP.PGMLIB(<strong>IMS</strong>AUTO)’” -alias=<strong>IMS</strong>AUTO \<br />

-target=<strong>IMS</strong> \<br />

-lerunopts=”ENVAR(CLASSPATH=$<strong>IMS</strong>JAVA:$<strong>IMS</strong>JDLL:$<strong>IMS</strong>CLIB:$<strong>IMS</strong>HPJ)” \<br />

-verbose \<br />

-include=dealership.application.DealerDatabaseView \<br />

-exclude=com.ibm.ims.db.* \<br />

-exclude=com.ibm.ims.application.* \<br />

-exclude=com.ibm.ims.base.*<br />

#<br />

# ##### COMMENTED OUT - STATICALLY BIND OBJECTS INTO EXECUTABLE<br />

#<br />

# -exclude=com.ibm.ims.db.* \<br />

# -exclude=com.ibm.ims.application.* \<br />

# -exclude=com.ibm.ims.base.*<br />

#<br />

echo END Dealerhpj.sh.ver3<br />

Figure 107. u/imsres4/Dealerhpj.sh.ver3 - HPJ binder script<br />

Chapter 7. VisualAge for <strong>Java</strong> <strong>IMS</strong> application development 147


7.5 Executing your <strong>Java</strong> program in <strong>IMS</strong><br />

The <strong>Java</strong> program is now ready for execution in <strong>IMS</strong>. But the <strong>IMS</strong><br />

environment setup needs to be completed, as shown in Figure 108 on page<br />

148, Figure 109 on page 149, <strong>and</strong> Figure 110 on page 150.<br />

1. Define the necessary <strong>IMS</strong> Gen resources.<br />

Stage1 Gen Input:<br />

**********************************************************************<br />

* <strong>IMS</strong>AUTO DEALERDB DEFINITION<br />

**********************************************************************<br />

DATABASE DBD=DEALERDB,ACCESS=UP HDAM/VSAM<br />

**********************************************************************<br />

* <strong>IMS</strong>AUTO NON-CONVERSATIONAL APPLICATION DEFINITION<br />

**********************************************************************<br />

APPLCTN PSB=<strong>IMS</strong>AUTO,PGMTYPE=TP HDAM/VSAM<br />

Figure 108. Stage1 Gen input<br />

148 <strong>IMS</strong> <strong>Version</strong> 7 <strong>and</strong> <strong>Java</strong> <strong>Application</strong> <strong>Programming</strong><br />

TRANSACT CODE=<strong>IMS</strong>AUTO,MODE=SNGL, X<br />

MSGTYPE=(SNGLSEG,NONRESPONSE,1)


DBD Gen Input:<br />

***********************************************************************<br />

* DESCRIPTION OF DEALER DATABASE<br />

* FOR ITSO SAMPLE APPLICATION<br />

* DOCUMENTED IN <strong>IMS</strong> JAVA USER’S GUIDE<br />

* ----------------------------------------<br />

*<br />

DBD NAME=DEALERDB,ACCESS=(HDAM,VSAM), X<br />

RMNAME=(DFSHDC40,4,80,500)<br />

*<br />

DATASET DD1=DEALERDD,DEVICE=3330,MODEL=1,SIZE=4096<br />

*<br />

* DEALER - GENERAL INFORMATION (ROOT)<br />

* ---------------------------------------<br />

SEGM NAME=DEALER,PARENT=0,BYTES=94<br />

FIELD START=01,BYTES=4,TYPE=C,NAME=(DLRNO,SEQ,U)<br />

FIELD START=05,BYTES=30,TYPE=C,NAME=DLRNAME<br />

*<br />

* DEALER - MODEL INFORMATION<br />

* ---------------------------------------<br />

SEGM NAME=MODEL,PARENT=DEALER,BYTES=43<br />

FIELD START=1,BYTES=2,TYPE=C,NAME=(MODTYPE,SEQ,U)<br />

FIELD START=3,BYTES=10,TYPE=C,NAME=MAKE<br />

FIELD START=13,BYTES=10,TYPE=C,NAME=MODEL<br />

FIELD START=23,BYTES=4,TYPE=C,NAME=YEAR<br />

FIELD START=27,BYTES=5,TYPE=P,NAME=MSRP<br />

*<br />

* DEALER - ORDER INFORMATION<br />

* ---------------------------------------<br />

SEGM NAME=ORDER,PARENT=MODEL,BYTES=127<br />

FIELD START=1,BYTES=6,TYPE=C,NAME=(ORDNBR,SEQ,U)<br />

FIELD START=50,BYTES=25,TYPE=C,NAME=LASTNME<br />

FIELD START=75,BYTES=25,TYPE=C,NAME=FIRSTNME<br />

*<br />

* DEALER - SALES INFORMATION<br />

* ---------------------------------------<br />

SEGM NAME=SALES,PARENT=MODEL,BYTES=113<br />

FIELD START=1,BYTES=8,TYPE=C,NAME=(SALDATE,SEQ,U)<br />

FIELD START=9,BYTES=25,TYPE=C,NAME=LASTNME<br />

FIELD START=34,BYTES=25,TYPE=C,NAME=FIRSTNME<br />

FIELD START=94,BYTES=20,TYPE=C,NAME=STKVIN<br />

*<br />

* DEALER - STOCK INFORMATION<br />

* ---------------------------------------<br />

SEGM NAME=STOCK,PARENT=MODEL,BYTES=62<br />

FIELD START=1,BYTES=20,TYPE=C,NAME=(STKVIN,SEQ,U)<br />

FIELD START=37,BYTES=10,TYPE=C,NAME=COLOR<br />

FIELD START=47,BYTES=5,TYPE=C,NAME=PRICE<br />

FIELD START=53,BYTES=10,TYPE=C,NAME=LOT<br />

*<br />

DBDGEN<br />

FINISH<br />

END<br />

Figure 109. DB2 Gen input<br />

Chapter 7. VisualAge for <strong>Java</strong> <strong>IMS</strong> application development 149


PSB Gen Input:<br />

***********************************************************************<br />

* PSB: <strong>IMS</strong>AUTO<br />

* <strong>IMS</strong>AUTO PROGRAM SPECIFICATION BLOCK FOR<br />

* ITSO AUTO/DEALER <strong>IMS</strong>/JAVA APPLICATION<br />

*<br />

* IOPCB PCB TYPE=TP GENERATED AUTOMATICALLY FOR ONLINE TRAN<br />

*<br />

PCB TYPE=TP,MODIFY=YES ALTERNATE MODIFIABLE IOPCB<br />

*<br />

DEALPCB1 PCB TYPE=DB,DBDNAME=DEALERDB,PROCOPT=AP,KEYLEN=40<br />

SENSEG NAME=DEALER,PARENT=0,PROCOPT=AP<br />

SENSEG NAME=MODEL,PARENT=DEALER,PROCOPT=AP<br />

SENSEG NAME=ORDER,PARENT=MODEL,PROCOPT=AP<br />

SENSEG NAME=SALES,PARENT=MODEL,PROCOPT=AP<br />

SENSEG NAME=STOCK,PARENT=MODEL,PROCOPT=AP<br />

*<br />

DEALPCB2 PCB TYPE=DB,DBDNAME=DEALERDB,PROCOPT=AP,KEYLEN=40<br />

SENSEG NAME=DEALER,PARENT=0<br />

SENSEG NAME=MODEL,PARENT=DEALER<br />

SENSEG NAME=ORDER,PARENT=MODEL<br />

SENSEG NAME=SALES,PARENT=MODEL<br />

SENSEG NAME=STOCK,PARENT=MODEL<br />

*<br />

DEALPCB3 PCB TYPE=DB,DBDNAME=DEALERDB,PROCOPT=GOP,KEYLEN=6<br />

SENSEG NAME=DEALER,PARENT=0<br />

SENSEG NAME=MODEL,PARENT=DEALER<br />

*<br />

DEALPCB4 PCB TYPE=DB,DBDNAME=DEALERDB,PROCOPT=AP,KEYLEN=12<br />

SENSEG NAME=DEALER,PARENT=0<br />

SENSEG NAME=MODEL,PARENT=DEALER<br />

SENSEG NAME=ORDER,PARENT=MODEL<br />

*<br />

DEALPCB5 PCB TYPE=DB,DBDNAME=DEALERDB,PROCOPT=GP,KEYLEN=14<br />

SENSEG NAME=DEALER,PARENT=0<br />

SENSEG NAME=MODEL,PARENT=DEALER<br />

SENSEG NAME=SALES,PARENT=MODEL<br />

*<br />

DEALPCB6 PCB TYPE=DB,DBDNAME=DEALERDB,PROCOPT=GOP,KEYLEN=26<br />

SENSEG NAME=DEALER,PARENT=0<br />

SENSEG NAME=MODEL,PARENT=DEALER<br />

SENSEG NAME=STOCK,PARENT=MODEL<br />

*<br />

PSBGEN LANG=ASSEM,CMPAT=YES,PSBNAME=<strong>IMS</strong>AUTO<br />

END<br />

Figure 110. PSB Gen input<br />

150 <strong>IMS</strong> <strong>Version</strong> 7 <strong>and</strong> <strong>Java</strong> <strong>Application</strong> <strong>Programming</strong>


2. <strong>IMS</strong> message region preparation<br />

In the message region STEPLIB concatenation you have to include the<br />

PDSE PGMLIB which contains the HPJ bound executables for the<br />

<strong>IMS</strong>Auto application. Also include the <strong>IMS</strong> <strong>Java</strong> Class Library <strong>and</strong> HPJ<br />

Class Libraries in the STEPLIB (see Figure 111).<br />

//STEPLIB DD DSN=<strong>IMS</strong>.SJ<strong>IMS</strong>R.SDFSJLIB,DISP=SHR <strong>IMS</strong> CLASS LIBRARY<br />

// DD DSN=HPJ390.SHPJMOD,DISP=SHR HPJ CLASS LIBRARY<br />

// DD DSN=HPJ390.SHPOMOD,DISP=SHR HPJ CLASS LIBRARY<br />

// DD DSN=<strong>IMS</strong>.SJ<strong>IMS</strong>R.IVP.PGMLIB,DISP=SHRPDSE PGMLIB<br />

// DD DSN=<strong>IMS</strong>.SJ<strong>IMS</strong>R.PGMLIB,DISP=SHR PDS PGMLIB<br />

// DD DSN=<strong>IMS</strong>.SJ<strong>IMS</strong>R.SDFSRESL,DISP=SHR<strong>IMS</strong> RESLIB<br />

Figure 111. <strong>IMS</strong> message region STEPLIB concatenation<br />

3. <strong>IMS</strong>Auto transaction input<br />

The <strong>IMS</strong>Auto executable contains methods that:<br />

- List all car models in the DEALER database.<br />

- Show the details for a specific car model in the DEALER database.<br />

- Find a specific type, model <strong>and</strong> color of car in the DEALER database.<br />

- Accept an order for a car with a specific vehicle identification number.<br />

- Cancel a specific order in the DEALER database.<br />

- Record a specific car sale in the DEALER database.<br />

Various techniques can be used to queue <strong>IMS</strong> transaction input messages.<br />

Since our <strong>IMS</strong>Auto application had not existed prior to our testing, no MFS<br />

code or any other method for message inputting existed. So, we chose to use<br />

the simplest method to test the <strong>IMS</strong>Auto transaction — native 3270 <strong>IMS</strong><br />

terminal input <strong>and</strong> output.<br />

Note<br />

Note: We did install <strong>and</strong> utilize successfully the <strong>IMS</strong> Client for <strong>Java</strong>. This<br />

product requires the <strong>IMS</strong> Connector.<br />

The following code listings show the <strong>IMS</strong>Auto transaction input messages for<br />

the various <strong>IMS</strong>Auto comm<strong>and</strong> codes. After each input message we have<br />

listed the corresponding output message, extracted from the x’03’ log record,<br />

which was sent back to the terminal.<br />

Chapter 7. VisualAge for <strong>Java</strong> <strong>IMS</strong> application development 151


LISTMODELS<br />

INPUT MESSAGE:<br />

123456789012345678<br />

<strong>IMS</strong>AUTO LISTMODELS<br />

OUTPUT MESSAGE:<br />

....15HONDA ACCORD 200016HONDA CIVIC 200017HONDA PRELUDE 20<br />

0003FFCDDCC44444CCCDDC4444FFFFFFCDDCC44444CCECC44444FFFFFFCDDCC44444DDCDECC444FF<br />

00091586541000001336940000200016865410000039593000002000178654100000795344500020<br />

0018HONDA CR-V 200015HONDA ACCORD 200016HONDA CIVIC 2000<br />

FFFFCDDCC44444CD6E444444FFFFFFCDDCC44444CCCDDC4444FFFFFFCDDCC44444CCECC44444FFFF<br />

00188654100000390500000020001586541000001336940000200016865410000039593000002000<br />

17HONDA PRELUDE 200018HONDA CR-V 200011TOYOTA AVALON 200012<br />

FFCDDCC44444DDCDECC444FFFFFFCDDCC44444CD6E444444FFFFFFEDEDEC4444CECDDD4444FFFFFF<br />

17865410000079534450002000188654100000390500000020001136863100001513650000200012<br />

TOYOTA CAMRY 200013TOYOTA SOLARA 200014TOYOTA 4RUNNER 200001FO<br />

EDEDEC4444CCDDE44444FFFFFFEDEDEC4444EDDCDC4444FFFFFFEDEDEC4444FDEDDCD444FFFFFFCD<br />

36863100003149800000200013368631000026319100002000143686310000494555900020000166<br />

RD TAURUS 200002FORD ESCORT 200003FORD<br />

DC444444ECEDEE4444FFFFFFCDDC444444CECDDE4444FFFFFFCDDC444444 etc...<br />

940000003149420000200002669400000052369300002000036694000000<br />

SHOWMODELDETAIL<br />

INPUT MESSAGE:<br />

123456789012345678901234567890<br />

<strong>IMS</strong>AUTO SHOWMODELDETAILS 11<br />

OUTPUT MESSAGE:<br />

11TOYOTA AVALON 200034000002700300225<br />

FFEDEDEC4444CECDDD4444FFFFFFFFFFFFFFFFFFFFF<br />

1136863100001513650000200034000002700300225<br />

152 <strong>IMS</strong> <strong>Version</strong> 7 <strong>and</strong> <strong>Java</strong> <strong>Application</strong> <strong>Programming</strong>


FINDACAR<br />

INPUT MESSAGE:<br />

123456789012345678901234567890123456789012345678901234567890123456789012<br />

<strong>IMS</strong>AUTO FINDACAR TOYOTA AVALON 20003000040000SILVER<br />

OUTPUT MESSAGE:<br />

....GGGG TOYOTA INC. TOYOTA AVALON 2000TOYOLOT 71HHHH TOYOTA<br />

0000CCCC4EDEDEC4CDC444444444444444EDEDEC4444CECDDD4444FFFFEDEDDDE4FFCCCC4EDEDEC4<br />

0003777703686310953B000000000000003686310000151365000020003686363071888803686310<br />

INC. TOYOTA AVALON 2000TOYOLOT 81IIII TOYOTA INC.<br />

CDC444444444444444EDEDEC4444CECDDD4444FFFFEDEDDDE4FFCCCC4EDEDEC4CDC4444444444444<br />

953B000000000000003686310000151365000020003686363081999903686310953B000000000000<br />

TOYOTA AVALON 2000TOYOLOT 91.....................<br />

44EDEDEC4444CECDDD4444FFFFEDEDDDE4FF000000000000000000000 etc...<br />

003686310000151365000020003686363091000000000000000000000<br />

ACCEPTORDER<br />

INPUT MESSAGE:<br />

12345678901234567890123456789012345678901234567890123456789012<br />

<strong>IMS</strong>AUTO ACCEPTORDER T0074D08252000TOYOVIN 300711T1T1T1<br />

OUTPUT MESSAGE:<br />

Order updated<br />

D98894A988A88<br />

6945904741354<br />

CANCELORDER<br />

INPUT MESSAGE:<br />

12345678901234567890123456789012345678<br />

<strong>IMS</strong>AUTO CANCELORDER T0074D3007<br />

OUTPUT MESSAGE:<br />

1<br />

F444<br />

1000<br />

Chapter 7. VisualAge for <strong>Java</strong> <strong>IMS</strong> application development 153


RECORDASALE<br />

INPUT MESSAGE:<br />

12345678901234567890123456789012345678901234567890123456789012345678901234<br />

<strong>IMS</strong>AUTO RECORDASALE 30071108252000DORKLE DARLING<br />

5678901234567890123456789012345678901234567890123456789012345678901234567<br />

1111 MAIN ST ANYWHERE USASELLER9999TOYOVIN 300711T1T1T1<br />

OUTPUT MESSAGE:<br />

Sales recorded<br />

E898A498899888444444444444444444444444444444444444444444444444444444444444444444<br />

21352095369454000000000000000000000000000000000000000000000000000000000000000000<br />

154 <strong>IMS</strong> <strong>Version</strong> 7 <strong>and</strong> <strong>Java</strong> <strong>Application</strong> <strong>Programming</strong>


Part 3. Debugging <strong>and</strong> problem determination<br />

This part of the book describes debugging <strong>and</strong> problem determination.<br />

It contains the following chapters:<br />

Chapter 8, “Diagnostic techniques” on page 157<br />

Chapter 9, “Development limitations” on page 165<br />

© Copyright <strong>IBM</strong> Corp. 2001 155


156 <strong>IMS</strong> <strong>Version</strong> 7 <strong>and</strong> <strong>Java</strong> <strong>Application</strong> <strong>Programming</strong>


Chapter 8. Diagnostic techniques<br />

8.1 <strong>IMS</strong>Trace<br />

This chapter describes various diagnostic techniques that can be used to<br />

help debug your <strong>Java</strong> applications.<br />

<strong>IMS</strong>Trace provides you with the ability to debug your <strong>Java</strong> applications by<br />

tracing, or documenting, the flow of control throughout your application. By<br />

having the ability to set up tracepoints throughout your applications for<br />

output, you can isolate problem areas <strong>and</strong>, therefore, know where to make<br />

adjustments to produce the results you expect. In addition, because<br />

<strong>IMS</strong>Trace supports writing input parameters <strong>and</strong> results, <strong>and</strong> the <strong>IMS</strong> <strong>Java</strong><br />

library provided routines use this feature, you can verify that correct results<br />

occur across method boundaries.<br />

8.1.1 Initiating <strong>IMS</strong>Tracing<br />

To debug with <strong>IMS</strong>Trace, you must first turn on the tracing function by setting<br />

the <strong>IMS</strong>Trace.traceOn variable to true. Because tracing does not occur until<br />

this variable is set, it is best to do so within a static block of the<br />

<strong>IMS</strong><strong>Application</strong> subclass. Then, you must decide how closely you want to<br />

trace the <strong>IMS</strong> <strong>Java</strong> library’s flow of control, as well as how much tracing you<br />

want to add to your application code.<br />

You determine the amount of tracing in the <strong>IMS</strong> <strong>Java</strong> library by setting the<br />

value of <strong>IMS</strong>Trace.libTraceLevel to one of its predefined values. By default,<br />

this value is set to <strong>IMS</strong>Trace.TRACE_EXCEPTIONS, which traces the<br />

construction of <strong>IMS</strong>-<strong>Java</strong>-library-provided exceptions. <strong>IMS</strong>Trace also defines<br />

constants for three types of additional tracing. These constants provide<br />

successively more tracing from <strong>IMS</strong>Trace.TRACE_CTOR1 (level one tracing<br />

of constructions) to <strong>IMS</strong>Trace.TRACE_DATA3 (level three tracing of data).<br />

8.1.2 Setting up tracing for the <strong>IMS</strong> <strong>Java</strong> library routines<br />

To turn on the tracing shipped with the <strong>IMS</strong> <strong>Java</strong> library routines:<br />

1. Turn on the flag enabling tracing. (It is turned off by default.)<br />

<strong>IMS</strong>Trace.traceOn = true;<br />

2. Set the level of tracing for the <strong>IMS</strong> <strong>Java</strong> library routines. In this example,<br />

the constructors are traced, as is the entry <strong>and</strong> exit of level one methods:<br />

<strong>IMS</strong>Trace.libTraceLevel = <strong>IMS</strong>Trace.TRACE_METHOD1;<br />

© Copyright <strong>IBM</strong> Corp. 2001 157


3. Set an output stream (a print stream or a character output writer) as the<br />

current trace stream.<br />

For example:<br />

a. Set the system error stream as the current trace stream:<br />

catch (Exception e) {<br />

// Use st<strong>and</strong>ard error if the file couldn’t be opened for writing<br />

<strong>IMS</strong>Trace.setOutputStream(System.err);<br />

}<br />

b. Set a StringWriter (an in-memory buffer) as the current trace stream:<br />

StringWriter stringWriter = new StringWriter();<br />

<strong>IMS</strong>Trace.setOutputWriter(stringWriter);<br />

These steps are best implemented within a static method of your<br />

<strong>IMS</strong><strong>Application</strong> subclass main routine:<br />

public class <strong>IMS</strong>Auto extends <strong>IMS</strong><strong>Application</strong>{<br />

static {<br />

<strong>IMS</strong>Trace.traceOn = true;<br />

<strong>IMS</strong>Trace.libTraceLevel = <strong>IMS</strong>Trace.TRACE_METHOD1;<br />

<strong>IMS</strong>Trace.setOutputStream(System.err);<br />

}<br />

public static void main(String args[]){<br />

<strong>IMS</strong>Auto application = new <strong>IMS</strong>Auto();<br />

application.begin();<br />

}<br />

}<br />

8.1.3 Adding trace statements to your application<br />

You can add trace statements to your application, similar to those provided by<br />

the <strong>IMS</strong> <strong>Java</strong> Library, by defining an integer variable that you test prior to<br />

writing trace statements. Using a variable other than <strong>IMS</strong>Trace.libTraceLevel<br />

enables you to control the level of tracing in your application independently of<br />

the tracing in the <strong>IMS</strong> <strong>Java</strong> library. For example, you can turn off the tracing of<br />

<strong>IMS</strong> <strong>Java</strong> library routines by setting <strong>IMS</strong>Trace.libTraceLevel to zero while still<br />

tracing your application code.<br />

158 <strong>IMS</strong> <strong>Version</strong> 7 <strong>and</strong> <strong>Java</strong> <strong>Application</strong> <strong>Programming</strong>


Follow these steps to add tracing to your application code:<br />

1. Define an integer variable to contain the trace level for<br />

application-provided code:<br />

public class <strong>IMS</strong>Auto extends <strong>IMS</strong><strong>Application</strong> {<br />

public int application TraceLevel = <strong>IMS</strong>Trace.TRACE_CTOR3;<br />

2. Call <strong>IMS</strong>Trace routines to trace methods, parameters, <strong>and</strong> return values<br />

as necessary:<br />

public class <strong>IMS</strong>Auto extends <strong>IMS</strong>Applicatio {<br />

public static int applicationTraceLevel=<strong>IMS</strong>Trace.TRACE_CTOR3;<br />

static{<br />

<strong>IMS</strong>Trace.traceOn = true;<br />

<strong>IMS</strong>Trace.libTraceLevel = <strong>IMS</strong>Trace.TRACE_METHOD1;<br />

<strong>IMS</strong>Trace.setOutputStream(System.err);<br />

}<br />

public static void main (String args[]){<br />

<strong>IMS</strong>Auto application = new <strong>IMS</strong>Auto();<br />

application.begin();<br />

}<br />

public void doBegin() throws <strong>IMS</strong>Exception {<br />

if(<strong>IMS</strong>Auto.applicationTraceLevel >= <strong>IMS</strong>Trace.TRACE_METHOD1)<br />

<strong>IMS</strong>Trace.currentTrace().logEntry("<strong>IMS</strong>Auto.doBegin");<br />

try {<br />

//Add code here ...<br />

}<br />

finally {<br />

if(<strong>IMS</strong>Auto.applicationTraceLevel >= <strong>IMS</strong>Trace.TRACE_METHOD1)<br />

<strong>IMS</strong>Trace.currentTrace().logExit("<strong>IMS</strong>Auto.doBegin");<br />

}<br />

}<br />

public String method1(String parm ){<br />

if(<strong>IMS</strong>Auto.applicationTraceLevel >= <strong>IMS</strong>Trace.TRACE_METHOD2) {<br />

<strong>IMS</strong>Trace.currentTrace().logEntry("<strong>IMS</strong>Auto.method1");<br />

if(<strong>IMS</strong>Auto.applicationTraceLevel >= <strong>IMS</strong>Trace.TRACE_DATA2)<br />

<strong>IMS</strong>Trace.currentTrace().logParm(“parm1”,parm1);<br />

}<br />

String result = new String();<br />

try {<br />

// Add code here . . .<br />

result = “result”;<br />

}<br />

finally {<br />

if (<strong>IMS</strong>Auto.applicationTraceLevel >= <strong>IMS</strong>Trace.TRACE_METHOD2)<br />

<strong>IMS</strong>Trace.currentTrace().logExit(“<strong>IMS</strong>Auto.method1”);<br />

}<br />

return result;<br />

}<br />

}<br />

Chapter 8. Diagnostic techniques 159


8.2 Writing your <strong>Java</strong> code with problem detection in mind<br />

This section describes some features that you could include in your programs<br />

to simplify problem detection in the program. However, if you are writing<br />

code, or have the opportunity to add to existing code, you might think about<br />

adding some of these features.<br />

8.2.1 <strong>Java</strong> sample tracing<br />

There are a number of ways you might consider adding debug tracing to your<br />

code. In this section we offer some guidance on writing trace facilities.<br />

8.2.2 Trace started using a program argument<br />

This feature traces processing at a very high level. The trace is displayed in<br />

the st<strong>and</strong>ard output, which is useful for tracing a single request. However, for<br />

tracing multiple requests, a trace file is required to allow detailed analysis.<br />

When the program being traced has several threads, one of the parameters<br />

that must be traced is the thread identifier that is running the request. This<br />

enables the trace to detect problems in thread synchronization.<br />

8.2.3 Debugging trace method in each class<br />

Each class in your program might provide a trace function. There are a<br />

number of alternatives to activate such a trace, such as: Having the trace<br />

code compiled into the main program function, <strong>and</strong> activated by a trace flag.<br />

For example, each class might test the value of the flag on initialization (that<br />

is, in the constructor) to determine whether to use the trace method. The flag<br />

could also specify different levels of tracing, such as method calls, or tracing<br />

the contents of variables. The flag could be set in a properties file. To avoid a<br />

large performance impact using this technique, class initialization could set a<br />

local flag which then dictates whether to use tracing. For example, you could<br />

do something like the following:<br />

int tracing_flag = 0; // initialize trace flag<br />

tracing_flag = System.getProperty("traceflag");<br />

...<br />

if (tracing_flag > 0) trace(tracing_flag);<br />

Have the trace code compiled into a debug version of the software.<br />

160 <strong>IMS</strong> <strong>Version</strong> 7 <strong>and</strong> <strong>Java</strong> <strong>Application</strong> <strong>Programming</strong>


This is a lower level of trace, which is useful during unit test or for debugging<br />

of a problem. Although <strong>Java</strong> does not have conditional compilation, most<br />

<strong>Java</strong> compilers will not include unreachable code in a class. Therefore you<br />

could set up a static variable to turn debugging on or off, <strong>and</strong> have the call to<br />

the debug method dependent on the setting of that flag. To compile a version<br />

of your software without debugging code, simply set the flag to false, <strong>and</strong><br />

compile.<br />

8.2.4 H<strong>and</strong>ling exceptions<br />

<strong>Java</strong> provides an elegant solution to the problem of error management of<br />

exceptions. Exceptions enable you to write the main flow of your code <strong>and</strong><br />

deal with exceptional cases outside the mainline code. In fact, OS/390 uses a<br />

similar architecture for its error h<strong>and</strong>ling in Functional Recovery Routines.<br />

However, exceptions do not spare you the effort of doing the work of<br />

detecting, reporting, <strong>and</strong> h<strong>and</strong>ling errors.<br />

We have many examples of <strong>Java</strong> code where exceptions are caught, but no<br />

action is taken in the catch phrase. This should never be allowed. At a<br />

minimum, the exception should be traced, preferably to a file (note that<br />

writing to a file can also cause an exception, which you should be prepared to<br />

deal with). Following is a short sample of how to trace the complete<br />

information from an exception:<br />

/**<br />

* This method prints an exception to the log file.<br />

* @param ex java.lang.Exception<br />

*/<br />

public static void printException(Exception ex) {<br />

java.text.SimpleDateFormat formatter = new<br />

java.text.SimpleDateFormat(DATE);<br />

java.util.Date date = new java.util.Date();<br />

String dateString = formatter.format(date);<br />

try {<br />

getOutput().write(dateString);<br />

} catch (IOException ioe){<br />

ioe.printStackTrace();<br />

}<br />

ex.printStackTrace(new PrintWriter(getOutput())) ;<br />

try {<br />

getOutput().flush();<br />

} catch (IOException ioe){<br />

ioe.printStackTrace();<br />

}<br />

}<br />

Chapter 8. Diagnostic techniques 161


The output is defined as follows:<br />

/**<br />

* This method creates an outputWriter to file named LSI115.<br />

* @param ex java.lang.Exception<br />

*/<br />

public static Writer getOutput() {<br />

if (fileName == null )<br />

fileName = "LSI001.LOG" ;<br />

try {<br />

if (output == null)<br />

output = (Writer)new FileWriter(fileName);<br />

} catch (IOException ioe) {<br />

ioe.printStackTrace();<br />

}<br />

return output;<br />

}<br />

Every time an exception is caught, we have to trace the exception as follows:<br />

} catch (Exception e){<br />

Log.printException(e);<br />

return ;<br />

}<br />

Sample output from the log file is as follows:<br />

1999.August.19 11:36:02 java.lang.ArrayIndexOutOfBoundsException<br />

java.lang.Throwable()<br />

java.lang.Exception()<br />

java.lang.RuntimeException()<br />

java.lang.IndexOutOfBoundsException()<br />

java.lang.ArrayIndexOutOfBoundsException()<br />

void fileio.PortableFileReader.main(java.lang.String [])<br />

void fileio.PortableFileReader.main(java.lang.String [])<br />

162 <strong>IMS</strong> <strong>Version</strong> 7 <strong>and</strong> <strong>Java</strong> <strong>Application</strong> <strong>Programming</strong>


8.3 Diagnosing problems with <strong>Java</strong> on OS/390<br />

For severe problems with running, <strong>IMS</strong> <strong>Java</strong> generates two types of files in<br />

the file system:<br />

.CEEDUMP.yyyymmdd.hhmmss.nnnnnnnn<br />

.JAVADUMP.yyyymmdd.hhmmss.nnnnnnnnnn<br />

The CEEDUMP file is a language environment dump. A very useful section of<br />

this dump file is the “traceback”, which traces function calls <strong>and</strong> reports<br />

where the exception that caused the dump took place.<br />

8.4 Diagnosing LE (Language Environment) messages <strong>and</strong> abends<br />

Here are some common CEL messages:<br />

CEE3201S - Indicates ABEND0C1<br />

CEE3204S - Indicates ABEND0C4<br />

CEE32xxS - Indicates ABEND0Cy<br />

- where y is the hex equivalent of decimal xx<br />

CEE3250C - Indicates some non-0Cx ABEND occurred<br />

CEE0802C <strong>and</strong> CEE0813S - Error with HEAP storage (normally a user<br />

problem)<br />

The following describes the LE Condition Token (Feedback Code)<br />

- Example: 00030C84 59C3C5C5 xxxxxxxx<br />

- 0003 Severity<br />

- 0000 Informational<br />

- 0001 Warning (W)<br />

- 0002 Error (E)<br />

- 0003 Severe (S)<br />

- 0004 Critical (C)<br />

0C84 Hex message number (3204)<br />

59 Flags (ignore)<br />

C3C5C5 Prefix (Facility ID)<br />

xxxxxxx Used internally<br />

This token represents Message CEE3204S.<br />

Chapter 8. Diagnostic techniques 163


164 <strong>IMS</strong> <strong>Version</strong> 7 <strong>and</strong> <strong>Java</strong> <strong>Application</strong> <strong>Programming</strong>


Chapter 9. Development limitations<br />

This chapter lists several development limitations you may encounter:<br />

Use of AIB requires PCBNAMES in PSB.<br />

Cannot call COBOL subroutines.<br />

Must be single-threaded.<br />

Use PDSE VS HFS FILE.<br />

PDSE in STEPLIB concatenation (may impact existing JCL inserting a<br />

database record).<br />

Inserting database record.<br />

Be sure to refer to the latest <strong>IMS</strong> <strong>Java</strong> <strong>IBM</strong> documentation if you need more<br />

details on any of the above topics.<br />

© Copyright <strong>IBM</strong> Corp. 2001 165


166 <strong>IMS</strong> <strong>Version</strong> 7 <strong>and</strong> <strong>Java</strong> <strong>Application</strong> <strong>Programming</strong>


Part 4. Appendices<br />

This part of the book contains ten useful appendices for reference:<br />

Appendix A, “<strong>IMS</strong> <strong>Java</strong> package” on page 169<br />

Appendix B, “Debugging <strong>and</strong> problem determination” on page 301<br />

Appendix C, “<strong>IMS</strong> abend codes” on page 305<br />

Appendix D, “<strong>IMS</strong> <strong>Java</strong> tracing facilities” on page 307<br />

Appendix E, “IVP application — <strong>Java</strong> source (<strong>Java</strong> to DLI version)” on<br />

page 311<br />

Appendix F, “IVP application — <strong>Java</strong> source (JDBC version)” on page 325<br />

Appendix G, “IVP application — COBOL source” on page 339<br />

Appendix H, “Installing the IVP Phone application” on page 351<br />

Appendix I, “Dealership sample application” on page 357<br />

Appendix J, “Options for the hpj comm<strong>and</strong>” on page 385<br />

© Copyright <strong>IBM</strong> Corp. 2001 167


168 <strong>IMS</strong> <strong>Version</strong> 7 <strong>and</strong> <strong>Java</strong> <strong>Application</strong> <strong>Programming</strong>


Appendix A. <strong>IMS</strong> <strong>Java</strong> package<br />

The <strong>IMS</strong> <strong>Java</strong> package contains the following packages <strong>and</strong> is installed with<br />

<strong>IMS</strong> <strong>Version</strong> 7 via SMP/E:<br />

1. The package com.ibm.ims.base (Base package), provides the lowest level<br />

of access. This package provides <strong>Java</strong> method calls which have been<br />

written to match the DL/I calls currently supported in the other languages.<br />

(CEETDLI for C/C++, PLITDLI for PL/I).The mapping is achieved using<br />

<strong>Java</strong> Native Interface calls (JNI) from <strong>Java</strong> to the CEETDLI interface.<br />

Since <strong>Java</strong> does not have structures as do these other languages, the<br />

base package includes the classes AIB, DBPCB, <strong>and</strong> IOPCB to map to the<br />

data of these structures. The base package is provided primarily as an<br />

implementation vehicle for the high level packages com.ibm.ims.db<br />

(the db package) <strong>and</strong> com.ibm.ims.application (the application package).<br />

2. The package com.ibm.ims.db (the db package) provides high level access<br />

to <strong>IMS</strong> databases. This access includes full support for applications to<br />

build Segment Search Arguments (SSAs), <strong>and</strong> to use these SSA objects<br />

to retrieve, insert, update, <strong>and</strong> delete segments.<br />

3. The package com.ibm.ims.application (<strong>Application</strong> package) provides<br />

higher level access to many of the <strong>IMS</strong> transaction <strong>and</strong> system services.<br />

This includes Sync point services <strong>and</strong> access to the message queues.<br />

4. The following class documentation can be found in the directory<br />

/usr/lpp/ims/imsjava71/docs/api.zip. You can use NFS or FTP to transfer<br />

the file to a workstation to unzip <strong>and</strong> use it as a reference for the individual<br />

classes. When you unzip the api file it will create .html files containing all<br />

the class documentation.<br />

A.1 Contents of com.ibm.ims.application package<br />

The com.ibm.ims.application package contains the following classes:<br />

com.ibm.ims.application.<strong>IMS</strong><strong>Application</strong><br />

com.ibm.ims.application.<strong>IMS</strong>ErrorMessages<br />

com.ibm.ims.application.<strong>IMS</strong>FieldMessage<br />

com.ibm.ims.application.<strong>IMS</strong>MessageQueue<br />

com.ibm.ims.application.<strong>IMS</strong>Transaction<br />

© Copyright <strong>IBM</strong> Corp. 2001 169


A.2 Class com.ibm.ims.application.<strong>IMS</strong><strong>Application</strong><br />

Constructors<br />

Methods<br />

java.lang.Object<br />

+----com.ibm.ims.application.<strong>IMS</strong><strong>Application</strong><br />

public abstract class <strong>IMS</strong><strong>Application</strong> extends Object<br />

<strong>IMS</strong><strong>Application</strong> is the abstract base class for all <strong>Java</strong> <strong>IMS</strong> programs. Each<br />

application receives control in its static main method, where it is responsible to<br />

create an instance of its class <strong>and</strong> call the begin method of its base class,<br />

<strong>IMS</strong><strong>Application</strong>. The begin method does application setup, invokes its<br />

abstract doBegin method, <strong>and</strong> upon its return, terminates the application. <strong>Java</strong><br />

application programs implement their entire application from within their<br />

doBegin override.<br />

<strong>IMS</strong><strong>Application</strong> ()<br />

protected <strong>IMS</strong><strong>Application</strong>()<br />

Creates a new <strong>IMS</strong><strong>Application</strong> object.<br />

begin ()<br />

public final void begin()<br />

This will run the application. It first sets up the environments for <strong>IMS</strong> <strong>and</strong><br />

JDBC/SQLJ driver, then invokes its abstract doBegin method, <strong>and</strong> upon its<br />

return, terminates the application. Any exception caught from running the<br />

application will result in abending the transaction.<br />

do Begin()<br />

public abstract void doBegin() throws <strong>IMS</strong>Exception<br />

Implementation of the <strong>IMS</strong> application. All application programs should<br />

override this method <strong>and</strong> define their own application here.<br />

Throws: <strong>IMS</strong>Exception<br />

170 <strong>IMS</strong> <strong>Version</strong> 7 <strong>and</strong> <strong>Java</strong> <strong>Application</strong> <strong>Programming</strong>


programName ()<br />

public String programName() throws <strong>IMS</strong>Exception<br />

Returns the application program name.<br />

Returns: The application program name.<br />

Throws: <strong>IMS</strong>Exception if a non-blank status code is returned from the<br />

system call.<br />

A.3 Class com.ibm.ims.application.<strong>IMS</strong>ErrorMessages<br />

Constructors<br />

Methods<br />

Note<br />

The application should h<strong>and</strong>le all <strong>IMS</strong> exception properly. All<br />

uncaught exceptions will result in abending the transaction in the<br />

begin method.<br />

java.lang.Object<br />

+----java.util.ResourceBundle<br />

+----java.util.ListResourceBundle<br />

public class <strong>IMS</strong>ErrorMessages extends ListResourceBundle<br />

This class contains all the error messages used in the<br />

com.ibm.ims.application package.<br />

<strong>IMS</strong>ErrorMessages ()<br />

public <strong>IMS</strong>ErrorMessages()<br />

Instantiates a new <strong>IMS</strong>ErrorMessages object.<br />

getContents ()<br />

protected Object[ ][ ] getContents()<br />

Returns the contents of the error messages.<br />

Overrides: getContents in class ListResourceBundle<br />

Appendix A. <strong>IMS</strong> <strong>Java</strong> package 171


get<strong>IMS</strong>Bundle ()<br />

public static <strong>IMS</strong>ErrorMessages get<strong>IMS</strong>Bundle()<br />

Returns the contents of the error messages.<br />

A.4 Class com.ibm.ims.application.<strong>IMS</strong>FieldMessage<br />

java.lang.Object<br />

+----com.ibm.ims.base.DLIBaseSegment<br />

+----com.ibm.ims.application.<strong>IMS</strong>FieldMessage<br />

public abstract class <strong>IMS</strong>FieldMessage extends DLIBaseSegment<br />

<strong>IMS</strong>FieldMessage is an abstract base class for objects representing messages<br />

in an <strong>IMS</strong> message queue. These <strong>IMS</strong>FieldMessage subclasses provide the<br />

mapping between the data in the message <strong>and</strong> access functions on the class.<br />

User applications can reference the fields of the message by field index or by<br />

field name <strong>and</strong> utilize a wide range of data conversion functions provided in<br />

the base class DLIBaseSegment.<br />

To provide the mapping, the subclasses must provide an array of DLITypeInfo<br />

objects for the fields in the message as an argument to the <strong>IMS</strong>FieldMessage<br />

constructor. By doing so, the DLIBaseSegment class knows the layout of each<br />

field in the message <strong>and</strong> can access as well as update each of these fields.<br />

<strong>IMS</strong>FieldMessage is used to define either normal input <strong>and</strong> output messages<br />

(usually a separate subclass for each) or to define a data area called the<br />

Scratch Pad Area (SPA). The SPA is used in conversational transactions to<br />

store information between one step of the conversation <strong>and</strong> the next. To<br />

define a SPA message, the <strong>IMS</strong>FieldMessage subclass sets isSPA to true on<br />

the <strong>IMS</strong>FieldMessage constructor.<br />

Note<br />

Fields of type CHAR or VARCHAR will be encoded using the platform's default<br />

character encoding. If another encoding is desired, invoke the inherited<br />

setDefaultEncoding method of the <strong>IMS</strong>FieldMessage class, which isused to<br />

specify the character encoding for all character data in a message.<br />

A typical <strong>IMS</strong>FieldMessage subclass for an input message should look similar to<br />

Figure 112.<br />

172 <strong>IMS</strong> <strong>Version</strong> 7 <strong>and</strong> <strong>Java</strong> <strong>Application</strong> <strong>Programming</strong>


Variables<br />

public class InputMessage extends com.ibm.ims.application.<strong>IMS</strong>FieldMessage {<br />

static final DLITypeInfo[] segmentInfo = {<br />

new DLITypeInfo("Field1", DLITypeInfo.CHAR, 1, 10),<br />

new DLITypeInfo("Field2", DLITypeInfo.INTEGER, 11, 4),<br />

new DLITypeInfo("Field3", DLITypeInfo.SMALLINT, 15, 2)<br />

};<br />

public MySegment() {<br />

super(segmentInfo, 16, false);<br />

// can set the default character encoding to be used here for all character data<br />

// in this segment, otherwise it will default to the system's default encoding<br />

// this.setDefaultEncoding("UTF8");<br />

}<br />

}<br />

Figure 112. A typical <strong>IMS</strong>FieldMessage subclass<br />

Code to access the fields in InputMessage should look similar to Figure 113.<br />

InputMessage inputMessage = new InputMessage();<br />

messageQueue.getUniqueMessage(inputMessage);<br />

// Return "Field1" as a String using its index<br />

String field1 = inputMessage.getString(1);<br />

// Return "Field2" as a String using its field name (note: int to String conversion)<br />

String field2 = inputMessage.getString("Field2");<br />

Figure 113. Example of how to access the fields in subclass InputMessage<br />

MAX_MESSAGE_LENGTH<br />

public static final short MAX_MESSAGE_LENGTH<br />

The maximum size of the body of a message.<br />

TRANSCODE_VAR_8<br />

public static final int TRANSCODE_VAR_8<br />

The transcode rule for transcode up to 8 bytes long. A blank will be<br />

present between the transcode <strong>and</strong> the message body if the transcode is<br />

less than 8 bytes.<br />

TRANSCODE_FIXED_9<br />

public static final int TRANSCODE_FIXED_9<br />

The transcode rule for transcode that is exactly 8 bytes long <strong>and</strong> a blank is<br />

present between the transcode <strong>and</strong> the message body.<br />

Appendix A. <strong>IMS</strong> <strong>Java</strong> package 173


Constructors<br />

TRANSCODE_FIXED_8<br />

public static final int TRANSCODE_FIXED_8<br />

The transcode rule for transcode that is less than 8 bytes <strong>and</strong> is blank<br />

padded to 8 bytes long.<br />

<strong>IMS</strong>FieldMessage (DLITypeInfo, int, boolean)<br />

public <strong>IMS</strong>FieldMessage(DLITypeInfo typeInfo[ ],<br />

int length,<br />

boolean isSPA) throws IllegalArgumentException<br />

Creates a new <strong>IMS</strong>FieldMessage with the specified message length. The<br />

maximum length can be MAX_MESSAGE_LENGTH (32750) bytes.<br />

Parameters:<br />

174 <strong>IMS</strong> <strong>Version</strong> 7 <strong>and</strong> <strong>Java</strong> <strong>Application</strong> <strong>Programming</strong><br />

typeInfo - The array of DLITypeInfo objects defining the fields in the<br />

message.<br />

length - Tthe length for the message body of this message.<br />

isSPA - Flag telling whether this message is a SPA message.<br />

Throws: IllegalArgumentException if the length is invalid.<br />

<strong>IMS</strong>FieldMessage(<strong>IMS</strong>FieldMessage, DLITypeInfo [ ])<br />

public <strong>IMS</strong>FieldMessage(<strong>IMS</strong>FieldMessage message,<br />

DLITypeInfo typeInfo[ ])<br />

Creates a new <strong>IMS</strong>FieldMessage from an existing <strong>IMS</strong>FieldMessage. This<br />

allows an application to define one message that contains definitions of<br />

fields common to any input message <strong>and</strong> use this message to construct<br />

other messages that define the remaining fields.<br />

The following code in Figure 114 demonstrates how this can be used to<br />

define three messages that have the field 'Comm<strong>and</strong>Code' in common.


public class LogicalBaseMessage extends <strong>IMS</strong>FieldMessage {<br />

final static DLITypeInfo[] typeInfo = {<br />

new DLITypeInfo("Comm<strong>and</strong>Code", DLITypeInfo.CHAR, 1, 20),<br />

}<br />

public LogicalBaseMessage() {<br />

super(typeInfo, 30, false);<br />

}<br />

}<br />

public class LogicalSublcassA extends <strong>IMS</strong>FieldMessage {<br />

final static DLITypeInfo[] typeInfo = {<br />

new DLITypeInfo("Comm<strong>and</strong>Code", DLITypeInfo.CHAR, 1, 20),<br />

new DLITypeInfo("SomeFieldA", DLITypeInfo.CHAR, 21, 10),<br />

}<br />

public LogicalSubclassA(<strong>IMS</strong>FieldMessage message) {<br />

super(message, typeInfo);<br />

}<br />

public class LogicalSubclassB extends <strong>IMS</strong>FieldMessage {<br />

final static DLITypeInfo[] typeInfo = {<br />

new DLITypeInfo("Comm<strong>and</strong>Code", DLITypeInfo.CHAR, 1, 20),<br />

new DLITypeInfo("SomeFieldB", DLITypeInfo.CHAR, 21, 5),<br />

}<br />

public LogicalSubclassB(<strong>IMS</strong>FieldMessage message) {<br />

super(message, typeInfo);<br />

}<br />

}<br />

Figure 114. Example of coding messages that have the same field in common<br />

Notice a few points about Figure 114.<br />

- The Comm<strong>and</strong>Code field is defined within every class. This is really only<br />

necessary if users of LogicalSubclassA <strong>and</strong> LogicalSubclassB require<br />

access to this field.<br />

- The length of the "logical" base class, LogicalBaseClass, must be large<br />

enough to contain any of its "logical" subclasses. Therefore,<br />

LogicalBaseClass is 30 bytes long because the fields of<br />

LogicalSubclassA require it.<br />

- Each "logical" subclass must provide a constructor to create itself from<br />

another <strong>IMS</strong>FieldMessage. Given this approach, an application can<br />

provide message reading logic similar to Figure 115.<br />

Appendix A. <strong>IMS</strong> <strong>Java</strong> package 175


Methods<br />

LogicalBaseClass inputMessage = new LogicalBaseClass();<br />

while(messageQueue.getUniqueMessage(inputMessage)) {<br />

String comm<strong>and</strong>Code = inputMessage.getString("Comm<strong>and</strong>Code").trim();<br />

if (comm<strong>and</strong>Code.equals("LogicalSubclassA")) {<br />

processA(new LogicalSubclassA(inputMessage));<br />

}<br />

else if (comm<strong>and</strong>Code.equals("LogicalSubclassB")) {<br />

processB(new LogicalSubclassB(inputMessage));<br />

}<br />

else {<br />

// process an error<br />

}<br />

}<br />

Figure 115. Example of Message reading logic<br />

Parameters:<br />

176 <strong>IMS</strong> <strong>Version</strong> 7 <strong>and</strong> <strong>Java</strong> <strong>Application</strong> <strong>Programming</strong><br />

message - The <strong>IMS</strong>FieldMessage, or "logical" base class, that this<br />

message can be created from.<br />

typeInfo - The array of DLITypeInfo objects defining the fields in the<br />

message.<br />

clearBody ()<br />

public void clearBody()<br />

Clears out message body. All other parts of message are left untounched.<br />

clearWarnings ()<br />

public void clearWarnings()<br />

Clears the warning chain for this <strong>IMS</strong>FieldMessage. After this call<br />

getWarnings returns null until a new warning is reported for this<br />

<strong>IMS</strong>FieldMessage.<br />

Overrides: clearWarnings in class DLIBaseSegment<br />

getMessageLength ()<br />

public int getMessageLength()<br />

Returns the length of this message. This applies to the message body<br />

only, which excludes the length for the header of the message.<br />

Returns: The length of the message body.


getTransactionID ()<br />

public String getTransactionID()<br />

Return the transaction ID for this input message following reading of the<br />

message by <strong>IMS</strong>MessageQueue.<br />

Returns: The transactions ID or null if the transaction is not present for<br />

this message.<br />

getWarnings ()<br />

public DLIWarning getWarnings()<br />

Returns the first warning reported by calls on this <strong>IMS</strong>FieldMessage.<br />

Subsequent warnings will be chained to this DLIWarning. The warning<br />

chain is automatically cleared each time a new message is read from the<br />

queue.<br />

Note<br />

This warning chain only covers warnings caused by <strong>IMS</strong>FieldMessage<br />

methods.<br />

Returns: The first DLIWarning or null<br />

Overrides: getWarnings in class DLIBaseSegment<br />

setTransCodeRule (int)<br />

public static final void setTransCodeRule(int rule) throws<br />

IllegalArgumentException<br />

Set the Transcode rule for this message. Valid transcode rules are<br />

TRANSCODE_VAR_8, TRANSCODE_FIXED_9, or TRANSCODE_FIXED_8 (default). The<br />

transcode rule is used to determine the length of the transaction code<br />

when parsing the input message. As default, the rule is set to<br />

TRANSCODE_VAR_8, which means that the transcode can be either 8 bytes<br />

long or if less than 8 bytes, there is a blank between the transcode <strong>and</strong> the<br />

message body in the input message. If the transcode is exactly 8 bytes<br />

long <strong>and</strong> there is a trailing blank, set the rule to TRANSCODE_FIXED_9. If the<br />

transcode is less than 8 bytes long but is always blank padded to 8 bytes,<br />

set the rule to TRANSCODE_FIXED_8.<br />

Parameters:<br />

rule - The transcode rule for this message<br />

Appendix A. <strong>IMS</strong> <strong>Java</strong> package 177


A.5 Class com.ibm.ims.application.<strong>IMS</strong>MessageQueue<br />

java.lang.Object<br />

+----com.ibm.ims.application.<strong>IMS</strong>MessageQueue<br />

public final class <strong>IMS</strong>MessageQueue extends Object<br />

<strong>IMS</strong>MessageQueue provides services to send <strong>and</strong> receive messages to an <strong>IMS</strong><br />

message queue or to the application's Scratch Pad Area (SPA). The SPA is<br />

used in conversational transactions to store information between one step of<br />

the conversation <strong>and</strong> the next.<br />

<strong>IMS</strong>MessageQueue also supports sending messages to another application if an<br />

alternate PCB for that application is specified on the <strong>IMS</strong>MessageQueue<br />

constructor.<br />

In a non-conversational transaction, it is possible to code the application with<br />

a message loop that retrieves messages until <strong>IMS</strong> indicates that no more<br />

messages exist on the queue. To support this style of programming,<br />

<strong>IMS</strong>MessageQueue.getUniqueMessage returns true if a message could be returned<br />

from the queue <strong>and</strong> false if it could not. The application is required to call<br />

<strong>IMS</strong>Transaction.commit prior to receiving the second full message.<br />

Figure 116 demonstrates this style of programming.<br />

// Read the first segment of the input message<br />

while(messageQueue.getUniqueMessage(inputMessage1)) {<br />

// Read the second segment of the input message<br />

messageQueue.getNextMessage(inputMessage2);<br />

// Add logic here<br />

// Commit the transaction.<br />

trans.commit();<br />

} // end while<br />

Figure 116. Example of retrieving messages using a while loop<br />

Constructors<br />

<strong>IMS</strong>MessageQueue ()<br />

public <strong>IMS</strong>MessageQueue()<br />

Creates a new <strong>IMS</strong>MessageQueue which sends <strong>and</strong> receives messages to<br />

<strong>and</strong> from a terminal.<br />

178 <strong>IMS</strong> <strong>Version</strong> 7 <strong>and</strong> <strong>Java</strong> <strong>Application</strong> <strong>Programming</strong>


Methods<br />

<strong>IMS</strong>MessageQueue (String)<br />

public <strong>IMS</strong>MessageQueue(String alternatePCBName)<br />

Creates a new <strong>IMS</strong>MessageQueue with the alternate PCB Name to send<br />

messages to a different terminal or application program.<br />

Parameters:<br />

alternatePCBName - The alternate PCB Name where the message is<br />

sent.<br />

getAIB ()<br />

public final AIB getAIB()<br />

Returns the <strong>Application</strong> Interface Block (AIB) used by the message queue.<br />

Returns: AIB The <strong>Application</strong> Interface Block (AIB).<br />

getNextMessage (<strong>IMS</strong>FieldMessage)<br />

public boolean getNextMessage(<strong>IMS</strong>FieldMessage message) throws <strong>IMS</strong>Exception<br />

Receives the next segment of the message from <strong>IMS</strong>. This will receive the<br />

remaining segments for a multisegments message in the program.<br />

Parameters:<br />

message - The <strong>IMS</strong>FieldMessage object to receive the message.<br />

Returns: True if the message was retrieve, false if no more messages.<br />

Throws: <strong>IMS</strong>Exception if a non-blank status code is returned from the<br />

GN call.<br />

getUniqueMessage (<strong>IMS</strong>FieldMessage)<br />

public boolean getUniqueMessage(<strong>IMS</strong>FieldMessage message) throws<br />

<strong>IMS</strong>Exception<br />

Receives the first segment of an input message from <strong>IMS</strong>. It is also used<br />

to retrieve the SPA if the program is conversational.<br />

Returns: Flag telling whether a message has been retrieved.<br />

Throws: <strong>IMS</strong>Exception if a non-blank status code is returned from the<br />

GU call or if getUniqueMessage is called without commiting the previous<br />

changes.<br />

Appendix A. <strong>IMS</strong> <strong>Java</strong> package 179


insertMessage (<strong>IMS</strong>FieldMessage)<br />

public void insertMessage(<strong>IMS</strong>FieldMessage message) throws <strong>IMS</strong>Exception<br />

Send the output message to <strong>IMS</strong>. The default formatting will be used.<br />

Parameters:<br />

message - The message to send.<br />

Throws: <strong>IMS</strong>Exception if a non-blank status code is returned from the<br />

ISRT call.<br />

insertMessage (<strong>IMS</strong>FieldMessage, boolean)<br />

public void insertMessage(<strong>IMS</strong>FieldMessage message,<br />

boolean isLast) throws <strong>IMS</strong>Exception<br />

Send the SPA to <strong>IMS</strong> <strong>and</strong> end the conversation if isLast is true. This<br />

method should be used in a convesational program only.<br />

Parameters:<br />

message - The message to send.<br />

isLast - Flag telling whether this is the last segment for the<br />

conversation.<br />

Throws: <strong>IMS</strong>Exception if a non-blank status code is returned from the<br />

ISRT call.<br />

insertMessage (<strong>IMS</strong>FieldMessage, String)<br />

public void insertMessage(<strong>IMS</strong>FieldMessage message,<br />

String modName) throws <strong>IMS</strong>Exception<br />

Send the output message to <strong>IMS</strong>, specifying the Message Output<br />

Descriptor to format the output message.<br />

Parameters:<br />

message - The message to send.<br />

modName - The Message Output Descriptor (MOD) for formatting the<br />

output message.<br />

Throws: <strong>IMS</strong>Exception if a non-blank status code is returned from the<br />

ISRT call.<br />

insertMessage (<strong>IMS</strong>FieldMessage, String, boolean)<br />

public void insertMessage(<strong>IMS</strong>FieldMessage message,<br />

String modName,<br />

boolean isLast) throws <strong>IMS</strong>Exception<br />

180 <strong>IMS</strong> <strong>Version</strong> 7 <strong>and</strong> <strong>Java</strong> <strong>Application</strong> <strong>Programming</strong>


Send the SPA to <strong>IMS</strong> with the Message Output Descriptor specified <strong>and</strong><br />

end the conversation if isLast is true. This method is used in a<br />

convesational program only.<br />

Parameters:<br />

message - The message to send.<br />

modName - The Message Output Descriptor (MOD) for formatting.<br />

isLast - Flag telling whether this is the last segment for the<br />

conversation.<br />

Throws: <strong>IMS</strong>Exception if a non-blank status code is returned from the<br />

ISRT call.<br />

setModifiableAlternatePCB (String)<br />

public void setModifiableAlternatePCB(String destination) throws<br />

<strong>IMS</strong>Exception<br />

This method should be used to set the destination in the modifiable<br />

alternate PCB. Call this method prior to inserting a message to another<br />

program or logical terminal.<br />

Parameters:<br />

destination - Transaction or logical terminal destination.<br />

A.6 Class com.ibm.ims.application.<strong>IMS</strong>Transaction<br />

java.lang.Object<br />

+----com.ibm.ims.application.<strong>IMS</strong>Transaction<br />

public final class <strong>IMS</strong>Transaction extends Object<br />

The <strong>IMS</strong>Transaction class provides <strong>Java</strong> <strong>IMS</strong> Programs with access to <strong>IMS</strong><br />

transaction services such as commit <strong>and</strong> rollback. The singleton<br />

<strong>IMS</strong>Transaction object is returned to an application when it calls the static<br />

<strong>IMS</strong>Transaction method getTransaction. This ensures both that only a single<br />

<strong>IMS</strong>Transaction object exists for the application <strong>and</strong>, because the constructor<br />

for <strong>IMS</strong>Transaction is private, that the class can not be subclassed.<br />

Appendix A. <strong>IMS</strong> <strong>Java</strong> package 181


Methods<br />

abend ()<br />

public void abend()<br />

Abnormally terminates the application. It backs out the output messages<br />

sent by the conversational application program.<br />

Parameters:<br />

182 <strong>IMS</strong> <strong>Version</strong> 7 <strong>and</strong> <strong>Java</strong> <strong>Application</strong> <strong>Programming</strong><br />

exception - The exception that causes the program to abend.<br />

commit ()<br />

public void commit() throws <strong>IMS</strong>Exception<br />

Commits the transaction <strong>and</strong> cleans up the resources. It invokes the JDBC<br />

driver commit method to clean up the JDBC/SQLJ resources.<br />

Throws: <strong>IMS</strong>Exception if a non-blank status code is returned from the<br />

system call or if the call to JDBC commit failed.<br />

getTransaction ()<br />

public static <strong>IMS</strong>Transaction getTransaction()<br />

Returns a new <strong>IMS</strong>Transaction object.<br />

Returns: An <strong>IMS</strong>Transaction object.<br />

rollback ()<br />

public void rollback() throws <strong>IMS</strong>Exception<br />

Rolls back the transaction <strong>and</strong> cleans up the resources. It backs out the<br />

messages sent by the application program <strong>and</strong> invokes the JDBC driver<br />

rollback method to clean up the JDBC/SQLJ resources.<br />

Throws: <strong>IMS</strong>Exception if a non-blank status code is returned from the<br />

system call or if the call to JDBC rollback failed.<br />

A.7 Contents of com.ibm.ims.base package<br />

The com.ibm.ims.base package contains the following classes:<br />

com.ibm.ims.base.AIB<br />

com.ibm.ims.base.AlternatePCB<br />

com.ibm.ims.base.DBPCB<br />

com.ibm.ims.base.DLIBaseSegment<br />

com.ibm.ims.base.DLITypeInfo<br />

com.ibm.ims.base.DLITypeInfoList<br />

com.ibm.ims.base.<strong>IMS</strong>ErrorMessages


com.ibm.ims.base.<strong>IMS</strong>Info<br />

com.ibm.ims.base.<strong>IMS</strong>Trace<br />

com.ibm.ims.base.IOPCB<br />

com.ibm.ims.base.<strong>Java</strong>ToDLI<br />

The com.ibm.ims.base package contains the following exemption classes:<br />

com.ibm.ims.base.DLIJNICallbackException<br />

com.ibm.ims.base.DLIWarning<br />

com.ibm.ims.base.<strong>IMS</strong>Exception<br />

A.8 Class com.ibm.ims.base.AIB<br />

java.lang.Object<br />

+----com.ibm.ims.base.AIB<br />

public final class AIB extends Object<br />

The <strong>Application</strong> Interface Block (AIB) is used by your program to<br />

communicate with <strong>IMS</strong>. The AIB class contains all the data attributes of the<br />

<strong>IMS</strong> <strong>Application</strong> Interface Block <strong>and</strong> the necessary getter <strong>and</strong> setter methods.<br />

It contains an IOPCB object, an alternate PCB object, <strong>and</strong> a DBPCB object. It<br />

also contains a boolean variable indicating if the IOPCB object references an<br />

alternate PCB. See <strong>IMS</strong> <strong>Application</strong> <strong>Programming</strong>: Database Manager.<br />

See also: IOPCB, AlternatePCB, DBPCB .<br />

Constructors<br />

AIB ()<br />

public AIB()<br />

Constructs an AIB. Resource name <strong>and</strong> I/O area length must be set before<br />

use.<br />

AIB (String, int)<br />

public AIB(String resourceName,<br />

int ioAreaLength)<br />

Constructs an AIB with a resource name <strong>and</strong> the I/O area length.<br />

Parameters:<br />

resourceName - A PCB name. This parameter should be a maximum<br />

of 8 characters, if greater, will be truncated to 8 characters.<br />

Appendix A. <strong>IMS</strong> <strong>Java</strong> package 183


Methods<br />

ioAreaLength - The length of the I/O area.<br />

setAlternatePCB ()<br />

public void setAlternatePCB(boolean isAlternate)<br />

Sets an indicator designating whether the PCB is an alternate PCB.<br />

Parameters:<br />

isAlternate - True if PCB is alternate.<br />

isAlternatePCB ()<br />

public boolean isAlternatePCB()<br />

Returns true if PCB is an alternate PCB.<br />

Returns: True if PCB is alternate or false if PCB is not alternate.<br />

getSubFunctionCode ()<br />

public String getSubFunctionCode()<br />

Returns the subfunction code in this AIB.<br />

Returns: The AIB's subfunction code.<br />

setSubFunctionCode ()<br />

public void setSubFunctionCode(String subFunctionCode)<br />

Sets the subfunction code in this AIB. This parameter should be a<br />

maximum of 8 characters, if greater, will be truncated to 8 characters.<br />

Parameters:<br />

184 <strong>IMS</strong> <strong>Version</strong> 7 <strong>and</strong> <strong>Java</strong> <strong>Application</strong> <strong>Programming</strong><br />

subFunctionCode - The AIB's subfunction code.<br />

getResourceName ()<br />

public String getResourceName()<br />

Returns the resource name (PCB name) in this AIB.<br />

Returns: The AIB's resource name.<br />

setResourceName ()<br />

public void setResourceName(String resourceName)<br />

Sets the resource name (usually PCB name) in this AIB. This parameter<br />

should be a maximum of 8 characters, if greater, will be truncated to 8<br />

characters.


Parameters:<br />

resourceName - The AIB's resource name.<br />

getOALength ()<br />

public int getOALength()<br />

Returns the maximum output area length in this AIB.<br />

Returns: The output area length used.<br />

setOALength ()<br />

public void setOALength(int length)<br />

Sets the maximum output area length in this AIB.<br />

Parameters:<br />

length - The output area length used.<br />

getOAUse ()<br />

public int getOAUse()<br />

Returns the output area length used in this AIB.<br />

Returns: The output area length used.<br />

getReturnCode ()<br />

public int getReturnCode()<br />

Returns the return code produced by the last DLI call through this AIB.<br />

Returns: The return code of the last DLI call.<br />

getReasonCode ()<br />

public int getReasonCode()<br />

Returns the reason code produced by the last DLI call through this AIB.<br />

Returns: The reason code of the last DLI call.<br />

getErrorCodeExtension ()<br />

public int getErrorCodeExtension()<br />

Returns the error code extension produced by the last DLI call through this<br />

AIB.<br />

Returns: The error code extension of the last DLI call.<br />

getDBPCB ()<br />

public DBPCB getDBPCB()<br />

Appendix A. <strong>IMS</strong> <strong>Java</strong> package 185


Returns the DBPCB object in this AIB.<br />

Returns: The DBPCB in this AIB.<br />

getIOPCB ()<br />

public IOPCB getIOPCB()<br />

Returns the IOPCB object in this AIB.<br />

Returns: The IOPCB in this AIB.<br />

getAlternatePCB ()<br />

public AlternatePCB getAlternatePCB()<br />

Returns the Alternate PCB object in this AIB.<br />

Returns: The Alternate PCB in this AIB.<br />

A.9 Class com.ibm.ims.base.AlternatePCB<br />

Methods<br />

java.lang.Object<br />

+----com.ibm.ims.base.AlternatePCB<br />

public final class AlternatePCB extends Object<br />

The AlternatePCB class contains all the data attributes of the <strong>IMS</strong> Alternate<br />

Program Communication Block <strong>and</strong> the necessary getter <strong>and</strong> setter methods.<br />

Use alternate PCB to send output messages to terminal other than the<br />

originating terminal or to send messages to other application programs.<br />

Alternate PCBs can be found for a particular terminal or program, or they can<br />

be defined as modifiable. If the alternate PCB is modifiable, set the<br />

destination using the CHNG (Change) call. For further information, see the<br />

manual, <strong>IMS</strong> <strong>Application</strong> <strong>Programming</strong>: Transaction Manager.<br />

getMessageDestination ()<br />

public String getMessageDestination()<br />

Returns the logical terminal name in this Alternate PCB.<br />

Returns: The Alternate PCB's logical terminal name.<br />

getStatusCode ()<br />

public short getStatusCode()<br />

186 <strong>IMS</strong> <strong>Version</strong> 7 <strong>and</strong> <strong>Java</strong> <strong>Application</strong> <strong>Programming</strong>


Returns the status code from the last DLI call using this Alternate PCB.<br />

See <strong>IMS</strong> V7 Messages <strong>and</strong> Codes, GC26-9433-00 for information about<br />

<strong>IMS</strong> status codes.<br />

Returns: The Alternate PCB's <strong>IMS</strong> status code.<br />

A.10 Class com.ibm.ims.base.DBPCB<br />

Methods<br />

java.lang.Object<br />

+----com.ibm.ims.base.DBPCB<br />

public final class DBPCB extends Object<br />

The DBPCB class contains all the data attributes of the <strong>IMS</strong> Database Program<br />

Communication Block <strong>and</strong> the necessary getter <strong>and</strong> setter methods. <strong>IMS</strong><br />

describes the results of the calls your program issues in the DB PCB that is<br />

referenced in the call. For more information, see <strong>IMS</strong> <strong>Application</strong><br />

<strong>Programming</strong>: Database Manager, SC26-9422-00.<br />

getDBName ()<br />

public String getDBName()<br />

Returns the database name in this DBPCB. The maximum length of this<br />

field is 8 characters.<br />

Returns: The DBPCB's database name.<br />

getStatusCode ()<br />

public short getStatusCode()<br />

Returns the <strong>IMS</strong> status code of the last DLI call using this DBPCB.<br />

Returns: The DBPCB's <strong>IMS</strong> status code.<br />

getProcessOptions ()<br />

public String getProcessOptions()<br />

Returns the <strong>IMS</strong> processing options in this DBPCB.<br />

Returns: The DBPCB's <strong>IMS</strong> processing options.<br />

getSegmentName ()<br />

public String getSegmentName()<br />

Appendix A. <strong>IMS</strong> <strong>Java</strong> package 187


Returns the <strong>IMS</strong> segment name in this DBPCB from the last DLI call using<br />

this DBPCB.<br />

Returns: The DBPCB's segment name.<br />

getKeyFeedback ()<br />

public byte[ ] getKeyFeedback()<br />

Returns the concatenated key in this DBPCB from the last DLI call using<br />

this DBPCB. Returns null if no concatenated key returned from <strong>IMS</strong>.<br />

Returns: The DBPCB's concatenated key.<br />

getSegmentLevelNumber ()<br />

public int getSegmentLevelNumber()<br />

Returns the segment level in this DBPCB from the last DLI call using this<br />

DBPCB.<br />

Returns: The DBPCB's segment level.<br />

getKeyFeedbackLength ()<br />

public int getKeyFeedbackLength()<br />

Returns the concatenated key length in this DBPCB from the last DLI call<br />

using this DBPCB.<br />

Returns: The DBPCB's concatenated key length.<br />

getNumberSensitiveSegments ()<br />

public int getNumberSensitiveSegments()<br />

Returns the number of sensitive segments in this DBPCB from the last DLI<br />

call using this DBPCB.<br />

Returns: The DBPCB's number of sensitive segments.<br />

getRSA ()<br />

public byte[ ] getRSA()<br />

Returns the record search argument (RSA) from GSAM DB PCB. It is 8<br />

bytes long or null if DB PCB is not GSAM. NOTE: if GSAM, the<br />

keyFeedback is 12 bytes long. The first 8 bytes is record search argument<br />

which can be used later on if you want to retrieve that record directly by<br />

including it as one of the parameters on a GU call. The last 4 bytes is the<br />

length of the undefined-length record(RECFM=U).<br />

Returns: GSAM DB PCB record search argument (RSA).<br />

188 <strong>IMS</strong> <strong>Version</strong> 7 <strong>and</strong> <strong>Java</strong> <strong>Application</strong> <strong>Programming</strong>


getUndefinedLengthRecordLength ()<br />

public int getUndefinedLengthRecordLength()<br />

Returns the length of the undefined-length record after GSAM GU or GN<br />

call. Return 0 if DB PCB is not GSAM.<br />

Returns: The length of the undefined-length record.<br />

A.11 Class com.ibm.ims.base.DLIBaseSegment<br />

Variables<br />

Constructors<br />

Methods<br />

java.lang.Object<br />

+----com.ibm.ims.base.DLIBaseSegment<br />

public abstract class DLIBaseSegment extends Object Implements Cloneable.<br />

IoArea<br />

protected byte ioArea[]<br />

ioAreaOffset<br />

protected int ioAreaOffset<br />

ioAreaLength<br />

protected int ioAreaLength<br />

DLIBaseSegment (String, DLITypeInfo, int)<br />

protected DLIBaseSegment(String segmentName,<br />

DLITypeInfo typeInfo[],<br />

int length)<br />

clearWarnings ()<br />

protected void clearWarnings()<br />

clone ()<br />

public Object clone()<br />

Creates a new object of the same class as this object. This method does<br />

not copy the type information so that all instances share the same field<br />

definitions.<br />

Appendix A. <strong>IMS</strong> <strong>Java</strong> package 189


Returns: java.lang.Object.<br />

Overrides: clone in class Object.<br />

getBigDecimal (int)<br />

public BigDecimal getBigDecimal(int index) throws DLIException<br />

Returns the field indicated by the index as a BigDecimal. The index<br />

parameter is the index of the desired field that was passed to the<br />

constructor in the DLITypeInfo array. The index is one based.<br />

For example, if the fields in the segment were added to the DLITypeInfo<br />

array in order, then the first field in the segment would be index 1, the<br />

second index 2, <strong>and</strong> so on.<br />

Parameters:<br />

index - The one-based index of the desired field in the DLITypeInfo<br />

array.<br />

Returns: The value of the field as a BigDecimal.<br />

Throws: DLIException if the conversion cannot be done.<br />

getBigDecimal (int, int)<br />

public BigDecimal getBigDecimal(int index,<br />

int scale) throws DLIException<br />

Returns the field indicated by the index as a BigDecimal. The index<br />

parameter is the index of the desired field that was passed to the<br />

constructor in the DLITypeInfo array. The index is one based. For<br />

example, if the fields in the segment were added to the DLITypeInfo<br />

array in order, then the first field in the segment would be index 1, the<br />

second index 2, <strong>and</strong> so on.<br />

Parameters:<br />

190 <strong>IMS</strong> <strong>Version</strong> 7 <strong>and</strong> <strong>Java</strong> <strong>Application</strong> <strong>Programming</strong><br />

index - The one-based index of the desired field in the DLITypeInfo<br />

array.<br />

scale - The number of digits to the right of the decimal.<br />

Returns: The value of the field as a BigDecimal.<br />

Throws: DLIException if the conversion cannot be done.


getBigDecimal (String)<br />

public BigDecimal getBigDecimal(String fieldName) throws DLIException<br />

Returns the field specified by the parameter as a BigDecimal. The<br />

fieldName parameter is the name of the field as it was registered in the<br />

DLITypeInfo array.<br />

Parameters:<br />

fieldName - The name of the field as registered in the DLITypeInfo<br />

array.<br />

Returns: The value of the field as a BigDecimal.<br />

Throws: DLIException if the field name is not found in the segment.<br />

getBigDecimal (String, int)<br />

public BigDecimal getBigDecimal(String fieldName,<br />

int scale) throws DLIException<br />

Returns the field specified by the parameter as a BigDecimal. The<br />

fieldName parameter is the name of the field as it was registered in the<br />

DLITypeInfo array.<br />

Parameters:<br />

fieldName - The name of the field as registered in the DLITypeInfo<br />

array.<br />

scale - The number of digits to the right of the decimal.<br />

Returns: The value of the field as a BigDecimal.<br />

Throws: DLIException if the field name is not found in the segment.<br />

getBoolean (int)<br />

public boolean getBoolean(int index) throws DLIException<br />

Returns the field indicated by the index as a boolean. The index parameter<br />

is the index of the desired field that was passed to the constructor in the<br />

DLITypeInfo array. The index is one based. For example, if the fields in the<br />

segment were added to the DLITypeInfo array in order, then the first field in<br />

the segment would be index 1, the second index 2, <strong>and</strong> so on.<br />

Parameters:<br />

index - The 1-based index of the desired field in the DLITypeInfo<br />

array.<br />

Returns: The value of the field as a boolean.<br />

Throws: DLIException if the conversion cannot be done.<br />

Appendix A. <strong>IMS</strong> <strong>Java</strong> package 191


getBoolean (String)<br />

public boolean getBoolean(String fieldName) throws DLIException<br />

Returns the field specified by the parameter as a boolean. The fieldName<br />

parameter is the name of the field as it was registered in the DLITypeInfo<br />

array.<br />

Parameters:<br />

fieldName - The name of the field as registered in the DLITypeInfo<br />

array.<br />

Returns: The value of the field as a boolean.<br />

Throws: DLIException if the field name is not found in the segment.<br />

getByte (int)<br />

public byte getByte(int index) throws DLIException<br />

Returns the field indicated by the index as a byte. The index parameter is<br />

the index of the desired field that was passed to the constructor in the<br />

DLITypeInfo array. The index is one based. For example, if the fields in the<br />

segment were added to the DLITypeInfo array in order, then the first field in<br />

the segment would be index 1, the second index 2, <strong>and</strong> so on.<br />

Parameters:<br />

index - The one-based index of the desired field in the DLITypeInfo<br />

array.<br />

Returns: The value of the field as a byte.<br />

Throws: DLIException if the conversion cannot be done.<br />

getByte (String)<br />

public byte getByte(String fieldName) throws DLIException<br />

Returns the field specified by the parameter as a byte. The fieldName<br />

parameter is the name of the field as it was registered in the DLITypeInfo<br />

array.<br />

Parameters:<br />

fieldName - The name of the field as registered in the DLITypeInfo<br />

array.<br />

Returns: The value of the field as a byte.<br />

Throws: DLIException if the field name is not found in the segment.<br />

192 <strong>IMS</strong> <strong>Version</strong> 7 <strong>and</strong> <strong>Java</strong> <strong>Application</strong> <strong>Programming</strong>


getBytes (int)<br />

public byte[ ] getBytes(int index) throws DLIException<br />

Returns the field indicated by the index "as is" (ie; the raw bytes of the<br />

field). The index parameter is the index of the desired field that was<br />

passed to the constructor in the DLITypeInfo array. The index is one based.<br />

For example, if the fields in the segment were added to the DLITypeInfo<br />

array in order, then the first field in the segment would be index 1, the<br />

second index 2, <strong>and</strong> so on.<br />

Parameters:<br />

index - The 1-based index of the desired field in the DLITypeInfo<br />

array.<br />

Returns: The raw bytes of the field as an array of bytes.<br />

Throws: DLIException if the conversion cannot be done.<br />

getBytes (String)<br />

public byte[] getBytes(String fieldName) throws DLIException<br />

Returns the field specified by the parameter "as is" (ie; the raw bytes of<br />

the field). The fieldName parameter is the name of the field as it was<br />

registered in the DLITypeInfo array.<br />

Parameters:<br />

fieldName - The name of the field as registered in the DLITypeInfo<br />

array.<br />

Returns: The raw bytes of the field as a byte array.<br />

Throws: DLIException if the field name is not found in the segment.<br />

getDate (int)<br />

public Date getDate(int index) throws DLIException<br />

Returns the field indicated by the index as a java.sql.Date object. The<br />

index parameter is the index of the desired field that was passed to the<br />

constructor in the DLITypeInfo array. The index is one based. For example,<br />

if the fields in the segment were added to the DLITypeInfo array in order,<br />

then the first field in the segment would be index 1, the second index 2,<br />

<strong>and</strong> so on.<br />

Parameters:<br />

index - The 1-based index of desired field in the DLITypeInfo array.<br />

Returns: The value of the field as a java.sql.Date object.<br />

Throws: DLIException if the conversion cannot be done.<br />

Appendix A. <strong>IMS</strong> <strong>Java</strong> package 193


getDate (String)<br />

public Date getDate(String fieldName) throws DLIException<br />

Returns the field specified by the parameter as a java.sql.Date object. The<br />

fieldName parameter is the name of the field as it was registered in the<br />

DLITypeInfo array.<br />

Parameters:<br />

fieldName - The name of the field as registered in the DLITypeInfo<br />

array.<br />

Returns: The value of the field as a java.sql.Date object.<br />

Throws: DLIException if the field name is not found in the segment.<br />

getDefaultEncoding ()<br />

public String getDefaultEncoding()<br />

Returns the default character encoding for this segment.<br />

Returns: java.lang.String.<br />

getDouble (int)<br />

public double getDouble(int index) throws DLIException<br />

Returns the field indicated by the index as a double. The index parameter<br />

is the index of the desired field that was passed to the constructor in the<br />

DLITypeInfo array. The index is one based.<br />

For example, if the fields in the segment were added to the DLITypeInfo<br />

array in order, then the first field in the segment would be index 1, the<br />

second index 2, <strong>and</strong> so on.<br />

Parameters:<br />

index - The 1-based index of the desired field in the DLITypeInfo<br />

array.<br />

Returns: The value of the field as a double.<br />

Throws: DLIException if the conversion cannot be done.<br />

getDouble (String)<br />

public double getDouble(String fieldName) throws DLIException<br />

Returns the field specified by the parameter as a double. The fieldName<br />

parameter is the name of the field as it was registered in the DLITypeInfo<br />

array.<br />

194 <strong>IMS</strong> <strong>Version</strong> 7 <strong>and</strong> <strong>Java</strong> <strong>Application</strong> <strong>Programming</strong>


Parameters:<br />

fieldName - The name of the field as registered in the DLITypeInfo<br />

array.<br />

Returns: The value of the field as a double.<br />

Throws: DLIException if the field name is not found in the segment.<br />

getFloat (int)<br />

public float getFloat(int index) throws DLIException<br />

Returns the field indicated by the index as a float. The index parameter is<br />

the index of the desired field that was passed to the constructor in the<br />

DLITypeInfo array. The index is one based.<br />

For example, if the fields in the segment were added to the DLITypeInfo<br />

array in order, then the first field in the segment would be index 1, the<br />

second index 2, <strong>and</strong> so on.<br />

Parameters:<br />

index - The 1-based index of the desired field in the DLITypeInfo<br />

array.<br />

Returns: The value of the field as a float.<br />

Throws: DLIException if the conversion cannot be done.<br />

getFloat (String)<br />

public float getFloat(String fieldName) throws DLIException<br />

Returns the field specified by the parameter as a float. The fieldName<br />

parameter is the name of the field as it was registered in the DLITypeInfo<br />

array.<br />

Parameters:<br />

fieldName - The name of the field as registered in the DLITypeInfo<br />

array.<br />

Returns: The value of the field as a float.<br />

Throws: DLIException if the field name is not found in the segment.<br />

getInt (int)<br />

public int getInt(int index) throws DLIException<br />

Returns the field indicated by the index as an int. The index parameter is<br />

the index of the desired field that was passed to the constructor in the<br />

DLITypeInfo array. The index is one based. For example, if the fields in the<br />

Appendix A. <strong>IMS</strong> <strong>Java</strong> package 195


segment were added to the DLITypeInfo array in order, then the first field in<br />

the segment would be index 1, the second index 2, <strong>and</strong> so on.<br />

Parameters:<br />

index - The 1-based index of the desired field in the DLITypeInfo<br />

array.<br />

Returns: The value of the field as an int.<br />

Throws: DLIException if the conversion cannot be done.<br />

getInt (String)<br />

public int getInt(String fieldName) throws DLIException<br />

Returns the field specified by the parameter as an int. The fieldName<br />

parameter is the name of the field as it was registered in the DLITypeInfo<br />

array.<br />

Parameters:<br />

fieldName - The name of the field as registered in the DLITypeInfo<br />

array.<br />

Returns: The value of the field as an int.<br />

Throws: DLIException if the field name is not found in the segment.<br />

getLong (int)<br />

public long getLong(int index) throws DLIException<br />

Returns the field indicated by the index as a long. The index parameter is<br />

the index of the desired field that was passed to the constructor in the<br />

DLITypeInfo array. The index is one based. For example, if the fields in the<br />

segment were added to the DLITypeInfo array in order, then the first field in<br />

the segment would be index 1, the second index 2, <strong>and</strong> so on.<br />

Parameters:<br />

index - The 1-based index of the desired field in the DLITypeInfo<br />

array.<br />

Returns: The value of the field as a long.<br />

Throws: DLIException if the conversion cannot be done.<br />

getLong (String)<br />

public long getLong(String fieldName) throws DLIException<br />

Returns the field specified by the parameter as a long. The fieldName<br />

parameter is the name of the field as it was registered in the DLITypeInfo<br />

array.<br />

196 <strong>IMS</strong> <strong>Version</strong> 7 <strong>and</strong> <strong>Java</strong> <strong>Application</strong> <strong>Programming</strong>


Parameters:<br />

fieldName - The name of the field as registered in the DLITypeInfo<br />

array.<br />

Returns: The value of the field as a long.<br />

Throws: DLIException if the field name is not found in the segment.<br />

getSegmentName ()<br />

public String getSegmentName()<br />

Returns the name of the segment as stored in the database.<br />

Returns: java.lang.String.<br />

getShort (int)<br />

public short getShort(int index) throws DLIException<br />

Returns the field indicated by the index as a short. The index parameter is<br />

the index of the desired field that was passed to the constructor in the<br />

DLITypeInfo array. The index is one based. For example, if the fields in the<br />

segment were added to the DLITypeInfo array in order, then the first field in<br />

the segment would be index 1, the second index 2, <strong>and</strong> so on.<br />

Parameters:<br />

index - The 1-based index of the desired field in the DLITypeInfo<br />

array.<br />

Returns: The value of the field as a short.<br />

Throws: DLIException if the conversion cannot be done.<br />

getShort (String)<br />

public short getShort(String fieldName) throws DLIException<br />

Returns the field specified by the parameter as a short. The fieldName<br />

parameter is the name of the field as it was registered in the DLITypeInfo<br />

array.<br />

Parameters:<br />

fieldName - The name of the field as registered in the DLITypeInfo<br />

array.<br />

Returns: The value of the field as a short.<br />

Throws: DLIException if the field name is not found in the segment.<br />

Appendix A. <strong>IMS</strong> <strong>Java</strong> package 197


getString (int)<br />

public String getString(int index) throws DLIException<br />

Returns the field indicated by the index as a String. The index parameter<br />

is the index of the desired field that was passed to the constructor in the<br />

DLITypeInfo array. The index is one based. For example, if the fields in the<br />

segment were added to the DLITypeInfo array in order, then the first field in<br />

the segment would be index 1, the second index 2, <strong>and</strong> so on.<br />

Parameters:<br />

index - The 1-based index of the desired field in the DLITypeInfo<br />

array.<br />

Returns: The value of the field as a String.<br />

Throws: DLIException if the conversion cannot be done.<br />

getString (String)<br />

public String getString(String fieldName) throws DLIException<br />

Returns the field specified by the parameter as a String. The fieldName<br />

parameter is the name of the field as it was registered in the DLITypeInfo<br />

array.<br />

Parameters:<br />

fieldName - The name of the field as registered in the DLITypeInfo<br />

array.<br />

Returns: The value of the field as a String.<br />

Throws: DLIException if the field name is not found in the segment.<br />

getTime (int)<br />

public Time getTime(int index) throws DLIException<br />

Returns the field indicated by the index as a java.sql.Time object. The<br />

index parameter is the index of the desired field that was passed to the<br />

constructor in the DLITypeInfo array. The index is one based. For example,<br />

if the fields in the segment were added to the DLITypeInfo array in order,<br />

then the first field in the segment would be index 1, the second index 2,<br />

<strong>and</strong> so on.<br />

Parameters:<br />

index - The 1-based index of the desired field in the DLITypeInfo<br />

array.<br />

Returns: The value of the field as a java.sql.Time object.<br />

Throws: DLIException if the conversion cannot be done.<br />

198 <strong>IMS</strong> <strong>Version</strong> 7 <strong>and</strong> <strong>Java</strong> <strong>Application</strong> <strong>Programming</strong>


getTime (String)<br />

public Time getTime(String fieldName) throws DLIException<br />

Returns the field specified by the parameter as a java.sql.Time object. The<br />

fieldName parameter is the name of the field as it was registered in the<br />

DLITypeInfo array.<br />

Parameters:<br />

fieldName - The name of the field as registered in the DLITypeInfo<br />

array.<br />

Returns: The value of the field as a java.sql.Time object.<br />

Throws: DLIException if the field name is not found in the segment.<br />

getTimestamp (int)<br />

public Timestamp getTimestamp(int index) throws DLIException<br />

Returns the field indicated by the index as a java.sql.Timestamp object.<br />

The index parameter is the index of the desired field that was passed to<br />

the constructor in the DLITypeInfo array. The index is one based. For<br />

example, if the fields in the segment were added to the DLITypeInfo array<br />

in order, then the first field in the segment would be index 1, the second<br />

index 2, <strong>and</strong> so on.<br />

Parameters:<br />

index - The 1-based index of desired field in the DLITypeInfo array.<br />

Returns: The value of the field as a java.sql.Timestamp object.<br />

Throws: DLIException if the conversion cannot be done.<br />

getTimestamp (String)<br />

public Timestamp getTimestamp(String fieldName) throws DLIException<br />

Returns the field specified by the parameter as a java.sql.Timestamp<br />

object. The fieldName parameter is the name of the field as it was<br />

registered in the DLITypeInfo array.<br />

Parameters:<br />

fieldName - The name of the field as registered in the DLITypeInfo<br />

array.<br />

Returns: The value of the field as a java.sql.Timestamp object.<br />

Throws: DLIException if the field name is not found in the segment.<br />

getTypeInfo ()<br />

public DLITypeInfo[] getTypeInfo()<br />

Appendix A. <strong>IMS</strong> <strong>Java</strong> package 199


Returns an array of the DLITypeInfo instances for this segment.<br />

Returns: The DLITypeInfo array.<br />

getTypeInfo (int)<br />

public DLITypeInfo getTypeInfo(int index)<br />

Returns the DLITypeInfo of the field specified by the index parameter.<br />

Parameters:<br />

index - The 1-based index of the desired field.<br />

Returns: The DLITypeInfo of the specified field.<br />

getTypeInfo (String)<br />

public DLITypeInfo getTypeInfo(String fieldName) throws DLIException<br />

Returns the DLITypeInfo of the field specified by the fieldName parameter.<br />

The fieldName parameter is the name given to the field when it was<br />

registered with this class's constructor.<br />

Parameters:<br />

index - The zero-based index of the desired field.<br />

Returns: The DLITypeInfo of the specified field.<br />

Throws: DLIException if the field does not exist.<br />

getWarnings ()<br />

protected DLIWarning getWarnings()<br />

Returns: java.sql.SQLWarning.<br />

setBigDecimal (int, BigDecimal)<br />

public void setBigDecimal(int index,<br />

BigDecimal value) throws DLIException<br />

Sets the field indicated by the index to the specified BigDecimal value. The<br />

index parameter is the index of the desired field that was passed to the<br />

constructor in the DLITypeInfo array. The index is one based. For example,<br />

if the fields in the segment were added to the DLITypeInfo array in order,<br />

then the first field in the segment would be index 1, the second index 2,<br />

<strong>and</strong> so on.<br />

Parameters:<br />

200 <strong>IMS</strong> <strong>Version</strong> 7 <strong>and</strong> <strong>Java</strong> <strong>Application</strong> <strong>Programming</strong><br />

index - The 1-based index of the desired field in the DLITypeInfo<br />

array.<br />

value - The new value for the field.


Throws: DLIException if there is a conversion failure.<br />

setBigDecimal (String,BigDecimal)<br />

public void setBigDecimal(String fieldName,<br />

BigDecimal value) throws DLIException<br />

Sets the field indicated by the fieldName parameter to the specified<br />

BigDecimal value. The fieldName parameter is the name of the field as it<br />

was registered in the DLITypeInfo array. The index is zero based. For<br />

example, if the fields in the segment were added to the DLITypeInfo array<br />

in order, then the first field in the segment would be index 0, the second<br />

index 1, <strong>and</strong> so on.<br />

Parameters:<br />

fieldName - The name of the field as registered in the DLITypeInfo<br />

array.<br />

value - The new value for the field.<br />

Throws: DLIException if the field name is not found in the segment or if<br />

there is a conversion failure.<br />

setBoolean (int,boolean)<br />

public void setBoolean(int index,<br />

boolean value) throws DLIException<br />

Sets the field indicated by the index to the specified boolean value. The<br />

index parameter is the index of the desired field that was passed to the<br />

constructor in the DLITypeInfo array. The index is one based. For example,<br />

if the fields in the segment were added to the DLITypeInfo array in order,<br />

then the first field in the segment would be index 1, the second index 2,<br />

<strong>and</strong> so on.<br />

Parameters:<br />

index - The 1-based index of the desired field in the DLITypeInfo<br />

array.<br />

value - The new value for the field.<br />

Throws: DLIException if there is a conversion failure.<br />

setBoolean (String,boolean)<br />

public void setBoolean(String fieldName,<br />

boolean value) throws DLIException<br />

Sets the field indicated by the fieldName parameter to the specified boolean<br />

value. The fieldName parameter is the name of the field as it was<br />

registered in the DLITypeInfo array. The index is zero based. For example,<br />

Appendix A. <strong>IMS</strong> <strong>Java</strong> package 201


if the fields in the segment were added to the DLITypeInfo array in order,<br />

then the first field in the segment would be index 0, the second index 1,<br />

<strong>and</strong> so on.<br />

Parameters:<br />

202 <strong>IMS</strong> <strong>Version</strong> 7 <strong>and</strong> <strong>Java</strong> <strong>Application</strong> <strong>Programming</strong><br />

fieldName - The name of the field as registered in the DLITypeInfo<br />

array.<br />

value - The new value for the field.<br />

Throws: DLIException if the field name is not found in the segment or if<br />

there is a conversion failure.<br />

setByte (int,byte)<br />

public void setByte(int index,<br />

byte value) throws DLIException<br />

Sets the field indicated by the index to the specified byte value. The index<br />

parameter is the index of the desired field that was passed to the<br />

constructor in the DLITypeInfo array. The index is one based. For example,<br />

if the fields in the segment were added to the DLITypeInfo array in order,<br />

then the first field in the segment would be index 1, the second index 2,<br />

<strong>and</strong> so on.<br />

Parameters:<br />

index - The 1-based index of the desired field in the DLITypeInfo<br />

array.<br />

value - The new value for the field.<br />

Throws: DLIException if there is a conversion failure.<br />

setByte (String,byte)<br />

public void setByte(String fieldName,<br />

byte value) throws DLIException<br />

Sets the field indicated by the fieldName parameter to the specified byte<br />

value. The fieldName parameter is the name of the field as it was<br />

registered in the DLITypeInfo array. The index is zero based. For example,<br />

if the fields in the segment were added to the DLITypeInfo array in order,<br />

then the first field in the segment would be index 0, the second index 1,<br />

<strong>and</strong> so on.<br />

Parameters:<br />

fieldName - The name of the field as registered in the DLITypeInfo<br />

array.<br />

value - The new value for the field.


Throws: DLIException if the field name is not found in the segment or if<br />

there is a conversion failure.<br />

setBytes (int, byte)<br />

public void setBytes(int index,<br />

byte value[]) throws DLIException<br />

Sets the field indicated by the index to the exact bytes passed in the array,<br />

with no conversion. The index parameter is the index of the desired field<br />

that was passed to the constructor in the DLITypeInfo array. The index is<br />

one based. For example, if the fields in the segment were added to the<br />

DLITypeInfo array in order, then the first field in the segment would be<br />

index 1, the second index 2, <strong>and</strong> so on.<br />

Parameters:<br />

index - The 1-based index of the desired field in the DLITypeInfo<br />

array.<br />

value - The new value for the field.<br />

Throws: NumberFormatException if the length of the byte array is not<br />

equal to the length of the field as defined in the DLITypeInfo.<br />

setBytes (String, byte)<br />

public void setBytes(String fieldName,<br />

byte value[]) throws DLIException<br />

Sets the field indicated by the fieldName parameter to the exact bytes<br />

passed in the array, with no conversion. The fieldName parameter is the<br />

name of the field as it was registered in the DLITypeInfo array. The index is<br />

zero based. For example, if the fields in the segment were added to the<br />

DLITypeInfo array in order, then the first field in the segment would be<br />

index 0, the second index 1, <strong>and</strong> so on.<br />

Parameters:<br />

fieldName - The name of the field as registered in the DLITypeInfo<br />

array.<br />

value - The new value for the field.<br />

Throws:<br />

NumberFormatException if the length of the byte array is not equal to<br />

the length of the field as defined in the DLITypeInfo.<br />

DLIException if the field name is not found in the segment.<br />

setDate (int, Date)<br />

public void setDate(int index,<br />

Date value) throws DLIException<br />

Appendix A. <strong>IMS</strong> <strong>Java</strong> package 203


Sets the field indicated by the index to the specified Date value. The index<br />

parameter is the index of the desired field that was passed to the<br />

constructor in the DLITypeInfo array. The index is one based. For example,<br />

if the fields in the segment were added to the DLITypeInfo array in order,<br />

then the first field in the segment would be index 1, the second index 2,<br />

<strong>and</strong> so on.<br />

Parameters:<br />

index - The 1-based index of the desired field in the DLITypeInfo<br />

array.<br />

value - The new value for the field.<br />

Throws: DLIException if the encoding scheme for the Date when it is<br />

formatted to a String is not supported or if there is a conversion failure.<br />

setDate (String, Date)<br />

public void setDate(String fieldName,<br />

Date value) throws DLIException<br />

Sets the field indicated by the fieldName parameter to the specified Date<br />

value. The fieldName parameter is the name of the field as it was<br />

registered in the DLITypeInfo array. The index is zero based. For example,<br />

if the fields in the segment were added to the DLITypeInfo array in order,<br />

then the first field in the segment would be index 0, the second index 1,<br />

<strong>and</strong> so on.<br />

Parameters:<br />

fieldName - The name of the field as registered in the DLITypeInfo<br />

array.<br />

value - The new value for the field.<br />

Throws: DLIException if the encoding scheme for the Date when it is<br />

formatted to a String is not supported, if the field name is not found in<br />

the segment, or if there is a conversion failure.<br />

setDefaultEncoding (String)<br />

public void setDefaultEncoding(String encoding)<br />

Sets the character encoding that all character data in the segment<br />

adheres to. This encoding can also be overridden on a per field basis.<br />

Parameters:<br />

encoding - The character encoding.<br />

See Also: DLITypeInfo.<br />

204 <strong>IMS</strong> <strong>Version</strong> 7 <strong>and</strong> <strong>Java</strong> <strong>Application</strong> <strong>Programming</strong>


setDouble (int, double)<br />

public void setDouble(int index,<br />

double value) throws DLIException<br />

Sets the field indicated by the index to the specified double value. The<br />

index parameter is the index of the desired field that was passed to the<br />

constructor in the DLITypeInfo array. The index is one based. For example,<br />

if the fields in the segment were added to the DLITypeInfo array in order,<br />

then the first field in the segment would be index 1, the second index 2,<br />

<strong>and</strong> so on.<br />

Parameters:<br />

index - The 1-based index of the desired field in the DLITypeInfo<br />

array.<br />

value - The new value for the field.<br />

Throws: DLIException if there is a conversion failure.<br />

setDouble (String, double)<br />

public void setDouble(String fieldName,<br />

double value) throws DLIException<br />

Sets the field indicated by the fieldName parameter to the specified double<br />

value. The fieldName parameter is the name of the field as it was<br />

registered in the DLITypeInfo array. The index is zero based. For example,<br />

if the fields in the segment were added to the DLITypeInfo array in order,<br />

then the first field in the segment would be index 0, the second index 1,<br />

<strong>and</strong> so on.<br />

Parameters:<br />

fieldName - The name of the field as registered in the DLITypeInfo<br />

array.<br />

value - The new value for the field.<br />

Throws: DLIException if the field name is not found in the segment or<br />

there is a conversion failure.<br />

setFloat (int, float)<br />

public void setFloat(int index,<br />

float value) throws DLIException<br />

Sets the field indicated by the index to the specified float value. The index<br />

parameter is the index of the desired field that was passed to the<br />

constructor in the DLITypeInfo array. The index is one based. For example,<br />

if the fields in the segment were added to the DLITypeInfo array in order,<br />

then the first field in the segment would be index 1, the second index 2,<br />

<strong>and</strong> so on.<br />

Appendix A. <strong>IMS</strong> <strong>Java</strong> package 205


Parameters:<br />

index - The 1-based index of the desired field in the DLITypeInfo<br />

array.<br />

value - The new value for the field.<br />

Throws: DLIException if there is a conversion failure.<br />

setFloat (String, float)<br />

public void setFloat(String fieldName,<br />

float value) throws DLIException<br />

Sets the field indicated by the index to the specified float value. The index<br />

parameter is the index of the desired field that was passed to the<br />

constructor in the DLITypeInfo array. The index is one based. For example,<br />

if the fields in the segment were added to the DLITypeInfo array in order,<br />

then the first field in the segment would be index 1, the second index 2,<br />

<strong>and</strong> so on.<br />

Parameters:<br />

index - The 1-based index of the desired field in the DLITypeInfo<br />

array.<br />

value - The new value for the field.<br />

Throws: DLIException if the field name is not found in the segment or<br />

there is a conversion failure.<br />

setInt (int, int)<br />

public void setInt(int index,<br />

int value) throws DLIException<br />

Sets the field indicated by the index to the specified int value. The index<br />

parameter is the index of the desired field that was passed to the constructor<br />

in the DLITypeInfo array. The index is one based. For example, if the fields in<br />

the segment were added to the DLITypeInfo array in order, then the first field<br />

in the segment would be index 1, the second index 2, <strong>and</strong> so on.<br />

Parameters:<br />

index - The 1-based index of the desired field in the DLITypeInfo<br />

array.<br />

value - The new value for the field.<br />

Throws: DLIException if there is a conversion failure.<br />

setInt (String, int)<br />

public void setInt(String fieldName,<br />

int value) throws DLIException<br />

206 <strong>IMS</strong> <strong>Version</strong> 7 <strong>and</strong> <strong>Java</strong> <strong>Application</strong> <strong>Programming</strong>


Sets the field indicated by the fieldName parameter to the specified int<br />

value. The fieldName parameter is the name of the field as it was<br />

registered in the DLITypeInfo array. The index is zero based. For example,<br />

if the fields in the segment were added to the DLITypeInfo array in order,<br />

then the first field in the segment would be index 0, the second index 1,<br />

<strong>and</strong> so on.<br />

Parameters:<br />

fieldName - The name of the field as registered in the DLITypeInfo<br />

array.<br />

value - The new value for the field.<br />

Throws: DLIException if the field name is not found in the segment or if<br />

there is a conversion failure.<br />

setLong (int, long)<br />

public void setLong(int index,<br />

long value) throws DLIException<br />

Sets the field indicated by the index to the specified long value. The index<br />

parameter is the index of the desired field that was passed to the<br />

constructor in the DLITypeInfo array. The index is one based. For example,<br />

if the fields in the segment were added to the DLITypeInfo array in order,<br />

then the first field in the segment would be index 1, the second index 2,<br />

<strong>and</strong> so on.<br />

Parameters:<br />

index - The 1-based index of the desired field in the DLITypeInfo<br />

array.<br />

value - The new value for the field.<br />

Throws: DLIException if there is a conversion failure.<br />

setLong (String, long)<br />

public void setLong(String fieldName, long value) throws DLIException<br />

Sets the field indicated by the fieldName parameter to the specified long<br />

value. The fieldName parameter is the name of the field as it was<br />

registered in the DLITypeInfo array. The index is zero based. For example,<br />

if the fields in the segment were added to the DLITypeInfo array in order,<br />

then the first field in the segment would be index 0, the second index 1,<br />

<strong>and</strong> so on.<br />

Parameters:<br />

fieldName - The name of the field as registered in the DLITypeInfo<br />

array.<br />

Appendix A. <strong>IMS</strong> <strong>Java</strong> package 207


value - The new value for the field.<br />

Throws: DLIException if the field name is not found in the segment or if<br />

there is a conversion failure.<br />

setShort (int, short)<br />

public void setShort(int index,<br />

short value) throws DLIException<br />

Sets the field indicated by the index to the specified short value. The<br />

index parameter is the index of the desired field that was passed to the<br />

constructor in the DLITypeInfo array. The index is one based. For example,<br />

if the fields in the segment were added to the DLITypeInfo array in order,<br />

then the first field in the segment would be index 1, the second index 2,<br />

<strong>and</strong> so on.<br />

Parameters:<br />

index - The 1-based index of the desired field in the DLITypeInfo<br />

array.<br />

value - The new value for the field.<br />

Throws: DLIException if there is a conversion failure.<br />

setShort (String, short)<br />

public void setShort(String fieldName,<br />

short value) throws DLIException<br />

Sets the field indicated by the fieldName parameter to the specified short<br />

value. The fieldName parameter is the name of the field as it was<br />

registered in the DLITypeInfo array. The index is zero based. For example,<br />

if the fields in the segment were added to the DLITypeInfo array in order,<br />

then the first field in the segment would be index 0, the second index 1,<br />

<strong>and</strong> so on.<br />

Parameters:<br />

fieldName - The name of the field as registered in the DLITypeInfo<br />

array.<br />

value - The new value for the field.<br />

Throws: DLIException if the field name is not found in the segment or if<br />

there is a conversion failure.<br />

setString (int,String)<br />

public void setString(int index,<br />

String value) throws DLIException<br />

208 <strong>IMS</strong> <strong>Version</strong> 7 <strong>and</strong> <strong>Java</strong> <strong>Application</strong> <strong>Programming</strong>


Sets the field indicated by the index to the specified String value. The<br />

index parameter is the index of the desired field that was passed to the<br />

constructor in the DLITypeInfo array. The index is one based. For example,<br />

if the fields in the segment were added to the DLITypeInfo array in order,<br />

then the first field in the segment would be index 1, the second index 2,<br />

<strong>and</strong> so on.<br />

Parameters:<br />

index - The 1-based index of the desired field in the DLITypeInfo<br />

array.<br />

value - The new value for the field.<br />

Throws: DLIException if the encoding scheme is not supported or if<br />

there is a conversion failure.<br />

setString (String, String)<br />

public void setString(String fieldName,<br />

String value) throws DLIException<br />

Sets the field indicated by the fieldName parameter to the specified String<br />

value. The fieldName parameter is the name of the field as it was<br />

registered in the DLITypeInfo array. The index is zero based. For example,<br />

if the fields in the segment were added to the DLITypeInfo array in order,<br />

then the first field in the segment would be index 0, the second index 1,<br />

<strong>and</strong> so on.<br />

Parameters:<br />

fieldName - The name of the field as registered in the DLITypeInfo<br />

array.<br />

value - The new value for the field.<br />

Throws: DLIException if the field name is not found in the segment, if<br />

the encoding scheme is not supported, or if there is a conversion<br />

failure.<br />

setTime (int, Time)<br />

public void setTime(int index,<br />

Time value) throws DLIException<br />

Sets the field indicated by the index to the specified Time value. The index<br />

parameter is the index of the desired field that was passed to the<br />

constructor in the DLITypeInfo array. The index is one based. For example,<br />

if the fields in the segment were added to the DLITypeInfo array in order,<br />

then the first field in the segment would be index 1, the second index 2,<br />

<strong>and</strong> so on.<br />

Parameters:<br />

Appendix A. <strong>IMS</strong> <strong>Java</strong> package 209


index - The 1-based index of the desired field in the DLITypeInfo<br />

array.<br />

value - The new value for the field.<br />

Throws: DLIException if the encoding scheme for the Time when it is<br />

formatted to a String is not supported or if there is a conversion failure.<br />

setTime (String, Time)<br />

public void setTime(String fieldName,<br />

Time value) throws DLIException<br />

Sets the field indicated by the fieldName parameter to the specified Time<br />

value. The fieldName parameter is the name of the field as it was<br />

registered in the DLITypeInfo array. The index is zero based. For example,<br />

if the fields in the segment were added to the DLITypeInfo array in order,<br />

then the first field in the segment would be index 0, the second index 1,<br />

<strong>and</strong> so on.<br />

Parameters:<br />

fieldName - The name of the field as registered in the DLITypeInfo<br />

array.<br />

value - The new value for the field.<br />

Throws: DLIException if the encoding scheme for the Time when it is<br />

formatted to a String is not supported, if the field name is not found in<br />

the segment, or if there is a conversion failure.<br />

setTimestamp (int, Timestamp)<br />

public void setTimestamp(int index,<br />

Timestamp value) throws DLIException<br />

Sets the field indicated by the index to the specified Timestamp value. The<br />

index parameter is the index of the desired field that was passed to the<br />

constructor in the DLITypeInfo array. The index is one based. For example,<br />

if the fields in the segment were added to the DLITypeInfo array in order,<br />

then the first field in the segment would be index 1, the second index 2,<br />

<strong>and</strong> so on.<br />

Parameters:<br />

210 <strong>IMS</strong> <strong>Version</strong> 7 <strong>and</strong> <strong>Java</strong> <strong>Application</strong> <strong>Programming</strong><br />

index - The 1-based index of the desired field in the DLITypeInfo<br />

array.<br />

value - The new value for the field.<br />

Throws: DLIException if the encoding scheme for the Timestamp when it<br />

is formatted to a String is not supported or if there is a conversion<br />

failure.


setTimestamp (String, Timestamp)<br />

public void setTimestamp(String fieldName,<br />

Timestamp value) throws DLIException<br />

Sets the field indicated by the fieldName parameter to the specified<br />

Timestamp value. The fieldName parameter is the name of the field as it was<br />

registered in the DLITypeInfo array. The index is zero based. For example,<br />

if the fields in the segment were added to the DLITypeInfo array in order,<br />

then the first field in the segment would be index 0, the second index 1,<br />

<strong>and</strong> so on.<br />

Parameters:<br />

fieldName - The name of the field as registered in the DLITypeInfo<br />

array.<br />

value - The new value for the field.<br />

Throws: DLIException if the encoding scheme for the Timestamp when it<br />

is formatted to a String is not supported, if the field name is not found in<br />

the segment, or if there is a conversion failure.<br />

A.12 Class com.ibm.ims.base.DLITypeInfo<br />

java.lang.Object<br />

+----com.ibm.ims.base.DLITypeInfo<br />

public class DLITypeInfo extends Object<br />

A DLITypeInfo object is used to provide the layout of a segment's fields to the<br />

base class DLISegment. With this metadata, the DLISegment class is able to<br />

provide access to all of the fields in any segment using either the defined field<br />

name or the 1-based index of the DLITypeInfo object in the array that is<br />

registered for each segment type. The defined field name can be an alias for<br />

the defined search field name in the DBD source file. When referring to the<br />

field,you can use the field alias instead of the search or key field name, as<br />

these field names are limited to only 8 characters. Note that the field names<br />

are case sensitive <strong>and</strong> must be written exactly as defined in the DLITypeInfo<br />

objects. When defining a key or search field, you must use the<br />

DLITypeInfo(String, int, int, int, String) constructor, which allows you to<br />

provide the alias <strong>and</strong> actual name of the search or key field.<br />

Appendix A. <strong>IMS</strong> <strong>Java</strong> package 211


Variables<br />

TINYINT<br />

public static final int TINYINT<br />

INTEGER<br />

public static final int INTEGER<br />

CHAR<br />

public static final int CHAR<br />

DOUBLE<br />

public static final int DOUBLE<br />

FLOAT<br />

public static final int FLOAT<br />

BIT<br />

public static final int BIT<br />

BLOB<br />

public static final int BLOB<br />

BIGINT<br />

public static final int BIGINT<br />

SMALLINT<br />

public static final int SMALLINT<br />

VARCHAR<br />

public static final int VARCHAR<br />

PACKEDDECIMAL<br />

public static final int PACKEDDECIMAL<br />

ZONEDDECIMAL<br />

public static final int ZONEDDECIMAL<br />

DATE<br />

public static final int DATE<br />

TIME<br />

public static final int TIME<br />

212 <strong>IMS</strong> <strong>Version</strong> 7 <strong>and</strong> <strong>Java</strong> <strong>Application</strong> <strong>Programming</strong>


Constructors<br />

TIMESTAMP<br />

public static final int TIMESTAMP<br />

TYPELIST<br />

public static final int TYPELIST<br />

BINARY<br />

public static final int BINARY<br />

DLITypeInfo (String, int, int, int)<br />

public DLITypeInfo(String fieldName,<br />

int type,<br />

int startingOffset,<br />

int length)<br />

Constructs a DLITypeInfo object. This constructor is only to be used with<br />

non-key <strong>and</strong> non-search fields. It cannot be used for zoned decmial, packed<br />

decimal, date, time, <strong>and</strong> timestamp fields. Use the DLITypeInfo(String,<br />

String, int, int, int) or DLITypeInfo(String, String, int, int, int, String)<br />

constructors for these types. The DLITypeInfo class defines several constants<br />

that can be supplied as values for the type argument: CHAR, INTEGER, DOUBLE,<br />

FLOAT, BIT, BLOB, BIGINT, TINYINT, BINARY, <strong>and</strong> SMALLINT. Certain types have<br />

predefined lengths <strong>and</strong> cannot be changed. The INTEGER <strong>and</strong> FLOAT types are<br />

always 4 bytes long. The DOUBLE <strong>and</strong> BIGINT types are always 8 bytes long.<br />

The SMALLINT type is always 2 bytes long. The TINYINT <strong>and</strong> BIT types are<br />

always 1 byte long. If another length value is specified for one of these types,<br />

an exception will be thrown.<br />

Parameters:<br />

fieldName - The name of the field.<br />

type - The type of the field.<br />

startingOffset - The starting offset in the I/O area of this field,<br />

beginning at offset 1.<br />

length - The length, in bytes, of this field.<br />

Throws: IllegalArgumentException if the starting offset is less than zero,<br />

an unsupported type is given, or an invalid length is given.<br />

See Also: DLISegment.<br />

Appendix A. <strong>IMS</strong> <strong>Java</strong> package 213


DLITypeInfo (String, int, int, int, String)<br />

public DLITypeInfo(String fieldName,<br />

int type,<br />

int startingOffset,<br />

int length,<br />

String searchFieldName)<br />

Constructs a DLITypeInfo object. This constructor is to be used with all key<br />

<strong>and</strong> search fields. It cannot be used for zoned decmial, packed decimal, date,<br />

time, <strong>and</strong> timestamp fields. Use the DLITypeInfo(String, String, int, int,<br />

int) or DLITypeInfo(String, String, int, int, int, String) constructors for<br />

these types. It provides functionality to provide an alias for the key <strong>and</strong><br />

search fields. This alias name is not limited to 8 characters. The DLITypeInfo<br />

class defines several constants that can be supplied as values for the type<br />

argument: CHAR, INTEGER, DOUBLE, FLOAT, BIT, BLOB, BIGINT, TINYINT, BINARY, <strong>and</strong><br />

SMALLINT. Certain types have predefined lengths <strong>and</strong> cannot be changed. The<br />

INTEGER <strong>and</strong> FLOAT types are always 4 bytes long. The DOUBLE <strong>and</strong> BIGINT types<br />

are always 8 bytes long. The SMALLINT type is always 2 bytes long. The<br />

TINYINT <strong>and</strong> BIT types are always 1 byte long. If another length value is<br />

specified for one of these types, an exception will be thrown.<br />

Parameters:<br />

fieldName - The name of the field. This name can be an alias that<br />

maps to the the actual name as defined in the DBD source file,<br />

which is given by the searchFieldName parameter.<br />

type - The type of the field.<br />

startingOffset - The starting offset in the I/O area of this field,<br />

beginning at offset 1.<br />

length - The length, in bytes, of this field.<br />

searchFieldName - The name of the search or key field exactly as<br />

defined in the DBD source file.<br />

Throws: IllegalArgumentException if the starting offset is less than zero,<br />

an unsupported type is given, or an invalid length is given.<br />

See Also: DLISegment.<br />

DLITypeInfo (String, String, int, int)<br />

public DLITypeInfo(String fieldName,<br />

String typeQualifier,<br />

int type,<br />

int startingOffset,int length)<br />

Constructs a DLITypeInfo object. This constructor is to be used with non-key<br />

<strong>and</strong> non-search fields of zoned or packed decimal <strong>and</strong> Date/Time/Timestamp<br />

214 <strong>IMS</strong> <strong>Version</strong> 7 <strong>and</strong> <strong>Java</strong> <strong>Application</strong> <strong>Programming</strong>


data. Use the DLITypeInfo(String, String, int, int, int) or<br />

DLITypeInfo(String, String, int, int, int, String) constructors for all other<br />

types.<br />

The uses of the type qualifier are as follows: If the field type is either packed<br />

or zoned decimal, the type qualifier is the PICTURE string representing the<br />

layout of the field. All COBOL PICTURE strings containing valid combinations<br />

of 9s. Ps, Vs, <strong>and</strong> Ss are supported. For zoned decimal numbers, the decimal<br />

point (.) can also be used in the PICTURE string. If the field contains<br />

Date/Time/Timestamp data, the type qualifier specifies the format of the data.<br />

For example, a type qualifier of ddMMyyyy indicates that the data is formatted<br />

as follows: 02011999 is January 2, 1999.<br />

The DLITypeInfo class defines several constants that can be supplied as<br />

values for the type argument: DATE, TIME, TIMESTAMP, ZONEDDECIMAL <strong>and</strong><br />

PACKEDDECIMAL.<br />

Parameters:<br />

fieldName - The name of the field.<br />

typeQualifier - The type qualifier for the field.<br />

type - The type of the field.<br />

startingOffset - The starting offset in the I/O area of this field,<br />

beginning at offset 1.<br />

length - The length of the field for a PACKEDDECIMAL number, the<br />

length can be calculated with the following function: ceiling((number<br />

of digits + 1)/2) for a ZONEDDECIMAL number, the length can be<br />

calculated with the following function: number of digits + 1 (if the<br />

decimal is stored in memory) number of digits (if the decimal is not<br />

stored in memory).<br />

Throws: IllegalArgumentException if the starting offset is less than zero,<br />

an unsupported type is given, or an invalid length is given.<br />

DLITypeInfo (String, String, int, int, int, String)<br />

public DLITypeInfo(String fieldName,<br />

String typeQualifier,<br />

int type,<br />

int startingOffset,<br />

int length,<br />

String searchFieldName)<br />

Constructs a DLITypeInfo object. This constructor is to be used with all key<br />

<strong>and</strong> search fields of zoned or packed decimal <strong>and</strong> Date/Time/Timestamp<br />

data. Use the DLITypeInfo(String, String, int, int, int) or<br />

Appendix A. <strong>IMS</strong> <strong>Java</strong> package 215


Methods<br />

DLITypeInfo(String, String, int, int, int, String) constructors for all other<br />

types. This constructor provides functionality to provide an alias for the key<br />

<strong>and</strong> search fields. This alias name is not limited to 8 characters. The uses of<br />

the type qualifier are as follows: If the field type is either packed or zoned<br />

decimal, the type qualifier is the PICTURE string representing the layout of<br />

the field. All COBOL PICTURE strings containing valid combinations of 9s.<br />

Ps, Vs, <strong>and</strong> Ss are supported. For zoned decimal numbers, the decimal point<br />

(.) can also be used in the PICTURE string. If the field contains<br />

Date/Time/Timestamp data, the type qualifier specifies the format of the data.<br />

For example, a type qualifier of ddMMyyyy indicates that the data is formatted<br />

as follows: 02011999 is January 2, 1999.<br />

The DLITypeInfo class defines several constants that can be supplied as<br />

values for the type argument: DATE, TIME, TIMESTAMP, ZONEDDECIMAL <strong>and</strong><br />

PACKEDDECIMAL.<br />

Parameters:<br />

216 <strong>IMS</strong> <strong>Version</strong> 7 <strong>and</strong> <strong>Java</strong> <strong>Application</strong> <strong>Programming</strong><br />

fieldName - The name of the field. This name can be an alias that<br />

maps to the the actual name as defined in the DBD source file,<br />

which is given by the searchFieldName parameter.<br />

typeQualifier - The type qualifier for the field.<br />

type - The type of the field.<br />

startingOffset - The starting offset in the I/O area of this field,<br />

beginning at offset 1.<br />

length - The length of the field.<br />

searchFieldName - The name of the search or key field exactly as<br />

defined in the DBD source file.<br />

Throws: IllegalArgumentException if the starting offset is less than<br />

zero, an unsupported type is given, or an invalid length is given.<br />

getFieldLength ()<br />

public int getFieldLength()<br />

Returns the length of the field's value in the segment.<br />

Returns: The length, in bytes.


getFieldName ()<br />

public String getFieldName()<br />

Returns the field name given to this field in the segment.<br />

Returns: The name of the field.<br />

getFieldOffset ()<br />

public int getFieldOffset()<br />

Returns the offset of the field in the segment's I/O area.<br />

Returns: The zero-based offset.<br />

getFieldType ()<br />

public int getFieldType()<br />

Returns the type assigned to a field's value in the segment.<br />

Returns: The type.<br />

getSearchFieldName ()<br />

public String getSearchFieldName()<br />

Returns the search field name given to this field in the segment, which<br />

must be exactly as defined in the DBD source file.<br />

Returns: The name of the search field as defined in the DBD source<br />

file.<br />

getTypeQualifier ()<br />

public String getTypeQualifier()<br />

Returns the type qualifier for this type.<br />

Returns: The type qualifier.<br />

A.13 Class com.ibm.ims.base.DLITypeInfoList<br />

java.lang.Object<br />

+----com.ibm.ims.base.DLITypeInfo<br />

+----com.ibm.ims.base.DLITypeInfoList<br />

public class DLITypeInfoList extends DLITypeInfo<br />

A DLITypeInfoList object is a specialization of a DLITypeInfo object that<br />

defines a set of fields that occur more than once. You construct a<br />

DLITypeInfoList object by providing the offset <strong>and</strong> entire length of the fields<br />

Appendix A. <strong>IMS</strong> <strong>Java</strong> package 217


Constructors<br />

that repeat, as well as a count of the number of occurrences of the repeating<br />

fields. The following example demonstrates how to define a ModelOutput<br />

message containing a variable number of entries for Make, Model, <strong>and</strong> Color<br />

(Figure 117). The total message will be 6004 bytes long <strong>and</strong> can contain a<br />

maximum of 100 60 byte entries of Make, Model, <strong>and</strong> Color.<br />

public class ModelOutput extends <strong>IMS</strong>FieldMessage {<br />

static DLITypeInfo[] modelTypeInfo = {<br />

new DLITypeInfo("Make", DLITypeInfo.CHAR, 1, 20),<br />

new DLITypeInfo("Model", DLITypeInfo.CHAR, 21, 20),<br />

new DLITypeInfo("Color", DLITypeInfo.CHAR, 41, 20)<br />

};<br />

static DLITypeInfo[] modelOutputTypeInfo = {<br />

new DLITypeInfo ("ModelCount", DLITypeInfo.INTEGER, 1, 4),<br />

new DLITypeInfoList ("ModelList", modelTypeInfo, 5, 60, 100)<br />

};<br />

public ModelOutput() {<br />

super(modelOutputTypeInfo, 6004, false);<br />

}<br />

}<br />

Figure 117. Example defining an OutputModel message<br />

DLITypeInfoList(String, DLITypeInfo[ ], int, int, int)<br />

public DLITypeInfoList(String listName,<br />

DLITypeInfo typeInfo[],<br />

int startingOffset,<br />

int length,<br />

int count)<br />

Constructs a DLITypeInfoList object<br />

Parameters:<br />

218 <strong>IMS</strong> <strong>Version</strong> 7 <strong>and</strong> <strong>Java</strong> <strong>Application</strong> <strong>Programming</strong><br />

listName - The name of the repeating set of fields.<br />

startingOffset - The starting offset in the I/O area of this set of<br />

fields, beginning at offset 1.<br />

length - The length, in bytes, of one instance of this set of fields.<br />

count - The number of times the fields repeat.<br />

Throws: IllegalArgumentException if the starting offset is less than zero,<br />

or an invalid length is given.


Methods<br />

getCount ()<br />

public final int getCount()<br />

Returns the count of repeating fields.<br />

Returns: The count.<br />

A.14 Class com.ibm.ims.base.<strong>IMS</strong>ErrorMessages<br />

Constructor<br />

Methods<br />

java.lang.Object<br />

+----java.util.ResourceBundle<br />

+----java.util.ListResourceBundle<br />

+----com.ibm.ims.base.<strong>IMS</strong>ErrorMessages<br />

public class <strong>IMS</strong>ErrorMessages extends ListResourceBundle<br />

<strong>IMS</strong>ErrorMessages ()<br />

public <strong>IMS</strong>ErrorMessages()<br />

Creates a resource bundle for giving error messages.<br />

getContents ()<br />

protected Object[][] getContents()<br />

Overrides: getContents in class ListResourceBundle.<br />

get<strong>IMS</strong>Bundle ()<br />

public static <strong>IMS</strong>ErrorMessages get<strong>IMS</strong>Bundle()<br />

Returns the translated resource bundle.<br />

Returns: com.ibm.ims.base.<strong>IMS</strong>ErrorMessages.<br />

getString (String, Object [ ])<br />

public String getString(String key,<br />

Object inserts[ ])<br />

Appendix A. <strong>IMS</strong> <strong>Java</strong> package 219


A.15 Class com.ibm.ims.base.<strong>IMS</strong>Info<br />

Methods<br />

java.lang.Object<br />

+----com.ibm.ims.base.<strong>IMS</strong>Info<br />

public final class <strong>IMS</strong>Info extends Object<br />

The <strong>IMS</strong>Info class provides information about the application’s current<br />

execution environment. This information is determined by making the System<br />

Service Call INQY with the ENVIRON subfunction. This includes the <strong>IMS</strong><br />

identifier, release, region, program name, PSB name, transaction name, user<br />

identifier, group name, <strong>and</strong> status group indicator.<br />

applicationRegionType ()<br />

public String applicationRegionType()<br />

Returns <strong>IMS</strong> active application region type. The active region could be<br />

BATCH (<strong>IMS</strong> Batch), BMP (Batch Message Processing), IFP (<strong>IMS</strong> Fast Path)<br />

or MPP (Message Processing).<br />

Returns: The active <strong>IMS</strong> application region type.<br />

controlRegionType ()<br />

public String controlRegionType()<br />

Returns the active <strong>IMS</strong> Control Region Type. The active region type could<br />

be BATCH (<strong>IMS</strong> Batch), DB (only the <strong>IMS</strong> Database Manager is active --<br />

DBCTL system), TM (only the <strong>IMS</strong> Transaction Manager is active -- DCCTL<br />

system), or DB/DC (both the <strong>IMS</strong> Database <strong>and</strong> Transaction managers are<br />

active -- DB/DC system),<br />

Returns: the active <strong>IMS</strong> Control Region Type.<br />

get<strong>IMS</strong>Info ()<br />

public static final <strong>IMS</strong>Info get<strong>IMS</strong>Info() throws <strong>IMS</strong>Exception<br />

Creates an <strong>IMS</strong>Info object containing information about the <strong>IMS</strong> system.<br />

Returns: A new <strong>IMS</strong>Info object containing the <strong>IMS</strong> system information.<br />

Throws: <strong>IMS</strong>Exception if a non-blank status code is returned from the<br />

system call.<br />

220 <strong>IMS</strong> <strong>Version</strong> 7 <strong>and</strong> <strong>Java</strong> <strong>Application</strong> <strong>Programming</strong>


groupName ()<br />

public String groupName()<br />

Returns the Group Name.<br />

Returns: The Group Name or blanks if the Group Name is unavailable.<br />

programName ()<br />

public String programName()<br />

Returns the <strong>Application</strong> Program Name of the application program being<br />

run.<br />

Returns: The <strong>Application</strong> Program Name.<br />

psbName ()<br />

public String psbName()<br />

Returns the name of the PSB currently allocated.<br />

Returns: The PSB name.<br />

regionID ()<br />

public int regionID()<br />

Returns the <strong>IMS</strong> Region Identifier.<br />

Returns: The <strong>IMS</strong> Region Identifier.<br />

releaseLevel ()<br />

public int releaseLevel()<br />

Returns <strong>IMS</strong> Release Level. For example, for <strong>IMS</strong> Versio 7 Release 1, 710<br />

will be returned.<br />

Returns: The Release Level for <strong>IMS</strong>.<br />

statusGroupIndicator ()<br />

public String statusGroupIndicator()<br />

Returns the Status Group Indicator. The indicator could be A (INIT<br />

STATUS GROUPA call is issued), B (INIT STATUS GROUPB call is<br />

issued).<br />

Returns: <strong>IMS</strong> Status Group indicator or blank if a status group is not<br />

initialized.<br />

systemID ()<br />

public String systemID()<br />

Returns the identifier from the execute parameters.<br />

Appendix A. <strong>IMS</strong> <strong>Java</strong> package 221


Returns: The <strong>IMS</strong> system Identifier.<br />

transactionName ()<br />

public String transactionName()<br />

Returns the name of the transaction.<br />

Returns: The transaction name or blanks if there is no transaction.<br />

userID ()<br />

public String userID()<br />

Returns the user ID derived from the PSTUSID field of the PST that<br />

represents the region making the INQY ENVIRON call.<br />

Returns: The user ID or blanks if the user ID is unavailable.<br />

A.16 Class com.ibm.ims.base.<strong>IMS</strong>Trace<br />

java.lang.Object<br />

+----com.ibm.ims.base.<strong>IMS</strong>Trace<br />

public class <strong>IMS</strong>Trace extends Object<br />

<strong>IMS</strong>Trace provides tracing facilities to document the flow of control in an <strong>IMS</strong><br />

<strong>Java</strong> application.<br />

The static public variable <strong>IMS</strong>Trace.traceOn determines whether tracing is<br />

enabled or not. By default <strong>IMS</strong>Trace.traceOn is set to false. If an application<br />

wishes to utilize tracing, it should set this variable to true within a static block<br />

of their <strong>IMS</strong><strong>Application</strong> subclass.<br />

The static public variable <strong>IMS</strong>Trace.libTraceLevel determines the amount of<br />

tracing that will occur within <strong>IMS</strong> provided packages. If libTraceLevel is zero,<br />

no library tracing occurs. <strong>IMS</strong>Trace defines three levels of three types of<br />

tracing constants which are used within library provided code. These<br />

constants represent progressively more tracing at each successive level.<br />

Generally, level 1 constants are used for larger objects while level 3<br />

constants are used for smaller objects or high volume functions. The higher<br />

the value of <strong>IMS</strong>Trace.libTraceLevel, the more trace data will be written to the<br />

output stream. In addition, <strong>IMS</strong>Trace defines the constant TRACE_EXCEPTIONS.<br />

This level 0 constant is used to trace the construction of library provided<br />

exceptions. The following traceLevel constants represent successively higher<br />

levels of tracing:<br />

222 <strong>IMS</strong> <strong>Version</strong> 7 <strong>and</strong> <strong>Java</strong> <strong>Application</strong> <strong>Programming</strong>


TRACE_EXCEPTIONS Causes tracing of exception construction.<br />

TRACE_CTOR1 Causes tracing of level 1 constructors.<br />

TRACE_METHOD1 Causes tracing of level 1 methods <strong>and</strong><br />

constructors.<br />

TRACE_DATA1 Causes tracing of level 1 parameters, return<br />

values, methods, <strong>and</strong> constructors.<br />

TRACE_CTOR2 Causes tracing of level 2 constructors <strong>and</strong> all level<br />

1 entries.<br />

TRACE_METHOD2 Causes tracing of level 2 methods <strong>and</strong><br />

constructors, <strong>and</strong> all level 1 entries.<br />

TRACE_DATA2 Causes tracing of level 2 parameters, return<br />

values, methods, constructors, <strong>and</strong> all level 1<br />

entries.<br />

TRACE_CTOR3 Causes tracing of level 3 constructors <strong>and</strong> all level<br />

1 <strong>and</strong> level 2 entries.<br />

TRACE_METHOD3 Causes tracing of level 3 methods <strong>and</strong><br />

constructors, <strong>and</strong> all level 1 <strong>and</strong> level 2 entries.<br />

TRACE_DATA3 Causes tracing of level 3 parameters, return<br />

values, methods, constructors, <strong>and</strong> all level 1 <strong>and</strong><br />

level 2 entries.<br />

By default, <strong>IMS</strong>Trace.libTraceLevel is set to TRACE_EXCEPTIONS. If an application<br />

wishes to change the amount of tracing within the <strong>IMS</strong> library provided<br />

packages, it should update this variable within a static block of their<br />

<strong>IMS</strong><strong>Application</strong> subclass.<br />

An application can control the output location used for tracing by calling<br />

<strong>IMS</strong>Trace.setOutputStream with a valid print stream or by calling<br />

<strong>IMS</strong>Trace.setOutputWriter with a valid character output stream. One of these<br />

function should be called within a static block of an <strong>IMS</strong><strong>Application</strong> subclass.<br />

Figure 118 shows how to use System.out for trace output <strong>and</strong> set<br />

libTraceLevel to TRACE_DATA2.<br />

Appendix A. <strong>IMS</strong> <strong>Java</strong> package 223


public class My<strong>Application</strong> extends <strong>IMS</strong><strong>Application</strong> {<br />

static {<br />

<strong>IMS</strong>Trace.traceOn = true;<br />

<strong>IMS</strong>Trace.setOutputStream(System.out);<br />

<strong>IMS</strong>Trace.libTraceLevel=<strong>IMS</strong>Trace.TRACE_DATA2;<br />

}<br />

public abstract void doBegin() throws com.ibm.ims.base.<strong>IMS</strong>Exception {<br />

...<br />

}<br />

} // end My<strong>Application</strong><br />

Figure 118. Using System.out for trace output<br />

<strong>IMS</strong>Trace.logData is the primary method for writing trace data. If either<br />

<strong>IMS</strong>Trace.setOutputStream or <strong>IMS</strong>Trace.setOutputWriter was called with a valid<br />

output stream, <strong>and</strong> <strong>IMS</strong>Trace.traceOn is set to true, logData writes its string<br />

data to this stream. If an error occurs writing to one of these streams, or<br />

tracing is enabled <strong>and</strong> a stream has not been provided, the trace data is<br />

written to the System.err stream. Prior to writing its data to an output stream,<br />

<strong>IMS</strong>Trace.logData prepends a newline character <strong>and</strong> a number of blank<br />

characters based on the current nested method level.<br />

The <strong>IMS</strong> library provided packages utilize XML tags when logging its data.<br />

The following tags are used:<br />

methodName A method entry<br />

methodName A method exit<br />

A parameter<br />

parmName The name of a parameter<br />

parmCharValue Character data for a<br />

parameter<br />

parmHexValue Hex data for a parameter<br />

Data<br />

dataName The name of a data value<br />

dataCharValue Character data value<br />

dataHexValue Hex data value<br />

The result of a method<br />

resultCharValue Character result value<br />

resultHexValue Hex result value<br />

224 <strong>IMS</strong> <strong>Version</strong> 7 <strong>and</strong> <strong>Java</strong> <strong>Application</strong> <strong>Programming</strong>


Variables<br />

As a convenience, <strong>IMS</strong>Trace contains logging methods that add some of the<br />

appropriate XML tags prior to writing the data to the log. These include:<br />

logEntry Adds the tags<br />

logExit Adds the tags<br />

logParms Adds the , ,<br />

, tags<br />

logData Adds the , ,<br />

, tags<br />

logResult Adds the ,<br />

, tags<br />

To write to the <strong>IMS</strong>Trace, you need to get an <strong>IMS</strong>Trace object by calling the<br />

method <strong>IMS</strong>Trace.currentTrace. For example:<br />

<strong>IMS</strong>Trace.currentTrace().logData(“dataName”, “dataValue”);<br />

Some of the <strong>IMS</strong> library supplied packages implement tracing using “Trace”<br />

subclasses. These subclasses re-implement the methods in the base class<br />

needing to be traced by wrapping <strong>IMS</strong>Trace calls around the calls to the base<br />

class methods. In addition, prior to instantiating an object implementing<br />

tracing, a test is made to see if tracing is enabled. If tracing is enabled, the<br />

“Trace” subclass is instantiated instead of the base class. This style of tracing<br />

is limited to classes that hide their constructors <strong>and</strong> support object creation<br />

using “createInstance” style methods on the class (or on a related class).<br />

Tracing the entry point of constructors in <strong>Java</strong> is made difficult by the<br />

language requirement that the first line of a constructor be a call to its super<br />

class constructor. The result of this behavior is that the trace will show an<br />

entry <strong>and</strong> exit of the base class constructor prior to showing an entry to the<br />

derived class constructor.<br />

traceOn<br />

public static boolean traceOn<br />

The flag to indicate whether tracing is enabled.<br />

Appendix A. <strong>IMS</strong> <strong>Java</strong> package 225


TRACE_EXCEPTIONS<br />

public static final int TRACE_EXCEPTIONS<br />

Causes tracing of Exception constructors.<br />

TRACE_CTOR1<br />

public static final int TRACE_CTOR1<br />

Causes tracing of level 1 constructors.<br />

TRACE_METHOD1<br />

public static final int TRACE_METHOD1<br />

Causes tracing of level 1 methods <strong>and</strong> constructors.<br />

TRACE_DATA1<br />

public static final int TRACE_DATA1<br />

Causes tracing of level 1 parameters, return values, methods, <strong>and</strong><br />

constructors.<br />

TRACE_CTOR2<br />

public static final int TRACE_CTOR2<br />

Causes tracing of level 2 constructors <strong>and</strong> all level 1 entries.<br />

TRACE_METHOD2<br />

public static final int TRACE_METHOD2<br />

Causes tracing of level 2 methods <strong>and</strong> constructors, <strong>and</strong> all level 1 entries.<br />

TRACE_DATA2<br />

public static final int TRACE_DATA2<br />

Causes tracing of level 2 parameters, return values, methods,<br />

constructors, <strong>and</strong> all level 1 entries.<br />

TRACE_CTOR3<br />

public static final int TRACE_CTOR3<br />

Causes tracing of level 3 constructors <strong>and</strong> all level 1 <strong>and</strong> level 2 entries.<br />

TRACE_METHOD3<br />

public static final int TRACE_METHOD3<br />

Causes tracing of level 3 methods <strong>and</strong> constructors, <strong>and</strong> all level 1 <strong>and</strong><br />

level 2 entries.<br />

226 <strong>IMS</strong> <strong>Version</strong> 7 <strong>and</strong> <strong>Java</strong> <strong>Application</strong> <strong>Programming</strong>


Methods<br />

TRACE_DATA3<br />

public static final int TRACE_DATA3<br />

Causes tracing of level 3 parameters, return values, methods,<br />

constructors, <strong>and</strong> all level 1 <strong>and</strong> level 2 entries.<br />

libTraceLevel ()<br />

public static int libTraceLevel<br />

The trace level for <strong>IMS</strong> Library code.<br />

currentTrace ()<br />

public static <strong>IMS</strong>Trace currentTrace()<br />

Returns the <strong>IMS</strong>Trace object for the current thread.<br />

Returns: The <strong>IMS</strong>Trace object for the current thread.<br />

setOutputStream (PrintStream)<br />

public static void setOutputStream(PrintStream outputStream)<br />

Sets the output stream used for tracing to a print stream. If neither a<br />

character output stream nor print stream has been set, <strong>and</strong> tracing is<br />

enabled, the trace data is written to the System.err stream.<br />

Parameters:<br />

outputStream - A PringStream for tracing.<br />

setOutputWriter (Writer)<br />

public static void setOutputWriter(Writer outputStream)<br />

Sets the output stream used for tracing to a character output stream. If<br />

neither a character output stream nor a print stream has been set, <strong>and</strong><br />

tracing is enabled, the trace data is written to the System.err stream.<br />

Parameters:<br />

outputStream - An output stream for tracing.<br />

getOutputStream ()<br />

public static PrintStream getOutputStream()<br />

Returns the print stream used for tracing or null if a print stream has not<br />

been set. It also returns null if a character output stream has been set<br />

using setOutputWriter. If neither a character output stream nor a print<br />

stream has been set, <strong>and</strong> tracing is enabled, the trace data is written to<br />

the System.err stream.<br />

Appendix A. <strong>IMS</strong> <strong>Java</strong> package 227


Returns: An output stream or null if an output stream has not been set.<br />

getOutputWriter ()<br />

public static Writer getOutputWriter()<br />

Returns the character output stream used for tracing or null if a character<br />

output stream has not been set. It also returns null if a print stream has<br />

been set using setOutputStream. If neither a character output stream nor a<br />

print stream has been set, <strong>and</strong> tracing is enabled, the trace data is written<br />

to the System.err stream.<br />

Returns: A character output stream or null if an output stream has not<br />

been set.<br />

setMaxBinaryLength (int)<br />

public static void setMaxBinaryLength(int maxBinaryLength)<br />

Sets the maximum length when tracing binary data. If not called by an<br />

application, the maximum length of binary data traced is 50 bytes.<br />

getMaxBinaryLength ()<br />

public static int getMaxBinaryLength()<br />

Returns the maximum length when tracing binary data (e.g. a byte array).<br />

If setMaxBinaryLength has not bee called by an application, the maximum<br />

length of binary data traced is 50 bytes.<br />

Returns: The maximum length traced for binary data.<br />

setTIDTracing (boolean)<br />

public static void setTIDTracing(boolean on)<br />

Adds or removes the thread identifier to trace entries. This value must be<br />

set before any trace activity <strong>and</strong> before a call to <strong>IMS</strong>Trace.currentTrace. It<br />

is recommended that this method be used within a static block of the main<br />

application class.<br />

logData (String)<br />

public void logData(String entry)<br />

Writes a trace entry. If <strong>IMS</strong>Trace.traceOn is true <strong>and</strong> an output stream has<br />

been established, the trace data is written to that output stream. The<br />

output stream can be either a print stream, set by calling setOutputStream,<br />

or a character output stream, set by calling setOutputWriter. If traceOn is<br />

true <strong>and</strong> an output stream has not been established, the trace data is<br />

written to the System.err stream.<br />

228 <strong>IMS</strong> <strong>Version</strong> 7 <strong>and</strong> <strong>Java</strong> <strong>Application</strong> <strong>Programming</strong>


Parameters:<br />

entry - The string to write to the log.<br />

logEntry (String)<br />

public void logEntry(String methodName)<br />

Writes a method entry point. This method adds XML tags for an entry point<br />

prior to writing the method name to the log.<br />

Parameters:<br />

methodName - The method being entered.<br />

logExit (String)<br />

public void logExit(String methodName)<br />

Writes a method exit point. This method adds XML tags for an exit point<br />

prior to writing the method name to the log.<br />

Parameters:<br />

methodName - The method being entered.<br />

logResult (String)<br />

public void logResult(String result)<br />

Writes the result of a method. This method adds XML tags for a result prior<br />

to writing the result to the log.<br />

Parameters:<br />

result - The result to be written.<br />

logResult (byte)<br />

public void logResult(byte result[])<br />

Writes the byte array result of a method. This method adds XML tags for a<br />

result prior to writing the result to the log <strong>and</strong> it dumps the byte array as<br />

hex characters.<br />

Parameters:<br />

result - The result to be written in hex.<br />

logParm (String, byte)<br />

public void logParm(String parmName,<br />

byte parmValue[])<br />

Writes the parameters of a method. This method adds XML tags for a<br />

parameter, <strong>and</strong> optionally the value of the parameter, prior to writing the<br />

parameter to the log.<br />

Appendix A. <strong>IMS</strong> <strong>Java</strong> package 229


Parameters:<br />

parmName - The name of the parameter.<br />

230 <strong>IMS</strong> <strong>Version</strong> 7 <strong>and</strong> <strong>Java</strong> <strong>Application</strong> <strong>Programming</strong><br />

parmValue - The string value of the parameter or null.<br />

logData (String, String)<br />

public void logData(String dataName,<br />

String dataValue)<br />

Writes a data name-value pair. This method adds XML tags for the data<br />

<strong>and</strong> the value of the data prior to writing the data to the log.<br />

Parameters:<br />

dataName - The name of the data to be written.<br />

dataValue - The value of the data to be written.<br />

logData (String, byte)<br />

public void logData(String dataName,<br />

byte dataValue[])<br />

Writes a data value in binary <strong>and</strong> character. This method adds XML tags<br />

for the data name <strong>and</strong> value prior to writing the parameter to the log.<br />

Parameters:<br />

dataName - The name of the parameter.<br />

dataValue - The byte array value null.<br />

logParm (String, String)<br />

public void logParm(String parmName,<br />

String parmValue)<br />

Writes the parameters of a method. This method adds XML tags for a<br />

parameter, <strong>and</strong> optionally the value of the parameter, prior to writing the<br />

parameter to the log.<br />

Parameters:<br />

parmName - The name of the parameter.<br />

parmValue - The string value of the parameter or null.<br />

logParm (String, String, String, String)<br />

public void logParm(String parm1Name,<br />

String parm1Value,<br />

String parm2Name,<br />

String parm2Value)


Writes the parameters of a method. This method adds XML tags for two<br />

parameters, <strong>and</strong> optionally the value of these parameters, prior to writing<br />

them to the log.<br />

Parameters:<br />

parm1Name - The name of the first parameter.<br />

parm1Value - The string value of the first parameter or null.<br />

parm2Name - The name of the second parameter.<br />

parm2Value - The string value of the second parameter or null.<br />

logParm (String, String, String, String, String, String)<br />

public void logParm(String parm1Name,<br />

String parm1Value,<br />

String parm2Name,<br />

String parm2Value,<br />

String parm3Name,<br />

String parm3Value)<br />

Writes the parameters of a method. This method adds XML tags for three<br />

parameters, <strong>and</strong> optionally the value of these parameters, prior to writing<br />

them to the log.<br />

Parameters:<br />

parm1Name - The name of the first parameter.<br />

parm1Value - The string value of the first parameter or null.<br />

parm2Name - The name of the second parameter.<br />

parm2Value - The string value of the second parameter or null.<br />

parm3Name - The name of the third parameter.<br />

parm3Value - The string value of the third parameter or null.<br />

logParm (String, String)<br />

public void logParm(String parmNameArray[ ],<br />

String parmValueArray[ ])<br />

Writes the parameters of a method. This method adds XML tags for an<br />

array of parameter names, <strong>and</strong> optionally the value of these parameters,<br />

prior to writing them to the log.<br />

Parameters:<br />

parmArray - The array of parameter names.<br />

parmValueArray - The array of string values of the parameters or null.<br />

Appendix A. <strong>IMS</strong> <strong>Java</strong> package 231


A.17 Class com.ibm.ims.base.IOPCB<br />

Methods<br />

java.lang.Object<br />

+----com.ibm.ims.base.IOPCB<br />

public final class IOPCB extends Object<br />

The IOPCB class contains all the data attributes of the <strong>IMS</strong> I/O Program<br />

Communication Block <strong>and</strong> the necessary getter <strong>and</strong> setter method. <strong>IMS</strong><br />

describes the results of the calls your program issues in the I/O PCB that is<br />

referenced in the call. For more information, see <strong>IMS</strong> <strong>Application</strong><br />

<strong>Programming</strong>: Transaction Manager.<br />

getLogicalTerminalName ()<br />

public String getLogicalTerminalName()<br />

Returns the logical terminal name in this IOPCB. The maximun length is 8<br />

characters.<br />

Returns: The IOPCB’s logical terminal name.<br />

getStatusCode ()<br />

public short getStatusCode()<br />

Returns the status code from the last DLI call using this IOPCB.<br />

Returns: The IOPCB’s <strong>IMS</strong> status code.<br />

getLocalDate ()<br />

public String getLocalDate()<br />

Returns the local date from the last DLI call using this IOPCB. The local<br />

date is in the format yyddd.<br />

Returns: The IOPCB’s local date.<br />

getLocalTime ()<br />

public String getLocalTime()<br />

Returns the local time from the last DLI call using this IOPCB. The local<br />

time is in the format hhmmsst.<br />

Returns: The IOPCB’s local time.<br />

232 <strong>IMS</strong> <strong>Version</strong> 7 <strong>and</strong> <strong>Java</strong> <strong>Application</strong> <strong>Programming</strong>


getInputMessageSequenceNumber ()<br />

public int getInputMessageSequenceNumber()<br />

Returns the input message sequence number from the last DLI call using<br />

this IOPCB.<br />

Returns: The IOPCB’s input message sequence number.<br />

getMODName ()<br />

public String getMODName()<br />

Returns the message output descriptor (MOD) name from the last DLI call<br />

using this IOPCB. The maximum length is 8 characters.<br />

Returns: The IOPCB’s message output descriptor (MOD) name.<br />

getUserid ()<br />

public String getUserid()<br />

Returns the userid from the last DLI call using this IOPCB. The maximum<br />

length is 8 characters.<br />

Returns: The IOPCB’s userid.<br />

getGroupName ()<br />

public String getGroupName()<br />

Returns the group name from the last DLI call using this IOPCB. The<br />

maximum length is 8 characters.<br />

Returns: The IOPCB’s group name.<br />

A.18 Class com.ibm.ims.base.<strong>Java</strong>ToDLI<br />

java.lang.Object<br />

+----com.ibm.ims.base.<strong>Java</strong>ToDLI<br />

public final class <strong>Java</strong>ToDLI extends Object<br />

The <strong>Java</strong>ToDLI class is used to issue DL/I calls to get, update, insert, <strong>and</strong><br />

delete data in <strong>IMS</strong> databases, to get <strong>and</strong> insert messages to the <strong>IMS</strong><br />

message queues, <strong>and</strong> to perform <strong>IMS</strong> system service calls. <strong>Java</strong>ToDLI is<br />

defined as public final. This class also loads the native code DLL in a static<br />

block.<br />

Appendix A. <strong>IMS</strong> <strong>Java</strong> package 233


Variables<br />

A1<br />

public static final short A1<br />

A2<br />

public static final short A2<br />

A3<br />

public static final short A3<br />

A4<br />

public static final short A4<br />

A5<br />

public static final short A5<br />

A6<br />

public static final short A6<br />

A7<br />

public static final short A7<br />

A8<br />

public static final short A8<br />

A9<br />

public static final short A9<br />

AA<br />

public static final short AA<br />

AB<br />

public static final short AB<br />

AC<br />

public static final short AC<br />

AD<br />

public static final short AD<br />

AF<br />

public static final short AF<br />

234 <strong>IMS</strong> <strong>Version</strong> 7 <strong>and</strong> <strong>Java</strong> <strong>Application</strong> <strong>Programming</strong>


AG<br />

public static final short AG<br />

AH<br />

public static final short AH<br />

AI<br />

public static final short AI<br />

AJ<br />

public static final short AJ<br />

AK<br />

public static final short AK<br />

AL<br />

public static final short AL<br />

AM<br />

public static final short AM<br />

AO<br />

public static final short AO<br />

AP<br />

public static final short AP<br />

AQ<br />

public static final short AQ<br />

AR<br />

public static final short AR<br />

AS<br />

public static final short AS<br />

AT<br />

public static final short AT<br />

AU<br />

public static final short AU<br />

Appendix A. <strong>IMS</strong> <strong>Java</strong> package 235


AX<br />

public static final short AX<br />

AY<br />

public static final short AY<br />

AZ<br />

public static final short AZ<br />

BA<br />

public static final short BA<br />

BB<br />

public static final short BB<br />

BC<br />

public static final short BC<br />

BJ<br />

public static final short BJ<br />

BK<br />

public static final short BK<br />

CA<br />

public static final short CA<br />

CB<br />

public static final short CB<br />

CC<br />

public static final short CC<br />

CD<br />

public static final short CD<br />

CE<br />

public static final short CE<br />

CF<br />

public static final short CF<br />

236 <strong>IMS</strong> <strong>Version</strong> 7 <strong>and</strong> <strong>Java</strong> <strong>Application</strong> <strong>Programming</strong>


CG<br />

public static final short CG<br />

CH<br />

public static final short CH<br />

CI<br />

public static final short CI<br />

CJ<br />

public static final short CJ<br />

CK<br />

public static final short CK<br />

CL<br />

public static final short CL<br />

CM<br />

public static final short CM<br />

CN<br />

public static final short CN<br />

DA<br />

public static final short DA<br />

DJ<br />

public static final short DJ<br />

DX<br />

public static final short DX<br />

FA<br />

public static final short FA<br />

FC<br />

public static final short FC<br />

FD<br />

public static final short FD<br />

Appendix A. <strong>IMS</strong> <strong>Java</strong> package 237


FE<br />

public static final short FE<br />

FF<br />

public static final short FF<br />

FG<br />

public static final short FG<br />

FH<br />

public static final short FH<br />

FI<br />

public static final short FI<br />

FM<br />

public static final short FM<br />

FN<br />

public static final short FN<br />

FP<br />

public static final short FP<br />

FR<br />

public static final short FR<br />

FS<br />

public static final short FS<br />

FT<br />

public static final short FT<br />

FV<br />

public static final short FV<br />

FW<br />

public static final short FW<br />

FY<br />

public static final short FY<br />

238 <strong>IMS</strong> <strong>Version</strong> 7 <strong>and</strong> <strong>Java</strong> <strong>Application</strong> <strong>Programming</strong>


GA<br />

public static final short GA<br />

GB<br />

public static final short GB<br />

GC<br />

public static final short GC<br />

GD<br />

public static final short GD<br />

GE<br />

public static final short GE<br />

GG<br />

public static final short GG<br />

GK<br />

public static final short GK<br />

GL<br />

public static final short GL<br />

GP<br />

public static final short GP<br />

II<br />

public static final short II<br />

IX<br />

public static final short IX<br />

LB<br />

public static final short LB<br />

LC<br />

public static final short LC<br />

LD<br />

public static final short LD<br />

Appendix A. <strong>IMS</strong> <strong>Java</strong> package 239


LE<br />

public static final short LE<br />

MR<br />

public static final short MR<br />

NA<br />

public static final short NA<br />

NE<br />

public static final short NE<br />

NI<br />

public static final short NI<br />

NL<br />

public static final short NL<br />

NO<br />

public static final short NO<br />

NU<br />

public static final short NU<br />

QC<br />

public static final short QC<br />

QD<br />

public static final short QD<br />

QE<br />

public static final short QE<br />

QF<br />

public static final short QF<br />

QH<br />

public static final short QH<br />

RA<br />

public static final short RA<br />

240 <strong>IMS</strong> <strong>Version</strong> 7 <strong>and</strong> <strong>Java</strong> <strong>Application</strong> <strong>Programming</strong>


RC<br />

public static final short RC<br />

RX<br />

public static final short RX<br />

SA<br />

public static final short SA<br />

SB<br />

public static final short SB<br />

SC<br />

public static final short SC<br />

SY<br />

public static final short SY<br />

TA<br />

public static final short TA<br />

TC<br />

public static final short TC<br />

TE<br />

public static final short TE<br />

TG<br />

public static final short TG<br />

TH<br />

public static final short TH<br />

TI<br />

public static final short TI<br />

TJ<br />

public static final short TJ<br />

TL<br />

public static final short TL<br />

Appendix A. <strong>IMS</strong> <strong>Java</strong> package 241


TN<br />

public static final short TN<br />

TO<br />

public static final short TO<br />

TP<br />

public static final short TP<br />

TR<br />

public static final short TR<br />

TY<br />

public static final short TY<br />

TZ<br />

public static final short TZ<br />

UC<br />

public static final short UC<br />

UR<br />

public static final short UR<br />

US<br />

public static final short US<br />

UX<br />

public static final short UX<br />

V1<br />

public static final short V1<br />

V2<br />

public static final short V2<br />

V3<br />

public static final short V3<br />

V4<br />

public static final short V4<br />

242 <strong>IMS</strong> <strong>Version</strong> 7 <strong>and</strong> <strong>Java</strong> <strong>Application</strong> <strong>Programming</strong>


V5<br />

public static final short V5<br />

V6<br />

public static final short V6<br />

V7<br />

public static final short V7<br />

X2<br />

public static final short X2<br />

X3<br />

public static final short X3<br />

X4<br />

public static final short X4<br />

X5<br />

public static final short X5<br />

X6<br />

public static final short X6<br />

X7<br />

public static final short X7<br />

X8<br />

public static final short X8<br />

XA<br />

public static final short XA<br />

XB<br />

public static final short XB<br />

XC<br />

public static final short XC<br />

XD<br />

public static final short XD<br />

Appendix A. <strong>IMS</strong> <strong>Java</strong> package 243


XE<br />

public static final short XE<br />

XF<br />

public static final short XF<br />

XG<br />

public static final short XG<br />

XX<br />

public static final short XX<br />

JNI1<br />

public static final short JNI1<br />

JNI2<br />

public static final short JNI2<br />

JNI3<br />

public static final short JNI3<br />

JNI4<br />

public static final short JNI4<br />

AUTH_CLASS_CHNG_DESTINATION<br />

public static final short AUTH_CLASS_CHNG_DESTINATION<br />

CHNG_WITH_INVALID_PCB<br />

public static final short CHNG_WITH_INVALID_PCB<br />

PCB_DESTINATION<br />

public static final short PCB_DESTINATION<br />

CONVERSATIONAL_RESPONSE_SECURITY<br />

public static final short CONVERSATIONAL_RESPONSE_SECURITY<br />

MODNAME_SUBSEQUENT_MESSAGE<br />

public static final short MODNAME_SUBSEQUENT_MESSAGE<br />

MESSAGE_SEGMENT_SIZE_EXCEEDED<br />

public static final short MESSAGE_SEGMENT_SIZE_EXCEEDED<br />

244 <strong>IMS</strong> <strong>Version</strong> 7 <strong>and</strong> <strong>Java</strong> <strong>Application</strong> <strong>Programming</strong>


NUMBER_OF_OUTPUT_SEGMENTS_EXCEEDED<br />

public static final short NUMBER_OF_OUTPUT_SEGMENTS_EXCEEDED<br />

INSERT_TO_IOPCB_AND_ALTERNATE_PCB<br />

public static final short INSERT_TO_IOPCB_AND_ALTERNATE_PCB<br />

ALTERNATE_PCB_PHYSICAL_TERMINAL<br />

public static final short ALTERNATE_PCB_PHYSICAL_TERMINAL<br />

ALTERNATE_RESPONSE_DESTINATION<br />

public static final short ALTERNATE_RESPONSE_DESTINATION<br />

MISSING_IO_AREA<br />

public static final short MISSING_IO_AREA<br />

SSA_HIERARCHIC_ERROR<br />

public static final short SSA_HIERARCHIC_ERROR<br />

INVALID_FUNCTION_FOR_PCB<br />

public static final short INVALID_FUNCTION_FOR_PCB<br />

GSAM_INVALID_RECORD_LENGTH<br />

public static final short GSAM_INVALID_RECORD_LENGTH<br />

INQY_IO_LENGTH<br />

public static final short INQY_IO_LENGTH<br />

REQUIRED_SSA_MISSING<br />

public static final short REQUIRED_SSA_MISSING<br />

DATA_MANAGEMENT_OPEN_ERROR<br />

public static final short DATA_MANAGEMENT_OPEN_ERROR<br />

INVALID_SSA_OR_PARAMETER<br />

public static final short INVALID_SSA_OR_PARAMETER<br />

SSA_FIELDNAME_ERROR<br />

public static final short SSA_FIELDNAME_ERROR<br />

IOPCB_IN_BATCH<br />

public static final short IOPCB_IN_BATCH<br />

Appendix A. <strong>IMS</strong> <strong>Java</strong> package 245


INCOMPATIBLE_CALL_FUNCTION<br />

public static final short INCOMPATIBLE_CALL_FUNCTION<br />

PHYSICAL_IO_ERROR<br />

public static final short PHYSICAL_IO_ERROR<br />

PARAMETER_LIMIT<br />

public static final short PARAMETER_LIMIT<br />

INVALID_SUB_FUNCTION<br />

public static final short INVALID_SUB_FUNCTION<br />

OPTIONS_LIST_ERROR<br />

public static final short OPTIONS_LIST_ERROR<br />

IAFP_ERROR<br />

public static final short IAFP_ERROR<br />

IO_AREA_LENGTH<br />

public static final short IO_AREA_LENGTH<br />

SSA_TOTAL_LENGTH<br />

public static final short SSA_TOTAL_LENGTH<br />

SYSTEM_ERROR<br />

public static final short SYSTEM_ERROR<br />

MULTIPLE_PHYSICAL_TERMINAL<br />

public static final short MULTIPLE_PHYSICAL_TERMINAL<br />

PURG_IGNORED<br />

public static final short PURG_IGNORED<br />

UNAVAILABLE_DATA<br />

public static final short UNAVAILABLE_DATA<br />

UNAVAILABLE_DATA_WITH_BACKOUT<br />

public static final short UNAVAILABLE_DATA_WITH_BACKOUT<br />

DEADLOCK_WITH_BACKOUT<br />

public static final short DEADLOCK_WITH_BACKOUT<br />

246 <strong>IMS</strong> <strong>Version</strong> 7 <strong>and</strong> <strong>Java</strong> <strong>Application</strong> <strong>Programming</strong>


ALL_DATABASES_UNAVAILABLE<br />

public static final short ALL_DATABASES_UNAVAILABLE<br />

DATABASE_IN_PCB_UNAVAILABLE<br />

public static final short DATABASE_IN_PCB_UNAVAILABLE<br />

INVALID_COMMAND<br />

public static final short INVALID_COMMAND<br />

AOI_COMMAND<br />

public static final short AOI_COMMAND<br />

COMMAND_RESPONSE_RETURNED<br />

public static final short COMMAND_RESPONSE_RETURNED<br />

COMMAND_SECURITY<br />

public static final short COMMAND_SECURITY<br />

MESSAGE_RESCHEDULED<br />

public static final short MESSAGE_RESCHEDULED<br />

MESSAGE_QUEUED_PRIOR_TO_LAST_START<br />

public static final short MESSAGE_QUEUED_PRIOR_TO_LAST_START<br />

MESSAGE_ORIGINATED_FROM_AOI_EXIT<br />

public static final short MESSAGE_ORIGINATED_FROM_AOI_EXIT<br />

AOI_COMMAND_IGNORED<br />

public static final short AOI_COMMAND_IGNORED<br />

MESSAGE_QUEUED_PRIOR_RESCHEDULED<br />

public static final short MESSAGE_QUEUED_PRIOR_RESCHEDULED<br />

MESSAGE_FROM_AOI_EXIT_RESCHEDULED<br />

public static final short MESSAGE_FROM_AOI_EXIT_RESCHEDULED<br />

MESSAGE_QUEUED_PRIOR_FROM_AOI_EXIT<br />

public static final short MESSAGE_QUEUED_PRIOR_FROM_AOI_EXIT<br />

AOI_EXIT_MESSAGE_QUEUED_PRIOR_RESCHEDULED<br />

public static final short AOI_EXIT_MESSAGE_QUEUED_PRIOR_RESCHEDULED<br />

Appendix A. <strong>IMS</strong> <strong>Java</strong> package 247


WKAP_INSUFFICIENT<br />

public static final short WKAP_INSUFFICIENT<br />

IOASIZE_TOO_SMALL<br />

public static final short IOASIZE_TOO_SMALL<br />

KEY_MODIFICATION<br />

public static final short KEY_MODIFICATION<br />

SEGMENT_NOT_HELD<br />

public static final short SEGMENT_NOT_HELD<br />

SEGMENT_DELETE_RULE<br />

public static final short SEGMENT_DELETE_RULE<br />

DATABASE_ARITHMETIC_OVERFLOW<br />

public static final short DATABASE_ARITHMETIC_OVERFLOW<br />

INVALID_REQUEST_FOR_SEGMENT<br />

public static final short INVALID_REQUEST_FOR_SEGMENT<br />

BMP_DEADLOCK<br />

public static final short BMP_DEADLOCK<br />

FLD_CALL<br />

public static final short FLD_CALL<br />

MSDB_FREE_SPACE<br />

public static final short MSDB_FREE_SPACE<br />

FLD_CALL_BUFFER_SPACE<br />

public static final short FLD_CALL_BUFFER_SPACE<br />

DEDB_AREA_INACCESSIBLE<br />

public static final short DEDB_AREA_INACCESSIBLE<br />

IO_AREA_INACCESSIBLE<br />

public static final short IO_AREA_INACCESSIBLE<br />

RANDOMIZING_ROUTINE_REQUEST<br />

public static final short RANDOMIZING_ROUTINE_REQUEST<br />

248 <strong>IMS</strong> <strong>Version</strong> 7 <strong>and</strong> <strong>Java</strong> <strong>Application</strong> <strong>Programming</strong>


FLD_FIELD_NAME<br />

public static final short FLD_FIELD_NAME<br />

INVALID_HEXADECIMAL_OR_DECIMAL_DATA<br />

public static final short INVALID_HEXADECIMAL_OR_DECIMAL_DATA<br />

TOTAL_BUFFER_ALLOCATION_EXCEEDED<br />

public static final short TOTAL_BUFFER_ALLOCATION_EXCEEDED<br />

DEDB_AREAS_FULL<br />

public static final short DEDB_AREAS_FULL<br />

SSA_LIMIT_EXCEEDED<br />

public static final short SSA_LIMIT_EXCEEDED<br />

VERIFY_OPERATION<br />

public static final short VERIFY_OPERATION<br />

BMP_BUFFER_SPACE<br />

public static final short BMP_BUFFER_SPACE<br />

BACKWARD_ACCESS_VIOLATION<br />

public static final short BACKWARD_ACCESS_VIOLATION<br />

HIERARCHIC_BOUNDARY<br />

public static final short HIERARCHIC_BOUNDARY<br />

END_OF_DATA<br />

public static final short END_OF_DATA<br />

CROSSING_UOW_BOUNDARY<br />

public static final short CROSSING_UOW_BOUNDARY<br />

UNQUALIFIED_INSERT<br />

public static final short UNQUALIFIED_INSERT<br />

SEGMENT_NOT_FOUND<br />

public static final short SEGMENT_NOT_FOUND<br />

INVALID_SEGMENT_POINTER<br />

public static final short INVALID_SEGMENT_POINTER<br />

Appendix A. <strong>IMS</strong> <strong>Java</strong> package 249


DIFFERENT_SEGMENT_TYPE<br />

public static final short DIFFERENT_SEGMENT_TYPE<br />

INVALID_LOG_CODE<br />

public static final short INVALID_LOG_CODE<br />

PARENTAGE_NOT_ESTABLISHED<br />

public static final short PARENTAGE_NOT_ESTABLISHED<br />

DUPLICATE_SEGMENT<br />

public static final short DUPLICATE_SEGMENT<br />

SEGMENT_INSERT_RULE<br />

public static final short SEGMENT_INSERT_RULE<br />

DUPLICATE_SEGMENT_LOAD<br />

public static final short DUPLICATE_SEGMENT_LOAD<br />

KEY_SEQUENCE<br />

public static final short KEY_SEQUENCE<br />

PARENT_NOT_LOADED<br />

public static final short PARENT_NOT_LOADED<br />

SIBLING_SEQUENCE<br />

public static final short SIBLING_SEQUENCE<br />

RESERVED<br />

public static final short RESERVED<br />

DATABASE_UNAVAILABLE<br />

public static final short DATABASE_UNAVAILABLE<br />

SEGMENT_NOT_FOUND_BY_INDEX_MAINTENACE<br />

public static final short SEGMENT_NOT_FOUND_BY_INDEX_MAINTENACE<br />

DUPLICATE_SEGMENT_SECONDARY_INDEX<br />

public static final short DUPLICATE_SEGMENT_SECONDARY_INDEX<br />

LOG_DATASET_DD_MISSING<br />

public static final short LOG_DATASET_DD_MISSING<br />

250 <strong>IMS</strong> <strong>Version</strong> 7 <strong>and</strong> <strong>Java</strong> <strong>Application</strong> <strong>Programming</strong>


INDEX_MAINTENANCE_IO_ERROR<br />

public static final short INDEX_MAINTENANCE_IO_ERROR<br />

DATABASE_UNAVAILABLE_FOR_UPDATE<br />

public static final short DATABASE_UNAVAILABLE_FOR_UPDATE<br />

END_OF_MESSAGES<br />

public static final short END_OF_MESSAGES<br />

END_OF_MESSAGE_SEGMENTS<br />

public static final short END_OF_MESSAGE_SEGMENTS<br />

CALL_SEQUENCE<br />

public static final short CALL_SEQUENCE<br />

SEGMENT_LENGTH<br />

public static final short SEGMENT_LENGTH<br />

TERMINAL_SYMBOLIC_ERROR<br />

public static final short TERMINAL_SYMBOLIC_ERROR<br />

UNMATCHED_TOKEN<br />

public static final short UNMATCHED_TOKEN<br />

ROLS_UNSUPPORTED_PCB<br />

public static final short ROLS_UNSUPPORTED_PCB<br />

SEGMENT_REPLACE_RULE<br />

public static final short SEGMENT_REPLACE_RULE<br />

SETS_REQUEST_STORAGE_EXCEEDED<br />

public static final short SETS_REQUEST_STORAGE_EXCEEDED<br />

SETS_LEVELS_EXCEEDED<br />

public static final short SETS_LEVELS_EXCEEDED<br />

SETS_UNSUPPORTED_PCB<br />

public static final short SETS_UNSUPPORTED_PCB<br />

SYNC_FAILURE<br />

public static final short SYNC_FAILURE<br />

Appendix A. <strong>IMS</strong> <strong>Java</strong> package 251


PSB_DIRECTORY<br />

public static final short PSB_DIRECTORY<br />

PSB_ALREADY_SCHEDULED<br />

public static final short PSB_ALREADY_SCHEDULED<br />

PSB_INITIALIZATION_ERROR<br />

public static final short PSB_INITIALIZATION_ERROR<br />

TERMINATE_UNSCHEDULED_PSB<br />

public static final short TERMINATE_UNSCHEDULED_PSB<br />

DATABASE_ACCESS_WITH_UNSCHEDULED_PSB<br />

public static final short DATABASE_ACCESS_WITH_UNSCHEDULED_PSB<br />

INVALID_PATH_TO_SEGMENT<br />

public static final short INVALID_PATH_TO_SEGMENT<br />

DLI_NOT_ACTIVE<br />

public static final short DLI_NOT_ACTIVE<br />

SCHEDULING_INTENT_CONFLICT<br />

public static final short SCHEDULING_INTENT_CONFLICT<br />

INVALID_SDIB<br />

public static final short INVALID_SDIB<br />

PATH_REPLACE_ERROR<br />

public static final short PATH_REPLACE_ERROR<br />

INVALID_PCB_NUMBER_OR_PROC_OPTIONS<br />

public static final short INVALID_PCB_NUMBER_OR_PROC_OPTIONS<br />

XDLIPRE<br />

public static final short XDLIPRE<br />

DATABASE_NOT_OPEN<br />

public static final short DATABASE_NOT_OPEN<br />

SEGMENT_EXCEEDS_64K<br />

public static final short SEGMENT_EXCEEDS_64K<br />

252 <strong>IMS</strong> <strong>Version</strong> 7 <strong>and</strong> <strong>Java</strong> <strong>Application</strong> <strong>Programming</strong>


CHECKPOINT_WRITTEN_TO_UCF<br />

public static final short CHECKPOINT_WRITTEN_TO_UCF<br />

PROGRAM_RESTARTED_UNDER_UCF<br />

public static final short PROGRAM_RESTARTED_UNDER_UCF<br />

UCF_STOP<br />

public static final short UCF_STOP<br />

CHECKPOINT_AND_STOP<br />

public static final short CHECKPOINT_AND_STOP<br />

VARIABLE_SEGMENT_LENGTH<br />

public static final short VARIABLE_SEGMENT_LENGTH<br />

INVALID_SEGMENT_LENGTH<br />

public static final short INVALID_SEGMENT_LENGTH<br />

INVALID_FIELD_LENGTH<br />

public static final short INVALID_FIELD_LENGTH<br />

INVALID_VARIABLE_SEGMENTLENGTH<br />

public static final short INVALID_VARIABLE_SEGMENTLENGTH<br />

INVALID_OFFSET<br />

public static final short INVALID_OFFSET<br />

INVALID_CONCATENATED_KEY_LENGTH<br />

public static final short INVALID_CONCATENATED_KEY_LENGTH<br />

INVALID_STATISTICS_AREA_LENGTH<br />

public static final short INVALID_STATISTICS_AREA_LENGTH<br />

FIRST_INSERT_TO_ALTERNATE_PCB_NOT_SPA<br />

public static final short FIRST_INSERT_TO_ALTERNATE_PCB_NOT_SPA<br />

INVALID_SPA<br />

public static final short INVALID_SPA<br />

INVALID_SPA_DESTINATION<br />

public static final short INVALID_SPA_DESTINATION<br />

Appendix A. <strong>IMS</strong> <strong>Java</strong> package 253


MULTIPLE_SPAS_PERMESSAGE<br />

public static final short MULTIPLE_SPAS_PERMESSAGE<br />

INVALID_SPA_TRANSACTION_CODE<br />

public static final short INVALID_SPA_TRANSACTION_CODE<br />

INVALID_SPA_LENGTH<br />

public static final short INVALID_SPA_LENGTH<br />

SPA_IO_ERROR<br />

public static final short SPA_IO_ERROR<br />

INVALID_SPA_PASS<br />

public static final short INVALID_SPA_PASS<br />

INVALID_SPA_RESPOND<br />

public static final short INVALID_SPA_RESPOND<br />

INVALID_Z1_FIELD<br />

public static final short INVALID_Z1_FIELD<br />

<strong>IMS</strong>_TERMINATING<br />

public static final short <strong>IMS</strong>_TERMINATING<br />

INSERT_SPA_TO_EXPRESS_PCB<br />

public static final short INSERT_SPA_TO_EXPRESS_PCB<br />

INSERT_TO_SPA_NOT_ALTRESP<br />

public static final short INSERT_TO_SPA_NOT_ALTRESP<br />

FIXED_LENGTH_SPA_ERROR<br />

public static final short FIXED_LENGTH_SPA_ERROR<br />

GSAM_ERROR<br />

public static final short GSAM_ERROR<br />

<strong>Java</strong>ToDLI ()<br />

public <strong>Java</strong>ToDLI()<br />

254 <strong>IMS</strong> <strong>Version</strong> 7 <strong>and</strong> <strong>Java</strong> <strong>Application</strong> <strong>Programming</strong>


Methods<br />

decimalToString (byte[], int, int)<br />

public static native String decimalToString(byte decimalData[ ],<br />

int offset,<br />

int length)<br />

execute (String)<br />

public static void execute(String function) throws <strong>IMS</strong>Exception<br />

Executes CEETDLI(String function) call. DLI ROLL <strong>and</strong> TERM calls.<br />

Parameters:<br />

function - DLI function.<br />

Throws: <strong>IMS</strong>Exception if <strong>IMS</strong> status code returned is non-blank.<br />

execute (String, AIB)<br />

public static void execute(String function,<br />

AIB aib) throws <strong>IMS</strong>Exception<br />

Executes CEETDLI(String function, AIB aib) call. DLI APSB, CLSE, OPEN, PURG,<br />

<strong>and</strong> SYNC calls.<br />

Parameters:<br />

function - DLI function.<br />

aib - <strong>IMS</strong> AIB.<br />

Throws: <strong>IMS</strong>Exception if <strong>IMS</strong> status code returned is non-blank.<br />

execute (String, AIB, byte[ ])<br />

public static void execute(String function,<br />

AIB aib,<br />

byte ioArea[ ]) throws <strong>IMS</strong>Exception<br />

Executes CEETDLI(String function, AIB aib, byte[] ioarea) calls. DLI AUTH,<br />

CHKP (basic), CMD, DEQ, FLD, GCMD, GMSG, GSCD, GU, GN, ICMD, INIT, INQY, LOG, OPEN,<br />

POS, PURG, ROLB, RCMD, <strong>and</strong> SNAP..<br />

Parameters:<br />

function - DLI function.<br />

aib - <strong>IMS</strong> AIB.<br />

ioArea - Area to pass data to <strong>and</strong> receive data from <strong>IMS</strong>.<br />

Throws: <strong>IMS</strong>Exception if <strong>IMS</strong> status code returned is non-blank.<br />

Appendix A. <strong>IMS</strong> <strong>Java</strong> package 255


execute (String, AIB, String)<br />

public static void execute(String function,<br />

AIB aib,<br />

String destinationName) throws <strong>IMS</strong>Exception<br />

Executes CEETDLI(String function, AIB aib, String destinationName) call.<br />

DLI CHNG.<br />

Parameters:<br />

function - DLI function.<br />

aib - <strong>IMS</strong> AIB.<br />

destinationName - Terminal name or transaction name.<br />

Throws: <strong>IMS</strong>Exception If <strong>IMS</strong> status code returned is non-blank.<br />

execute (String, AIB, String, byte[])<br />

public static void execute(String function,<br />

AIB aib,<br />

String destinationName,<br />

byte optionsList[]) throws <strong>IMS</strong>Exception<br />

Executes CEETDLI(String function, AIB aib, String destinationName,<br />

byte[] optionsList) calls.<br />

Parameters:<br />

function - DLI function.<br />

aib - <strong>IMS</strong> AIB.<br />

256 <strong>IMS</strong> <strong>Version</strong> 7 <strong>and</strong> <strong>Java</strong> <strong>Application</strong> <strong>Programming</strong><br />

destinationName - Terminal name or transaction name.<br />

optionsList - Processing options.<br />

Throws: <strong>IMS</strong>Exception if <strong>IMS</strong> status code returned is non-blank.<br />

execute (String, AIB, byte[ ], byte[ ], byte[ ])<br />

public static void execute(String function,<br />

AIB aib,<br />

byte ioArea[ ],<br />

byte optionsList[],<br />

byte feedbackArea[]) throws <strong>IMS</strong>Exception<br />

Executes CEETDLI(String function, AIB aib, byte[] ioArea, byte[]<br />

optionsList, byte[] feedbackArea) calls. DLI SETO call.<br />

Parameters:<br />

function - DLI function.<br />

aib - <strong>IMS</strong> AIB.


optionsList - Processing options.<br />

feedbackArea - Error information returned.<br />

Throws: <strong>IMS</strong>Exception if <strong>IMS</strong> status code returned is non-blank.<br />

execute (String, AIB, String, byte[ ],byte[ ])<br />

public static void execute(String function,<br />

AIB aib,<br />

String destinationName,<br />

byte optionsList[ ],<br />

byte feedbackArea[]) throws <strong>IMS</strong>Exception<br />

Executes CEETDLI(String function, AIB aib, String destinationName,<br />

byte[] optionsList, byte[] feedbackArea) calls. DLI CHNG call.<br />

Parameters:<br />

function - DLI function.<br />

aib - <strong>IMS</strong> AIB.<br />

destinationName - Terminal name or transaction name.<br />

optionsList - Processing options.<br />

feedbackArea - Error information returned.<br />

Throws: <strong>IMS</strong>Exception If <strong>IMS</strong> status code returned is non-blank.<br />

execute (String, AIB, byte[ ], byte [ ])<br />

public static void execute(String function,<br />

AIB aib,<br />

byte ioArea[ ],<br />

byte token[ ]) throws <strong>IMS</strong>Exception<br />

Executes CEETDLI(String function, AIB aib, byte[] ioarea, byte[] token)<br />

calls. DLI FLD, ROLS, SETS, SETU, <strong>and</strong> STAT calls.<br />

Parameters:<br />

function - DLI function.<br />

aib - <strong>IMS</strong> AIB.<br />

ioArea - Area to pass data to <strong>and</strong> receive data from <strong>IMS</strong>.<br />

token - Identifier.<br />

Throws: <strong>IMS</strong>Exception if <strong>IMS</strong> status code returned is non-blank.<br />

Appendix A. <strong>IMS</strong> <strong>Java</strong> package 257


execute (String, AIB, byte[ ], byte[ ][ ])<br />

public static void execute(String function,<br />

AIB aib,<br />

byte ioArea[ ],<br />

byte ssaL[ ][ ]) throws <strong>IMS</strong>Exception<br />

execute (String, AIB, byte[ ], String)<br />

public static void execute(String function,<br />

AIB aib,<br />

byte ioArea[ ],<br />

String modName) throws <strong>IMS</strong>Exception<br />

Executes CEETDLI(String function, AIB aib, byte[] ioArea, String<br />

modName) calls. DLI message ISRT call.<br />

Parameters:<br />

function - DLI function.<br />

aib - <strong>IMS</strong> AIB.<br />

258 <strong>IMS</strong> <strong>Version</strong> 7 <strong>and</strong> <strong>Java</strong> <strong>Application</strong> <strong>Programming</strong><br />

ioArea - Area to pass data to <strong>and</strong> receive data from <strong>IMS</strong>.<br />

modName - <strong>IMS</strong> Message Output Descriptor name.<br />

Throws: <strong>IMS</strong>Exception if <strong>IMS</strong> status code returned is non-blank.<br />

checkESAF ()<br />

public static native boolean checkESAF()<br />

doubleToByteArray (double)<br />

public static native byte[] doubleToByteArray(double d)<br />

byteArrayToDouble (byte[ )<br />

public static native double byteArrayToDouble(byte bArr[])<br />

A.19 Class com.ibm.ims.base.DLIJNICallbackException<br />

java.lang.Object<br />

+----java.lang.Throwable<br />

+----java.lang.Exception<br />

+----java.lang.RuntimeException<br />

+----com.ibm.ims.base.DLIJNICallbackException<br />

public class DLIJNICallbackException extends RuntimeException


Method<br />

This exception is thrown to indicate a JNI error has occured while issuing a<br />

DLI call. This is an internal error <strong>and</strong> should not be caught, but allowed to<br />

abend the <strong>IMS</strong><strong>Java</strong> application.<br />

DLIJNICallbackException ()<br />

public DLIJNICallbackException()<br />

A.20 Class com.ibm.ims.base.DLIWarning<br />

Constructor<br />

java.lang.Object<br />

+----java.lang.Throwable<br />

+----java.lang.Exception<br />

+----com.ibm.ims.base.DLIWarning<br />

public class DLIWarning extends Exception<br />

The DLIWarning class provides information when data was lost due to a type<br />

conversion. For example, a field in an input message or database segment is<br />

defined as a DLITypeInfo.DOUBLE <strong>and</strong> retrieved as a <strong>Java</strong> short. Warnings are<br />

silently chained to the object whose method caused it to be reported.<br />

getNextWarning ()<br />

public DLIWarning getNextWarning()<br />

Get the warning chained to this one.<br />

Returns: The next DLIWarning in the chain, null if none<br />

A.21 Class com.ibm.ims.base.<strong>IMS</strong>Exception<br />

java.lang.Object<br />

+----java.lang.Throwable<br />

+----java.lang.Exception<br />

+----com.ibm.ims.base.<strong>IMS</strong>Exception<br />

public class <strong>IMS</strong>Exception extends Exception<br />

This exception is thrown to indicate a DLI error has ocurred. These include all<br />

errors which result in a non-blank <strong>IMS</strong> status code <strong>and</strong> DLI calls resulting in a<br />

Appendix A. <strong>IMS</strong> <strong>Java</strong> package 259


Constructor<br />

Methods<br />

non-zero return code for which there s no PCB (<strong>and</strong> therefore no status<br />

code).<br />

<strong>IMS</strong>Exception (String, AIB, short, String)<br />

public <strong>IMS</strong>Exception(String function,<br />

AIB aib,<br />

short statCode,<br />

String exceptionType)<br />

Constructor for DLI exceptions.<br />

Parameters:<br />

function - The DLI function.<br />

aib - AIB<br />

statCode - The status code<br />

260 <strong>IMS</strong> <strong>Version</strong> 7 <strong>and</strong> <strong>Java</strong> <strong>Application</strong> <strong>Programming</strong><br />

exceptionType - The exception description message.<br />

<strong>IMS</strong>Exception (String)<br />

public <strong>IMS</strong>Exception(String message)<br />

Constructor for exceptions with a message.<br />

Parameters:<br />

message - The message.<br />

<strong>IMS</strong>Exception ()<br />

public <strong>IMS</strong>Exception()<br />

Constructor for exceptions.<br />

getAIB ()<br />

public AIB getAIB()<br />

Returns the <strong>IMS</strong> AIB from DLI call which caused this exception.<br />

Returns: AIB.<br />

getFunction ()<br />

public String getFunction()<br />

Returns the <strong>IMS</strong> function from DLI call which caused this exception.<br />

Returns: Function.


getStatusCode ()<br />

public short getStatusCode()<br />

Returns the <strong>IMS</strong> status code from DLI call which caused this exception.<br />

Returns: Status code.<br />

A.22 Contents of com.ibm.ims.db package<br />

The com.ibm.ims.db package contains the following Interface Class:<br />

com.ibm.ims.db.DLIParserConstants<br />

The com.ibm.ims.db package contains the following classes:<br />

com.ibm.ims.db.ASCII_UCodeESC_CharStream<br />

com.ibm.ims.db.DLIConnection<br />

com.ibm.ims.db.DLIConnectionTrace<br />

com.ibm.ims.db.DLIDatabaseView<br />

com.ibm.ims.db.DLIDriver<br />

com.ibm.ims.db.DLIParserTokenManager<br />

com.ibm.ims.db.DLIRecord<br />

com.ibm.ims.db.DLISegment<br />

com.ibm.ims.db.DLISegmentInfo<br />

com.ibm.ims.db.DLIStatement<br />

com.ibm.ims.db.DLIStatementTrace<br />

com.ibm.ims.db.<strong>IMS</strong>ErrorMessages<br />

com.ibm.ims.db.SSA<br />

com.ibm.ims.db.SSAList<br />

com.ibm.ims.db.SSAQualificationStatement<br />

com.ibm.ims.db.SSAQualificationStatementTrace<br />

com.ibm.ims.db.Token<br />

The com.ibm.ims.db package contains the following exception classes:<br />

com.ibm.ims.db.DLIException<br />

com.ibm.ims.db.DLISQLException<br />

com.ibm.ims.db.ParseException<br />

The com.ibm.ims.db package contains the following Error h<strong>and</strong>ling classes:<br />

com.ibm.ims.db.TokenMgrError<br />

Appendix A. <strong>IMS</strong> <strong>Java</strong> package 261


A.23 Class com.ibm.ims.db.DLIConnection<br />

Constructors<br />

Methods<br />

java.lang.Object<br />

+----com.ibm.ims.db.DLIConnection<br />

public class DLIConnection extends Object<br />

A DLIConnection object represents a connection with a DL/I database. It<br />

provides the interface to create DLIStatement objects as well as the interface<br />

to read, write, update, <strong>and</strong> delete segments in a DL/I database.<br />

DLIConnection (DLIDatabaseView)<br />

protected DLIConnection (DLIDatabaseView dbView)<br />

DLIConnection (String url)<br />

protected DLIConnection (String url)<br />

createInstance (DLIDatabaseView)<br />

public static DLIConnection createInstance(DLIDatabaseView dbView)<br />

Creates a connection with a DL/I database.<br />

Parameters:<br />

dbView - A DLIDatabaseView object.<br />

See Also: DLIDatabaseView.<br />

createInstance (String)<br />

public static DLIConnection createInstance(String url)<br />

Creates a connection with a DL/I database. For example, the following<br />

code fragment creates a database connection<br />

262 <strong>IMS</strong> <strong>Version</strong> 7 <strong>and</strong> <strong>Java</strong> <strong>Application</strong> <strong>Programming</strong><br />

DLIConnection connection =<br />

DLIConnection.createInstance(“samples.ivp.IVPDatabaseView”);<br />

Parameters:<br />

url - The fully qualified path to a DLIDatabaseView class name.<br />

See Also: DLIDatabaseView.


deleteSegments ()<br />

public void deleteSegments() throws <strong>IMS</strong>Exception<br />

Removes a segment <strong>and</strong> its dependents from the database. This call must<br />

be preceded by either getNextSegment, getNextSegmentInParent, or<br />

getUniqueSegment, as each of these calls get a ‘hold’ on a segment so<br />

that it may be modified in some way.<br />

Throws: <strong>IMS</strong>Exception if an error occurs trying to delete the segment.<br />

getAIB ()<br />

public final AIB getAIB()<br />

Returns the <strong>Application</strong> Interface Block (AIB) used by the connection.<br />

Returns: The <strong>Application</strong> Interface Block (AIB).<br />

getNextRecord (DLIRecord, SSAList)<br />

public boolean getNextRecord(DLIRecord record,<br />

SSAList ssaList) throws <strong>IMS</strong>Exception<br />

Retrieves segments in a path call sequentially from the database. This call<br />

is usually preceded by a getUniqueRecord call, which establishes a starting<br />

position for sequential processing. If not, this call will position at the root of<br />

the entire database.<br />

Parameters:<br />

segment - The DLIRecord that will be populated with the segments<br />

specified by the SSAList parameter.<br />

ssaList - The SSA list specifying the desired DL/I segments in the<br />

path.<br />

Returns: True if there was a record in the database matching the<br />

ssaList, false otherwise.<br />

Throws: <strong>IMS</strong>Exception if an error occurs trying to retrieve the record.<br />

getNextSegment (DLISegment, SSAList)<br />

public boolean getNextSegment(DLISegment segment,<br />

SSAList ssaList) throws <strong>IMS</strong>Exception<br />

Retrieves a segment sequentially from the database. This call is usually<br />

preceded by a getUniqueSegment call, which establishes a starting position<br />

for sequential processing. If not, this call will position at the root of the<br />

entire database.<br />

Parameters:<br />

Appendix A. <strong>IMS</strong> <strong>Java</strong> package 263


264 <strong>IMS</strong> <strong>Version</strong> 7 <strong>and</strong> <strong>Java</strong> <strong>Application</strong> <strong>Programming</strong><br />

segment - The DL/I segment that will be populated with the segment<br />

specified by the SSAList parameter.<br />

ssaList - The SSA list specifying the desired DL/I segment.<br />

Returns: True if was a segment in the database matching the ssaList,<br />

false otherwise.<br />

Throws: <strong>IMS</strong>Exception if an error occurs trying to retrieve the segment.<br />

getNextSegment (SSAList)<br />

public DLISegment getNextSegment(SSAList ssaList) throws <strong>IMS</strong>Exception<br />

Retrieves a segment sequentially from the database. This call is usually<br />

preceded by a getUniqueSegment call, which establishes a starting position<br />

for sequential processing. If not, this call will position at the root of the<br />

entire database. To perform an unqualified call, pass in null for the ssaList<br />

parameter.<br />

Parameters:<br />

ssaList - The SSA list specifying the desired DL/I segment, or null if<br />

performing an unqualified call.<br />

Returns: The DLISegment satisfying the SSAList.<br />

Throws:<br />

<strong>IMS</strong>Exception if an error occurs trying to retrieve the segment.<br />

DLIException if a segment is returned from the call that is not in the<br />

DLIDatabaseView of the application.<br />

getNextSegmentInParent (DLISegment, SSAList)<br />

public boolean getNextSegmentInParent(DLISegment segment,<br />

SSAList ssaList) throws <strong>IMS</strong>Exception<br />

Retrieves a dependent segment sequentially from the database. This call<br />

is usually preceded by a getUniqueSegment call, which establishes a starting<br />

position for sequential processing. If not, this call will position at the root of<br />

the entire database.<br />

Parameters:<br />

segment - The DL/I segment that will be populated with the segment<br />

specified by the SSAList parameter.<br />

ssaList - The SSA list specifying the desired DL/I segment.<br />

Returns: True if was a segment in the database matching the ssaList,<br />

false otherwise.<br />

Throws: <strong>IMS</strong>Exception if an error occurs trying to retrieve the segment.


getNextSegmentInParent (SSAList)<br />

public DLISegment getNextSegmentInParent(SSAList ssaList) throws<br />

<strong>IMS</strong>Exception<br />

Retrieves a dependent segment sequentially from the database. This call<br />

is usually preceded by a getUniqueSegment call, which establishes a starting<br />

position for sequential processing. If not, this call will position at the root of<br />

the entire database. To perform an unqualified call, pass in null for the<br />

ssaList parameter.<br />

Parameters:<br />

ssaList - The SSA list specifying the desired DL/I segment, or null if<br />

performing an unqualified call.<br />

Returns: True if was a segment in the database matching the ssaList,<br />

false otherwise.<br />

Throws:<br />

<strong>IMS</strong>Exception if an error occurs trying to retrieve the segment.<br />

DLIException if a segment is returned from the call that is not in the<br />

DLIDatabaseView of the application.<br />

getUniqueRecord (DLIRecord, SSAList)<br />

public boolean getUniqueRecord(DLIRecord record,<br />

SSAList ssaList) throws <strong>IMS</strong>Exception<br />

Directly retrieves the segments in a path from the database <strong>and</strong><br />

establishes a starting position in the database for sequential processing.<br />

Parameters:<br />

record - The DLIRecord that will be populated with the segments<br />

specified by the SSAList parameter.<br />

ssaList - The SSA list specifying the desired DL/I leaf segment. The<br />

SSAs in the SSAList should have the PATH_CALL comm<strong>and</strong> code<br />

set on each segment to be retrieved. The P processing option must<br />

be specified in the PCB to use this function.<br />

Returns: True if there was a record in the database matching the<br />

ssaList, false otherwise.<br />

Throws: <strong>IMS</strong>Exception if an error occurs trying to retrieve the record.<br />

getUniqueSegment (DLISegment, SSAList)<br />

public boolean getUniqueSegment(DLISegment segment,<br />

SSAList ssaList) throws <strong>IMS</strong>Exception<br />

Appendix A. <strong>IMS</strong> <strong>Java</strong> package 265


Directly retrieves a segment from the database <strong>and</strong> establishes a starting<br />

position in the database for sequential processing.<br />

Parameters:<br />

266 <strong>IMS</strong> <strong>Version</strong> 7 <strong>and</strong> <strong>Java</strong> <strong>Application</strong> <strong>Programming</strong><br />

segment - The DL/I segment that will be populated with the segment<br />

specified by the SSAList parameter.<br />

ssaList - The SSA list specifying the desired DL/I segment.<br />

Returns: True if there was a segment in the database matching the<br />

ssaList, false otherwise.<br />

Throws: <strong>IMS</strong>Exception if an error occurs trying to retrieve the segment.<br />

getUniqueSegment (SSAList)<br />

public DLISegment getUniqueSegment(SSAList ssaList) throws <strong>IMS</strong>Exception<br />

Directly retrieves a segment from the database <strong>and</strong> establishes a starting<br />

position in the database for sequential processing. To perform an<br />

unqualified call, pass in null for the ssaList parameter.<br />

Parameters:<br />

ssaList - The SSA list specifying the desired DL/I segment, or null if<br />

performing an unqualified call.<br />

Returns: true if there was a segment in the database matching the<br />

ssaList, false otherwise.<br />

Throws:<br />

<strong>IMS</strong>Exception if an error occurs trying to retrieve the segment.<br />

DLIException if a segment is returned from the call that is not in the<br />

DLIDatabaseView of the application.<br />

insertSegment (DLISegment, SSAList)<br />

public void insertSegment(DLISegment segment,<br />

SSAList ssaList) throws <strong>IMS</strong>Exception<br />

Inserts a segment into the database. The SSAList parameter specifies<br />

where this segment will be inserted.<br />

Parameters:<br />

segment - The segment to be inserted into the database.<br />

ssaList - The SSA list specifying where the segment will be added.<br />

Throws: <strong>IMS</strong>Exception if an error occurs trying to insert the segment.


eplaceSegment (DLISegment)<br />

public void replaceSegment(DLISegment segment) throws <strong>IMS</strong>Exception<br />

Replaces a segment in the database. This call must be preceded by either<br />

getNextSegment, getNextSegmentInParent, or getUniqueSegment, as each of<br />

these calls get a ‘hold’ on a segment so that it may be modified in some<br />

way.<br />

Parameters:<br />

segment - The segment that will replace the existing segment in the<br />

database that was returned with one of the three hold calls.<br />

Throws: <strong>IMS</strong>Exception if an error occurs trying to replace the segment.<br />

A.24 Class com.ibm.ims.db.DLIDatabaseView<br />

java.lang.Object<br />

+----com.ibm.ims.db.DLIDatabaseView<br />

public abstract class DLIDatabaseView extends Object<br />

DLIDatabaseView is a container for segment information in a DL/I database.<br />

During static initialization of a DLIDatabaseView subclass, the subclass should<br />

create an array of DLISegmentInfo objects. The subclass constructor then<br />

provides both the array <strong>and</strong> the name of the view to the DLIDatabaseView<br />

constructor. DLISegmentInfo contains a DLISegment instance <strong>and</strong> the 0-based<br />

offset of the parent instance within the array. DLIDatabaseView stores the array<br />

of DLISegmentInfo objects <strong>and</strong> also creates a Hashtable for fast lookup by<br />

segment class name. Figure 119 shows code typical of a DLIDatabaseView<br />

subclass.<br />

Appendix A. <strong>IMS</strong> <strong>Java</strong> package 267


Variables<br />

Methods<br />

class MyDatabaseView extends DLIDatabaseView {<br />

static DLISegmentInfo[] segments = {<br />

new DLISegmentInfo(new RootSegment(), DLIDatabaseView.ROOT),<br />

new DLISegmentInfo(new Seg1(), 0),<br />

new DLISegmentInfo(new Seg2(), 0),<br />

new DLISegmentInfo(new Seg11(), 1),<br />

new DLISegmentInfo(new Seg21(), 2),<br />

new DLISegmentInfo(new Seg211(), 4)<br />

};<br />

public MyDatabaseView ( ) {<br />

super (“DBPCBName”, segments);<br />

}<br />

}<br />

Figure 119. Example: A typical DLIDatabaseView subclass<br />

ROOT<br />

public static final int ROOT<br />

Used to identify that the root segment in a DLIDatabaseView has no parent.<br />

DLIDatabaseView (String, DLISegmentInfo)<br />

protected DLIDatabaseView(String dbPCBName,<br />

DLISegmentInfo segments[])<br />

Constructs a DLIDatabaseView object from the view name <strong>and</strong> an array of<br />

DLISegmentInfo objects that define the segments contained in the view.<br />

Parameters:<br />

dbPCBName - The name of the database PCB.<br />

segments - The array of segments contained in the view identifying<br />

the segment hierarchy.<br />

Throws: SQLException if a database access error occurs.<br />

A.25 Class com.ibm.ims.db.DLIRecord<br />

java.lang.Object<br />

+----com.ibm.ims.db.DLIRecord<br />

public class DLIRecord extends Object<br />

268 <strong>IMS</strong> <strong>Version</strong> 7 <strong>and</strong> <strong>Java</strong> <strong>Application</strong> <strong>Programming</strong>


Constructor<br />

Method<br />

An object that represents a path of segments Note: This is package level for<br />

now.<br />

DLIRecord (int, int)<br />

public DLIRecord(int segmentCount,int ioAreaLength)<br />

addSegment (DLISegment)<br />

public void addSegment(DLISegment segment)<br />

A.26 Class com.ibm.ims.db.DLISegment<br />

java.lang.Object<br />

+----com.ibm.ims.base.DLIBaseSegment<br />

+----com.ibm.ims.db.DLISegment<br />

public abstract class DLISegment extends DLIBaseSegment<br />

DLISegment is the abstract base class for objects representing segments in a<br />

DL/I database. These DLISegment subclasses provide the mapping between<br />

the data in the segment <strong>and</strong> access functions on the class. To provide the<br />

mapping, the subclasses must register their DLITypeInfo with this class by<br />

providing it as the argument to the constructor. By doing so, the DLISegment<br />

class knows the layout of each segment in the database <strong>and</strong> can access as<br />

well as update each of the fields within a segment. Note that when creating<br />

the DLITypeInfo objects to register with a DLISegment the offsets are 1-based.<br />

In the example below, the first paramter is an alias for the key <strong>and</strong> search<br />

fields. This alias would then be used throughout the application when<br />

referring to the key or search field. The key <strong>and</strong> search fields are given as the<br />

last paramter <strong>and</strong> must be defined exactly as they are defined in the DBD<br />

source file. The reason for this is that in the DBD source the field names are<br />

limited to 8 characters, whereas the alias has no such limitations. Figure 120<br />

shows code typical of a DLISegment subclass:<br />

Appendix A. <strong>IMS</strong> <strong>Java</strong> package 269


Constructor<br />

Methods<br />

class MySegment extends DLISegment {<br />

static DLITypeInfo[] typeInfo = {<br />

new DLITypeInfo(“FieldAlias1”,DLITypeInfo.CHAR, 1, 6, “Field1”),<br />

new DLITypeInfo(“FieldAlias2”,DLITypeInfo.INTEGER, 7, 4, “Field2”),<br />

new DLITypeInfo(“FieldAlias3”,DLITypeInfo.BIGINT, 11, 8, “Field3”),<br />

};<br />

public MySegment() {<br />

super (“SegmentName”, typeInfo, 18);<br />

}<br />

}<br />

Figure 120. Example: A typical DLISegment subclass<br />

See Also: DLITypeInfo.<br />

DLISegment (String, DLITypeInfo[ ], int)<br />

protected DLISegment(String segmentName,DLITypeInfo typeInfo[],int length)<br />

Constructs a DL/I Segment object. By providing an array of DLITypeInfo<br />

objects as an argument, this class knows the layout of the segment <strong>and</strong><br />

can access as well as update each field within the segment.<br />

Parameters:<br />

270 <strong>IMS</strong> <strong>Version</strong> 7 <strong>and</strong> <strong>Java</strong> <strong>Application</strong> <strong>Programming</strong><br />

segmentName - The name of the segment in the database.<br />

typeInfo - An array of DLITypeInfo objects, which tells this class the<br />

layout of the segment.<br />

length - The length of the I/O area of the segment.<br />

clearWarnings ()<br />

public void clearWarnings()<br />

Clears the warning chain for this DLISegment. After this call getWarnings<br />

returns null until a new warning is reported for this DLISegment.<br />

Overrides: clearWarnings in class DLIBaseSegment.<br />

getWarnings ()<br />

public DLIWarning getWarnings()<br />

The first warning reported by calls on this DLISegment is returned.<br />

Subsequent warnings will be chained to this DLIWarning. The warning chain


is automatically cleared each time a new segment is read from the<br />

database.<br />

Returns: The first DLIWarning or null.<br />

Overrides: getWarnings in class DLIBaseSegment.<br />

A.27 Class com.ibm.ims.db.DLISegmentInfo<br />

Constructor<br />

Note:<br />

This warning chain only covers warnings caused by DLISegment<br />

methods.<br />

java.lang.Object<br />

+----com.ibm.ims.db.DLISegmentInfo<br />

public final class DLISegmentInfo extends Object<br />

A DLISegmentInfo object is wrapper class used to associate a DLISegment<br />

object with its hierarchical parent for use within a DLIDatabaseView object.<br />

Subclasses of DLIDatabaseView statically create an array of DLISegmentInfo<br />

objects <strong>and</strong> pass the array to the DLIDatabaseView constructor.<br />

DLISegmentInfo (DLISegment, int)<br />

public DLISegmentInfo(DLISegment segment,int parentIndex)<br />

Constructs a DLISegmentInfo object from an instance of a DLISegment <strong>and</strong><br />

the index of the hierarchical parent in an array of DLISegmentInfo objects.<br />

Parameters:<br />

segment - A DLISegment object.<br />

parentIndex - The index of the parent’s DLISegmentInfo object in an<br />

array of DLISegmentInfo objects.<br />

A.28 Class com.ibm.ims.db.DLIStatement<br />

java.lang.Object<br />

+----com.ibm.ims.db.DLIStatement<br />

Appendix A. <strong>IMS</strong> <strong>Java</strong> package 271


Methods<br />

public class DLIStatement extends Object implements Statement<br />

The object used for executing a static SQL statement <strong>and</strong> obtaining the<br />

results produced by it. Only one ResultSet per Statement can be open at any<br />

point in time. Therefore, if the reading of one ResultSet is interleaved with the<br />

reading of another, each must have been generated by different Statements.<br />

All statement execute methods implicitly close a statment's current ResultSet<br />

if an open one exists.<br />

See Also: createStatement, ResultSet.<br />

executeQuery (String)<br />

public ResultSet executeQuery(String sql) throws SQLException<br />

Executes a SQL statement that returns a single ResultSet.<br />

Parameters:<br />

sql - Typically this is a static SQL SELECT statement.<br />

Returns: A ResultSet that contains the data produced by the query;<br />

never null.<br />

Throws: SQLException if a database access error occurs.<br />

executeQuery (DLIParser)<br />

protected ResultSet executeQuery(DLIParser parser) throws SQLException<br />

executeUpdate (String)<br />

public int executeUpdate(String sql) throws SQLException<br />

Executes an SQL INSERT, UPDATE or DELETE statement. In addition, SQL<br />

statements that return nothing, such as SQL DDL statements, can be<br />

executed.<br />

Parameters:<br />

sql - A SQL INSERT, UPDATE or DELETE statement or a SQL statement<br />

that returns nothing.<br />

Returns: Either the row count for INSERT, UPDATE or DELETE or 0 for SQL<br />

statements that return nothing.<br />

Throws: SQLException if a database access error occurs.<br />

272 <strong>IMS</strong> <strong>Version</strong> 7 <strong>and</strong> <strong>Java</strong> <strong>Application</strong> <strong>Programming</strong>


executeUpdate (DLIParser)<br />

protected int executeUpdate(DLIParser parser) throws SQLException<br />

close ()<br />

public void close() throws SQLException<br />

Releases this Statement object's database <strong>and</strong> JDBC resources<br />

immediately instead of waiting for this to happen when it is automatically<br />

closed. It is generally good practice to release resources as soon as you<br />

are finished with them to avoid tying up database resources.<br />

Note<br />

Note: A Statement is automatically closed when it is garbage collected.<br />

When a Statement is closed, its current ResultSet, if one exists, is also<br />

closed.<br />

Throws: SQLException if a database access error occurs.<br />

getMaxFieldSize ()<br />

public int getMaxFieldSize() throws SQLException<br />

Returns the maximum number of bytes allowed for any column value. This<br />

limit is the maximum number of bytes that can be returned for any column<br />

value. The limit applies only to BINARY, VARBINARY, LONGVARBINARY, CHAR,<br />

VARCHAR, <strong>and</strong> LONGVARCHAR columns. If the limit is exceeded, the excess data<br />

is silently discarded.<br />

Returns: The current max column size limit; zero means unlimited.<br />

Throws: SQLException if a database access error occurs.<br />

setMaxFieldSize (int)<br />

public void setMaxFieldSize(int max) throws SQLException<br />

Sets the limit for the maximum number of bytes in a column to the given<br />

number of bytes. This is the maximum number of bytes that can be<br />

returned for any column value. This limit applies only to BINARY, VARBINARY,<br />

LONGVARBINARY, CHAR, VARCHAR, <strong>and</strong> LONGVARCHAR fields. If the limit is exceeded,<br />

the excess data is silently discarded. For maximum portability, use values<br />

greater than 256.<br />

Parameters:<br />

max - The new max column size limit; zero means unlimited.<br />

Throws: SQLException if a database access error occurs.<br />

Appendix A. <strong>IMS</strong> <strong>Java</strong> package 273


getMaxRows ()<br />

public int getMaxRows() throws SQLException<br />

Retrieves the maximum number of rows that a ResultSet can contain. If the<br />

limit is exceeded, the excess rows are silently dropped.<br />

Returns: The current max row limit; zero means unlimited.<br />

Throws: SQLException if a database access error occurs.<br />

setMaxRows (int)<br />

public void setMaxRows(int max) throws SQLException<br />

Sets the limit for the maximum number of rows that any ResultSet can<br />

contain to the given number. If the limit is exceeded, the excess rows are<br />

silently dropped.<br />

Parameters:<br />

max - The new max rows limit; zero means unlimited.<br />

Throws: SQLException if a database access error occurs.<br />

setEscapeProcessing (boolean)<br />

public void setEscapeProcessing(boolean enable) throws SQLException<br />

Sets escape processing on or off. If escape scanning is on (the default),<br />

the driver will do escape substitution before sending the SQL to the<br />

database.<br />

Note<br />

Since prepared statements have usually been parsed prior to making<br />

this call, disabling escape processing for prepared statements will have<br />

no effect.<br />

Parameters:<br />

enable - True to enable; false to disable.<br />

Throws: SQLException if a database access error occurs.<br />

getQueryTimeout ()<br />

public int getQueryTimeout() throws SQLException<br />

Retrieves the number of seconds the driver will wait for a Statement to<br />

execute. If the limit is exceeded, a SQLException is thrown.<br />

Returns: The current query timeout limit in seconds; zero means<br />

unlimited.<br />

274 <strong>IMS</strong> <strong>Version</strong> 7 <strong>and</strong> <strong>Java</strong> <strong>Application</strong> <strong>Programming</strong>


Throws: SQLException if a database access error occurs.<br />

setQueryTimeout (int)<br />

public void setQueryTimeout(int seconds) throws SQLException<br />

Sets the number of seconds the driver will wait for a Statement to execute<br />

to the given number of seconds. If the limit is exceeded, a SQLException<br />

is thrown.<br />

Parameters:<br />

seconds - The new query timeout limit in seconds; zero means<br />

unlimited.<br />

Throws: SQLException if a database access error occurs.<br />

cancel ()<br />

public void cancel() throws SQLException<br />

Cancels this Statement object if both the DBMS <strong>and</strong> driver support aborting<br />

an SQL statement. This method can be used by one thread to cancel a<br />

statement that is being executed by another thread.<br />

Throws: SQLException if a database access error occurs.<br />

getWarnings ()<br />

public SQLWarning getWarnings() throws SQLException<br />

Retrieves the first warning reported by calls on this Statement.<br />

Subsequent Statement warnings will be chained to this SQLWarning. The<br />

warning chain is automatically cleared each time a statement is<br />

(re)executed.<br />

Note:<br />

If you are processing a ResultSet, any warnings associated with<br />

ResultSet reads will be chained on the ResultSet object.<br />

Returns: the first SQLWarning or null.<br />

Throws: SQLException if a database access error occurs.<br />

clearWarnings ()<br />

public void clearWarnings() throws SQLException<br />

Clears all the warnings reported on this Statement object. After a call to<br />

this method, the method getWarnings will return null until a new warning is<br />

reported for this Statement.<br />

Appendix A. <strong>IMS</strong> <strong>Java</strong> package 275


Throws: SQLException if a database access error occurs.<br />

setCursorName (String)<br />

public void setCursorName(String name) throws SQLException<br />

Defines the SQL cursor name that will be used by subsequent Statement<br />

execute methods. This name can then be used in SQL positioned<br />

update/delete statements to identify the current row in the ResultSet<br />

generated by this statement. If the database doesn't support positioned<br />

update/delete, this method is a noop. To insure that a cursor has the<br />

proper isolation level to support updates, the cursor's SELECT statement<br />

should be of the form 'select for update ...'. If the 'for update' phrase is<br />

omitted, positioned updates may fail.<br />

Note<br />

By definition, positioned update/delete execution must be done by a<br />

different Statement than the one which generated the ResultSet being<br />

used for positioning. Also, cursor names must be unique within a<br />

connection.<br />

Parameters:<br />

name - The new cursor name, which must be unique within a<br />

connection.<br />

Throws: SQLException if a database access error occurs.<br />

execute (String)<br />

public boolean execute(String sql) throws SQLException<br />

Executes a SQL statement that may return multiple results. Under some<br />

(uncommon) situations a single SQL statement may return multiple result<br />

sets <strong>and</strong>/or update counts. Normally you can ignore this unless you are (1)<br />

executing a stored procedure that you know may return multiple results or<br />

(2) you are dynamically executing an unknown SQL string. The methods<br />

execute, getMoreResults, getResultSet, <strong>and</strong> getUpdateCount let you navigate<br />

through multiple results. The execute method executes a SQL statement<br />

<strong>and</strong> indicates the form of the first result. You can then use getResultSet or<br />

getUpdateCount to retrieve the result, <strong>and</strong> getMoreResults to move to any<br />

subsequent result(s).<br />

Parameters:<br />

sql - Any SQL statement.<br />

276 <strong>IMS</strong> <strong>Version</strong> 7 <strong>and</strong> <strong>Java</strong> <strong>Application</strong> <strong>Programming</strong>


Returns: true if the next result is a ResultSet; false if it is an update<br />

count or there are no more results.<br />

Throws: SQLException if a database access error occurs.<br />

See Also: getResultSet, getUpdateCount, getMoreResults.<br />

execute (DLIParser)<br />

protected boolean execute(DLIParser parser) throws SQLException<br />

getResultSet ()<br />

public ResultSet getResultSet() throws SQLException<br />

Returns the current result as a ResultSet object. This method should be<br />

called only once per result.<br />

Returns: The current result as a ResultSet; null if the result is an<br />

update count or there are no more results.<br />

Throws: SQLException if a database access error occurs.<br />

See Also: execute.<br />

getUpdateCount ()<br />

public int getUpdateCount() throws SQLException<br />

Returns the current result as an update count; if the result is a ResultSet<br />

or there are no more results, -1 is returned. This method should be called<br />

only once per result.<br />

Returns: the current result as an update count; -1 if it is a ResultSet or<br />

there are no more results.<br />

Throws: SQLException if a database access error occurs.<br />

See Also: execute.<br />

getMoreResults ()<br />

public boolean getMoreResults() throws SQLException<br />

Moves to a Statement's next result. It returns true if this result is a<br />

ResultSet. This method also implicitly closes any current ResultSet<br />

obtained with getResultSet. There are no more results when<br />

(!getMoreResults() && (getUpdateCount() == -1).<br />

Returns: True if the next result is a ResultSet; false if it is an update<br />

count or there are no more results.<br />

Throws: SQLException if a database access error occurs.<br />

See Also: execute.<br />

Appendix A. <strong>IMS</strong> <strong>Java</strong> package 277


setFetchDirection (int)<br />

public void setFetchDirection(int direction) throws SQLException<br />

JDBC 2.0 Gives the driver a hint as to the direction in which the rows in a<br />

result set will be processed. The hint applies only to result sets created<br />

using this Statement object. The default value is ResultSet.FETCH_FORWARD.<br />

Note that this method sets the default fetch direction for result sets<br />

generated by this Statement object. Each result set has its own methods<br />

for getting <strong>and</strong> setting its own fetch direction.<br />

Parameters:<br />

direction - The initial direction for processing rows.<br />

Throws: SQLException if a database access error occurs or the given<br />

direction is not one of ResultSet.FETCH_FORWARD,<br />

ResultSet.FETCH_REVERSE, or ResultSet.FETCH_UNKNOWN.<br />

getFetchDirection ()<br />

public int getFetchDirection() throws SQLException<br />

JDBC 2.0 Retrieves the direction for fetching rows from database tables<br />

that is the default for result sets generated from this Statement object. If<br />

this Statement object has not set a fetch direction by calling the method<br />

setFetchDirection, the return value is implementation-specific.<br />

Returns: the default fetch direction for result sets generated from this<br />

Statement object.<br />

Throws: SQLException if a database access error occurs.<br />

setFetchSize (int)<br />

public void setFetchSize(int rows) throws SQLException<br />

JDBC 2.0 Gives the JDBC driver a hint as to the number of rows that<br />

should be fetched from the database when more rows are needed. The<br />

number of rows specified affects only result sets created using this<br />

statement. If the value specified is zero, then the hint is ignored. The<br />

default value is zero.<br />

Parameters:<br />

rows - The number of rows to fetch.<br />

Throws: SQLException if a database access error occurs, or the<br />

condition 0


JDBC 2.0 Retrieves the number of result set rows that is the default fetch<br />

size for result sets generated from this Statement object. If this Statement<br />

object has not set a fetch size by calling the method setFetchSize, the<br />

return value is implementation-specific.<br />

Returns: The default fetch size for result sets generated from this<br />

Statement object.<br />

Throws: SQLException if a database access error occurs.<br />

A.29 Class com.ibm.ims.db.<strong>IMS</strong>ErrorMessages<br />

Constructor<br />

Methods<br />

java.lang.Object<br />

+----java.util.ResourceBundle<br />

+----java.util.ListResourceBundle<br />

+----com.ibm.ims.db.<strong>IMS</strong>ErrorMessages<br />

public class <strong>IMS</strong>ErrorMessages extends ListResourceBundle<br />

<strong>IMS</strong>ErrorMessages ()<br />

public <strong>IMS</strong>ErrorMessages()<br />

Creates a resource bundle for giving error messages.<br />

getContents ()<br />

protected Object[ ][ ] getContents()<br />

getContents method comment.<br />

Overrides: getContents in class ListResourceBundle.<br />

get<strong>IMS</strong>Bundle ()<br />

public static <strong>IMS</strong>ErrorMessages get<strong>IMS</strong>Bundle()<br />

Returns the translated resource bundle.<br />

Returns: com.ibm.ims.db.<strong>IMS</strong>ErrorMessages.<br />

getString (String, Object)<br />

public String getString(String key,<br />

Object inserts[ ])<br />

Parameters:<br />

Appendix A. <strong>IMS</strong> <strong>Java</strong> package 279


key - java.lang.String.<br />

inserts - java.lang.Object[ ].<br />

Returns: java.lang.String.<br />

A.30 Class com.ibm.ims.db.SSA<br />

Variables<br />

java.lang.Object<br />

+----com.ibm.ims.db.SSA<br />

public class SSA extends Object<br />

EQUALS<br />

public static final short EQUALS<br />

Relational operator for equals (=).<br />

GREATER_OR_EQUAL<br />

public static final short GREATER_OR_EQUAL<br />

Relational operator for greater than or equal to (>=).<br />

LESS_OR_EQUAL<br />

public static final short LESS_OR_EQUAL<br />

Relational operator for less than or equal to ().<br />

LESS_THAN<br />

public static final short LESS_THAN<br />

Relational operator for less than (


Boolean operator AND.<br />

OR<br />

public static final byte OR<br />

Boolean operator OR.<br />

INDEPENDENT_AND<br />

public static final byte INDEPENDENT_AND<br />

Boolean operator INDEPENDENT AND.<br />

NULL_COMMAND<br />

public static final byte NULL_COMMAND<br />

Comm<strong>and</strong> code meaning null comm<strong>and</strong> code (ignored).<br />

CONCATENATED_KEY<br />

public static final byte CONCATENATED_KEY<br />

Comm<strong>and</strong> code meaning concatenated key.<br />

PATH_CALL<br />

public static final byte PATH_CALL<br />

FIRST_OCCURRENCE<br />

public static final byte FIRST_OCCURRENCE<br />

Comm<strong>and</strong> code meaning first occurrence.<br />

LAST_OCCURRENCE<br />

public static final byte LAST_OCCURRENCE<br />

Comm<strong>and</strong> code meaning last occurrence.<br />

PATH_CALL_IGNORE<br />

public static final byte PATH_CALL_IGNORE<br />

Comm<strong>and</strong> code meaning path call ignore.<br />

SET_PARENTAGE<br />

public static final byte SET_PARENTAGE<br />

Comm<strong>and</strong> code meaning set parentage.<br />

ENQUEUE_SEGMENT<br />

public static final byte ENQUEUE_SEGMENT<br />

Comm<strong>and</strong> code meaning enqueue segment.<br />

Appendix A. <strong>IMS</strong> <strong>Java</strong> package 281


MAINTAIN_POS_AT_LEVEL<br />

public static final byte MAINTAIN_POS_AT_LEVEL<br />

Comm<strong>and</strong> code meaning maintain position at this level.<br />

MAINTAIN_POS_AT_SUPERIOR_LEVELS<br />

public static final byte MAINTAIN_POS_AT_SUPERIOR_LEVELS<br />

Comm<strong>and</strong> code meaning maintain position at this level <strong>and</strong> all superior<br />

levels.<br />

LOCK_CLASS_A<br />

public static final byte LOCK_CLASS_A<br />

Code designating the lock class of a segment (for use with comm<strong>and</strong> code<br />

Q).<br />

LOCK_CLASS_B<br />

public static final byte LOCK_CLASS_B<br />

Code designating the lock class of a segment (for use with comm<strong>and</strong> code<br />

Q).<br />

LOCK_CLASS_C<br />

public static final byte LOCK_CLASS_C<br />

Code designating the lock class of a segment (for use with comm<strong>and</strong> code<br />

Q).<br />

LOCK_CLASS_D<br />

public static final byte LOCK_CLASS_D<br />

Code designating the lock class of a segment (for use with comm<strong>and</strong> code<br />

Q).<br />

LOCK_CLASS_E<br />

public static final byte LOCK_CLASS_E<br />

Code designating the lock class of a segment (for use with comm<strong>and</strong> code<br />

Q).<br />

LOCK_CLASS_F<br />

public static final byte LOCK_CLASS_F<br />

Code designating the lock class of a segment (for use with comm<strong>and</strong> code<br />

Q).<br />

282 <strong>IMS</strong> <strong>Version</strong> 7 <strong>and</strong> <strong>Java</strong> <strong>Application</strong> <strong>Programming</strong>


Constructors<br />

LOCK_CLASS_G<br />

public static final byte LOCK_CLASS_G<br />

Code designating the lock class of a segment (for use with comm<strong>and</strong> code<br />

Q).<br />

LOCK_CLASS_H<br />

public static final byte LOCK_CLASS_H<br />

Code designating the lock class of a segment (for use with comm<strong>and</strong> code<br />

Q).<br />

LOCK_CLASS_I<br />

public static final byte LOCK_CLASS_I<br />

Code designating the lock class of a segment (for use with comm<strong>and</strong> code<br />

Q).<br />

LOCK_CLASS_J<br />

public static final byte LOCK_CLASS_J<br />

Code designating the lock class of a segment (for use with comm<strong>and</strong> code<br />

Q).<br />

SSA (String)<br />

protected SSA(String segmentClassName)<br />

Protected constructor to create an unqualified SAA.<br />

Parameters:<br />

segmentClassName - the class name of the DLISegment subclass.<br />

SSA (String, String, short, String)<br />

protected SSA(String segmentClassName,<br />

String fieldName,<br />

short ssaRelationalOperator,String comparisonValue)<br />

Package constructor to create a qualified SAA.<br />

Parameters:<br />

segmentClassName - The class name of the DLISegment subclass.<br />

fieldName - The field name to be used to further qualify the SSA.<br />

ssaRelationalOperator - The relational operator to indicate the kind<br />

of checking.<br />

Appendix A. <strong>IMS</strong> <strong>Java</strong> package 283


Methods<br />

284 <strong>IMS</strong> <strong>Version</strong> 7 <strong>and</strong> <strong>Java</strong> <strong>Application</strong> <strong>Programming</strong><br />

comparisonValue - The value the field name is compared with.<br />

addComm<strong>and</strong>Code (byte)<br />

public void addComm<strong>and</strong>Code(byte ssaComm<strong>and</strong>Code)<br />

Adds a comm<strong>and</strong> code to an SSA. The SSA class defines several<br />

constants that can be supplied as values for the ssaComm<strong>and</strong>Code argument:<br />

NULL_COMMAND, CONCATENATED_KEY, FIRST_OCCURRENCE, LAST_OCCURRENCE,<br />

PATH_CALL, PATH_CALL_IGNORE, SET_PARENTAGE, MAINTAIN_POS_AT_LEVEL, <strong>and</strong><br />

MAINTAIN_POS_AT_SUPERIOR_LEVELS.<br />

Parameters:<br />

ssaComm<strong>and</strong>Code - A constant to indicate the function to execute.<br />

addComm<strong>and</strong>Code (byte, byte)<br />

public void addComm<strong>and</strong>Code(byte ssaComm<strong>and</strong>Code,byte lockClass)<br />

Adds a comm<strong>and</strong> code to an SSA. This method is used to specify a lock<br />

class for a segment. The SSA class defines the constant ENQUEUE_SEGMENT to<br />

be supplied as the value for the ssaComm<strong>and</strong>Code argument. The following<br />

codes are provided to specify the lock class for the segment: LOCK_CLASS_A,<br />

LOCK_CLASS_B, LOCK_CLASS_C, LOCK_CLASS_D, LOCK_CLASS_E, LOCK_CLASS_F,<br />

LOCK_CLASS_G, LOCK_CLASS_H, LOCK_CLASS_I, <strong>and</strong> LOCK_CLASS_J..<br />

Parameters:<br />

ssaComm<strong>and</strong>Code - A constant to indicate the function to execute.<br />

addQualificationStatement (byte, String, short, String)<br />

public void addQualificationStatement(byte ssaBooleanOperator,<br />

String fieldName,<br />

short ssaRelationalOperator,<br />

String comparisonValue) throws<br />

DLIException<br />

Adds a qualification statement to an SSA. To indicate that a comparison<br />

value may be changed at a later time, pass a null reference for the value.<br />

When using the SSA, call the setValue(int index, String value) method in<br />

SSAList to substitute in the desired value. The SSA class defines several<br />

constants that can be supplied as values for the ssaBooleanOperator<br />

argument: AND, OR, <strong>and</strong> INDEPENDENT_AND. The SSA class defines several<br />

constants that can be supplied as values for the ssaRelationalOperator<br />

argument: EQUALS, GREATER_OR_EQUAL, LESS_OR_EQUAL, GREATER_THAN,<br />

LESS_THAN, <strong>and</strong> NOT_EQUAL.


Parameters:<br />

ssaBooleanOperator - A constant to link qualifications together in<br />

SSAs with multiple qualifications.<br />

fieldName - The field name to be used to further qualify the SSA.<br />

ssaRelationalOperator - A constant to indicate the kind of checking.<br />

comparisonValue - The value the field name is compared with.<br />

Throws: DLIException if the SSA is formed incorrectly (the first<br />

qualification statement added is a multiple qualification statement).<br />

See Also: setValue.<br />

addQualificationStatement (SSAQualificationStatement)<br />

public void addQualificationStatement(SSAQualificationStatement<br />

ssaQualificationStatement) throws DLIException<br />

Adds a qualification statement specified by the ssaQualificationStatement<br />

argument to an SSA.<br />

Parameters:<br />

ssaQualificationStatement - An SSA qualification statement.<br />

Throws: DLIException if the SSA is formed incorrectly (the first<br />

qualification statement added is a multiple qualification statement).<br />

addQualificationStatement (String, short, String)<br />

public void addQualificationStatement(String fieldName,<br />

short ssaRelationalOperator,<br />

String comparisonValue) throws<br />

DLIException<br />

Adds a qualification statement to an SSA. To indicate that a comparison<br />

value may be changed at a later time, pass a null reference for the value.<br />

When using the SSA, call the setValue(int index, String value) method in<br />

SSAList to substitute in the desired value. The SSA class defines several<br />

constants that can be supplied as values for the ssaBooleanOperator<br />

argument: AND, OR, <strong>and</strong> INDEPENDENT_AND. The SSA class defines several<br />

constants that can be supplied as values for the ssaRelationalOperator<br />

argument: EQUALS, GREATER_OR_EQUAL, LESS_OR_EQUAL, GREATER_THAN,<br />

LESS_THAN, <strong>and</strong> NOT_EQUAL.<br />

Parameters:<br />

fieldName - The field name to be used to further qualify the SSA.<br />

ssaRelationalOperator - A constant to indicate the kind of checking.<br />

Appendix A. <strong>IMS</strong> <strong>Java</strong> package 285


comparisonValue - The value the field name is compared with.<br />

Throws: DLIException if the SSA is formed incorrectly (the first<br />

qualification statement added is a multiple qualification statement).<br />

See Also: setValue.<br />

createInstance (String)<br />

public static SSA createInstance(String segmentClassName)<br />

Creates an unqualified SSA. Qualification statements may be added to<br />

this SSA to qualify it.<br />

Parameters:<br />

286 <strong>IMS</strong> <strong>Version</strong> 7 <strong>and</strong> <strong>Java</strong> <strong>Application</strong> <strong>Programming</strong><br />

segmentClassName - The class name of the DLISegment subclass.<br />

createInstance (String, String, short, String)<br />

public static SSA createInstance(String segmentClassName,<br />

String fieldName,<br />

short ssaRelationalOperator,<br />

String comparisonValue)<br />

Creates a qualified SSA. More qualification statements may also be<br />

added. To indicate that a comparison value may be changed at a later<br />

time, pass a null reference for the value. When using the SSA, call one of<br />

the overloaded setValue() methods of the SSAList class to substitute in the<br />

desired value.<br />

Parameters:<br />

segmentClassName - The class name of the DLISegment subclass.<br />

fieldName - The field name to be used to further qualify the SSA.<br />

ssaRelationalOperator - The relational operator to indicate the kind<br />

of checking.<br />

comparisonValue - The value the field name is compared with.<br />

See Also: setValue, setValue, setValue, setValue, setValue, setValue,<br />

setValue.<br />

getBytes (DLIDatabaseView)<br />

public byte[ ] getBytes(DLIDatabaseView dbView) throws DLIException<br />

Returns the SSA in EBCDIC exactly as <strong>IMS</strong> needs it to be.<br />

Returns: a byte array specifying the entire SSA in EBCDIC.<br />

resetComm<strong>and</strong>Codes ()<br />

public void resetComm<strong>and</strong>Codes()


Turns off all comm<strong>and</strong> codes for this SSA.<br />

A.31 Class com.ibm.ims.db.SSAList<br />

Constructors<br />

Methods<br />

java.lang.Object<br />

+----com.ibm.ims.db.SSAList<br />

public class SSAList extends Object<br />

SSAList ()<br />

protected SSAList()<br />

Creates an SSA list.<br />

SSAList (SSA)<br />

protected SSAList(SSA ssa)<br />

Creates an SSA list from an existing SSA, <strong>and</strong> places the ssa argument at<br />

the head of the list.<br />

Parameters:<br />

ssa - An SSA.<br />

addSSA (SSA)<br />

public void addSSA(SSA ssa) throws <strong>IMS</strong>Exception<br />

Adds the ssa argument to an existing SSA list, placing it at the end of the<br />

list.<br />

Parameters:<br />

ssa - An SSA.<br />

clearParameters ()<br />

public void clearParameters()<br />

createInstance ()<br />

public static SSAList createInstance()<br />

Creates an SSA list.<br />

Appendix A. <strong>IMS</strong> <strong>Java</strong> package 287


createInstance (SSA)<br />

public static SSAList createInstance(SSA ssa)<br />

Creates an SSA list from an existing SSA, <strong>and</strong> places the ssa argument at<br />

the head of the list.<br />

Parameters:<br />

ssa - An SSA.<br />

getBytes (DLIDatabaseView)<br />

public byte[ ][ ] getBytes(DLIDatabaseView dbView) throws <strong>IMS</strong>Exception<br />

Returns the SSA list in a two-dimensional byte array. Each element in the<br />

array is an SSA in its EBCDIC format exactly as <strong>IMS</strong> needs it to be.<br />

Returns: A two-dimensional byte array containing all the SSAs in their<br />

EBCDIC format.<br />

Throws: DLIException if the SSAList does not have all its fields set (i.e.;<br />

some fields still have ‘null’ as their value).<br />

setValue (int, byte)<br />

public void setValue(int index,byte value[])<br />

Sets the value of a prepared parameter to the desired value. A prepared<br />

parameter is one whose value was set to null when the SSA or the<br />

SSAQualificationStatement was created, indicating that the value could be<br />

substituted in later. If an SSAList is composed of 2 SSAs, each with 2<br />

prepared parameters, then the index can be between 1 <strong>and</strong> 4, inclusive.<br />

For example, an index of 2 would specify the second prepared parameter<br />

of the first SSA in the SSAList.<br />

Parameters:<br />

288 <strong>IMS</strong> <strong>Version</strong> 7 <strong>and</strong> <strong>Java</strong> <strong>Application</strong> <strong>Programming</strong><br />

index - The index of the parameter value to be changed, starting<br />

with 1.<br />

value - The value of the parameter.<br />

See Also: SSA, SSAQualificationStatement.<br />

setValue (int, byte)<br />

public void setValue(int index,byte value)<br />

Sets the value of a prepared parameter to the desired value. A prepared<br />

parameter is one whose value was set to null when the SSA or the<br />

SSAQualificationStatement was created, indicating that the value could be<br />

substituted in later. If an SSAList is composed of 2 SSAs, each with 2<br />

prepared parameters, then the index can be between 1 <strong>and</strong> 4, inclusive.


For example, an index of 2 would specify the second prepared parameter<br />

of the first SSA in the SSAList.<br />

Parameters:<br />

index - The index of the parameter value to be changed, starting<br />

with 1.<br />

value - The value of the parameter.<br />

See Also: SSA, SSAQualificationStatement.<br />

setValue (int, double)<br />

public void setValue(int index,double value)<br />

Sets the value of a prepared parameter to the desired value. A prepared<br />

parameter is one whose value was set to null when the SSA or the<br />

SSAQualificationStatement was created, indicating that the value could be<br />

substituted in later. If an SSAList is composed of 2 SSAs, each with 2<br />

prepared parameters, then the index can be between 1 <strong>and</strong> 4, inclusive.<br />

For example, an index of 2 would specify the second prepared parameter<br />

of the first SSA in the SSAList.<br />

Parameters:<br />

index - The index of the parameter value to be changed, starting<br />

with 1.<br />

value - The value of the parameter.<br />

See Also: SSA, SSAQualificationStatement.<br />

setValue (int, float)<br />

public void setValue(int index,float value)<br />

Sets the value of a prepared parameter to the desired value. A prepared<br />

parameter is one whose value was set to null when the SSA or the<br />

SSAQualificationStatement was created, indicating that the value could be<br />

substituted in later. If an SSAList is composed of 2 SSAs, each with 2<br />

prepared parameters, then the index can be between 1 <strong>and</strong> 4, inclusive. For<br />

example, an index of 2 would specify the second prepared parameter of the<br />

first SSA in the SSAList.<br />

Parameters:<br />

index - The index of the parameter value to be changed, starting<br />

with 1.<br />

value - The value of the parameter.<br />

See Also: SSA, SSAQualificationStatement.<br />

Appendix A. <strong>IMS</strong> <strong>Java</strong> package 289


setValue (int, int)<br />

public void setValue(int index,int value)<br />

Sets the value of a prepared parameter to the desired value. A prepared<br />

parameter is one whose value was set to null when the SSA or the<br />

SSAQualificationStatement was created, indicating that the value could be<br />

substituted in later. If an SSAList is composed of 2 SSAs, each with 2<br />

prepared parameters, then the index can be between 1 <strong>and</strong> 4, inclusive.<br />

For example, an index of 2 would specify the second prepared parameter<br />

of the first SSA in the SSAList.<br />

Parameters:<br />

290 <strong>IMS</strong> <strong>Version</strong> 7 <strong>and</strong> <strong>Java</strong> <strong>Application</strong> <strong>Programming</strong><br />

index - The index of the parameter value to be changed, starting<br />

with 1.<br />

value - The value of the parameter.<br />

See Also: SSA, SSAQualificationStatement.<br />

setValue (int, long)<br />

public void setValue(int index,long value)<br />

Sets the value of a prepared parameter to the desired value. A prepared<br />

parameter is one whose value was set to null when the SSA or the<br />

SSAQualificationStatement was created, indicating that the value could be<br />

substituted in later. If an SSAList is composed of 2 SSAs, each with 2<br />

prepared parameters, then the index can be between 1 <strong>and</strong> 4, inclusive.<br />

For example, an index of 2 would specify the second prepared parameter<br />

of the first SSA in the SSAList.<br />

Parameters:<br />

index - The index of the parameter value to be changed, starting<br />

with 1.<br />

value - The value of the parameter.<br />

See Also: SSA, SSAQualificationStatement.<br />

setValue (int, String)<br />

public void setValue(int index,String value)<br />

Sets the value of a prepared parameter to the desired value. A prepared<br />

parameter is one whose value was set to null when the SSA or the<br />

SSAQualificationStatement was created, indicating that the value could be<br />

substituted in later. If an SSAList is composed of 2 SSAs, each with 2<br />

prepared parameters, then the index can be between 1 <strong>and</strong> 4, inclusive.


For example, an index of 2 would specify the second prepared parameter<br />

of the first SSA in the SSAList.<br />

Parameters:<br />

index - The index of the parameter value to be changed, starting<br />

with 1.<br />

value - The value of the parameter, which will be converted to its<br />

appropriate type as defined in the type info.<br />

See Also: SSA, SSAQualificationStatement.<br />

setValue (int, BigDecimal)<br />

public void setValue(int index,BigDecimal value)<br />

Sets the value of a prepared parameter to the desired value. A prepared<br />

parameter is one whose value was set to null when the SSA or the<br />

SSAQualificationStatement was created, indicating that the value could be<br />

substituted in later. If an SSAList is composed of 2 SSAs, each with 2<br />

prepared parameters, then the index can be between 1 <strong>and</strong> 4, inclusive.<br />

For example, an index of 2 would specify the second prepared parameter<br />

of the first SSA in the SSAList.<br />

Parameters:<br />

index - The index of the parameter value to be changed, starting<br />

with 1.<br />

value - The value of the parameter.<br />

See Also: SSA, SSAQualificationStatement.<br />

setValue (int, Date)<br />

public void setValue(int index,Date value)<br />

Sets the value of a prepared parameter to the desired value. A prepared<br />

parameter is one whose value was set to null when the SSA or the<br />

SSAQualificationStatement was created, indicating that the value could be<br />

substituted in later. If an SSAList is composed of 2 SSAs, each with 2<br />

prepared parameters, then the index can be between 1 <strong>and</strong> 4, inclusive.<br />

For example, an index of 2 would specify the second prepared parameter<br />

of the first SSA in the SSAList.<br />

Parameters:<br />

index - The index of the parameter value to be changed, starting<br />

with 1.<br />

value - The value of the parameter.<br />

Appendix A. <strong>IMS</strong> <strong>Java</strong> package 291


See Also: SSA, SSAQualificationStatement.<br />

setValue (int, Time)<br />

public void setValue(int index,<br />

Time value)<br />

Sets the value of a prepared parameter to the desired value. A prepared<br />

parameter is one whose value was set to null when the SSA or the<br />

SSAQualificationStatement was created, indicating that the value could be<br />

substituted in later. If an SSAList is composed of 2 SSAs, each with 2<br />

prepared parameters, then the index can be between 1 <strong>and</strong> 4, inclusive.<br />

For example, an index of 2 would specify the second prepared parameter<br />

of the first SSA in the SSAList.<br />

Parameters:<br />

292 <strong>IMS</strong> <strong>Version</strong> 7 <strong>and</strong> <strong>Java</strong> <strong>Application</strong> <strong>Programming</strong><br />

index - The index of the parameter value to be changed, starting<br />

with 1.<br />

value - The value of the parameter.<br />

See Also: SSA, SSAQualificationStatement.<br />

setValue (int, Timestamp)<br />

public void setValue(int index,<br />

Timestamp value)<br />

Sets the value of a prepared parameter to the desired value. A prepared<br />

parameter is one whose value was set to null when the SSA or the<br />

SSAQualificationStatement was created, indicating that the value could be<br />

substituted in later. If an SSAList is composed of 2 SSAs, each with 2<br />

prepared parameters, then the index can be between 1 <strong>and</strong> 4, inclusive.<br />

For example, an index of 2 would specify the second prepared parameter<br />

of the first SSA in the SSAList.<br />

Parameters:<br />

index - The index of the parameter value to be changed, starting<br />

with 1.<br />

value - The value of the parameter.<br />

See Also: SSA, SSAQualificationStatement.<br />

setValue (int, short)<br />

public void setValue(int index,short value)<br />

Sets the value of a prepared parameter to the desired value. A prepared<br />

parameter is one whose value was set to null when the SSA or the<br />

SSAQualificationStatement was created, indicating that the value could be


substituted in later. If an SSAList is composed of 2 SSAs, each with 2<br />

prepared parameters, then the index can be between 1 <strong>and</strong> 4, inclusive.<br />

For example, an index of 2 would specify the second prepared parameter<br />

of the first SSA in the SSAList.<br />

Parameters:<br />

index - The index of the parameter value to be changed, starting<br />

with 1.<br />

value - The value of the parameter.<br />

See Also: SSA, SSAQualificationStatement.<br />

setValue (int, boolean)<br />

public void setValue(int index,boolean value)<br />

Sets the value of a prepared parameter to the desired value. A prepared<br />

parameter is one whose value was set to null when the SSA or the<br />

SSAQualificationStatement was created, indicating that the value could be<br />

substituted in later. If an SSAList is composed of 2 SSAs, each with 2<br />

prepared parameters, then the index can be between 1 <strong>and</strong> 4, inclusive.<br />

For example, an index of 2 would specify the second prepared parameter<br />

of the first SSA in the SSAList.<br />

Parameters:<br />

index - The index of the parameter value to be changed, starting with 1.<br />

value - The value of the parameter.<br />

See Also: SSA, SSAQualificationStatement.<br />

size ()<br />

public final int size()<br />

Returns the number of SSAs in this list<br />

Returns: The number of SSAs in this list.<br />

ssaAt (int)<br />

public final SSA ssaAt(int index)<br />

Returns the SSA at the specified index.<br />

Parameters:<br />

index - The 1-based index into the list (i.e.; index 1 is the first SSA).<br />

Returns: the SSA at the specified index.<br />

Appendix A. <strong>IMS</strong> <strong>Java</strong> package 293


A.32 Class com.ibm.ims.db.SSAQualificationStatement<br />

Constructors<br />

Methods<br />

java.lang.Object<br />

+----com.ibm.ims.db.SSAQualificationStatement<br />

public class SSAQualificationStatement extends Object<br />

A SSAQualificationStatement represents logical qualification statements to a<br />

Segment Search Argument.<br />

SSAQualificationStatement (byte, String, short, String)<br />

protected SSAQualificationStatement(byte ssaBooleanOperator,<br />

String fieldName,<br />

short ssaRelationalOperator,<br />

String comparisonValue)<br />

Protected constructor to build an SSAQualificationStatement.<br />

Parameters:<br />

294 <strong>IMS</strong> <strong>Version</strong> 7 <strong>and</strong> <strong>Java</strong> <strong>Application</strong> <strong>Programming</strong><br />

ssaBooleanOperator - A constant to link qualifications together in<br />

SSAs with multiple qualifications.<br />

fieldName - The field name to be used to further qualify the SSA.<br />

ssaRelationalOperator - A constant to indicate the kind of checking.<br />

comparisonValue - The value the field name is compared with.<br />

SSAQualificationStatement (String, short, String)<br />

protected SSAQualificationStatement(String fieldName,<br />

short ssaRelationalOperator,<br />

String comparisonValue)<br />

Protected constructor to build an SSAQualificationStatement.<br />

Parameters:<br />

fieldName - The field name to be used to further qualify the SSA.<br />

ssaRelationalOperator - A constant to indicate the kind of checking.<br />

comparisonValue - The value the field name is compared with.<br />

createInstance (byte, String, short)<br />

public static SSAQualificationStatement createInstance(


yte ssaBooleanOperator,<br />

String fieldName,<br />

short ssaRelationalOperator)<br />

This creates an SSA Qualification Statement, which is used to further<br />

qualify a Segment Search Argument. This constructor is used to indicate<br />

that the comparison value will be set later using one of the overloaded<br />

setValue() methods of the SSAList class. The SSA class defines several<br />

constants that can be supplied as values for the ssaBooleanOperator<br />

argument: AND, OR, <strong>and</strong> INDEPENDENT_AND. The SSA class defines several<br />

constants that can be supplied as values for the ssaRelationalOperator<br />

argument: EQUALS, GREATER_OR_EQUAL, LESS_OR_EQUAL, GREATER_THAN,<br />

LESS_THAN, <strong>and</strong> NOT_EQUAL.<br />

Parameters:<br />

ssaBooleanOperator - A constant to link qualifications together in<br />

SSAs with multiple qualifications.<br />

fieldName - The field name to be used to further qualify the SSA.<br />

ssaRelationalOperator - A constant to indicate the kind of checking.<br />

See Also: setValue.<br />

createInstance (byte, String, short, String)<br />

public static SSAQualificationStatement createInstance(<br />

byte ssaBooleanOperator,<br />

String fieldName,<br />

short ssaRelationalOperator,<br />

String comparisonValue)<br />

This creates an SSA Qualification Statement, which is used to further<br />

qualify a Segment Search Argument. To indicate that a comparison value<br />

may be changed at a later time, pass a null reference for the value. When<br />

using the SSA, call the overloaded setValue() methods in the SSAList<br />

class to substitute in the desired value. The SSA class defines several<br />

constants that can be supplied as values for the ssaBooleanOperator<br />

argument: AND, OR, <strong>and</strong> INDEPENDENT_AND. The SSA class defines several<br />

constants that can be supplied as values for the ssaRelationalOperator<br />

argument: EQUALS, GREATER_OR_EQUAL, LESS_OR_EQUAL, GREATER_THAN,<br />

LESS_THAN, <strong>and</strong> NOT_EQUAL.<br />

Parameters:<br />

ssaBooleanOperator - A constant to link qualifications together in<br />

SSAs with multiple qualifications.<br />

fieldName - The field name to be used to further qualify the SSA.<br />

Appendix A. <strong>IMS</strong> <strong>Java</strong> package 295


296 <strong>IMS</strong> <strong>Version</strong> 7 <strong>and</strong> <strong>Java</strong> <strong>Application</strong> <strong>Programming</strong><br />

ssaRelationalOperator - A constant to indicate the kind of checking.<br />

comparisonValue - The value the field name is compared with.<br />

See Also: setValue.<br />

createInstance (String, short)<br />

public static SSAQualificationStatement createInstance(<br />

String fieldName,<br />

short ssaRelationalOperator)<br />

This creates an SSA Qualification Statement, which is used to further<br />

qualify a Segment Search Argument. This constructor is used to indicate<br />

that the comparison value will be set later using one of the overloaded<br />

setValue() methods of the SSAList class. The SSA class defines several<br />

constants that can be supplied as values for the ssaRelationalOperator<br />

argument: EQUALS, GREATER_OR_EQUAL, LESS_OR_EQUAL, GREATER_THAN,<br />

LESS_THAN, <strong>and</strong> NOT_EQUAL.<br />

Parameters:<br />

fieldName - The field name to be used to further qualify the SSA.<br />

ssaRelationalOperator - A constant to indicate the kind of checking.<br />

comparisonValue - The value the field name is compared with.<br />

See Also: setValue.<br />

createInstance (String, short, String)<br />

public static SSAQualificationStatement createInstance(<br />

String fieldName,<br />

short ssaRelationalOperator,<br />

String comparisonValue)<br />

This creates an SSA Qualification Statement, which is used to further<br />

qualify a Segment Search Argument. To indicate that a comparison value<br />

may be changed at a later time, pass a null reference for the value. When<br />

using the SSA, call the overloaded setValue() methods in the SSAList<br />

class to substitute in the desired value.<br />

The SSA class defines several constants that can be supplied as values for<br />

the ssaRelationalOperator argument: EQUALS, GREATER_OR_EQUAL,<br />

LESS_OR_EQUAL, GREATER_THAN, LESS_THAN, <strong>and</strong> NOT_EQUAL.<br />

Parameters:<br />

fieldName - The field name to be used to further qualify the SSA.<br />

ssaRelationalOperator - A constant to indicate the kind of checking.<br />

comparisonValue - The value the field name is compared with.


See Also: setValue.<br />

A.33 Class com.ibm.ims.db.Token<br />

Variables<br />

java.lang.Object<br />

+----com.ibm.ims.db.Token<br />

public class Token extends Object<br />

Describes the input token stream.<br />

beginLine<br />

public int beginLine<br />

beginLine <strong>and</strong> beginColumn describe the position of the first character of this<br />

token; endLine <strong>and</strong> endColumn describe the position of the last character<br />

of this token.<br />

beginColumn<br />

public int beginColumn<br />

beginLine <strong>and</strong> beginColumn describe the position of the first character of this<br />

token; endLine <strong>and</strong> endColumn describe the position of the last character of<br />

this token.<br />

endLine<br />

public int endLine<br />

beginLine <strong>and</strong> beginColumn describe the position of the first character of this<br />

token; endLine <strong>and</strong> endColumn describe the position of the last character of<br />

this token.<br />

endColumn<br />

public int endColumn<br />

beginLine <strong>and</strong> beginColumn describe the position of the first character of this<br />

token; endLine <strong>and</strong> endColumn describe the position of the last character of<br />

this token.<br />

image<br />

public String image<br />

The string image of the token.<br />

Appendix A. <strong>IMS</strong> <strong>Java</strong> package 297


Constructors<br />

Methods<br />

next<br />

public Token next<br />

A reference to the next regular (non-special) token from the input stream.<br />

If this is the last token from the input stream, or if the token manager has<br />

not read tokens beyond this one, this field is set to null. This is true only if<br />

this token is also a regular token. Otherwise, see below for a description of<br />

the contents of this field.<br />

specialToken<br />

public Token specialToken<br />

This field is used to access special tokens that occur prior to this token,<br />

but after the immediately preceding regular (non-special) token. If there<br />

are no such special tokens, this field is set to null. When there are more<br />

than one such special token, this field refers to the last of these special<br />

tokens, which in turn refers to the next previous special token through its<br />

specialToken field, <strong>and</strong> so on until the first special token (whose<br />

specialToken field is null). The next fields of special tokens refer to other<br />

special tokens that immediately follow it (without an intervening regular<br />

token). If there is no such token, this field is null.<br />

Token ()<br />

public Token()<br />

toString ()<br />

public final String toString()<br />

Returns the image.<br />

Overrides: toString in class Object.<br />

newToken (int)<br />

public static final Token newToken(int ofKind)<br />

Returns a new Token object, by default. However, if you want, you can<br />

create <strong>and</strong> return subclass objects based on the value of ofKind. Simply<br />

add the cases to the switch for all those special cases. For example, if you<br />

have a subclass of Token called IDToken that you want to create if ofKind is<br />

ID, simlpy add something like : case MyParserConstants.ID : return new<br />

IDToken(); to the following switch statement. Then you can cast<br />

matchedToken variable to the appropriate type <strong>and</strong> use it in your lexical<br />

actions.<br />

298 <strong>IMS</strong> <strong>Version</strong> 7 <strong>and</strong> <strong>Java</strong> <strong>Application</strong> <strong>Programming</strong>


A.34 Class com.ibm.ims.db.DLIException<br />

Constructors<br />

Method<br />

java.lang.Object<br />

+----java.lang.Throwable<br />

+----java.lang.Exception<br />

+----com.ibm.ims.base.<strong>IMS</strong>Exception<br />

+----com.ibm.ims.db.DLIException<br />

public class DLIException extends <strong>IMS</strong>Exception<br />

Thrown to indicate an error has occurred. These include all errors that occur<br />

in the <strong>Java</strong> space, not those that occur while processing an <strong>IMS</strong>/DLI call <strong>and</strong><br />

are propagated back.<br />

DLIException (String)<br />

public DLIException(String message)<br />

Creates an exception with the specified error message. The internal error<br />

code defaults to zero.<br />

Parameters:<br />

message - The error message.<br />

DLIException (String, int)<br />

public DLIException(String message,int code)<br />

Creates an exception with the specified error message <strong>and</strong> internal error<br />

code.<br />

Parameters:<br />

message - The error message.<br />

code - The internal error code.<br />

getErrorCode ()<br />

public int getErrorCode()<br />

Returns the internal error code. If there is no internal error code, 0 is<br />

returned.<br />

Appendix A. <strong>IMS</strong> <strong>Java</strong> package 299


300 <strong>IMS</strong> <strong>Version</strong> 7 <strong>and</strong> <strong>Java</strong> <strong>Application</strong> <strong>Programming</strong>


Appendix B. Debugging <strong>and</strong> problem determination<br />

B.1 Exceptions<br />

This appendix provides information on debugging <strong>and</strong> problem determination.<br />

Exceptions are thrown as a result of non-blank status codes <strong>and</strong> non-zero<br />

return codes (in cases when there were no PCBs to deliver status codes)<br />

from <strong>IMS</strong> DL/I calls. Exceptions are not all bad; some exceptions are caught<br />

by the following classes of the higher level of <strong>IMS</strong> <strong>Java</strong> <strong>and</strong> responded to in<br />

database <strong>and</strong> application processing.<br />

B.2 How exceptions map to DL/I status codes<br />

<strong>IMS</strong>Exception extends java.lang.Exception. DLIException extends<br />

<strong>IMS</strong>Exception by enabling <strong>IMS</strong> <strong>Java</strong> to detect errors in <strong>IMS</strong> DL/I calls from<br />

the database base package <strong>and</strong> catch them before they are sent to <strong>IMS</strong>.<br />

The following would be a constructor:<br />

public <strong>IMS</strong>Exception(String function,AIB aib,short statcode,String<br />

exceptiontype)<br />

Parameters:<br />

function - the DLI function<br />

aib - AIB<br />

statCode - The status code<br />

exception Type - The exception description message<br />

Useful methods for the <strong>IMS</strong> <strong>Java</strong> consumed exceptions are:<br />

getAIB<br />

Returns the <strong>IMS</strong> AIB from the DL/I call that caused the exception<br />

getStatusCode<br />

Returns the <strong>IMS</strong> status code from the DL/I call that caused the exception.<br />

Also works with the <strong>Java</strong>ToDLI set of constants.Status Code will be 0<br />

(zero) for a DLIException.<br />

© Copyright <strong>IBM</strong> Corp. 2001 301


getFunction<br />

Returns the <strong>IMS</strong> function from the DL/I call that caused the exception.<br />

These DB classes return false if they receive GE (segment not found) or<br />

GB (endof database) status codes <strong>and</strong> they are consumed by<br />

DLIConnection (Figure 121).<br />

DLIConnection.getUniqueSegment<br />

DLIConnection.getNextSegment<br />

DLIConnection.getUniqueRecord<br />

DLIConnection.getNextRecord<br />

DLIConnection.getNextSegmentInParent<br />

Figure 121. DLIConnection list<br />

The <strong>IMS</strong>MessageQueue.getUniqueMessage TM class returns false if it receives a<br />

QC (no more messages) status code. <strong>IMS</strong>MessageQueue.getNextMessage class<br />

returns false if it receives a QD (no more segments [for multi-segment<br />

messages]) status code. These exceptions are consumed by <strong>IMS</strong>MessageQueue.<br />

SQLException extends java.lang.Exception by enabling JDBC users to catch<br />

any <strong>IMS</strong>Exception, DLIException, or ParseException that are seen by <strong>IMS</strong> <strong>Java</strong><br />

as they are re-thrown as SQL exceptions.<br />

SQLException is thrown to indicate that an error has occurred either in the<br />

<strong>Java</strong> address space or during database processing.<br />

Each SQLException provides several kinds of information:<br />

1. A string describing the error.<br />

- This string is used as the <strong>Java</strong> Exception message. It is available<br />

through the use of the getMessage() method.<br />

2. An _SQLstate_ string that follows XOPEN SQLstate conventions.<br />

- The values of the SQLstate string are described in the XOPEN SQL<br />

specification.<br />

3. A chain to a next Exception through the use of the getNextException<br />

method.<br />

- The next exception is used as a source of additional error<br />

information.Status Code Call Methods on Exceptions to Extract<br />

(Figure 122).<br />

302 <strong>IMS</strong> <strong>Version</strong> 7 <strong>and</strong> <strong>Java</strong> <strong>Application</strong> <strong>Programming</strong>


B.3 Sync point failure<br />

final int MAX_IOAREA_SIZE = 054;<br />

AIB aib = new AIB();<br />

byte [] ioArea = new byte [MAX_IOAREA_SIZE];<br />

aib.setResourceName("IOPCB"); // IOPCB is for access the message queue<br />

aib.setOALe gth(80);<br />

try {<br />

<strong>Java</strong>ToDLI.execute("GN",aib,ioArea);<br />

} catch (<strong>IMS</strong>Exception e) {<br />

if (e.getStatusCode() != <strong>Java</strong>ToDLI.QD)<br />

//process failure<br />

}<br />

Figure 122. Status code call exception example<br />

Related reading<br />

For more information on DL/I Status Codes, see <strong>IMS</strong> <strong>Application</strong><br />

<strong>Programming</strong>: Transaction Manager, SC26-9425.<br />

If you receive an SY DL/I PCB status code, your <strong>IMS</strong> <strong>Java</strong> application SYNC<br />

request call has failed. Table 5 describes the failure.<br />

Table 5. Status code, reason <strong>and</strong> return code<br />

DL/1 return/<br />

reason<br />

code<br />

PCB<br />

status<br />

code<br />

System<br />

service<br />

call<br />

0108/056C SY <strong>IMS</strong> <strong>Java</strong><br />

sync<br />

Category Description<br />

5 Internal error during<br />

synchpoint porcessing<br />

for an <strong>IMS</strong> <strong>Java</strong><br />

application.AIBERRXT<br />

contains the Sync return code.<br />

A call to the sync point processor (DFSTMS00) returned a non-zero return<br />

code.<br />

Appendix B. Debugging <strong>and</strong> problem determination 303


B.4 “Try <strong>and</strong> catch” example<br />

Figure 123 is an example of “try <strong>and</strong> catch” methods, where the reply is a<br />

method that will place a message on the <strong>IMS</strong> output queue.<br />

try {<br />

Class.forName("com.ibm.ims.db.DLIDriver");<br />

connection = DriverManager.getConnectio<br />

("jdbc:dli:dealership.applicatio .DealerDatabaseView");<br />

}<br />

catch (Exception e){<br />

reply("Connection not established");<br />

}<br />

Figure 123. Example of “try <strong>and</strong> catch” methods<br />

304 <strong>IMS</strong> <strong>Version</strong> 7 <strong>and</strong> <strong>Java</strong> <strong>Application</strong> <strong>Programming</strong>


Appendix C. <strong>IMS</strong> abend codes<br />

This appendix covers abends <strong>and</strong> pseudoabends.<br />

C.1 Abends <strong>and</strong> pseudoabends<br />

An abend is the abnormal ending of a program or application. When an abend<br />

error condition occurs, an abend macro is issued either at the point of error<br />

detection or by branching to a routine that issues the abend macro.<br />

There are also pseudoabends wherein the module that detects the error<br />

condition does not issue the abend macro, but instead passes control back to<br />

the <strong>IMS</strong> call analyzer module, DFSDLA00, which writes the contents of important<br />

control blocks to the system log <strong>and</strong> indicates a dependent-region abend.<br />

C.2 Abends issued from <strong>IMS</strong> <strong>Java</strong> applications<br />

The following are the abends that you might encounter as a result of errors<br />

while running <strong>IMS</strong> <strong>Java</strong> applications.<br />

C.2.1 ABENDU0118 - Commit failure<br />

Explanation: This abend is issued if your <strong>IMS</strong> <strong>Java</strong> application attempts to<br />

terminate normally without issuing an explicit commit. An explicit commit is<br />

required for each <strong>IMS</strong> <strong>Java</strong> application before it can terminate normally.<br />

System action: The application program terminates abnormally.<br />

Programmer response: Increase the size of the I/O area to allow the data to<br />

be returned to the application.<br />

C.2.2 ABENDU0200 - Small I/O area defined<br />

Explanation: A GET type function was issued using the AIB interface that was<br />

expecting data to be returned in the I/O area. However, the length of the IO<br />

area was too small to receive the data<br />

System action: The application program terminates abnormally.<br />

Programmer response: Increase the size of the I/O area to allow the data to<br />

be returned to the application.<br />

© Copyright <strong>IBM</strong> Corp. 2001 305


C.2.3 ABENDU0462 - Get Unique was not issued<br />

Explanation: An application program was scheduled in a message region<br />

<strong>and</strong> terminated without successfully issuing a GET UNIQUE for an input<br />

message. The application program did successfully process at least one<br />

other call.<br />

System action: The application program is abnormally terminated, <strong>and</strong> the<br />

PSB <strong>and</strong> the SMB are stopped.<br />

Programmer response: Determine the problem in the user message<br />

processing program, correct it, <strong>and</strong> resubmit the job.<br />

C.2.4 ABENDU0475 - Batch run failure<br />

Explanation: This abend is issued if your <strong>IMS</strong> <strong>Java</strong> application attempts to<br />

run as an <strong>IMS</strong> Batch job. <strong>IMS</strong> batch does not currently support <strong>IMS</strong> <strong>Java</strong><br />

applications.<br />

System action: The application program terminates abnormally.<br />

Programmer response: Increase the size of the I/O area to allow the data to<br />

be returned to the application.<br />

C.2.5 ABENDU0778 - Rollback failure<br />

Explanation: This abend is issued by the DL/I ROLL call when a program<br />

determines that some of its processing is invalid. ABENDU0778 does not<br />

issue a dump.<br />

System action: The application program is abnormally terminated, <strong>and</strong> the<br />

PSB <strong>and</strong> the SMB are stopped.<br />

Programmer response: Determine the problem in the user message<br />

processing program, correct it, <strong>and</strong> resubmit the job.<br />

306 <strong>IMS</strong> <strong>Version</strong> 7 <strong>and</strong> <strong>Java</strong> <strong>Application</strong> <strong>Programming</strong>


Appendix D. <strong>IMS</strong> <strong>Java</strong> tracing facilities<br />

D.1 <strong>IMS</strong>Trace<br />

This appendix describes <strong>IMS</strong> <strong>Java</strong> tracing facilities.<br />

<strong>IMS</strong>Trace provides you with the ability to debug your <strong>Java</strong> applications by<br />

tracing, or documenting, the flow of control throughout your application. By<br />

having the ability to set up tracepoints throughout your applications for<br />

output, you can isolate problem areas <strong>and</strong>, therefore, know where to make<br />

adjustments to produce the results you expect. In addition, because<br />

<strong>IMS</strong>Trace supports writing input parameters <strong>and</strong> results, <strong>and</strong> the<br />

<strong>IMS</strong>-<strong>Java</strong>-library-provided routines use this feature, you can verify that<br />

correct results occur across method boundaries.<br />

D.2 Initiating <strong>IMS</strong>Tracing<br />

To debug with <strong>IMS</strong>Trace, you must first turn on the tracing function by setting<br />

the <strong>IMS</strong>Trace.traceOn variable to true. Because tracing does not occur until<br />

this variable is set, it is best to do so within a static block of the<br />

<strong>IMS</strong><strong>Application</strong> subclass. Then, you must decide how closely you want to<br />

trace the <strong>IMS</strong> <strong>Java</strong> library’s flow of control, as well as how much tracing you<br />

want to add to your application code.<br />

You determine the amount of tracing in the <strong>IMS</strong> <strong>Java</strong> library by setting the<br />

value of <strong>IMS</strong>Trace.libTraceLevel to one of its predefined values. By default,<br />

this value is set to <strong>IMS</strong>Trace.TRACE_EXCEPTIONS, which traces the construction<br />

of <strong>IMS</strong>-<strong>Java</strong>-library-provided exceptions. <strong>IMS</strong>Trace also defines constants for<br />

three types of additional tracing. These constants provide successively more<br />

tracing from<strong>IMS</strong>Trace.TRACE_CTOR1 (level one tracing of constructions) to<br />

<strong>IMS</strong>Trace.TRACE_DATA3 (level three tracing of data).<br />

D.3 Setting up tracing for the <strong>IMS</strong> <strong>Java</strong> library routines<br />

To turn on the tracing shipped with the <strong>IMS</strong> <strong>Java</strong> Library Routines:<br />

1. Turn on the flag enabling tracing. (It is turned off by default.)<br />

<strong>IMS</strong>Trace.traceO = true;<br />

2. Set the level of tracing for the <strong>IMS</strong> <strong>Java</strong> Library Routines.In this example<br />

the construction is traced as is the entry <strong>and</strong> exit of level one methods:<br />

<strong>IMS</strong>Trace.libTraceLevel = <strong>IMS</strong>Trace.TRACE_METHOD;<br />

© Copyright <strong>IBM</strong> Corp. 2001 307


3. Set an output stream (a print stream or a character output writer) as the<br />

current trace stream. For example:<br />

4. Set the system error stream as the current trace<br />

stream:<strong>IMS</strong>Trace.setOutputStream(System.err);<br />

5. Set a StringWriter (an in-memory buffer) as the current trace<br />

stream:StringWriter stri gWriter = ew Stri gWriter();<br />

<strong>IMS</strong>Trace.setOutputWriter(stri gWriter);<br />

These steps are best implemented within a static method of your<br />

<strong>IMS</strong><strong>Application</strong> subclass main routine:<br />

public class <strong>IMS</strong>Auto extends <strong>IMS</strong><strong>Application</strong>{<br />

static {<br />

<strong>IMS</strong>Trace.traceOn = true;<br />

<strong>IMS</strong>Trace.libTraceLevel = <strong>IMS</strong>Trace.TRACE_METHOD1;<br />

<strong>IMS</strong>Trace.setOutputStream(System.err);<br />

}<br />

public static void main(String args[]) {<br />

<strong>IMS</strong>Auto application = new <strong>IMS</strong>Auto();<br />

application.begin();<br />

}<br />

D.4 Adding trace statements to your application<br />

You can add trace statements to your application, similar to those provided by<br />

the <strong>IMS</strong> <strong>Java</strong> Library, by defining an integer variable that you test prior to<br />

writing trace statements. Using a variable other than <strong>IMS</strong>Trace.libTraceLevel<br />

enables you to control the level of tracing in your application independently of<br />

the tracing in the <strong>IMS</strong> <strong>Java</strong> library. For example, you can turn off the tracing of<br />

<strong>IMS</strong> <strong>Java</strong> Library routines by setting <strong>IMS</strong>Trace.libTraceLevel to zero while still<br />

tracing your application code.<br />

Follow these steps to add tracing to your application code:<br />

1. Define an integer variable to contain the trace level for<br />

application-provided code:<br />

public class <strong>IMS</strong>Auto extends <strong>IMS</strong><strong>Application</strong>{<br />

public int applicationTraceLevel = <strong>IMS</strong>Trace.TRACE_CTOR3;<br />

308 <strong>IMS</strong> <strong>Version</strong> 7 <strong>and</strong> <strong>Java</strong> <strong>Application</strong> <strong>Programming</strong>


2. Call <strong>IMS</strong>Trace routines to trace methods, parameters, <strong>and</strong> return values<br />

as necessary:<br />

public class <strong>IMS</strong>Auto extends <strong>IMS</strong><strong>Application</strong>{<br />

public static int applicationTraceLevel=<strong>IMS</strong>Trace.TRACE_CTOR3;<br />

static{<br />

<strong>IMS</strong>Trace.traceOn = true;<br />

<strong>IMS</strong>Trace.libTraceLevel = <strong>IMS</strong>Trace.TRACE_METHOD1;<br />

<strong>IMS</strong>Trace.setOutputStream(System.err);<br />

}<br />

public static void mai (String args[]){<br />

<strong>IMS</strong>Auto application = new <strong>IMS</strong>Auto();<br />

application.begin();<br />

}<br />

public void doBegin() throws <strong>IMS</strong>Exception{<br />

if(<strong>IMS</strong>Auto.applicationTraceLevel >= <strong>IMS</strong>Trace.TRACE_METHOD1)<br />

<strong>IMS</strong>Trace.currentTrace().logEntry("<strong>IMS</strong>Auto.doBegin");<br />

try {<br />

//Add code here ...<br />

String result = method ("Parameter one");<br />

}<br />

finally {<br />

if(<strong>IMS</strong>Auto.applicationTraceLevel >= <strong>IMS</strong>Trace.TRACE_METHOD1)<br />

<strong>IMS</strong>Trace.currentTrace().logExit("<strong>IMS</strong>Auto.doBegin");<br />

}<br />

}<br />

public String method (String parm ){<br />

if(<strong>IMS</strong>Auto.applicationTraceLevel >= <strong>IMS</strong>Trace.TRACE_METHOD2) {<br />

<strong>IMS</strong>Trace.currentTrace().logE try("<strong>IMS</strong>Auto.method1");<br />

if(<strong>IMS</strong>Auto.applicationTraceLevel >= <strong>IMS</strong>Trace.TRACE_DATA2)<br />

<strong>IMS</strong>Trace.currentTrace().logParm(“parm1”,parm1);<br />

}<br />

String result = new String();<br />

try {<br />

//Addcodehere...<br />

result = “result”;<br />

}<br />

finally {<br />

if (<strong>IMS</strong>Auto.applicationTraceLevel >= <strong>IMS</strong>Trace.TRACE_METHOD2)<br />

<strong>IMS</strong>Trace.currentTrace().logExit(“<strong>IMS</strong>Auto.method1”);<br />

}<br />

return result;<br />

}<br />

}<br />

Appendix D. <strong>IMS</strong> <strong>Java</strong> tracing facilities 309


310 <strong>IMS</strong> <strong>Version</strong> 7 <strong>and</strong> <strong>Java</strong> <strong>Application</strong> <strong>Programming</strong>


Appendix E. IVP application — <strong>Java</strong> source (<strong>Java</strong> to DLI version)<br />

The Installation Verification Program (IVP), mentioned throughout this book,<br />

is outlined in detail in the descriptions of the following classes. The IVP<br />

sample application is a very simple phone book application. Each of the<br />

application programs performs the same add, change, delete, <strong>and</strong> display<br />

functions. It was created using the lower level database classes:<br />

DLIConnection <strong>and</strong> the SSA classes (which are built on the <strong>Java</strong>ToDLI<br />

interface) to the <strong>IMS</strong> database. More information about the IVP program can<br />

be found in the <strong>IMS</strong> V7 Installation Volume 1: Installation <strong>and</strong> Verification,<br />

GC26-9429-00. The IVP <strong>Application</strong> contains the following methods:<br />

Add Adds an entry into the database.<br />

Delete Deletes an entry from the database.<br />

Display Displays a certain entry in the database.<br />

Reply Sends a response back to the user.<br />

SetOutput Updates the output message.<br />

SetPhonebookSegment Updates the phone book segment.<br />

Update Updates an entry in the database.<br />

UpdateSPA Updates the SPA message.<br />

This application was broken down into the following package:<br />

- samples.ivp<br />

The sample.ivp package contains the following classes:<br />

PhoneBookSegment Maps the A1111111 segment of the DFSIVD2<br />

database.<br />

IVPDatabaseView Contains the segment information for the<br />

database DFSIVD2.<br />

InputMessage This is the default Input Message class. The<br />

IVP program uses it to receive messages from<br />

the message queue.<br />

OutputMessage This is the default Output Message class. The<br />

IVP program uses it to send output to the<br />

message queue.<br />

SPAMessage The IVP program uses this class to save data<br />

between the conversation.<br />

© Copyright <strong>IBM</strong> Corp. 2001 311


E.1 PhoneBookSegment class<br />

package samples.ivp;<br />

import com.ibm.ims.base.*;<br />

/**<br />

* This is the PhoneBookSegment class which represents the A1111111 segment<br />

* for the DFSIVD2 database which is a root only database having the<br />

* following segment layout:<br />

* BYTES 1-10 LAST NAME (CHARACTER) - KEY<br />

* BYTES 11-20 FIRST NAME (CHARACTER)<br />

* BYTES 21-30 INTERNAL PHONE NUMBER (NUMERIC)<br />

* BYTES 31-37 INTERNAL ZIP (CHARACTER)<br />

* BYTES 38-40 RESERVED<br />

*/<br />

public class PhoneBookSegment extends com.ibm.ims.db.DLISegment<br />

{<br />

staticDLITypeInfo[] typeInfo = {<br />

new DLITypeInfo(“LastName”, DLITypeInfo.CHAR,1,10,”A1111111”),<br />

new DLITypeInfo(“FirstName”, DLITypeInfo.CHAR,11,10),<br />

new DLITypeInfo(“Extension”, DLITypeInfo.CHAR,21,10),<br />

new DLITypeInfo(“ZipCode”, DLITypeInfo.CHAR,31,7)<br />

};<br />

/**<br />

* Constructs an PhoneBookSegment class. Allocates the byte array for the<br />

* segment data. Total segment length is 40 bytes.<br />

*/<br />

protected PhoneBookSegment()<br />

{<br />

super(“A1111111”,typeInfo,40);<br />

}<br />

}<br />

E.2 IVPDatabaseView class<br />

package samples.ivp;<br />

import com.ibm.ims.db.*;<br />

/**<br />

* The TELEPCB class contains the segment info for the database DFSIVD2<br />

*/<br />

public class IVPDatabaseView extends com.ibm.ims.db.DLIDatabaseView<br />

312 <strong>IMS</strong> <strong>Version</strong> 7 <strong>and</strong> <strong>Java</strong> <strong>Application</strong> <strong>Programming</strong>


E.3 InputMessage class<br />

{<br />

static DLISegmentInfo[] segments = {new DLISegmentInfo(new<br />

samples.ivp.PhoneBookSegment(),DLIDatabaseView.ROOT)};<br />

/**<br />

* Constructs a new IVPDatabaseView object.<br />

*/<br />

protected IVPDatabaseView() {<br />

super(“TELEPCB”, segments);<br />

}<br />

}<br />

package samples.ivp;<br />

import com.ibm.ims.base.*;<br />

/** This is the Input Message class for receiving message from the message<br />

* queue<br />

*/<br />

public class InputMessage extends com.ibm.ims.application.<strong>IMS</strong>FieldMessage<br />

{<br />

static DLITypeInfo[] fieldInfo = {<br />

new DLITypeInfo(“Reserved”,DLITypeInfo.CHAR,1,4),<br />

new DLITypeInfo(“ProcessCode”,DLITypeInfo.CHAR,5,8),<br />

new DLITypeInfo(“LastName”,DLITypeInfo.CHAR,13,10),<br />

new DLITypeInfo(“FirstName”,DLITypeInfo.CHAR,23,10),<br />

new DLITypeInfo(“Extension”,DLITypeInfo.CHAR,33,10),<br />

new DLITypeInfo(“ZipCode”,DLITypeInfo.CHAR,43,7)<br />

};<br />

/**<br />

* Constructs an InputMessage. It allocates the byte array<br />

* for the input message. Total data length is 49 bytes.<br />

* The input message data has the following layout format<br />

* as defined in the MID:<br />

* Reserved ( 4 bytes)<br />

* Process Code ( 8 bytes)<br />

* Input Data : (37 bytes total)<br />

* - Last Name (10 bytes)<br />

* - First Name (10 bytes)<br />

* - Extension Number (10 bytes)<br />

* - Internal Zip Code ( 7 bytes)<br />

*/<br />

public InputMessage()<br />

Appendix E. IVP application — <strong>Java</strong> source (<strong>Java</strong> to DLI version) 313


{<br />

}<br />

}<br />

E.4 OutputMessage class<br />

super(fieldInfo,49, false);<br />

package samples.ivp;<br />

import com.ibm.ims.base.*;<br />

/**<br />

* This is the OuputMessage class which the IVP program uses to send output<br />

* to the message queue.<br />

*/<br />

public class OutputMessage extends com.ibm.ims.application.<strong>IMS</strong>FieldMessage<br />

{<br />

static DLITypeInfo[] fieldInfo = {<br />

new DLITypeInfo(“Message”,DLITypeInfo.CHAR,1,40),<br />

new DLITypeInfo(“ProcessCode”,DLITypeInfo.CHAR,41,8),<br />

new DLITypeInfo(“LastName”,DLITypeInfo.CHAR,49,10),<br />

new DLITypeInfo(“FirstName”,DLITypeInfo.CHAR,59,10),<br />

new DLITypeInfo(“Extension”,DLITypeInfo.CHAR,69,10),<br />

new DLITypeInfo(“ZipCode”,DLITypeInfo.CHAR,79,7),<br />

new DLITypeInfo(“SegmentNumber”,DLITypeInfo.CHAR,86,4)<br />

};<br />

/**<br />

* Constructs an OutputMessage. It allocates the byte array<br />

* for the output message. Total data length is 89 bytes.<br />

* The output message data has the following layout format:<br />

* Output Message (40 bytes)<br />

* Process Code ( 8 bytes)<br />

* Output Data (37 bytes)<br />

* - Last Name (10 bytes)<br />

* - First Name (10 bytes)<br />

* - Extension Number (10 bytes)<br />

* - Internal Zip Code ( 7 bytes)<br />

* Segment Number ( 4 bytes)<br />

*/<br />

public OutputMessage()<br />

{<br />

super(fieldInfo,89, false);<br />

}<br />

}<br />

314 <strong>IMS</strong> <strong>Version</strong> 7 <strong>and</strong> <strong>Java</strong> <strong>Application</strong> <strong>Programming</strong>


E.5 SPAMessage class<br />

package samples.ivp;<br />

import com.ibm.ims.base.*;<br />

/**<br />

* This is the SPAMessage class which the IVP program uses to save data<br />

* between the conversation.<br />

*/<br />

public class SPAMessage extends com.ibm.ims.application.<strong>IMS</strong>FieldMessage<br />

{<br />

static DLITypeInfo[] fieldInfo = {<br />

new DLITypeInfo(“SessionNumber”,DLITypeInfo.SMALLINT,1,2),<br />

new DLITypeInfo(“ProcessCode”,DLITypeInfo.CHAR,3,8),<br />

new DLITypeInfo(“LastName”,DLITypeInfo.CHAR,11,10),<br />

new DLITypeInfo(“FirstName”,DLITypeInfo.CHAR,21,10),<br />

new DLITypeInfo(“Extension”,DLITypeInfo.CHAR,31,10),<br />

new DLITypeInfo(“ZipCode”,DLITypeInfo.CHAR,41,7),<br />

new DLITypeInfo(“Reserved”,DLITypeInfo.CHAR,48,19)<br />

};<br />

/**<br />

* Constructs a SPAMessage. It allocates the byte array<br />

* for the spa message. Total data length is 66 bytes.<br />

* The output message data has the following layout format:<br />

* Session Number (2 bytes)<br />

* Process Code (8 bytes)<br />

* SPA Data (37 bytes total)<br />

* - Last Name (10 bytes)<br />

* - First Name (10 bytes)<br />

* - Extension Number (10 bytes)<br />

* - Internal Zip Code ( 7 bytes)<br />

* Reserved (19 bytes)<br />

*/<br />

public SPAMessage()<br />

{<br />

super(fieldInfo, 66, true);<br />

}<br />

/**<br />

* Increment the session number for the conversation.<br />

*/<br />

public void incrementSessionNumber() throws <strong>IMS</strong>Exception<br />

{<br />

setShort(“SessionNumber”,(short)(getShort(“SessionNumber”)+1));<br />

}<br />

}<br />

Appendix E. IVP application — <strong>Java</strong> source (<strong>Java</strong> to DLI version) 315


E.6 Installation Verification Program (IVP) application<br />

package samples.ivp;<br />

//<br />

// CONV TITLE ‘INSTALLATION VERIFICATION PROCEDURE - CONVERSATIONAL’<br />

//-------------------------------------------------------------------<br />

//<br />

// APPLICATION : <strong>IMS</strong> INSTALLATION VERIFICATION PROCEDURE<br />

// CONVERSATIONAL MPP PROGRAM HDAM/VSAM<br />

// TRANSACTION : IVTCC<br />

// PSB : DFSIVP32<br />

// DATABASE : DFSIVD2<br />

//<br />

//-------------------------------------------------------------------<br />

//<br />

// Licensed Materials - Property of <strong>IBM</strong><br />

// “Restricted Materials of <strong>IBM</strong>”<br />

// 5655-158 (C) Copyright <strong>IBM</strong> Corp. 1999<br />

//<br />

//-------------------------------------------------------------------<br />

//<br />

// INPUT:<br />

// TELEPHONE DIRECTORY SYSTEM<br />

// PROCESS CODE : CCCCCCCC<br />

// LAST NAME : XXXXXXXXXX<br />

// FIRST NAME : XXXXXXXXXX<br />

// EXTENTION# : N-NNN-NNNN<br />

// INTERNAL ZIP : XXX/XXX<br />

//<br />

// CCCCCCCC = COMMAND<br />

// ADD = INSERT ENTRY IN DB<br />

// TADD = NOT SUPPORTED. DEFAULT TO ADD<br />

// DELETE = DELETE ENTRY FROM DB<br />

// UPDATE = UPDATE ENTRY FROM DB<br />

// DISPLAY = DISPLAY ENTRY<br />

// END = TERMINATE CONVERSATION<br />

//<br />

//-------------------------------------------------------------------<br />

import com.ibm.ims.base.*;<br />

import com.ibm.ims.application.*;<br />

import com.ibm.ims.db.*;<br />

/**<br />

* The IVP class is the Installation Verification Program which is<br />

316 <strong>IMS</strong> <strong>Version</strong> 7 <strong>and</strong> <strong>Java</strong> <strong>Application</strong> <strong>Programming</strong>


* a conversational program that runs in the <strong>IMS</strong> MPP region.<br />

* This program works with the DFSIVD2 database, which defines<br />

* the phone book directory.<br />

**/<br />

public class IVP extends com.ibm.ims.application.<strong>IMS</strong><strong>Application</strong><br />

{<br />

private <strong>IMS</strong>MessageQueue msgQ = null;<br />

private IVPDatabaseView dbView = null;<br />

private DLIConnection connection = null;<br />

private int segNum = 0;<br />

/** Constructs a new IVP object. */<br />

public IVP() {}<br />

/**<br />

* Add an entry into the database.<br />

* All fields for the segment (Last Name, First Name, Extension Number,<br />

* <strong>and</strong> Internal Zip Code) should be entered for insert.<br />

* @param inputMessage - the input message from the user<br />

* @param outputMessage - the output message for this transaction<br />

*/<br />

public void add(InputMessage inputMessage, OutputMessage outputMessage)<br />

throws <strong>IMS</strong>Exception<br />

{<br />

PhoneBookSegment phonebookSegment = new PhoneBookSegment();<br />

SSA ssa = SSA.createInstance(“PhoneBookSegment”);<br />

SSAList ssaList = SSAList.createInstance();<br />

ssaList.addSSA(ssa);<br />

// Check for input fields<br />

if (inputMessage.getString(“FirstName”).trim().equals(““)<br />

|| inputMessage.getString(“LastName”).trim().equals(““)<br />

|| inputMessage.getString(“Extension”).trim().equals(““)<br />

|| inputMessage.getString(“ZipCode”).trim().equals(““))<br />

{ // Not enough input data<br />

outputMessage.setString(“Message”,<br />

”DATA IS NOT ENOUGH. PLEASE KEY IN MORE”);<br />

}<br />

else<br />

{<br />

try<br />

{<br />

setPhonebookSegment(inputMessage,phonebookSegment);<br />

// Insert the new segment into the database<br />

connection.insertSegment(phonebookSegment,ssaList);<br />

outputMessage.setString(“Message”,”ENTRY WAS ADDED”);<br />

}<br />

Appendix E. IVP application — <strong>Java</strong> source (<strong>Java</strong> to DLI version) 317


}<br />

catch (Exception e)<br />

{ // Error in inserting<br />

outputMessage.setString(“Message”,”ADDITION OF ENTRY HAS FAILED”);<br />

}<br />

}<br />

setOutput(inputMessage, outputMessage);<br />

/**<br />

* Delete an entry from the database.<br />

* @param inputMessage - the input message from the user<br />

* @param outputMessage - the output message for this transaction<br />

*/<br />

public void delete(InputMessage inputMessage, OutputMessage outputMessage)<br />

throws <strong>IMS</strong>Exception<br />

{<br />

PhoneBookSegment phonebookSegment = new PhoneBookSegment();<br />

SSA ssa = SSA.createInstance(“PhoneBookSegment”);<br />

SSAList ssaList = SSAList.createInstance();<br />

// Set the SSA List for retrieving the segment from the database<br />

ssa.addQualificationStatement(“LastName”,<br />

SSA.EQUALS,inputMessage.getString(“LastName”));<br />

ssaList.addSSA(ssa);<br />

// Check if the requested segment is found in the database<br />

if (!connection.getUniqueSegment(phonebookSegment,ssaList))<br />

{ // Requested data not found in database<br />

outputMessage.setString(“Message”,”SPECIFIED PERSON WAS NOT FOUND”);<br />

}<br />

else<br />

{<br />

try<br />

{ // Delete the segment<br />

connection.deleteSegments();<br />

outputMessage.setString(“Message”,”ENTRY WAS DELETED”);<br />

}<br />

catch (<strong>IMS</strong>Exception e)<br />

{ // Error in deleting the data<br />

outputMessage.setString(“Message”,”DELETION OF ENTRY HAS FAILED”);<br />

}<br />

}<br />

setOutput(inputMessage, outputMessage);<br />

}<br />

/**<br />

* Display a certain entry from the database.<br />

* @param inputMessage - the input message from the user<br />

* @param outputMessage - the output message for this transaction<br />

318 <strong>IMS</strong> <strong>Version</strong> 7 <strong>and</strong> <strong>Java</strong> <strong>Application</strong> <strong>Programming</strong>


*/<br />

public void display(InputMessage inputMessage, OutputMessage outputMessage)<br />

throws <strong>IMS</strong>Exception<br />

{<br />

PhoneBookSegment phonebookSegment = new PhoneBookSegment();<br />

SSA ssa = SSA.createInstance(“PhoneBookSegment”);<br />

SSAList ssaList = SSAList.createInstance();<br />

// Set the SSA List for retrieving the segment from the database<br />

ssa.addQualificationStatement(“LastName”,<br />

SSA.EQUALS,inputMessage.getString(“LastName”));<br />

ssaList.addSSA(ssa);<br />

// Retrieve the segment from the database<br />

if (!connection.getUniqueSegment(phonebookSegment,ssaList))<br />

{ // Data not found in database<br />

setOutput(inputMessage, outputMessage);<br />

outputMessage.setString(“Message”,”SPECIFIED PERSON IS NOT FOUND”);<br />

}<br />

else<br />

{ // Set output data fields<br />

setOutput(phonebookSegment, outputMessage);<br />

outputMessage.setString(“Message”,”ENTRY WAS DISPLAYED”);<br />

}<br />

}<br />

/**<br />

* This is the IVP application program.<br />

* It first reads the SPA message <strong>and</strong> determines the state of the<br />

* conversation program. It then reads the user input request <strong>and</strong><br />

* process the database comm<strong>and</strong> <strong>and</strong> send a response back to the<br />

* user according to the status of the processing.<br />

*/<br />

public void doBegin() throws <strong>IMS</strong>Exception<br />

{<br />

msgQ = new <strong>IMS</strong>MessageQueue();<br />

dbView = new IVPDatabaseView();<br />

connection = DLIConnection.createInstance(dbView);<br />

InputMessage inputMessage = new InputMessage();<br />

OutputMessage outputMessage = new OutputMessage();<br />

SPAMessage spaMessage = new SPAMessage();<br />

String procCode = null;<br />

boolean msgReceived = false;<br />

try<br />

{ // Get the SPA data<br />

msgReceived = msgQ.getUniqueMessage(spaMessage);<br />

}<br />

catch (<strong>IMS</strong>Exception e)<br />

Appendix E. IVP application — <strong>Java</strong> source (<strong>Java</strong> to DLI version) 319


{<br />

if (e.getStatusCode() !=<br />

<strong>Java</strong>ToDLI.MESSAGE_QUEUED_PRIOR_TO_LAST_START)<br />

throw e;<br />

}<br />

if (!msgReceived)<br />

outputMessage.setString(“Message”,”UNABLE TO READ SPA”);<br />

else if (!msgQ.getNextMessage(inputMessage))<br />

// No input message received<br />

outputMessage.setString(“Message”,”NO INPUT MESSAGE”);<br />

else if ((spaMessage.getShort(“SessionNumber”)==0)<br />

&&<br />

(!inputMessage.getString(“ProcessCode”).trim().equals(“END”))<br />

&& (inputMessage.getString(“LastName”).trim().equals(““)))<br />

// New Conversation. User has to specify last name.<br />

outputMessage.setString(“Message”,”LAST NAME WAS NOT SPECIFIED”);<br />

else<br />

{<br />

try<br />

{<br />

procCode = inputMessage.getString(“ProcessCode”).trim();<br />

if (spaMessage.getShort(“SessionNumber”) !=0)<br />

{ // Check if process code is specified. If not, use SPA data as<br />

// default<br />

if (procCode.equals(““))<br />

inputMessage.setString(“ProcessCode”,<br />

spaMessage.getString(“ProcessCode”));<br />

// Check if last name is specified. If not, use SPA data as<br />

// default<br />

if (inputMessage.getString(“LastName”).equals(““))<br />

inputMessage.setString(“LastName”,<br />

spaMessage.getString(“LastName”));<br />

}<br />

// Determine which comm<strong>and</strong> was requested<br />

if (procCode.equals(“ADD”) || procCode.equals(“TADD”))<br />

add(inputMessage, outputMessage); // Add the entry to the<br />

// database<br />

else if (procCode.equals(“DELETE”))<br />

delete(inputMessage, outputMessage);// Delete the entry from<br />

// the database<br />

else if (procCode.equals(“UPDATE”))<br />

update(inputMessage, outputMessage);// Update the entry in the<br />

// database<br />

else if (procCode.equals(“DISPLAY”))<br />

display(inputMessage, outputMessage);// Display the data from<br />

// the database<br />

else<br />

320 <strong>IMS</strong> <strong>Version</strong> 7 <strong>and</strong> <strong>Java</strong> <strong>Application</strong> <strong>Programming</strong>


}<br />

outputMessage.setString(“Message”,<br />

“PROCESS CODE WAS INVALID”);<br />

}<br />

catch (Exception e)<br />

{<br />

outputMessage.setString(“Message”,<br />

“Request failed. “ + e.toString());<br />

}<br />

}<br />

// Update the spa <strong>and</strong> send a response back to the user.<br />

updateSPA(inputMessage, spaMessage, procCode);<br />

reply(outputMessage, procCode);<br />

// Commit this transaction.<br />

<strong>IMS</strong>Transaction.getTransaction().commit();<br />

/** main entry point of the IVP program **/<br />

public static void main(String args[])<br />

{<br />

IVP ivp = new IVP();<br />

ivp.begin();<br />

}<br />

/**<br />

* Send a response back to the user.<br />

* @param outputMessage - the output message to be sent to user<br />

* @param procCode - the process code for this transaction<br />

*/<br />

public void reply(OutputMessage outputMessage, String procCode) throws<br />

<strong>IMS</strong>Exception<br />

{<br />

if (procCode.equals(“END”))<br />

outputMessage.setString(“Message”,”CONVERSATION HAS ENDED”);<br />

msgQ.insertMessage(outputMessage);<br />

}<br />

/**<br />

* Update the output message.<br />

* @param inputMessage - the input message from the user<br />

* @param outputMessage - the output message to be updated<br />

*/<br />

public void setOutput(InputMessage inputMessage, OutputMessage<br />

outputMessage) throws <strong>IMS</strong>Exception<br />

{<br />

// Set output data fields<br />

outputMessage.setString(“ProcessCode”,<br />

inputMessage.getString(“ProcessCode”));<br />

Appendix E. IVP application — <strong>Java</strong> source (<strong>Java</strong> to DLI version) 321


}<br />

outputMessage.setString(“LastName”,<br />

inputMessage.getString(“LastName”));<br />

outputMessage.setString(“FirstName”,<br />

inputMessage.getString(“FirstName”));<br />

outputMessage.setString(“Extension”,<br />

inputMessage.getString(“Extension”));<br />

outputMessage.setString(“ZipCode”,<br />

inputMessage.getString(“ZipCode”));<br />

/**<br />

* Update the output message.<br />

* @param phonebookSegment - the segment info from the database<br />

* @param outputMessage - the output message to be updated<br />

*/<br />

public void setOutput(PhoneBookSegment phonebookSegment, OutputMessage<br />

outputMessage) throws <strong>IMS</strong>Exception<br />

{<br />

// Set output data fields<br />

outputMessage.setString(“LastName”,<br />

phonebookSegment.getString(“LastName”));<br />

outputMessage.setString(“FirstName”,<br />

phonebookSegment.getString(“FirstName”));<br />

outputMessage.setString(“Extension”,<br />

phonebookSegment.getString(“Extension”));<br />

outputMessage.setString(“ZipCode”,<br />

phonebookSegment.getString(“ZipCode”));<br />

}<br />

/**<br />

* Update the phone book segment<br />

* @param inputMessage - the input message from the user<br />

* @param phonebookSegment - the phone book segment to be updated<br />

*/<br />

public void setPhonebookSegment(InputMessage inputMessage, PhoneBookSegment<br />

phonebookSegment) throws <strong>IMS</strong>Exception<br />

{<br />

// Set phone book segment data fields<br />

phonebookSegment.setString(“LastName”,<br />

inputMessage.getString(“LastName”));<br />

phonebookSegment.setString(“FirstName”,<br />

inputMessage.getString(“FirstName”));<br />

phonebookSegment.setString(“Extension”,<br />

inputMessage.getString(“Extension”));<br />

phonebookSegment.setString(“ZipCode”,<br />

inputMessage.getString(“ZipCode”));<br />

}<br />

322 <strong>IMS</strong> <strong>Version</strong> 7 <strong>and</strong> <strong>Java</strong> <strong>Application</strong> <strong>Programming</strong>


**<br />

* Update an entry in the database.<br />

* @param inputMessage - the input message from the user<br />

* @param outputMessage - the output message for this transaction<br />

*/<br />

public void update(InputMessage inputMessage, OutputMessage outputMessage)<br />

throws <strong>IMS</strong>Exception<br />

{<br />

PhoneBookSegment phonebookSegment = new PhoneBookSegment();<br />

SSA ssa = SSA.createInstance(“PhoneBookSegment”);<br />

SSAList ssaList = SSAList.createInstance();<br />

// Set the SSA List for retrieving the segment from the database<br />

ssa.addQualificationStatement(“LastName”,<br />

SSA.EQUALS,inputMessage.getString(“LastName”));<br />

ssaList.addSSA(ssa);<br />

// Retrieve the segment from the database<br />

if (!connection.getUniqueSegment(phonebookSegment,ssaList))<br />

{ // Requested data not found in database<br />

outputMessage.setString(“Message”,”SPECIFIED PERSON WAS NOT FOUND”);<br />

}<br />

else if (inputMessage.getString(“FirstName”).equals(““)<br />

|| inputMessage.getString(“LastName”).equals(““)<br />

|| inputMessage.getString(“Extension”).equals(““)<br />

|| inputMessage.getString(“ZipCode”).equals(““))<br />

{ // Requested input data not enough<br />

outputMessage.setString(“Message”,<br />

”DATA IS NOT ENOUGH. PLEASE KEY IN MORE”);<br />

}<br />

else<br />

{<br />

try<br />

{ // Update the new entry<br />

setPhonebookSegment(inputMessage,phonebookSegment);<br />

connection.replaceSegment(phonebookSegment);<br />

outputMessage.setString(“Message”,”ENTRY WAS UPDATED”);<br />

}<br />

catch (<strong>IMS</strong>Exception e)<br />

{ // Error with the update<br />

outputMessage.setString(“Message”,”UPDATE OF ENTRY HAS FAILED”);<br />

}<br />

}<br />

// Update the output data<br />

setOutput(inputMessage, outputMessage);<br />

}<br />

/**<br />

Appendix E. IVP application — <strong>Java</strong> source (<strong>Java</strong> to DLI version) 323


* Update the SPA message.<br />

* @param inputMessage - the input message from the user<br />

* @param spaMessage - the spa message to be updated<br />

*/<br />

public void updateSPA(InputMessage inputMessage, SPAMessage spaMessage,<br />

String procCode) throws <strong>IMS</strong>Exception<br />

{<br />

if (!procCode.equals(“END”))<br />

{<br />

// Set spa data fields<br />

spaMessage.setString(“ProcessCode”,<br />

inputMessage.getString(“ProcessCode”));<br />

spaMessage.setString(“LastName”,inputMessage.getString(“LastName”));<br />

spaMessage.setString(“FirstName”,<br />

inputMessage.getString(“FirstName”));<br />

spaMessage.setString(“Extension”,<br />

inputMessage.getString(“Extension”));<br />

spaMessage.setString(“ZipCode”,<br />

inputMessage.getString(“ZipCode”));<br />

spaMessage.incrementSessionNumber();<br />

msgQ.insertMessage(spaMessage);<br />

}<br />

else<br />

msgQ.insertMessage(spaMessage, true);<br />

}<br />

}<br />

324 <strong>IMS</strong> <strong>Version</strong> 7 <strong>and</strong> <strong>Java</strong> <strong>Application</strong> <strong>Programming</strong>


Appendix F. IVP application — <strong>Java</strong> source (JDBC version)<br />

The Installation Verification Program (IVP), mentioned throughout this book is<br />

outlined in detail in the following classes. The IVP sample application is a<br />

very simple phone book application. Each of the application programs<br />

performs the same add, change, delete, <strong>and</strong> display functions. It was created<br />

using the JDBC <strong>IMS</strong> interface. More information about the IVP program can<br />

be found in the <strong>IMS</strong> V7 Installation Volume 1: Installation <strong>and</strong> Verification,<br />

GC26-9429-00. The IVP <strong>Application</strong> contains the following methods:<br />

Add Adds an entry into the database.<br />

Delete Deletes an entry from the database.<br />

Display Displays a certain entry in the database.<br />

Reply Sends a response back to the user.<br />

SetOutput Updates the output message.<br />

SetPhonebookSegment Updates the phone book segment.<br />

Update Updates an entry in the database.<br />

UpdateSPA Updates the SPA message.<br />

This application was broken down into the following package:<br />

- samples.jdbc<br />

The sample.ivp package contains the following classes:<br />

PhoneBookSegment Maps the A1111111 segment of the DFSIVD2<br />

database.<br />

IVPDatabaseView Contains the segment information for the<br />

database DFSIVD2.<br />

InputMessage This is the default Input Message class. The<br />

IVP program uses it to receive messages from<br />

the message queue.<br />

OutputMessage This is the default Output Message class. The<br />

IVP program uses it to send output to the<br />

message queue.<br />

SPAMessage The IVP program uses this class to save data<br />

between the conversation.<br />

© Copyright <strong>IBM</strong> Corp. 2001 325


F.1 PhoneBookSegment class<br />

package samples.jdbc;<br />

import com.ibm.ims.base.*;<br />

/**<br />

* This is the PhoneBookSegment class which represents the A1111111 segment<br />

* for the DFSIVD2 database which is a root only database having the<br />

* following segment layout:<br />

* BYTES 1-10 LAST NAME (CHARACTER) - KEY<br />

* BYTES 11-20 FIRST NAME (CHARACTER)<br />

* BYTES 21-30 INTERNAL PHONE NUMBER (NUMERIC)<br />

* BYTES 31-37 INTERNAL ZIP (CHARACTER)<br />

* BYTES 38-40 RESERVED<br />

*/<br />

public class PhoneBookSegment extends com.ibm.ims.db.DLISegment<br />

{<br />

staticDLITypeInfo[] typeInfo = {<br />

new DLITypeInfo(“LastName”, DLITypeInfo.CHAR,1,10,”A1111111”),<br />

new DLITypeInfo(“FirstName”, DLITypeInfo.CHAR,11,10),<br />

new DLITypeInfo(“Extension”, DLITypeInfo.CHAR,21,10),<br />

new DLITypeInfo(“ZipCode”, DLITypeInfo.CHAR,31,7)<br />

};<br />

/**<br />

* Constructs an PhoneBookSegment class. Allocates the byte array for the<br />

* segment data. Total segment length is 40 bytes.<br />

*/<br />

protected PhoneBookSegment()<br />

{<br />

super(“A1111111”,typeInfo,40);<br />

}<br />

}<br />

F.2 IVPDatabaseView class<br />

package samples.jdbc;<br />

import com.ibm.ims.db.*;<br />

/**<br />

* The TELEPCB class contains the segment info for the database DFSIVD2<br />

*/<br />

public class IVPDatabaseView extends com.ibm.ims.db.DLIDatabaseView<br />

{<br />

326 <strong>IMS</strong> <strong>Version</strong> 7 <strong>and</strong> <strong>Java</strong> <strong>Application</strong> <strong>Programming</strong>


F.3 InputMessage class<br />

static DLISegmentInfo[] segments = {new DLISegmentInfo(new<br />

samples.jdbc.PhoneBookSegment(),DLIDatabaseView.ROOT)};<br />

/**<br />

* Constructs a new IVPDatabaseView object.<br />

*/<br />

protected IVPDatabaseView() {<br />

super(“TELEPCB”, segments);<br />

}<br />

}<br />

package samples.jdbc;<br />

import com.ibm.ims.base.*;<br />

/** This is the Input Message class for receiving message from the message<br />

queue */<br />

public class InputMessage extends com.ibm.ims.application.<strong>IMS</strong>FieldMessage<br />

{<br />

static DLITypeInfo[] fieldInfo = {<br />

new DLITypeInfo(“Reserved”,DLITypeInfo.CHAR,1,4),<br />

new DLITypeInfo(“ProcessCode”,DLITypeInfo.CHAR,5,8),<br />

new DLITypeInfo(“LastName”,DLITypeInfo.CHAR,13,10),<br />

new DLITypeInfo(“FirstName”,DLITypeInfo.CHAR,23,10),<br />

new DLITypeInfo(“Extension”,DLITypeInfo.CHAR,33,10),<br />

new DLITypeInfo(“ZipCode”,DLITypeInfo.CHAR,43,7)<br />

};<br />

/**<br />

* Constructs an InputMessage. It allocates the byte array<br />

* for the input message. Total data length is 49 bytes.<br />

* The input message data has the following layout format<br />

* as defined in the MID:<br />

* Reserved ( 4 bytes)<br />

* Process Code ( 8 bytes)<br />

* Input Data : (37 bytes total)<br />

* - Last Name (10 bytes)<br />

* - First Name (10 bytes)<br />

* - Extension Number (10 bytes)<br />

* - Internal Zip Code ( 7 bytes)<br />

*/<br />

public InputMessage()<br />

{<br />

Appendix F. IVP application — <strong>Java</strong> source (JDBC version) 327


}<br />

}<br />

F.4 OutputMessage class<br />

super(fieldInfo,49, false);<br />

package samples.jdbc;<br />

import com.ibm.ims.base.*;<br />

/**<br />

* This is the OuputMessage class which the IVP program uses to send output<br />

* to the message queue.<br />

*/<br />

public class OutputMessage extends com.ibm.ims.application.<strong>IMS</strong>FieldMessage<br />

{<br />

static DLITypeInfo[] fieldInfo = {<br />

new DLITypeInfo(“Message”,DLITypeInfo.CHAR,1,40),<br />

new DLITypeInfo(“ProcessCode”,DLITypeInfo.CHAR,41,8),<br />

new DLITypeInfo(“LastName”,DLITypeInfo.CHAR,49,10),<br />

new DLITypeInfo(“FirstName”,DLITypeInfo.CHAR,59,10),<br />

new DLITypeInfo(“Extension”,DLITypeInfo.CHAR,69,10),<br />

new DLITypeInfo(“ZipCode”,DLITypeInfo.CHAR,79,7),<br />

new DLITypeInfo(“SegmentNumber”,DLITypeInfo.CHAR,86,4)<br />

};<br />

/**<br />

* Constructs an OutputMessage. It allocates the byte array<br />

* for the output message. Total data length is 89 bytes.<br />

* The output message data has the following layout format:<br />

* Output Message (40 bytes)<br />

* Process Code ( 8 bytes)<br />

* Output Data (37 bytes)<br />

* - Last Name (10 bytes)<br />

* - First Name (10 bytes)<br />

* - Extension Number (10 bytes)<br />

* - Internal Zip Code ( 7 bytes)<br />

* Segment Number ( 4 bytes)<br />

*/<br />

public OutputMessage()<br />

{<br />

super(fieldInfo,89, false);<br />

}<br />

}<br />

328 <strong>IMS</strong> <strong>Version</strong> 7 <strong>and</strong> <strong>Java</strong> <strong>Application</strong> <strong>Programming</strong>


F.5 SPAMessage class<br />

package samples.jdbc;<br />

import com.ibm.ims.base.*;<br />

/**<br />

* This is the SPAMessage class which the IVP program uses to save data<br />

* between the conversation.<br />

*/<br />

public class SPAMessage extends com.ibm.ims.application.<strong>IMS</strong>FieldMessage<br />

{<br />

static DLITypeInfo[] fieldInfo = {<br />

new DLITypeInfo(“SessionNumber”,DLITypeInfo.SMALLINT,1,2),<br />

new DLITypeInfo(“ProcessCode”,DLITypeInfo.CHAR,3,8),<br />

new DLITypeInfo(“LastName”,DLITypeInfo.CHAR,11,10),<br />

new DLITypeInfo(“FirstName”,DLITypeInfo.CHAR,21,10),<br />

new DLITypeInfo(“Extension”,DLITypeInfo.CHAR,31,10),<br />

new DLITypeInfo(“ZipCode”,DLITypeInfo.CHAR,41,7),<br />

new DLITypeInfo(“Reserved”,DLITypeInfo.CHAR,48,19)<br />

};<br />

/**<br />

* Constructs a SPAMessage. It allocates the byte array<br />

* for the spa message. Total data length is 66 bytes.<br />

* The output message data has the following layout format:<br />

* Session Number (2 bytes)<br />

* Process Code (8 bytes)<br />

* SPA Data (37 bytes total)<br />

* - Last Name (10 bytes)<br />

* - First Name (10 bytes)<br />

* - Extension Number (10 bytes)<br />

* - Internal Zip Code ( 7 bytes)<br />

* Reserved (19 bytes)<br />

*/<br />

public SPAMessage()<br />

{<br />

super(fieldInfo, 66, true);<br />

}<br />

/**<br />

* Increment the session number for the conversation.<br />

*/<br />

public void incrementSessionNumber() throws <strong>IMS</strong>Exception<br />

{<br />

setShort(“SessionNumber”,(short)(getShort(“SessionNumber”)+1));<br />

Appendix F. IVP application — <strong>Java</strong> source (JDBC version) 329


}<br />

}<br />

F.6 Installation Verification Program (IVP) application<br />

package samples.jdbc;<br />

//<br />

// CONV TITLE ‘INSTALLATION VERIFICATION PROCEDURE - CONVERSATIONAL’<br />

//-------------------------------------------------------------------<br />

//<br />

// APPLICATION : <strong>IMS</strong> INSTALLATION VERIFICATION PROCEDURE<br />

// CONVERSATIONAL MPP PROGRAM HDAM/VSAM<br />

// TRANSACTION : IVTCC<br />

// PSB : DFSIVP32<br />

// DATABASE : DFSIVD2<br />

//<br />

//-------------------------------------------------------------------<br />

//<br />

// Licensed Materials - Property of <strong>IBM</strong><br />

// “Restricted Materials of <strong>IBM</strong>”<br />

// 5655-158 (C) Copyright <strong>IBM</strong> Corp. 1999<br />

//<br />

//-------------------------------------------------------------------<br />

//<br />

// INPUT:<br />

// TELEPHONE DIRECTORY SYSTEM<br />

// PROCESS CODE : CCCCCCCC<br />

// LAST NAME : XXXXXXXXXX<br />

// FIRST NAME : XXXXXXXXXX<br />

// EXTENTION# : N-NNN-NNNN<br />

// INTERNAL ZIP : XXX/XXX<br />

//<br />

// CCCCCCCC = COMMAND<br />

// ADD = INSERT ENTRY IN DB<br />

// TADD = NOT SUPPORTED. DEFAULT TO ADD<br />

// DELETE = DELETE ENTRY FROM DB<br />

// UPDATE = UPDATE ENTRY FROM DB<br />

// DISPLAY = DISPLAY ENTRY<br />

// END = TERMINATE CONVERSATION<br />

//<br />

//-------------------------------------------------------------------<br />

import com.ibm.ims.base.*;<br />

import com.ibm.ims.application.*;<br />

330 <strong>IMS</strong> <strong>Version</strong> 7 <strong>and</strong> <strong>Java</strong> <strong>Application</strong> <strong>Programming</strong>


import com.ibm.ims.db.*;<br />

import java.sql.*;<br />

/**<br />

* The IVP class is the Installation Verification Program which is<br />

* a conversational program that runs in the <strong>IMS</strong> MPP region.<br />

* This program works with the DFSIVD2 database, which defines<br />

* the phone book directory.<br />

**/<br />

public class IVP extends <strong>IMS</strong><strong>Application</strong><br />

{<br />

private <strong>IMS</strong>MessageQueue msgQ = null;<br />

private Connection connection = null;<br />

/** Constructs a new IVP object. */<br />

public IVP()<br />

{<br />

}<br />

/**<br />

* Add an entry into the database.<br />

* All fields for the segment (Last Name, First Name, Extension Number,<br />

* <strong>and</strong> Internal Zip Code) should be entered for insert.<br />

* @param inputMessage - the input message from the user<br />

* @param outputMessage - the output message for this transaction<br />

*/<br />

public void add(InputMessage inputMessage, OutputMessage outputMessage)<br />

throws <strong>IMS</strong>Exception<br />

{<br />

String firstName = inputMessage.getString(“FirstName”).trim();<br />

String lastName = inputMessage.getString(“LastName”).trim();<br />

String extension = inputMessage.getString(“Extension”).trim();<br />

String zip = inputMessage.getString(“ZipCode”).trim();<br />

// Check for input fields<br />

if (firstName.equals(““)<br />

|| lastName.equals(““)<br />

|| extension.equals(““)<br />

|| zip.equals(““))<br />

{ // Not enough input data<br />

outputMessage.setString(“Message”,”DATA IS NOT ENOUGH. PLEASE KEY IN<br />

MORE”);<br />

}<br />

else<br />

{<br />

try<br />

Appendix F. IVP application — <strong>Java</strong> source (JDBC version) 331


{ // Insert the new segment into the database<br />

Statement statement = connection.createStatement();<br />

statement.executeUpdate(“INSERT INTO PhoneBookSegment (FirstName,<br />

LastName, Extension, ZipCode) “<br />

+ “VALUES (‘” + firstName + “‘, ‘” + lastName + “‘, ‘”<br />

+ extension + “‘, ‘” + zip + “‘)”);<br />

outputMessage.setString(“Message”,”ENTRY WAS ADDED”);<br />

}<br />

catch (Exception e)<br />

{ // Error in inserting<br />

outputMessage.setString(“Message”,”ADDITION OF ENTRY HAS FAILED”);<br />

}<br />

}<br />

setOutput(inputMessage, outputMessage);<br />

}<br />

/**<br />

* Delete an entry from the database.<br />

* @param inputMessage - the input message from the user<br />

* @param outputMessage - the output message for this transaction<br />

*/<br />

public void delete(InputMessage inputMessage, OutputMessage outputMessage)<br />

throws <strong>IMS</strong>Exception<br />

{<br />

try<br />

{ // Delete the segment<br />

Statement statement = connection.createStatement();<br />

statement.executeUpdate(“DELETE FROM PhoneBookSegment “<br />

+ “WHERE LastName = ‘” + inputMessage.getString(“LastName”)<br />

+ “‘”);<br />

outputMessage.setString(“Message”,”ENTRY WAS DELETED”);<br />

}<br />

catch (Exception e)<br />

{ // Error in deleting the data<br />

outputMessage.setString(“Message”,”DELETION OF ENTRY HAS FAILED”);<br />

}<br />

setOutput(inputMessage, outputMessage);<br />

}<br />

/**<br />

* Display a certain entry from the database.<br />

* @param inputMessage - the input message from the user<br />

* @param outputMessage - the output message for this transaction<br />

*/<br />

public void display(InputMessage inputMessage, OutputMessage outputMessage)<br />

throws <strong>IMS</strong>Exception<br />

{<br />

332 <strong>IMS</strong> <strong>Version</strong> 7 <strong>and</strong> <strong>Java</strong> <strong>Application</strong> <strong>Programming</strong>


try<br />

{<br />

Statement statement = connection.createStatement();<br />

ResultSet result = statement.executeQuery(“SELECT * FROM<br />

PhoneBookSegment “<br />

+ “WHERE LastName = ‘” + inputMessage.getString(“LastName”)<br />

+ “‘”);<br />

setOutput(result, outputMessage);<br />

outputMessage.setString(“Message”,”ENTRY WAS DISPLAYED”);<br />

}<br />

catch (Exception e)<br />

{ // Set output data fields<br />

setOutput(inputMessage, outputMessage);<br />

outputMessage.setString(“Message”,”SPECIFIED PERSON IS NOT FOUND”);<br />

}<br />

}<br />

/**<br />

* This is the IVP application program.<br />

* It first reads the SPA message <strong>and</strong> determines the state of the<br />

* conversation program. It then reads the user input request <strong>and</strong><br />

* process the database comm<strong>and</strong> <strong>and</strong> send a response back to the<br />

* user according to the status of the processing.<br />

*/<br />

public void doBegin() throws <strong>IMS</strong>Exception<br />

{<br />

msgQ = new <strong>IMS</strong>MessageQueue();<br />

InputMessage inputMessage = new InputMessage();<br />

OutputMessage outputMessage = new OutputMessage();<br />

SPAMessage spaMessage = new SPAMessage();<br />

boolean msgReceived = false;<br />

String procCode = null;<br />

String errorMessage = null;<br />

try<br />

{<br />

Class.forName(“com.ibm.ims.db.DLIDriver”);<br />

connection = DriverManager.getConnection(<br />

“jdbc:dli:samples.jdbc.IVPDatabaseView”);<br />

// Get the SPA data<br />

msgReceived = msgQ.getUniqueMessage(spaMessage);<br />

if (!msgReceived)<br />

errorMessage = “UNABLE TO READ SPA”;<br />

}<br />

catch (<strong>IMS</strong>Exception e)<br />

{<br />

if (e.getStatusCode() !=<br />

Appendix F. IVP application — <strong>Java</strong> source (JDBC version) 333


<strong>Java</strong>ToDLI.MESSAGE_QUEUED_PRIOR_TO_LAST_START)<br />

throw e;<br />

}<br />

catch (Exception e)<br />

{<br />

errorMessage = “Could not load DLIDriver”;<br />

}<br />

if (errorMessage != null)<br />

{<br />

if (!msgQ.getNextMessage(inputMessage))<br />

// No input message received<br />

errorMessage = “NO INPUT MESSAGE”;<br />

else if ((spaMessage.getShort(“SessionNumber”)==0)<br />

&&<br />

(!inputMessage.getString(“ProcessCode”).trim().equals(“END”))<br />

&& (inputMessage.getString(“LastName”).trim().equals(““)))<br />

// New Conversation. User has to specify last name.<br />

errorMessage = “LAST NAME WAS NOT SPECIFIED”;<br />

else<br />

{<br />

try<br />

{<br />

procCode = inputMessage.getString(“ProcessCode”).trim();<br />

if (spaMessage.getShort(“SessionNumber”) !=0)<br />

{ // Check if process code is specified. If not, use SPA data<br />

// as default<br />

if (procCode.equals(““))<br />

inputMessage.setString(“ProcessCode”,<br />

spaMessage.getString(“ProcessCode”));<br />

// Check if last name is specified. If not, use SPA data as<br />

// default<br />

if (inputMessage.getString(“LastName”).equals(““))<br />

inputMessage.setString(“LastName”,<br />

spaMessage.getString(“LastName”));<br />

}<br />

// Determine which comm<strong>and</strong> was requested<br />

if (procCode.equals(“ADD”) || procCode.equals(“TADD”))<br />

add(inputMessage, outputMessage); // Add the entry to the<br />

// database<br />

else if (procCode.equals(“DELETE”))<br />

delete(inputMessage, outputMessage);// Delete the entry<br />

// from the database<br />

else if (procCode.equals(“UPDATE”))<br />

update(inputMessage, outputMessage);// Update the entry in<br />

// the database<br />

else if (procCode.equals(“DISPLAY”))<br />

display(inputMessage, outputMessage);// Display the data<br />

334 <strong>IMS</strong> <strong>Version</strong> 7 <strong>and</strong> <strong>Java</strong> <strong>Application</strong> <strong>Programming</strong>


}<br />

// from the database<br />

else<br />

errorMessage = “PROCESS CODE WAS INVALID”;<br />

}<br />

catch (Exception e)<br />

{<br />

outputMessage.setString(“Message”,<br />

“Request failed. “ + e.toString());<br />

}<br />

}<br />

}<br />

// Update the spa <strong>and</strong> send a response back to the user.<br />

updateSPA(inputMessage, spaMessage, procCode);<br />

if (errorMessage != null)<br />

outputMessage.setString(“Message”, errorMessage);<br />

reply(outputMessage, procCode);<br />

// Commit this transaction.<br />

<strong>IMS</strong>Transaction.getTransaction().commit();<br />

/** main entry point of the IVP program **/<br />

public static void main(String args[])<br />

{<br />

IVP ivp = new IVP();<br />

ivp.begin();<br />

}<br />

/**<br />

* Send a response back to the user.<br />

* @param outputMessage - the output message to be sent to user<br />

* @param procCode - the process code for this transaction<br />

*/<br />

public void reply(OutputMessage outputMessage, String procCode) throws<br />

<strong>IMS</strong>Exception<br />

{<br />

if (procCode.equals(“END”))<br />

outputMessage.setString(“Message”,”CONVERSATION HAS ENDED”);<br />

msgQ.insertMessage(outputMessage);<br />

}<br />

/**<br />

* Update the output message.<br />

* @param result - the segment info from the database<br />

* @param outputMessage - the output message to be updated<br />

*/<br />

public void setOutput(ResultSet result, OutputMessage outputMessage) throws<br />

SQLException, <strong>IMS</strong>Exception<br />

Appendix F. IVP application — <strong>Java</strong> source (JDBC version) 335


{<br />

}<br />

// Set output data fields<br />

outputMessage.setString(“LastName”,result.getString(“LastName”));<br />

outputMessage.setString(“FirstName”,result.getString(“FirstName”));<br />

outputMessage.setString(“Extension”,result.getString(“Extension”));<br />

outputMessage.setString(“ZipCode”,result.getString(“ZipCode”));<br />

/**<br />

* Update the output message.<br />

* @param inputMessage - the input message from the user<br />

* @param outputMessage - the output message to be updated<br />

*/<br />

public void setOutput(InputMessage inputMessage, OutputMessage<br />

outputMessage) throws <strong>IMS</strong>Exception<br />

{<br />

// Set output data fields<br />

outputMessage.setString(“ProcessCode”,<br />

inputMessage.getString(“ProcessCode”));<br />

outputMessage.setString(“LastName”,<br />

inputMessage.getString(“LastName”));<br />

outputMessage.setString(“FirstName”,<br />

inputMessage.getString(“FirstName”));<br />

outputMessage.setString(“Extension”,<br />

inputMessage.getString(“Extension”));<br />

outputMessage.setString(“ZipCode”,<br />

inputMessage.getString(“ZipCode”));<br />

}<br />

/**<br />

* Update an entry in the database.<br />

* @param inputMessage - the input message from the user<br />

* @param outputMessage - the output message for this transaction<br />

*/<br />

public void update(InputMessage inputMessage, OutputMessage outputMessage)<br />

throws <strong>IMS</strong>Exception<br />

{<br />

String firstName = inputMessage.getString(“FirstName”).trim();<br />

String lastName = inputMessage.getString(“LastName”).trim();<br />

String extension = inputMessage.getString(“Extension”).trim();<br />

String zip = inputMessage.getString(“ZipCode”).trim();<br />

// Check for input fields<br />

if (firstName.equals(““)<br />

|| lastName.equals(““)<br />

|| extension.equals(““)<br />

|| zip.equals(““))<br />

{ // Requested input data not enough<br />

336 <strong>IMS</strong> <strong>Version</strong> 7 <strong>and</strong> <strong>Java</strong> <strong>Application</strong> <strong>Programming</strong>


}<br />

outputMessage.setString(“Message”,<br />

”DATA IS NOT ENOUGH. PLEASE KEY IN MORE”);<br />

}<br />

else<br />

{<br />

try<br />

{ // Update the new entry<br />

Statement statement = connection.createStatement();<br />

statement.executeQuery(“UPDATE PhoneBookSegment<br />

SET FirstName = ‘” + firstName<br />

+ “‘, Extension = ‘” + extension<br />

+ “‘, ZipCode = ‘” +zip+“‘ “<br />

+ “WHERE LastName = ‘” + inputMessage.getString(“LastName”)<br />

+ “‘”);<br />

outputMessage.setString(“Message”,”ENTRY WAS UPDATED”);<br />

}<br />

catch (Exception e)<br />

{ // Error with the update<br />

outputMessage.setString(“Message”,”UPDATE OF ENTRY HAS FAILED”);<br />

}<br />

}<br />

// Update the output data<br />

setOutput(inputMessage, outputMessage);<br />

/**<br />

* Update the SPA message.<br />

* @param inputMessage - the input message from the user<br />

* @param spaMessage - the spa message to be updated<br />

*/<br />

public void updateSPA(InputMessage inputMessage, SPAMessage spaMessage,<br />

String procCode) throws <strong>IMS</strong>Exception<br />

{<br />

if (!procCode.equals(“END”))<br />

{<br />

// Set spa data fields<br />

spaMessage.setString(“ProcessCode”,inputMessage.getString(“ProcessCode”));<br />

spaMessage.setString(“LastName”,inputMessage.getString(“LastName”));<br />

spaMessage.setString(“FirstName”,inputMessage.getString(“FirstName”));<br />

spaMessage.setString(“Extension”,inputMessage.getString(“Extension”));<br />

spaMessage.setString(“ZipCode”,inputMessage.getString(“ZipCode”));<br />

spaMessage.incrementSessionNumber();<br />

msgQ.insertMessage(spaMessage);<br />

}<br />

Appendix F. IVP application — <strong>Java</strong> source (JDBC version) 337


}<br />

}<br />

else<br />

msgQ.insertMessage(spaMessage, true);<br />

338 <strong>IMS</strong> <strong>Version</strong> 7 <strong>and</strong> <strong>Java</strong> <strong>Application</strong> <strong>Programming</strong>


Appendix G. IVP application — COBOL source<br />

G.1 IVP application<br />

The application code for the Installation Verification Program (IVP), which is<br />

mentioned throughout this book, is listed here.<br />

More information about the IVP program can be found in the <strong>IMS</strong> V7<br />

Installation Volume 1: Installation <strong>and</strong> Verification, GC26-9429-00.<br />

IDENTIFICATION DIVISION.<br />

PROGRAM-ID. DFSIVA34.<br />

*<br />

********************************************************@SCPYRT**<br />

* *<br />

* Licensed Materials - Property of <strong>IBM</strong> *<br />

* *<br />

* “Restricted Materials of <strong>IBM</strong>” *<br />

* *<br />

* 5655-B01 (C) Copyright <strong>IBM</strong> Corp. 1991,1998 *<br />

* *<br />

********************************************************@ECPYRT**<br />

*<br />

* APPLICATION : CONVERSATIONAL PROGRAM<br />

* TRANSACTION : IVTCB<br />

* PSB : DFSIVP34<br />

* DATABASE : DFSIVD2<br />

* INPUT:<br />

* TELEPHONE DIRECTORY SYSTEM<br />

* PROCESS CODE : CCCCCCCC<br />

* LAST NAME : XXXXXXXXXX<br />

* FIRST NAME : XXXXXXXXXX<br />

* EXTENSION# : N-NNN-NNNN<br />

* INTERNAL ZIP : XXX/XXX<br />

* CCCCCCCC = COMMAND<br />

* ADD = INSERT ENTRY IN DB<br />

* DELETE = DELETE ENTRY FROM DB<br />

* UPDATE = UPDATE ENTRY FROM DB<br />

* DISPLAY = DISPLAY ENTRY<br />

* TADD = SAME AS ADD, BUT ALSO WRITE TO OPERATOR<br />

* END = TERMINATE CONVERSATION<br />

*<br />

* CHANGES: THIS MODULE IS NEW IN <strong>IMS</strong>/ESA 3.2<br />

* APAR... ID PREREQ. DATE.... DESCRIPTION...................<br />

* KNQ0115 01 11/17/91 ADD COBOL LANG VERSION<br />

© Copyright <strong>IBM</strong> Corp. 2001 339


*<br />

ENVIRONMENT DIVISION.<br />

CONFIGURATION SECTION.<br />

SOURCE-COMPUTER. <strong>IBM</strong>-370.<br />

OBJECT-COMPUTER. <strong>IBM</strong>-370.<br />

*<br />

DATA DIVISION.<br />

WORKING-STORAGE SECTION.<br />

* DL/I FUNCTION CODES<br />

77 GET-UNIQUE PICTURE X(4) VALUE ‘GU ‘.<br />

77 GET-HOLD-UNIQUE PICTURE X(4) VALUE ‘GHU ‘.<br />

77 GET-NEXT PICTURE X(4) VALUE ‘GN ‘.<br />

77 GET-HOLD-NEXT PICTURE X(4) VALUE ‘GHN ‘.<br />

77 DLET PICTURE X(4) VALUE ‘DLET’.<br />

77 ISRT PICTURE X(4) VALUE ‘ISRT’.<br />

77 REPL PICTURE X(4) VALUE ‘REPL’.<br />

* DL/I CALL STATUS CODES<br />

77 MESSAGE-EXIST PIC X(2) VALUE ‘CF’.<br />

77 NO-MORE-SEGMENT PIC X(2) VALUE ‘QD’.<br />

77 NO-MORE-MESSAGE PIC X(2) VALUE ‘QC’.<br />

* MESSAGES<br />

77 MDEL PICTURE X(40) VALUE<br />

‘ENTRY WAS DELETED ‘.<br />

77 MADD PICTURE X(40) VALUE<br />

‘ENTRY WAS ADDED ‘.<br />

77 MDIS PICTURE X(40) VALUE<br />

‘ENTRY WAS DISPLAYED ‘.<br />

77 MUPD PICTURE X(40) VALUE<br />

‘ENTRY WAS UPDATED ‘.<br />

77 MEND PICTURE X(40) VALUE<br />

‘CONVERSATION HAS ENDED ‘.<br />

77 MMORE PICTURE X(40) VALUE<br />

‘DATA IS NOT ENOUGH. PLEASE KEY IN MORE ‘.<br />

77 MINV PICTURE X(40) VALUE<br />

‘PROCESS CODE IS NOT VALID ‘.<br />

77 MNODATA PICTURE X(40) VALUE<br />

‘NO DATA WAS INPUT. PLEASE KEY IN MORE ‘.<br />

77 MNONAME PICTURE X(40) VALUE<br />

‘LAST NAME WAS NOT SPECIFIED ‘.<br />

77 MNOENT PICTURE X(40) VALUE<br />

340 <strong>IMS</strong> <strong>Version</strong> 7 <strong>and</strong> <strong>Java</strong> <strong>Application</strong> <strong>Programming</strong>


‘SPECIFIED PERSON WAS NOT FOUND ‘.<br />

77 MISRTE PICTURE X(40) VALUE<br />

‘ADDITION OF ENTRY HAS FAILED ‘.<br />

77 MDLETE PICTURE X(40) VALUE<br />

‘DELETION OF ENTRY HAS FAILED ‘.<br />

77 MREPLE PICTURE X(40) VALUE<br />

‘UPDATE OF ENTRY HAS FAILED ‘.<br />

* VARIABLES<br />

77 SSA1 PICTURE X(9) VALUE ‘A1111111 ‘.<br />

77 MODNAME PICTURE X(8) VALUE SPACES.<br />

77 TRAN-CODE PICTURE X(8) VALUE ‘IVTCB’.<br />

77 REPLY PICTURE X(16).<br />

77 TEMP-ONE PICTURE X(8) VALUE SPACES.<br />

77 TEMP-TWO PICTURE X(8) VALUE SPACES.<br />

* DATA AREA FOR TERMINAL INPUT<br />

01 INPUT-MSG.<br />

02 IN-LL PICTURE S9(3) COMP.<br />

02 IN-ZZ PICTURE S9(3) COMP.<br />

02 IN-FILL PICTURE X(4).<br />

02 IN-COMMAND PICTURE X(8).<br />

02 TEMP-COMMAND REDEFINES IN-COMMAND.<br />

04 TEMP-IOCMD PIC X(3).<br />

04 TEMP-FILLER PIC X(5).<br />

02 IN-LAST-NAME PICTURE X(10).<br />

02 IN-FIRST-NAME PICTURE X(10).<br />

02 IN-EXTENSION PICTURE X(10).<br />

02 IN-ZIP-CODE PICTURE X(7).<br />

* DATA AREA OUTPUT<br />

01 OUTPUT-AREA.<br />

02 OUT-LL PICTURE S9(3) COMP VALUE +95.<br />

02 OUT-ZZ PICTURE S9(3) COMP VALUE +0.<br />

02 OUTPUT-LINE PICTURE X(85) VALUE SPACES.<br />

02 OUTPUT-DATA REDEFINES OUTPUT-LINE.<br />

04 OUT-MESSAGE PIC X(40).<br />

04 OUT-COMMAND PIC X(8).<br />

04 OUT-DATA-TYPE.<br />

06 OUT-LAST-NAME PIC X(10).<br />

06 OUT-FIRST-NAME PIC X(10).<br />

06 OUT-EXTENSION PIC X(10).<br />

06 OUT-ZIP-CODE PIC X(7).<br />

02 OUT-SEGMENT-NO PICTURE X(4) VALUE ‘0001’.<br />

Appendix G. IVP application — COBOL source 341


* I/O AREA FOR DATA BASE HANDLING<br />

01 IOAREA.<br />

02 IO-LINE PICTURE X(37) VALUE SPACES.<br />

02 IO-DATA REDEFINES IO-LINE.<br />

04 IO-LAST-NAME PIC X(10).<br />

04 IO-FIRST-NAME PIC X(10).<br />

04 IO-EXTENSION PIC X(10).<br />

04 IO-ZIP-CODE PIC X(7).<br />

02 IO-FILLER PIC X(3) VALUE SPACES.<br />

02 IO-COMMAND PIC X(8) VALUE SPACES.<br />

* SCRATCH PAD AREA<br />

01 SPA.<br />

02 SPA-LL PICTURE X(2).<br />

02 SPA-ZZ PICTURE X(4).<br />

02 SPA-TRANCODE PICTURE X(8).<br />

02 SPA-CALL PICTURE X(2).<br />

02 SPA-COMMAND PICTURE X(8).<br />

02 SPA-DATA.<br />

04 SPA-LAST-NAME PIC X(10).<br />

04 SPA-FIRST-NAME PIC X(10).<br />

04 SPA-EXTENSION PIC X(10).<br />

04 SPA-ZIP-CODE PIC X(7).<br />

02 FILLER PICTURE X(19).<br />

* DC TEXT FOR ERROR CALL<br />

01 DC-TEXT.<br />

02 TEXT1 PIC X(7) VALUE ‘STATUS ‘.<br />

02 ERROR-STATUS PIC X(2).<br />

02 TEXT2 PIC X(12) VALUE ‘DLI CALL = ‘.<br />

02 ERROR-CALL PIC X(4).<br />

* SEGMENT SEARCH ARGUMENT<br />

01 SSA.<br />

02 SEGMENT-NAME PIC X(8) VALUE ‘A1111111’.<br />

02 SEG-KEY-NAME PIC X(11) VALUE ‘(A1111111 =’.<br />

02 SSA-KEY PIC X(10).<br />

02 FILLER PIC X VALUE ‘)’.<br />

* FLAGS<br />

01 FLAGS.<br />

342 <strong>IMS</strong> <strong>Version</strong> 7 <strong>and</strong> <strong>Java</strong> <strong>Application</strong> <strong>Programming</strong>


02 SET-DATA-FLAG PIC X VALUE ‘0’.<br />

88 NO-SET-DATA VALUE ‘1’.<br />

02 TADD-FLAG PIC X VALUE ‘0’.<br />

88 PROCESS-TADD VALUE ‘1’.<br />

* COUNTERS<br />

01 COUNTERS.<br />

02 SPA-CALL-NO PIC 9(2) COMP VALUE 0.<br />

02 L-SPACE-CTR PIC 9(2) COMP VALUE 0.<br />

LINKAGE SECTION.<br />

01 IOPCB.<br />

02 LTERM-NAME PICTURE X(8).<br />

02 FILLER PICTURE X(2).<br />

02 TPSTATUS PICTURE XX.<br />

02 FILLER PICTURE X(20).<br />

01 DBPCB.<br />

02 DBNAME PICTURE X(8).<br />

02 SEG-LEVEL-NO PICTURE X(2).<br />

02 DBSTATUS PICTURE XX.<br />

02 FILLER PICTURE X(20).<br />

PROCEDURE DIVISION USING IOPCB, DBPCB.<br />

ON ENTRY <strong>IMS</strong> PASSES ADDRESSES FOR IOPCB AND DBPCB<br />

MAIN-RTN.<br />

MOVE GET-UNIQUE TO ERROR-CALL.<br />

CALL ‘CBLTDLI’ USING GET-UNIQUE, IOPCB, SPA.<br />

IF TPSTATUS = ‘ ‘ OR MESSAGE-EXIST<br />

THEN<br />

CALL ‘CBLTDLI’ USING GET-NEXT, IOPCB, INPUT-MSG<br />

IF TPSTATUS = SPACES<br />

THEN PERFORM PROCESS-INPUT THRU PROCESS-INPUT-END<br />

ELSE IF TPSTATUS = NO-MORE-SEGMENT<br />

THEN GOBACK<br />

ELSE<br />

MOVE GET-NEXT TO ERROR-CALL<br />

PERFORM WRITE-DC-TEXT THRU WRITE-DC-TEXT-END<br />

ELSE IF TPSTATUS = NO-MORE-MESSAGE<br />

THEN GOBACK<br />

ELSE PERFORM WRITE-DC-TEXT THRU WRITE-DC-TEXT-END.<br />

GOBACK.<br />

PROCEDURE PROCESS-INPUT<br />

Appendix G. IVP application — COBOL source 343


PROCESS-INPUT.<br />

IF IN-LL < 5<br />

MOVE MNODATA TO OUT-MESSAGE<br />

PERFORM TERM-ROUTINE THRU TERM-ROUTINE-END.<br />

CHECK THE LEADING SPACE IN INPUT COMMAND AND TRIM IT OFF<br />

INSPECT IN-COMMAND TALLYING L-SPACE-CTR FOR LEADING SPACE<br />

REPLACING LEADING SPACE BY ‘*’.<br />

IF L-SPACE-CTR > 0<br />

UNSTRING IN-COMMAND DELIMITED BY ALL ‘*’ INTO TEMP-ONE<br />

TEMP-TWO<br />

MOVE TEMP-TWO TO IN-COMMAND<br />

MOVE 0 TO L-SPACE-CTR<br />

MOVE SPACES TO TEMP-TWO.<br />

CHECK THE LEADING SPACE IN INPUT LAST NAME AND TRIM IT OFF<br />

INSPECT IN-LAST-NAME TALLYING L-SPACE-CTR FOR LEADING<br />

SPACE REPLACING LEADING SPACE BY ‘*’.<br />

IF L-SPACE-CTR > 0<br />

UNSTRING IN-LAST-NAME DELIMITED BY ALL ‘*’ INTO TEMP-ONE<br />

TEMP-TWO<br />

MOVE TEMP-TWO TO IN-LAST-NAME<br />

MOVE 0 TO L-SPACE-CTR<br />

MOVE SPACES TO TEMP-TWO.<br />

* CHECK THE LEADING SPACE IN INPUT FIRST NAME AND TRIM IT OFF<br />

INSPECT IN-FIRST-NAME TALLYING L-SPACE-CTR FOR LEADING<br />

SPACE REPLACING LEADING SPACE BY ‘*’.<br />

IF L-SPACE-CTR > 0<br />

UNSTRING IN-FIRST-NAME DELIMITED BY ALL ‘*’ INTO TEMP-ONE<br />

TEMP-TWO<br />

MOVE TEMP-TWO TO IN-FIRST-NAME<br />

MOVE 0 TO L-SPACE-CTR<br />

MOVE SPACES TO TEMP-TWO.<br />

* CHECK THE LEADING SPACE IN INPUT EXTENSION AND TRIM IT OFF<br />

INSPECT IN-EXTENSION TALLYING L-SPACE-CTR FOR LEADING<br />

SPACE REPLACING LEADING SPACE BY ‘*’.<br />

IF L-SPACE-CTR > 0<br />

UNSTRING IN-EXTENSION DELIMITED BY ALL ‘*’ INTO TEMP-ONE<br />

TEMP-TWO<br />

MOVE TEMP-TWO TO IN-EXTENSION<br />

344 <strong>IMS</strong> <strong>Version</strong> 7 <strong>and</strong> <strong>Java</strong> <strong>Application</strong> <strong>Programming</strong>


*<br />

MOVE 0 TO L-SPACE-CTR<br />

MOVE SPACES TO TEMP-TWO.<br />

CHECK THE LEADING SPACE IN INPUT ZIP CODE AND TRIM IT OFF<br />

INSPECT IN-ZIP-CODE TALLYING L-SPACE-CTR FOR LEADING SPACE<br />

REPLACING LEADING SPACE BY ‘*’.<br />

IF L-SPACE-CTR > 0<br />

UNSTRING IN-ZIP-CODE DELIMITED BY ALL ‘*’ INTO TEMP-ONE<br />

TEMP-TWO<br />

MOVE TEMP-TWO TO IN-ZIP-CODE<br />

MOVE 0 TO L-SPACE-CTR<br />

MOVE SPACES TO TEMP-TWO.<br />

MOVE IN-LAST-NAME TO IO-LAST-NAME.<br />

MOVE IN-COMMAND TO IO-COMMAND.<br />

IF SPA-CALL-NO = 0<br />

MOVE IN-LAST-NAME TO IO-LAST-NAME<br />

MOVE IN-COMMAND TO IO-COMMAND<br />

ELSE IF IN-LAST-NAME EQUAL SPACES<br />

THEN MOVE SPA-LAST-NAME TO IO-LAST-NAME<br />

ELSE MOVE IN-LAST-NAME TO IO-LAST-NAME.<br />

IF IN-COMMAND EQUAL SPACES<br />

MOVE SPA-COMMAND TO IO-COMMAND<br />

ELSE<br />

MOVE IN-COMMAND TO IO-COMMAND.<br />

IF IO-COMMAND EQUAL SPACES<br />

THEN MOVE MINV TO OUT-MESSAGE<br />

PERFORM TERM-ROUTINE THRU TERM-ROUTINE-END<br />

ELSE IF IO-LAST-NAME EQUAL SPACES AND TEMP-IOCMD NOT = ‘END’<br />

THEN MOVE MNONAME TO OUT-MESSAGE<br />

PERFORM TERM-ROUTINE THRU TERM-ROUTINE-END<br />

ELSE IF TEMP-IOCMD EQUAL ‘ADD’<br />

THEN PERFORM TO-ADD THRU TO-ADD-END<br />

ELSE IF TEMP-IOCMD EQUAL ‘TAD’<br />

THEN MOVE 1 TO TADD-FLAG<br />

PERFORM TO-ADD THRU TO-ADD-END<br />

ELSE IF TEMP-IOCMD EQUAL ‘UPD’<br />

THEN PERFORM TO-UPD THRU TO-UPD-END<br />

ELSE IF TEMP-IOCMD EQUAL ‘DEL’<br />

THEN PERFORM TO-DEL THRU TO-DEL-END<br />

ELSE IF TEMP-IOCMD EQUAL ‘DIS’<br />

THEN PERFORM TO-DIS THRU TO-DIS-END<br />

ELSE IF TEMP-IOCMD EQUAL ‘END’<br />

THEN PERFORM TO-END THRU TO-END-END<br />

Appendix G. IVP application — COBOL source 345


ELSE<br />

MOVE MINV TO OUT-MESSAGE<br />

PERFORM TERM-ROUTINE THRU TERM-ROUTINE-END.<br />

PROCESS-INPUT-END.<br />

EXIT.<br />

* PROCEDURE TO-ADD : ADDITION REQUEST HANDLER<br />

TO-ADD.<br />

IF IO-LAST-NAME EQUAL SPA-LAST-NAME<br />

THEN MOVE SPA-DATA TO IO-DATA.<br />

IF IN-FIRST-NAME EQUAL SPACES OR<br />

IN-EXTENSION EQUAL SPACES OR<br />

IN-ZIP-CODE EQUAL SPACES<br />

THEN<br />

MOVE MMORE TO OUT-MESSAGE<br />

PERFORM TERM-ROUTINE THRU TERM-ROUTINE-END<br />

ELSE<br />

MOVE IN-FIRST-NAME TO IO-FIRST-NAME<br />

MOVE IN-EXTENSION TO IO-EXTENSION<br />

MOVE IN-ZIP-CODE TO IO-ZIP-CODE<br />

MOVE IO-DATA TO SPA-DATA<br />

MOVE IO-DATA TO OUT-DATA-TYPE<br />

MOVE IO-COMMAND TO OUT-COMMAND<br />

PERFORM ISRT-DB THRU ISRT-DB-END.<br />

TO-ADD-END.<br />

EXIT.<br />

* PROCEDURE TO-UPD : UPDATE REQUEST HANDLER<br />

TO-UPD.<br />

MOVE 0 TO SET-DATA-FLAG.<br />

MOVE IO-LAST-NAME TO SSA-KEY.<br />

PERFORM GET-HOLD-UNIQUE-DB THRU GET-HOLD-UNIQUE-DB-END.<br />

IF DBSTATUS = SPACES<br />

THEN<br />

IF IN-FIRST-NAME NOT = SPACES<br />

MOVE 1 TO SET-DATA-FLAG<br />

MOVE IN-FIRST-NAME TO IO-FIRST-NAME<br />

END-IF<br />

IF IN-EXTENSION NOT = SPACES<br />

MOVE 1 TO SET-DATA-FLAG<br />

MOVE IN-EXTENSION TO IO-EXTENSION<br />

END-IF<br />

IF IN-ZIP-CODE NOT = SPACES<br />

MOVE 1 TO SET-DATA-FLAG<br />

MOVE IN-ZIP-CODE TO IO-ZIP-CODE<br />

346 <strong>IMS</strong> <strong>Version</strong> 7 <strong>and</strong> <strong>Java</strong> <strong>Application</strong> <strong>Programming</strong>


END-IF<br />

MOVE IO-DATA TO OUT-DATA-TYPE.<br />

MOVE IO-COMMAND TO OUT-COMMAND.<br />

IF NO-SET-DATA<br />

THEN<br />

PERFORM REPL-DB THRU REPL-DB-END<br />

ELSE<br />

MOVE MNODATA TO OUT-MESSAGE<br />

PERFORM TERM-ROUTINE THRU TERM-ROUTINE-END.<br />

TO-UPD-END.<br />

EXIT.<br />

* PROCEDURE TO-DEL : DELETE REQUEST HANDLER<br />

TO-DEL.<br />

MOVE IO-LAST-NAME TO SSA-KEY.<br />

PERFORM GET-HOLD-UNIQUE-DB THRU GET-HOLD-UNIQUE-DB-END.<br />

IF DBSTATUS = SPACES<br />

THEN<br />

MOVE IO-DATA TO OUT-DATA-TYPE<br />

MOVE IO-COMMAND TO OUT-COMMAND<br />

PERFORM DLET-DB THRU DLET-DB-END.<br />

TO-DEL-END.<br />

EXIT.<br />

* PROCEDURE TO-DIS : DISPLAY REQUEST HANDLER<br />

TO-DIS.<br />

MOVE IO-LAST-NAME TO SSA-KEY.<br />

PERFORM GET-UNIQUE-DB THRU GET-UNIQUE-DB-END.<br />

IF DBSTATUS = SPACES<br />

THEN<br />

MOVE IO-DATA TO OUT-DATA-TYPE<br />

MOVE IO-COMMAND TO OUT-COMMAND<br />

MOVE MDIS TO OUT-MESSAGE<br />

PERFORM TERM-ROUTINE THRU TERM-ROUTINE-END.<br />

TO-DIS-END.<br />

EXIT.<br />

* PROCEDURE TO-END : END REQUEST HANDLER<br />

TO-END.<br />

MOVE SPACES TO SPA-TRANCODE.<br />

MOVE MEND TO OUT-MESSAGE.<br />

PERFORM TERM-ROUTINE THRU TERM-ROUTINE-END.<br />

TO-END-END.<br />

EXIT.<br />

Appendix G. IVP application — COBOL source 347


* PROCEDURE ISRT-DB : DATA BASE SEGMENT INSERT REQUEST HANDLER<br />

ISRT-DB.<br />

MOVE ISRT TO ERROR-CALL.<br />

CALL ‘CBLTDLI’ USING ISRT, DBPCB, IOAREA, SSA1.<br />

IF DBSTATUS = SPACES<br />

THEN<br />

IF PROCESS-TADD<br />

DISPLAY ‘INSERT IS DONE, REPLY’ UPON CONSOLE<br />

ACCEPT REPLY FROM CONSOLE<br />

MOVE 0 TO TADD-FLAG<br />

END-IF<br />

MOVE MADD TO OUT-MESSAGE<br />

PERFORM TERM-ROUTINE THRU TERM-ROUTINE-END<br />

ELSE<br />

MOVE MISRTE TO OUT-MESSAGE<br />

MOVE DBSTATUS TO ERROR-STATUS<br />

PERFORM WRITE-DC-TEXT THRU WRITE-DC-TEXT-END<br />

PERFORM TERM-ROUTINE THRU TERM-ROUTINE-END.<br />

ISRT-DB-END.<br />

EXIT.<br />

* PROCEDURE GET-UNIQUE-DB<br />

* DATA BASE SEGMENT GET-UNIQUE-DB REQUEST HANDLER<br />

GET-UNIQUE-DB.<br />

MOVE GET-UNIQUE TO ERROR-CALL.<br />

CALL ‘CBLTDLI’ USING GET-UNIQUE, DBPCB, IOAREA, SSA.<br />

IF DBSTATUS NOT = SPACES<br />

THEN<br />

MOVE MNOENT TO OUT-MESSAGE<br />

MOVE DBSTATUS TO ERROR-STATUS<br />

PERFORM WRITE-DC-TEXT THRU WRITE-DC-TEXT-END<br />

PERFORM TERM-ROUTINE THRU TERM-ROUTINE-END.<br />

GET-UNIQUE-DB-END.<br />

EXIT.<br />

* PROCEDURE GET-HOLD-UNIQUE-DB<br />

* DATA BASE SEGMENT GET-HOLD-UNIQUE-DB REQUEST HANDLER<br />

GET-HOLD-UNIQUE-DB.<br />

MOVE GET-HOLD-UNIQUE TO ERROR-CALL.<br />

CALL ‘CBLTDLI’ USING GET-HOLD-UNIQUE, DBPCB, IOAREA, SSA.<br />

IF DBSTATUS NOT = SPACES<br />

THEN<br />

MOVE MNOENT TO OUT-MESSAGE<br />

348 <strong>IMS</strong> <strong>Version</strong> 7 <strong>and</strong> <strong>Java</strong> <strong>Application</strong> <strong>Programming</strong>


MOVE DBSTATUS TO ERROR-STATUS<br />

PERFORM WRITE-DC-TEXT THRU WRITE-DC-TEXT-END<br />

PERFORM TERM-ROUTINE THRU TERM-ROUTINE-END.<br />

GET-HOLD-UNIQUE-DB-END.<br />

EXIT.<br />

* PROCEDURE REPL-DB : DATA BASE SEGMENT REPLACE REQUEST HANDLER<br />

REPL-DB.<br />

MOVE REPL TO ERROR-CALL.<br />

CALL ‘CBLTDLI’ USING REPL, DBPCB, IOAREA.<br />

IF DBSTATUS = SPACES<br />

THEN<br />

MOVE MUPD TO OUT-MESSAGE<br />

PERFORM TERM-ROUTINE THRU TERM-ROUTINE-END<br />

ELSE<br />

MOVE MREPLE TO OUT-MESSAGE<br />

MOVE DBSTATUS TO ERROR-STATUS<br />

PERFORM WRITE-DC-TEXT THRU WRITE-DC-TEXT-END<br />

PERFORM TERM-ROUTINE THRU TERM-ROUTINE-END.<br />

REPL-DB-END.<br />

EXIT.<br />

* PROCEDURE DLET-DB : DATA BASE SEGMENT DELETE REQUEST HANDLER<br />

DLET-DB.<br />

MOVE DLET TO ERROR-CALL.<br />

CALL ‘CBLTDLI’ USING DLET, DBPCB, IOAREA.<br />

IF DBSTATUS = SPACES<br />

THEN<br />

MOVE MDEL TO OUT-MESSAGE<br />

PERFORM TERM-ROUTINE THRU TERM-ROUTINE-END<br />

ELSE<br />

MOVE MDLETE TO OUT-MESSAGE<br />

MOVE DBSTATUS TO ERROR-STATUS<br />

PERFORM WRITE-DC-TEXT THRU WRITE-DC-TEXT-END<br />

PERFORM TERM-ROUTINE THRU TERM-ROUTINE-END.<br />

DLET-DB-END.<br />

EXIT.<br />

* PROCEDURE TERM-ROUTINE : TERMINAL ROUTINE<br />

TERM-ROUTINE.<br />

MOVE SPACES TO MODNAME.<br />

PERFORM INSERT-SPA THRU INSERT-SPA-END.<br />

IF IN-COMMAND = ‘END’<br />

MOVE TRAN-CODE TO MODNAME.<br />

Appendix G. IVP application — COBOL source 349


PERFORM INSERT-IO THRU INSERT-IO-END.<br />

TERM-ROUTINE-END.<br />

EXIT.<br />

* PROCEDURE INSERT-SPA : SPA INSERT FOR IOPCB REQUEST HANDLER<br />

INSERT-SPA.<br />

MOVE ISRT TO ERROR-CALL.<br />

MOVE IO-DATA TO SPA-DATA.<br />

MOVE IO-COMMAND TO SPA-COMMAND.<br />

ADD 1 TO SPA-CALL-NO.<br />

MOVE SPA-CALL-NO TO SPA-CALL.<br />

CALL ‘CBLTDLI’ USING ISRT, IOPCB, SPA.<br />

IF TPSTATUS NOT = SPACES<br />

THEN PERFORM WRITE-DC-TEXT THRU WRITE-DC-TEXT-END.<br />

INSERT-SPA-END.<br />

EXIT.<br />

* PROCEDURE INSERT-IO : INSERT FOR IOPCB REQUEST HANDLER<br />

INSERT-IO.<br />

MOVE ISRT TO ERROR-CALL.<br />

IF MODNAME EQUAL SPACES<br />

THEN<br />

CALL ‘CBLTDLI’ USING ISRT, IOPCB, OUTPUT-AREA<br />

ELSE<br />

CALL ‘CBLTDLI’ USING ISRT, IOPCB, OUTPUT-AREA, MODNAME<br />

MOVE SPACES TO MODNAME.<br />

IF TPSTATUS NOT = SPACES<br />

THEN PERFORM WRITE-DC-TEXT THRU WRITE-DC-TEXT-END.<br />

INSERT-IO-END.<br />

EXIT.<br />

* PROCEDURE WRITE-DC-TEXT : WRITE ERROR STATUS CODE<br />

WRITE-DC-TEXT.<br />

MOVE TPSTATUS TO ERROR-STATUS.<br />

DISPLAY DC-TEXT UPON CONSOLE.<br />

WRITE-DC-TEXT-END.<br />

EXIT.<br />

350 <strong>IMS</strong> <strong>Version</strong> 7 <strong>and</strong> <strong>Java</strong> <strong>Application</strong> <strong>Programming</strong>


Appendix H. Installing the IVP Phone application<br />

This appendix describes how to install the IVP Phone application.<br />

H.1 Installation verification process<br />

The following are example steps to verify an <strong>IMS</strong> <strong>Java</strong> install.<br />

1. Set up your profile.imsjava as shown in Figure 124.<br />

export <strong>IBM</strong><strong>IMS</strong>J_HOME=/usr/lpp/ims/imsjava71/classes.zip<br />

export CLASSPATH=$CLASSPATH:$<strong>IBM</strong><strong>IMS</strong>J_HOME<br />

#<br />

echo ‘*------------------------------------------------------*<br />

echo ‘ profile.imsjava executed ‘<br />

echo ‘*------------------------------------------------------*<br />

Figure 124. <strong>IMS</strong> <strong>Java</strong> profile sample<br />

2. Set up your user profile.<br />

3. Using OMVS foreground to compile <strong>and</strong> link the sample IVP:<br />

a. Go to the directory that <strong>IMS</strong> <strong>Java</strong> is installed in: cd<br />

usr/lpp/ims/imsjava71<br />

b. Compile the IVP java programs: javac samples/ivp/*.java<br />

4. Create the executable load module <strong>and</strong> put it in the IVP PGMLIB dataset<br />

(which should be pre-allocated <strong>and</strong> should be a PDSE):<br />

a. This can be done from OMVS, as shown in Figure 125.<br />

hpj samples.ivp.IVP -main =samples.ivp.IVP \<br />

-o="//'IVPEXEXX.PGMLIB(DFSIVP32)'" -alias=DFSIVP32 \<br />

-target=<strong>IMS</strong> \<br />

-leru opts="ENVAR(CLASSPATH=/usr/lpp/ims/imsjava7 :<br />

/usr/lpp/ims/imsjava7 /imsjava.dll:/usr/lpp/hpj/lib" \<br />

-exclude=com.ibm.ims.db.* \<br />

-exclude =com.ibm.ims.application.* \<br />

-exclude=com.ibm.ims.base.*<br />

Figure 125. HPJ comm<strong>and</strong> to create executable load<br />

© Copyright <strong>IBM</strong> Corp. 2001 351


. Or, it can be done using MVS BPXBATCH batch job, as shown in<br />

Figure 126 <strong>and</strong> Figure 127.<br />

//AUTOHPL JOB (@TS3,FA33),’ITSO <strong>IMS</strong> TEAM’,MSGCLASS=U,CLASS=A,<br />

// NOTIFY=&SYSUID,TIME=1440,REGION=0M<br />

/*JOBPARM S=SC47<br />

//* TYPRUN=SCAN<br />

//* ------------------------------------------------------------------<br />

//* EXECUTE SCRIPT<br />

//* ------------------------------------------------------------------<br />

//UXCALL EXEC PGM=BPXBATCH,REGION=0M,<br />

// PARM=’SH /u/imsres1/IVPhpj.ver1.st<strong>and</strong>alone’ IVP script<br />

//STEPLIB DD DISP=SHR,DSN=CEE.SCEERUN<br />

//STDENV DD DUMMY<br />

//STDIN DD DUMMY<br />

//************************************* THE OUTPUT *********<br />

//STDOUT DD PATH=’/u/imsres1/&SYSUID..autohpj.a082500.eout’,<br />

// PATHOPTS=(OWRONLY,OCREAT,OTRUNC),PATHMODE=SIRWXU<br />

//************************************* THE ERRORS *********<br />

//STDERR DD PATH=’/u/imsres1/&SYSUID..autohpj.a082500.eerr’,<br />

// PATHOPTS=(OWRONLY,OCREAT,OTRUNC),PATHMODE=SIRWXU<br />

//************************************* THE SYSOUT *********<br />

//SYSPRINT DD SYSOUT=*<br />

//* ------------------------------------------------------------------<br />

Figure 126. Sample MVS BPXBATCH JCL<br />

352 <strong>IMS</strong> <strong>Version</strong> 7 <strong>and</strong> <strong>Java</strong> <strong>Application</strong> <strong>Programming</strong>


echo BEGIN IVPhpj.ver1.st<strong>and</strong>alone<br />

date<br />

cd<br />

cd /u/imsres1<br />

. profile.imsjava<br />

. profile.imsres1<br />

cd<br />

cd usr/lpp/hpj/bin<br />

. profile.hpj<br />

#<br />

export <strong>IMS</strong>JAVA=/usr/lpp/ims/imsjava71<br />

export <strong>IMS</strong>JDLL=/usr/lpp/ims/imsjava71/imsjava.jll<br />

export <strong>IMS</strong>CLIB=/usr/lpp/ims/imsjava71/libJavTDLI.dll<br />

export <strong>IMS</strong>HPJ=/usr/lpp/hpj/lib<br />

export PATH=$PATH:/usr/lpp/hpj/bin<br />

echo <strong>IMS</strong>JAVA : $<strong>IMS</strong>JAVA<br />

echo <strong>IMS</strong>JDLL : $<strong>IMS</strong>JDLL<br />

echo <strong>IMS</strong>CLIB : $<strong>IMS</strong>CLIB<br />

echo <strong>IMS</strong>HPJ : $<strong>IMS</strong>HPJ<br />

echo PATH : $PATH<br />

#<br />

cd<br />

cd /u/imsres1/ims/imsjava71<br />

javac samples/ivp/IVP.java -verbose<br />

hpj samples.ivp.IVP \<br />

-main=samples.ivp.IVP \<br />

-o=”//’<strong>IMS</strong>.SJ<strong>IMS</strong>R.IVP.PGMLIB(DFSIVP32)’” -alias=DFSIVP32 \<br />

-target=<strong>IMS</strong> \<br />

-lerunopts=”ENVAR(CLASSPATH=$<strong>IMS</strong>JAVA:$<strong>IMS</strong>JDLL:$<strong>IMS</strong>CLIB:$<strong>IMS</strong>HPJ” \<br />

-verbose \<br />

-include=samples.ivp.IVPDatabaseView \<br />

-exclude=com.ibm.ims.db.* \<br />

-exclude=com.ibm.ims.application.* \<br />

-exclude=com.ibm.ims.base.*<br />

echo END IVPhpj.ver1.st<strong>and</strong>alone<br />

Figure 127. Sample IVP BPXBATCH Script<br />

5. Add the data set discussed above to the STEPLIB in the JCL that starts<br />

the <strong>IMS</strong> MPR region or <strong>IMS</strong> BMP region. In the Installation Verification<br />

Process, this data set must come before any other data set in the<br />

STEPLIB concatenation.<br />

STEPLIB DD DSN=IVPEXEXX.PGMLIB,DISP=SHR ==>> your program library<br />

Appendix H. Installing the IVP Phone application 353


6. Also include the dataset for the <strong>IMS</strong> <strong>Java</strong> class libraries <strong>and</strong> HPJ class<br />

libraries in the STEPLIB, as shown in Figure 128.<br />

DD DSN=hlq.SDFSJLIB,DISP=SHR<br />

DD DSN=VAJAVA.V3R0M0.SHPJMOD,DISP=SHR<br />

DD DSN=VAJAVA.V3R0M0.SHPOMOD,DISP=SHR<br />

Figure 128. Sample <strong>IMS</strong> <strong>Java</strong> class library <strong>and</strong> HPJ class libraries<br />

The HLQ (High Level Qualifier) is the PDSE which you specified during the<br />

installation process for <strong>IMS</strong> <strong>Java</strong>. You also need to change the <strong>Version</strong><br />

number of the HPJ to reflect the correct version of HPJ installed.<br />

7. On your <strong>IMS</strong> MTO, issue the following <strong>IMS</strong> comm<strong>and</strong>:<br />

/START <strong>IMS</strong>MSGx<br />

or<br />

/START <strong>IMS</strong>BMPx<br />

The comm<strong>and</strong>s above are just examples where you have built your JCL<br />

for Message Region (MPR) or Batch Message Region (BMP).<br />

8. Go to the <strong>IMS</strong> terminal <strong>and</strong> invoke the formatted screen for the<br />

transaction:<br />

/format IVTCC<br />

Note<br />

If you receive a DFS057 , the modname IVTCC might reside in your<br />

TFORMAT. Hence, issue the /TEST MFS first.<br />

354 <strong>IMS</strong> <strong>Version</strong> 7 <strong>and</strong> <strong>Java</strong> <strong>Application</strong> <strong>Programming</strong>


9. An input screen like the one in Figure 129 will be displayed.<br />

**************************************************<br />

* <strong>IMS</strong> INSTALLATION VERIFICATION PROCEDURE *<br />

**************************************************<br />

Figure 129. IVTCC input screen<br />

TRANSACTION TYPE : CONVERSATIONAL<br />

DATE : 09/01/00<br />

PROCESS CODE (*1) :<br />

LAST NAME :<br />

(*1) PROCESS CODE<br />

ADD<br />

DELETE<br />

FIRST NAME : UPDATE<br />

DISPLAY<br />

EXTENSION NUMBER : TADD<br />

END<br />

INTERNAL ZIP CODE :<br />

SEGMENT# :<br />

The result of the IVTCC DISPLAY Query will be as shown in Figure 130 <strong>and</strong><br />

Figure 131.<br />

Appendix H. Installing the IVP Phone application 355


Figure 130. IVTCC DISPLAY query<br />

Figure 131. IVTCC DISPLAY output query<br />

356 <strong>IMS</strong> <strong>Version</strong> 7 <strong>and</strong> <strong>Java</strong> <strong>Application</strong> <strong>Programming</strong><br />

**************************************************<br />

* <strong>IMS</strong> INSTALLATION VERIFICATION PROCEDURE *<br />

**************************************************<br />

TRANSACTION TYPE : CONVERSATIONAL<br />

DATE : 09/01/00<br />

PROCESS CODE (*1) : display<br />

LAST NAME : last1<br />

(*1) PROCESS CODE<br />

ADD<br />

DELETE<br />

FIRST NAME : UPDATE<br />

DISPLAY<br />

EXTENSION NUMBER : TADD<br />

END<br />

INTERNAL ZIP CODE :<br />

**************************************************<br />

* <strong>IMS</strong> INSTALLATION VERIFICATION PROCEDURE *<br />

**************************************************<br />

SEGMENT# :<br />

TRANSACTION TYPE : CONVERSATIONAL<br />

DATE : 09/01/00<br />

PROCESS CODE (*1) :<br />

LAST NAME : LAST1<br />

(*1) PROCESS CODE<br />

ADD<br />

DELETE<br />

FIRST NAME : FIRST1 UPDATE<br />

DISPLAY<br />

EXTENSION NUMBER : 8-111-1111 TADD<br />

END<br />

INTERNAL ZIP CODE : D01/R01<br />

ENTRY WAS DISPLAYED SEGMENT# :


Appendix I. Dealership sample application<br />

The dealership application mentioned throughout the book <strong>and</strong> the <strong>IMS</strong> <strong>Java</strong><br />

User’s Guide, SC27-0832-00 is outlined in detail in the following classes. This<br />

application was created using JDBC for calls to the <strong>IMS</strong> database. The auto<br />

dealership application contains the following methods:<br />

AcceptOrder Accepts an order.<br />

CancelOrder Cancels an order.<br />

FindACar Search for a car currently in stock.<br />

ListModels Lists all the models for every dealership.<br />

RecordASale Records a sale.<br />

ShowModelDetails Shows the details of a specific model.<br />

The application was broken down into the following two packages:<br />

- package dealership.database<br />

- package dealership.application<br />

The dealership.database package contains the following classes:<br />

Dealer Maps the Dealer segment.<br />

Model Maps the Model segment.<br />

Order Maps the Order segment.<br />

Sales Maps the Sales segment.<br />

Stock Maps the Stock segment.<br />

The dealership.application package contains the following classes:<br />

DealerDatabaseView Maps the database view of all the segments.<br />

<strong>IMS</strong>Auto The dealership application. It contains the<br />

main() method.<br />

InputMessage This is the default Input Message class. It<br />

defines the fields in the input message to the<br />

<strong>IMS</strong>Auto dealership application.<br />

OutputMessage This is the default Output Message class. It<br />

defines the fields in the output message to the<br />

<strong>IMS</strong>Auto dealership application.<br />

ErrorMessage The output message for error text.<br />

AcceptOrderInput This is an Input Message class. It defines the<br />

fields in the input message to the <strong>IMS</strong>Auto<br />

dealership application used to accept a car<br />

order.<br />

© Copyright <strong>IBM</strong> Corp. 2001 357


I.1 Dealer class<br />

OrderAccepted This is an Output Message class. It is the<br />

result of an accepted order<br />

CancelOrderInput This is an Input Message class. It defines the<br />

fields in the input message to the <strong>IMS</strong>Auto<br />

dealership application for cancelling an order.<br />

Cancelled This is an Output Message class. It is the<br />

message showing the results of cancelling an<br />

order.<br />

FindACarInput This is an Input Message class. It defines the<br />

fields in the input message to the <strong>IMS</strong>Auto<br />

dealership application to find a list of cars<br />

based on given information.<br />

CarFound This is an Output Message class. It contains<br />

the results after the find a car request.<br />

ListModelsInput This is an Input Message class. It defines the<br />

fields in the input message to the <strong>IMS</strong>Auto<br />

dealership application to list the cars in the<br />

database.<br />

ModelList This is an Output Message class. It contains<br />

the list of models.<br />

RecordASaleInput This is an Input Message class. It defines the<br />

fields in the input message to the <strong>IMS</strong>Auto<br />

dealership application specifying the<br />

information of a car sale.<br />

SalesRecord This is an Output Message class. It contains<br />

the result of recording a sale.<br />

ShowModelDetailsInput This is an Input Message class. It defines the<br />

fields in the input message to the <strong>IMS</strong>Auto<br />

dealership application requesting the details of<br />

a specified car model.<br />

ModelDetails This is an Output Message class. It contains<br />

the results after a show details request.<br />

package dealership.database;<br />

import com.ibm.ims.db.*;<br />

import com.ibm.ims.base.*;<br />

358 <strong>IMS</strong> <strong>Version</strong> 7 <strong>and</strong> <strong>Java</strong> <strong>Application</strong> <strong>Programming</strong>


public class Dealer extends DLISegment {<br />

}<br />

I.2 Model class<br />

static DLITypeInfo[] typeInfo = {<br />

new DLITypeInfo(“DealerNumber”, DLITypeInfo.CHAR,<br />

1, 4, “DLRNO”),<br />

new DLITypeInfo(“DealerName”, DLITypeInfo.CHAR,<br />

5, 30, “DLRNAME”),<br />

new DLITypeInfo(“DealerAddress”, DLITypeInfo.CHAR,<br />

35, 50),<br />

new DLITypeInfo(“YTDSales”, “9(10)”, DLITypeInfo.ZONEDDECIMAL,<br />

85, 10),<br />

};<br />

public Dealer() {<br />

super(“DEALER”, typeInfo, 94);<br />

}<br />

package dealership.database;<br />

import com.ibm.ims.db.*;<br />

import com.ibm.ims.base.*;<br />

public class Model extends DLISegment {<br />

static DLITypeInfo[] typeInfo = {<br />

new DLITypeInfo(“ModelTypeCode”, DLITypeInfo.CHAR,<br />

1, 2, “MODTYPE”),<br />

new DLITypeInfo(“CarMake”, DLITypeInfo.CHAR,<br />

3, 10, “MAKE”),<br />

new DLITypeInfo(“CarModel”, DLITypeInfo.CHAR,<br />

13, 10, “MODEL”),<br />

new DLITypeInfo(“CarYear”, DLITypeInfo.CHAR,<br />

23, 4, “YEAR”),<br />

new DLITypeInfo(“Price”, “99999”, DLITypeInfo.ZONEDDECIMAL,<br />

27, 5, “MSRP”),<br />

new DLITypeInfo(“EPACityMilage”, DLITypeInfo.CHAR,<br />

32, 4),<br />

new DLITypeInfo(“EPAHighwayMilage”, DLITypeInfo.CHAR,<br />

36, 4),<br />

new DLITypeInfo(“Horsepower”, DLITypeInfo.CHAR,<br />

40, 4),<br />

Appendix I. Dealership sample application 359


}<br />

I.3 Order class<br />

I.4 Sales class<br />

};<br />

public Model() {<br />

super(“MODEL”, typeInfo, 43);<br />

}<br />

package dealership.database;<br />

import com.ibm.ims.db.*;<br />

import com.ibm.ims.base.*;<br />

public class Order extends com.ibm.ims.db.DLISegment {<br />

static DLITypeInfo[] typeInfo = {<br />

new DLITypeInfo(“OrderNumber”, DLITypeInfo.CHAR,<br />

1, 6, “ORDNBR”),<br />

new DLITypeInfo(“Options”, DLITypeInfo.CHAR,<br />

7, 30),<br />

new DLITypeInfo(“Price”, “99999”, DLITypeInfo.ZONEDDECIMAL,<br />

37, 5),<br />

new DLITypeInfo(“OrderDate”, DLITypeInfo.CHAR,<br />

42, 8),<br />

new DLITypeInfo(“PurchaserLastName”, DLITypeInfo.CHAR,<br />

50, 25, “LASTNME”),<br />

new DLITypeInfo(“PurchaserFirstName”, DLITypeInfo.CHAR,<br />

75, 25, “FIRSTNME”),<br />

new DLITypeInfo(“SerialNo”, DLITypeInfo.CHAR,<br />

100, 20),<br />

new DLITypeInfo(“DeliverDate”, DLITypeInfo.CHAR,<br />

120, 8)<br />

};<br />

// Constructor.<br />

public Order() {<br />

super(“ORDER”, typeInfo, 127);<br />

}<br />

}<br />

package dealership.database;<br />

import com.ibm.ims.db.*;<br />

360 <strong>IMS</strong> <strong>Version</strong> 7 <strong>and</strong> <strong>Java</strong> <strong>Application</strong> <strong>Programming</strong>


I.5 Stock class<br />

import com.ibm.ims.base.*;<br />

public class Sales extends DLISegment {<br />

static DLITypeInfo[] typeInfo = {<br />

new DLITypeInfo(“DateSold”, DLITypeInfo.CHAR,<br />

1, 8, “SALDATE”),<br />

new DLITypeInfo(“PurchaserLastName”, DLITypeInfo.CHAR,<br />

9, 25, “LASTNME”),<br />

new DLITypeInfo(“PurchaserFirstName”, DLITypeInfo.CHAR,<br />

34, 25, “FIRSTNME”),<br />

new DLITypeInfo(“PurchaserAddress”, DLITypeInfo.CHAR,<br />

59, 25),<br />

new DLITypeInfo(“SoldBy”, DLITypeInfo.CHAR,<br />

84, 10),<br />

new DLITypeInfo(“StockVINumber”, DLITypeInfo.CHAR,<br />

94, 20, “STKVIN”),<br />

};<br />

// Constructor.<br />

public Sales() {<br />

super(“SALES”, typeInfo, 113);<br />

}<br />

}<br />

package dealership.database;<br />

import com.ibm.ims.db.*;<br />

import com.ibm.ims.base.*;<br />

public class Stock extends DLISegment {<br />

static DLITypeInfo[] typeInfo = {<br />

new DLITypeInfo(“StockVINumber”, DLITypeInfo.CHAR,<br />

1, 20, “STKVIN”),<br />

new DLITypeInfo(“DateIn”, DLITypeInfo.CHAR,<br />

21, 8),<br />

new DLITypeInfo(“DateOut”, DLITypeInfo.CHAR,<br />

29, 8),<br />

new DLITypeInfo(“Color”, DLITypeInfo.CHAR,<br />

37, 10, “COLOR”),<br />

new DLITypeInfo(“Price”, “99999”, DLITypeInfo.ZONEDDECIMAL,<br />

47, 5, “PRICE”),<br />

new DLITypeInfo(“Lot”, DLITypeInfo.CHAR,<br />

Appendix I. Dealership sample application 361


};<br />

52, 10, “LOT”)<br />

// Constructor.<br />

public Stock() {<br />

super(“STOCK”, typeInfo, 62);<br />

}<br />

}<br />

I.6 DealerDatabaseView class<br />

package dealership.application;<br />

import com.ibm.ims.db.*;<br />

import dealership.database.*;<br />

// The Database view of the all the segments.<br />

//<br />

// Dealer<br />

// |<br />

// |<br />

// |<br />

// Model<br />

// / | \<br />

// / | \<br />

// / | \<br />

// / | \<br />

// Order Sales Stock<br />

public class DealerDatabaseView extends DLIDatabaseView {<br />

static DLISegmentInfo[] segments = {<br />

new DLISegmentInfo(new Dealer(), DLIDatabaseView.ROOT),<br />

new DLISegmentInfo(new Model(), 0),<br />

new DLISegmentInfo(new Order(), 1),<br />

new DLISegmentInfo(new Sales(), 1),<br />

new DLISegmentInfo(new Stock(), 1),<br />

};<br />

// Constructor.<br />

public DealerDatabaseView() {<br />

super(“DEALPCB1”, segments);<br />

}<br />

}<br />

362 <strong>IMS</strong> <strong>Version</strong> 7 <strong>and</strong> <strong>Java</strong> <strong>Application</strong> <strong>Programming</strong>


I.7 <strong>IMS</strong>Auto class<br />

package dealership.application;<br />

/*<br />

* Classname <strong>IMS</strong>Auto<br />

* <strong>Version</strong> <strong>IMS</strong> 7.1<br />

* Date 4/14/2000<br />

*<br />

*-------------------------------------------------------------------<br />

*<br />

* APPLICATION : <strong>IMS</strong> <strong>Java</strong> sample program,<br />

*<br />

*<br />

* TRANSACTION : AUTOTRAN<br />

*<br />

* PSB : AUTOPSB<br />

*<br />

* DATABASE : DEALERDB<br />

*<br />

********************************************************************<br />

*<br />

*<br />

* Licensed Materials - Contains Property of <strong>IBM</strong><br />

*<br />

* (c) Copyright International Business Machines Corporation<br />

* 2000 All Rights Reserved.<br />

*<br />

* U. S. GOVERNMENT RESTRICTED RIGHTS<br />

*<br />

* U.S. Government Users Restricted Rights - Use, duplication,<br />

* or disclosure restricted by the GSA ADP Schedule Contract<br />

* with the <strong>IBM</strong> Corporation.<br />

*<br />

* DISCLAIMER OF WARRANTIES. The following enclosed code is<br />

* sample code created by <strong>IBM</strong> Corporation. This sample code is not<br />

* part of any st<strong>and</strong>ard or <strong>IBM</strong> product <strong>and</strong> is provided to you<br />

* solely for the purpose of assisting you in the development<br />

* of your applications. The code is provided “AS IS”, without<br />

* warranty of any kind. <strong>IBM</strong> shall not be liable for any damages<br />

* arising out of your use of the sample code, even if they have<br />

* been advised of the possibility of such damages.<br />

*<br />

*<br />

* “Restricted Materials of <strong>IBM</strong>”<br />

*<br />

Appendix I. Dealership sample application 363


* 5655-B01 (C) Copyright <strong>IBM</strong> Corp. 2000<br />

*<br />

*<br />

*/<br />

import com.ibm.ims.base.*;<br />

import com.ibm.ims.application.*;<br />

import java.sql.*;<br />

import java.io.*;<br />

public class <strong>IMS</strong>Auto extends <strong>IMS</strong><strong>Application</strong> {<br />

static {<br />

try {<br />

FileWriter fileWriter =<br />

new FileWriter(“/tmp/imsauto_itso.trace”);<br />

<strong>IMS</strong>Trace.setOutputWriter(fileWriter);<br />

} catch (Exception e) {<br />

<strong>IMS</strong>Trace.setOutputStream(System.err);<br />

}<br />

<strong>IMS</strong>Trace.libTraceLevel=<strong>IMS</strong>Trace.TRACE_DATA3;<br />

<strong>IMS</strong>Trace.traceOn = true;<br />

}<br />

// The application connection to the database.<br />

Connection connection = null;<br />

/**<br />

* Constructor.<br />

*/<br />

public <strong>IMS</strong>Auto() {<br />

super();<br />

}<br />

/**<br />

* This method is called when the user wants to accept an order.<br />

* When a customer accepts an order, the car’s “SerialNo” <strong>and</strong><br />

delivery dates are filled in.<br />

*<br />

* This is an example of an UPDATE.<br />

*/<br />

public <strong>IMS</strong>FieldMessage acceptOrder(AcceptOrderInput inputMessage)<br />

throws <strong>IMS</strong>Exception {<br />

OrderAccepted orderAccepted = new OrderAccepted();<br />

364 <strong>IMS</strong> <strong>Version</strong> 7 <strong>and</strong> <strong>Java</strong> <strong>Application</strong> <strong>Programming</strong>


}<br />

// Get the input parameters for SQL statement from the input message.<br />

String updateString = “UPDATE Order SET SerialNo = ‘”<br />

+ inputMessage.getString(“StockVINumber”).trim() + “‘, “<br />

+ “DeliverDate = ‘” + inputMessage.getString(“Date”).trim()<br />

+ “‘ WHERE OrderNumber = ‘”<br />

+ inputMessage.getString(“OrderNumber”).trim() + “‘”;<br />

try {<br />

Statement statement = connection.createStatement();<br />

if (statement.executeUpdate(updateString) == 1) {<br />

orderAccepted.setString(“ShortMessage”, “Order updated”);<br />

} else {<br />

<strong>IMS</strong>Transaction.getTransaction().rollback();<br />

orderAccepted.setString(“ShortMessage”, “Update failed”);<br />

}<br />

} catch (SQLException e) {<br />

return(reply (“Insert Failed:” + e.toString()));<br />

}<br />

return(orderAccepted);<br />

/**<br />

* Cancel an order.<br />

*<br />

* This is an example of a DELETE.<br />

*/<br />

public <strong>IMS</strong>FieldMessage cancelOrder(CancelOrderInput inputMessage)<br />

throws <strong>IMS</strong>Exception {<br />

Cancelled cancelled = new Cancelled();<br />

// Start with the basic “DELETE” fot SQL statement.<br />

StringBuffer queryString =<br />

new StringBuffer(“DELETE FROM Order WHERE “);<br />

// Get the input parameters from the input message.<br />

// Note: that we must have both parameters passed in order to<br />

// have a valid request.<br />

String desiredOrder =<br />

inputMessage.getString(“CancelOrderNumber”).trim();<br />

String desiredDealer =<br />

inputMessage.getString(“CancelDealerNumber”).trim();<br />

// Do the update only if both parameters exist.<br />

Appendix I. Dealership sample application 365


}<br />

if (!desiredOrder.equals(““) && !desiredDealer.equals(““)) {<br />

queryString.append(“OrderNumber = ‘” + desiredOrder + “‘”);<br />

queryString.append(“ AND “);<br />

queryString.append(“Dealer.DealerNumber = ‘”<br />

+ desiredDealer + “‘”);<br />

try {<br />

Statement statement = connection.createStatement();<br />

}<br />

366 <strong>IMS</strong> <strong>Version</strong> 7 <strong>and</strong> <strong>Java</strong> <strong>Application</strong> <strong>Programming</strong><br />

}<br />

// Do the delete - executeUpdate returns the number of orders<br />

// that were deleted (execute SQL statement).<br />

int results = statement.executeUpdate(queryString.toString());<br />

// Return the number of delete orders to the user.<br />

cancelled.setString(“Orders”, Integer.toString(results));<br />

catch (SQLException e) {<br />

return(reply (“Insert Failed:” + e.toString()));<br />

}<br />

// Invalid input - don’t do the request (return error message).<br />

else {<br />

cancelled.setString(“Orders”, “0”);<br />

}<br />

return(cancelled);<br />

/**<br />

* All <strong>IMS</strong> <strong>Java</strong> application logic is written by overriding<br />

* the doBegin method. The doBegin method is called from the<br />

* begin method.<br />

*/<br />

public void doBegin() throws <strong>IMS</strong>Exception {<br />

// The <strong>IMS</strong> messageQueue.<br />

<strong>IMS</strong>MessageQueue messageQueue = new <strong>IMS</strong>MessageQueue();<br />

// The generic inputMessage.<br />

InputMessage inputMessage = new InputMessage();<br />

// Get the input messages in a loop.<br />

// It processes these input messages until they are all processed.<br />

//<br />

// <strong>IMS</strong>MessageQueue.getUniqueMessage will check the status code <strong>and</strong>


eturns true if a message was retrieved <strong>and</strong> false if one was<br />

// not. It throws <strong>IMS</strong>Exception for true errors.<br />

//<br />

// This application is started when the message queue has a message<br />

// for it.<br />

//<br />

// This routine supports various types of input messages. It calls<br />

// additional methods based on the type of input messages it<br />

// received.<br />

//<br />

// Possible types of input messages are<br />

// ListModelsInput<br />

// ShowModelDetailsInput<br />

// FindACarInput<br />

// CancelOrderInput<br />

// RecordASaleInput<br />

// AcceptOrderInput<br />

while (messageQueue.getUniqueMessage(inputMessage)) {<br />

// Check to see if input was good <strong>and</strong> get Comm<strong>and</strong>Code.<br />

if (inputMessage.getMessageLength() > 0) {<br />

// Get a connection using the DLI JDBC driver.<br />

try {<br />

Class.forName(“com.ibm.ims.db.DLIDriver”);<br />

connection = DriverManager.getConnection<br />

(“jdbc:dli:dealership.application.DealerDatabaseView”);<br />

} catch (Exception e) {<br />

messageQueue.insertMessage<br />

(reply (“Connection not established”));<br />

}<br />

// Extract the comm<strong>and</strong>Code.<br />

String comm<strong>and</strong>Code =<br />

inputMessage.getString(“Comm<strong>and</strong>Code”).trim();<br />

// Do we really have a comm<strong>and</strong>Code?<br />

if (comm<strong>and</strong>Code.length() > 0) {<br />

// Determine which method to call <strong>and</strong> queue return results.<br />

// The comm<strong>and</strong>Code values will come into program in<br />

// uppercase.<br />

if (comm<strong>and</strong>Code.equalsIgnoreCase(“listModels”)) {<br />

messageQueue.insertMessage(listModels());<br />

} else if (comm<strong>and</strong>Code.equalsIgnoreCase(“findACar”)) {<br />

messageQueue.insertMessage<br />

(findACar(new FindACarInput(inputMessage)));<br />

Appendix I. Dealership sample application 367


{<br />

}<br />

}<br />

368 <strong>IMS</strong> <strong>Version</strong> 7 <strong>and</strong> <strong>Java</strong> <strong>Application</strong> <strong>Programming</strong><br />

} else if (comm<strong>and</strong>Code.equalsIgnoreCase(“showModelDetails”))<br />

messageQueue.insertMessage<br />

(showModelDetails<br />

(new ShowModelDetailsInput(inputMessage)));<br />

} else if (comm<strong>and</strong>Code.equalsIgnoreCase(“recordASale”)) {<br />

messageQueue.insertMessage<br />

(recordASale(new RecordASaleInput(inputMessage)));<br />

} else if (comm<strong>and</strong>Code.equalsIgnoreCase(“acceptOrder”)) {<br />

messageQueue.insertMessage<br />

(acceptOrder(new AcceptOrderInput(inputMessage)));<br />

} else if (comm<strong>and</strong>Code.equalsIgnoreCase(“cancelOrder”)) {<br />

messageQueue.insertMessage<br />

(cancelOrder(new CancelOrderInput(inputMessage)));<br />

} else {<br />

messageQueue.insertMessage<br />

(reply (“UNKNOWN COMMAND CODE”));<br />

}<br />

// Clear out the inputMessage for next message in queue.<br />

inputMessage.clearBody();<br />

} else {<br />

messageQueue.insertMessage(reply(“MISSING COMMAND CODE”));<br />

}<br />

} else {<br />

messageQueue.insertMessage(reply (“INVALID INPUT”));<br />

}<br />

// Do a commit before we process next message.<br />

<strong>IMS</strong>Transaction.getTransaction().commit();<br />

/**<br />

* Search for a car currently in stock at the dealership.<br />

*<br />

* This is an example of SELECT query where the fields of the resultset<br />

* are specified. Note that path information is specified<br />

* using the dot operator.<br />

*<br />

*/<br />

public <strong>IMS</strong>FieldMessage findACar(FindACarInput inputMessage)<br />

throws <strong>IMS</strong>Exception {<br />

CarFound carFound = new CarFound();


Start building the SQL statement - update it as we find<br />

// valid parameters.<br />

String queryString = “SELECT Color, Lot, Dealer.DealerName,”<br />

+ “ Model.CarMake, Model.CarModel,”<br />

+ “ Model.CarYear FROM Stock”;<br />

// Start creating the WHERE clause of SQL statement.<br />

StringBuffer whereClause = new StringBuffer(“ WHERE “);<br />

// Parameters is used to h<strong>and</strong>le the “ AND “ in the SQL statement.<br />

int parameters = 0;<br />

// Updated the query for Make.<br />

String desiredMake = inputMessage.getString(“Make”).trim();<br />

if (!desiredMake.equals(““)) {<br />

parameters++;<br />

whereClause.append(“Model.CarMake = ‘” + desiredMake + “‘”);<br />

}<br />

// Updated the query for Model.<br />

String desiredModel = inputMessage.getString(“Model”).trim();<br />

if (!desiredModel.equals(““)) {<br />

if (parameters > 0) {<br />

whereClause.append(“ AND “);<br />

}<br />

parameters++;<br />

whereClause.append(“Model.CarModel = ‘” + desiredModel + “‘”);<br />

}<br />

// Updated the query for Year.<br />

String desiredYear = inputMessage.getString(“Year”).trim();<br />

if (!desiredYear.equals(““)) {<br />

if (parameters > 0) {<br />

whereClause.append(“ AND “);<br />

}<br />

parameters++;<br />

whereClause.append(“Model.CarYear = ‘” + desiredYear + “‘”);<br />

}<br />

// Updated the query for Color.<br />

String desiredColor = inputMessage.getString(“Color”).trim();<br />

if (!desiredColor.equals(““)) {<br />

if (parameters > 0) {<br />

whereClause.append(“ AND “);<br />

}<br />

parameters++;<br />

Appendix I. Dealership sample application 369


}<br />

370 <strong>IMS</strong> <strong>Version</strong> 7 <strong>and</strong> <strong>Java</strong> <strong>Application</strong> <strong>Programming</strong><br />

whereClause.append(“Color = ‘” + desiredColor + “‘”);<br />

// Assume lowPrice is less than or equal to highPrice.<br />

double lowPrice = inputMessage.getDouble(“LowPrice”);<br />

double highPrice = inputMessage.getDouble(“HighPrice”);<br />

// Ensure that all prices are not less then zero<br />

if (lowPrice > 0) {<br />

if (parameters > 0) {<br />

whereClause.append(“ AND “);<br />

}<br />

parameters++;<br />

}<br />

// Note that this is the price from the Stock Segment.<br />

whereClause.append(“Price > “ + lowPrice);<br />

if (highPrice > 0) {<br />

if (parameters > 0) {<br />

whereClause.append(“ AND “);<br />

}<br />

parameters++;<br />

}<br />

// Note that this is the price from the Stock Segment.<br />

whereClause.append(“Price < “ + highPrice);<br />

// Append the where clause if needed.<br />

if (parameters > 0) {<br />

queryString = queryString + whereClause.toString();<br />

}<br />

// Do the query.<br />

try {<br />

Statement statement = connection.createStatement();<br />

ResultSet results = statement.executeQuery(queryString);<br />

// Counter to index through the carFound list.<br />

int counter = 0;<br />

// In loop, send back the result of the query as list<br />

// since multiple cars may be returned.<br />

while (results.next()) {<br />

// Increase counter for next car found.<br />

counter++;


}<br />

}<br />

carFound.setString(“Cars.” + counter +”.DealerName”,<br />

results.getString(“DealerName”).trim());<br />

carFound.setString(“Cars.” + counter +”.CarMake”,<br />

results.getString(“CarMake”).trim());<br />

carFound.setString(“Cars.” + counter +”.CarModel”,<br />

results.getString(“CarModel”).trim());<br />

carFound.setString(“Cars.” + counter +”.CarYear”,<br />

results.getString(“CarYear”).trim());<br />

carFound.setString(“Cars.” + counter +”.Lot”,<br />

results.getString(“Lot”).trim());<br />

carFound.setString(“Cars.” + counter +”.Price”,<br />

results.getString(“Price”).trim());<br />

// Check if any cars were found.<br />

if (counter == 0) {<br />

return(reply (“NO CAR FOUND”));<br />

}<br />

// Record the number of actual entries in the carFound message.<br />

carFound.setInt(“Count”, counter);<br />

} catch (SQLException e) {<br />

return(reply (“Query Failed:” + e.toString()));<br />

}<br />

return(carFound);<br />

/**<br />

* List all of the models being sold by this dealership.<br />

* This an example of a SELECT query a WHERE clause.<br />

*/<br />

public <strong>IMS</strong>FieldMessage listModels() throws <strong>IMS</strong>Exception {<br />

ModelList modelList = new ModelList();<br />

// Create the SQL statement - no inputs needed.<br />

String queryString = “SELECT * FROM Model”;<br />

// Do the query.<br />

try {<br />

Statement statement = connection.createStatement();<br />

ResultSet results = statement.executeQuery(queryString);<br />

// Counter to index through the carFound list.<br />

int counter = 0;<br />

Appendix I. Dealership sample application 371


}<br />

372 <strong>IMS</strong> <strong>Version</strong> 7 <strong>and</strong> <strong>Java</strong> <strong>Application</strong> <strong>Programming</strong><br />

// In loop, send back the result of the query.<br />

while (results.next()) {<br />

counter++;<br />

modelList.setString(“Cars.” + counter + “.ModelTypeCode”,<br />

results.getString(“ModelTypeCode”).trim());<br />

modelList.setString(“Cars.” + counter + “.CarMake”,<br />

results.getString(“CarMake”).trim());<br />

modelList.setString(“Cars.” + counter + “.CarModel”,<br />

results.getString(“CarModel”).trim());<br />

modelList.setString(“Cars.” + counter + “.CarYear”,<br />

results.getString(“CarYear”).trim());<br />

}<br />

// Record the number of actual entries in the modelList message.<br />

modelList.setInt(“Count”, counter);<br />

} catch (SQLException e) {<br />

return(reply (“Query Failed:” + e.toString()));<br />

}<br />

return(modelList);<br />

/**<br />

* Main.<br />

*/<br />

public static void main(String args []) {<br />

}<br />

<strong>IMS</strong>Auto imsauto = new <strong>IMS</strong>Auto();<br />

// ‘begin’ is a method of the abstract base class, <strong>IMS</strong><strong>Application</strong>.<br />

// It does initialization, calls doBegin, <strong>and</strong> does termination<br />

// processing.<br />

imsauto.begin();<br />

/**<br />

* This method is called when the user wants to record an sale.<br />

* This is an example of INSERT. Note that the where clause is needed to<br />

* specify the path. This is unique to <strong>IMS</strong> <strong>Java</strong>.<br />

*/<br />

public <strong>IMS</strong>FieldMessage recordASale(RecordASaleInput inputMessage)<br />

throws <strong>IMS</strong>Exception {<br />

SalesRecord salesRecord = new SalesRecord();


}<br />

// Create the SQL statement.<br />

String insertString = “INSERT INTO Sales “<br />

+ “(DateSold, PurchaserLastName, PurchaserFirstName, “<br />

+ “PurchaserAddress, SoldBy, StockVINumber) VALUES (‘”<br />

+ inputMessage.getString(“Date”).trim() + “‘, ‘”<br />

+ inputMessage.getString(“BuyerLastName”).trim() + “‘, ‘”<br />

+ inputMessage.getString(“BuyerFirstName”).trim() + “‘, ‘”<br />

+ inputMessage.getString(“BuyerAddress”).trim() + “‘, ‘”<br />

+ inputMessage.getString(“SoldBy”).trim() + “‘, ‘”<br />

+ inputMessage.getString(“StockVINumber”).trim() + “‘)”<br />

+ “ WHERE Dealer.DealerNumber = ‘”<br />

+ inputMessage.getString(“DealerNumber”).trim()<br />

+ “‘ AND Model.ModelTypeCode = ‘”<br />

+ inputMessage.getString(“ModelTypeCode”).trim() + “‘”;<br />

// Do the query.<br />

try {<br />

Statement statement = connection.createStatement();<br />

if (statement.executeUpdate(insertString) == 1) {<br />

// Success.<br />

salesRecord.setString(“ShortMessage”, “Sales recorded”);<br />

} else {<br />

// Failure.<br />

<strong>IMS</strong>Transaction.getTransaction().rollback();<br />

salesRecord.setString(“ShortMessage”, “Sales not accepted”);<br />

}<br />

} catch (SQLException e) {<br />

return(reply (“Insert Failed:” + e.toString()));<br />

}<br />

return(salesRecord);<br />

/**<br />

* This method is called when to send reply with an error message.<br />

*/<br />

public <strong>IMS</strong>FieldMessage reply(String errmsg) throws <strong>IMS</strong>Exception {<br />

ErrorMessage errorMessage = new ErrorMessage();<br />

// Build an error message from a string.<br />

errorMessage.setString(“MessageText”, errmsg);<br />

Appendix I. Dealership sample application 373


}<br />

return(errorMessage);<br />

/**<br />

* Show the details of a particular model - this comm<strong>and</strong><br />

* works with the listModels comm<strong>and</strong> for a “drill down”<br />

* type of query.<br />

*<br />

* This is an example of a SELECT query with a WHERE clause.<br />

*<br />

*/<br />

public <strong>IMS</strong>FieldMessage showModelDetails<br />

(ShowModelDetailsInput inputMessage)<br />

throws <strong>IMS</strong>Exception {<br />

ModelDetails modelDetails = new ModelDetails();<br />

// Build the SQL query.<br />

String queryString = “SELECT * FROM Model WHERE ModelTypeCode = ‘”<br />

+ inputMessage.getString(“ModelTypeCode”) +“‘”;<br />

// Do the query.<br />

try {<br />

Statement statement = connection.createStatement();<br />

ResultSet results = statement.executeQuery(queryString);<br />

374 <strong>IMS</strong> <strong>Version</strong> 7 <strong>and</strong> <strong>Java</strong> <strong>Application</strong> <strong>Programming</strong><br />

// Send back the result of the query.<br />

if (results.next()) {<br />

modelDetails.setString(“CarMake”,<br />

results.getString(“CarMake”).trim());<br />

modelDetails.setString(“ModelTypeCode”,<br />

results.getString(“ModelTypeCode”).trim());<br />

modelDetails.setString(“CarModel”,<br />

results.getString(“CarModel”).trim());<br />

modelDetails.setString(“CarYear”,<br />

results.getString(“CarYear”).trim());<br />

modelDetails.setString(“Price”,<br />

results.getString(“Price”).trim());<br />

modelDetails.setString(“EPACityMilage”,<br />

results.getString(“EPACityMilage”).trim());<br />

modelDetails.setString(“EPAHighwayMilage”,<br />

results.getString(“EPAHighwayMilage”).trim());<br />

modelDetails.setString(“HorsePower”,<br />

results.getString(“HorsePower”).trim());<br />

} else {<br />

return(reply (“UNKNOWN TYPE”));


I.8 InputMessage class<br />

}<br />

}<br />

}<br />

} catch (SQLException e) {<br />

return(reply (“showModelDetails - Query Failed:” + e.toString()));<br />

}<br />

return(modelDetails);<br />

package dealership.application;<br />

import com.ibm.ims.base.*;<br />

import com.ibm.ims.application.*;<br />

/**<br />

* This is the default Input Message class. It defines the<br />

* fields in the input message to the <strong>IMS</strong>Auto dealership<br />

* application.<br />

*/<br />

public class InputMessage extends <strong>IMS</strong>FieldMessage {<br />

final static DLITypeInfo[] fieldInfo = {<br />

new DLITypeInfo(“Comm<strong>and</strong>Code”, DLITypeInfo.CHAR, 1, 20),<br />

};<br />

// Constructor.<br />

public InputMessage() {<br />

super(fieldInfo, 141, false);<br />

}<br />

}<br />

I.9 OutputMessage class<br />

package dealership.application;<br />

import com.ibm.ims.db.*;<br />

import com.ibm.ims.base.*;<br />

import com.ibm.ims.application.*;<br />

/**<br />

* This is the Output Message class<br />

*/<br />

Appendix I. Dealership sample application 375


I.10 ErrorMessage class<br />

public class OutputMessage extends <strong>IMS</strong>FieldMessage {<br />

final static DLITypeInfo[] fieldInfo = {<br />

// common field to identify the type of output messages<br />

//<br />

// possible values could be<br />

// errormsg error messsages<br />

// qmodrlts result of comm<strong>and</strong> code = qmodels<br />

// canorlt result of comm<strong>and</strong> code = canorder<br />

// roster result of comm<strong>and</strong> code = salestaff<br />

new DLITypeInfo (“MessageType”, DLITypeInfo.CHAR, 1, 10),<br />

}<br />

// fields used for error message (errormsg)<br />

new DLITypeInfo (“MessageText”, DLITypeInfo.CHAR, 11, 246),<br />

// fields used to return results after a query models (qmodrlts)<br />

new DLITypeInfo (“ModelType”, DLITypeInfo.CHAR, 11, 1),<br />

new DLITypeInfo (“ModelColor”, DLITypeInfo.CHAR, 12, 10),<br />

new DLITypeInfo (“Price”, DLITypeInfo.DOUBLE, 22, 8),<br />

new DLITypeInfo (“Doors”, DLITypeInfo.INTEGER, 30, 4),<br />

// fields used to return results of canceling a order (canorlt)<br />

new DLITypeInfo (“Canceled”, DLITypeInfo.INTEGER, 11, 4),<br />

new DLITypeInfo (“CancelMessage”, DLITypeInfo.CHAR, 15, 30),<br />

// fields used to return results of query on sales staff roster)<br />

new DLITypeInfo (“StaffSize”, DLITypeInfo.INTEGER, 11, 4),<br />

};<br />

public OutputMessage()<br />

{<br />

super(fieldInfo, 256, false);<br />

}<br />

package dealership.application;<br />

import com.ibm.ims.base.*;<br />

import com.ibm.ims.application.*;<br />

/**<br />

* Output message for error text.<br />

*/<br />

public class ErrorMessage extends <strong>IMS</strong>FieldMessage {<br />

376 <strong>IMS</strong> <strong>Version</strong> 7 <strong>and</strong> <strong>Java</strong> <strong>Application</strong> <strong>Programming</strong>


final static DLITypeInfo[] fieldInfo = {<br />

new DLITypeInfo (“MessageText”, DLITypeInfo.CHAR, 1, 80)<br />

};<br />

// Constructor.<br />

public ErrorMessage() {<br />

super(fieldInfo, 79, false);<br />

}<br />

}<br />

I.11 AcceptOrderInput class<br />

package dealership.application;<br />

import com.ibm.ims.base.*;<br />

import com.ibm.ims.application.*;<br />

/**<br />

* This is an Input Message class. It defines the fields in the<br />

* input message to the <strong>IMS</strong>Auto dealership application used to<br />

* accept a car order.<br />

*/<br />

public class AcceptOrderInput extends <strong>IMS</strong>FieldMessage {<br />

final static DLITypeInfo[] fieldInfo = {<br />

new DLITypeInfo(“Comm<strong>and</strong>Code”, DLITypeInfo.CHAR, 1, 20),<br />

new DLITypeInfo(“OrderNumber”, DLITypeInfo.CHAR, 21, 6),<br />

new DLITypeInfo(“Date”, DLITypeInfo.CHAR, 27, 8),<br />

new DLITypeInfo(“StockVINumber”, DLITypeInfo.CHAR, 35, 20),<br />

};<br />

// Constructor.<br />

public AcceptOrderInput(InputMessage inputMessage) {<br />

super(inputMessage, fieldInfo);<br />

}<br />

}<br />

I.12 OrderAccepted class<br />

package dealership.application;<br />

import com.ibm.ims.base.*;<br />

import com.ibm.ims.application.*;<br />

/**<br />

* Result of accepted order.<br />

Appendix I. Dealership sample application 377


*/<br />

public class OrderAccepted extends <strong>IMS</strong>FieldMessage {<br />

final static DLITypeInfo[] fieldInfo = {<br />

new DLITypeInfo (“ShortMessage”, DLITypeInfo.CHAR, 1, 80)<br />

};<br />

// Constructor.<br />

public OrderAccepted() {<br />

super(fieldInfo, 79, false);<br />

}<br />

}<br />

I.13 CancelOrderInput class<br />

I.14 Cancelled class<br />

package dealership.application;<br />

import com.ibm.ims.base.*;<br />

import com.ibm.ims.application.*;<br />

/**<br />

* This is an Input Message class. It defines the fields in the<br />

* input message to the <strong>IMS</strong>Auto dealership application for<br />

* cancelling an order.<br />

*/<br />

public class CancelOrderInput extends <strong>IMS</strong>FieldMessage {<br />

final static DLITypeInfo[] fieldInfo = {<br />

new DLITypeInfo(“Comm<strong>and</strong>Code”, DLITypeInfo.CHAR, 1, 20),<br />

new DLITypeInfo(“CancelOrderNumber”, DLITypeInfo.CHAR, 21, 6),<br />

new DLITypeInfo(“CancelDealerNumber”, DLITypeInfo.CHAR, 27, 4),<br />

};<br />

// Constructor.<br />

public CancelOrderInput(InputMessage inputMessage) {<br />

super(inputMessage, fieldInfo);<br />

}<br />

}<br />

package dealership.application;<br />

import com.ibm.ims.base.*;<br />

import com.ibm.ims.application.*;<br />

/**<br />

378 <strong>IMS</strong> <strong>Version</strong> 7 <strong>and</strong> <strong>Java</strong> <strong>Application</strong> <strong>Programming</strong>


* Message showing the results of canceling a order<br />

*/<br />

public class Cancelled extends <strong>IMS</strong>FieldMessage {<br />

final static DLITypeInfo[] fieldInfo = {<br />

// Number of orders successfully deleted.<br />

new DLITypeInfo (“Orders”, DLITypeInfo.CHAR, 1, 4)<br />

};<br />

// Constructor.<br />

public Cancelled(){<br />

super(fieldInfo, 34, false);<br />

}<br />

}<br />

I.15 FindACarInput class<br />

package dealership.application;<br />

import com.ibm.ims.base.*;<br />

import com.ibm.ims.application.*;<br />

/**<br />

* This is an Input Message class. It defines the fields in the<br />

* input message to the <strong>IMS</strong>Auto dealership application to find a<br />

* list of cars based on given information.<br />

*/<br />

public class FindACarInput extends <strong>IMS</strong>FieldMessage {<br />

final static DLITypeInfo[] fieldInfo = {<br />

new DLITypeInfo(“Comm<strong>and</strong>Code”, DLITypeInfo.CHAR, 1, 20),<br />

new DLITypeInfo(“Make”, DLITypeInfo.CHAR, 21, 10),<br />

new DLITypeInfo(“Model”, DLITypeInfo.CHAR, 31, 10),<br />

new DLITypeInfo(“Year”, DLITypeInfo.CHAR, 41, 4),<br />

new DLITypeInfo(“LowPrice”, DLITypeInfo.CHAR, 45, 5),<br />

new DLITypeInfo(“HighPrice”, DLITypeInfo.CHAR, 50, 5),<br />

new DLITypeInfo(“Color”, DLITypeInfo.CHAR, 55, 10),<br />

};<br />

// Constructor.<br />

public FindACarInput(InputMessage inputMessage) {<br />

super(inputMessage, fieldInfo);<br />

}<br />

}<br />

Appendix I. Dealership sample application 379


I.16 Carfound class<br />

package dealership.application;<br />

import com.ibm.ims.base.*;<br />

import com.ibm.ims.application.*;<br />

/**<br />

* Results after find a car request.<br />

*/<br />

public class CarFound extends <strong>IMS</strong>FieldMessage {<br />

// This defines the fields needed to stored an individual car.<br />

final static DLITypeInfo[] fieldInfo = {<br />

new DLITypeInfo (“DealerName”, DLITypeInfo.CHAR, 1, 30),<br />

new DLITypeInfo (“CarMake”, DLITypeInfo.CHAR, 31, 10),<br />

new DLITypeInfo (“CarModel”, DLITypeInfo.CHAR, 41, 10),<br />

new DLITypeInfo (“CarYear”, DLITypeInfo.CHAR, 51, 4),<br />

new DLITypeInfo (“Lot”, DLITypeInfo.CHAR, 55, 10)<br />

};<br />

// This defines the fields needed to stored a list of 100 cars that are<br />

// individually instantiated as “fieldInfo” defined above.<br />

final static DLITypeInfo[] fieldListInfo = {<br />

new DLITypeInfo (“Count”, DLITypeInfo.INTEGER, 1, 4),<br />

new DLITypeInfoList (“Cars”, fieldInfo, 5, 64, 100),<br />

};<br />

// Constructor.<br />

public CarFound() {<br />

super(fieldListInfo, 6404, false);<br />

}<br />

}<br />

I.17 ListModelsInput class<br />

package dealership.application;<br />

import com.ibm.ims.base.*;<br />

import com.ibm.ims.application.*;<br />

/**<br />

* This is an Input Message class. It defines the fields in the<br />

* input message to the <strong>IMS</strong>Auto dealership application to list<br />

* the cars in the database.<br />

*/<br />

public class ListModelsInput extends <strong>IMS</strong>FieldMessage {<br />

380 <strong>IMS</strong> <strong>Version</strong> 7 <strong>and</strong> <strong>Java</strong> <strong>Application</strong> <strong>Programming</strong>


I.18 ModelList class<br />

final static DLITypeInfo[] fieldInfo = {<br />

new DLITypeInfo(“Comm<strong>and</strong>Code”, DLITypeInfo.CHAR, 1, 20),<br />

};<br />

// Constructor.<br />

public ListModelsInput(InputMessage inputMessage) {<br />

super(inputMessage, fieldInfo);<br />

}<br />

}<br />

package dealership.application;<br />

import com.ibm.ims.base.*;<br />

import com.ibm.ims.application.*;<br />

/**<br />

* List of Models.<br />

*/<br />

public class ModelList extends <strong>IMS</strong>FieldMessage {<br />

// This defines the fields needed to stored an individual car.<br />

final static DLITypeInfo[] fieldInfo = {<br />

new DLITypeInfo (“ModelTypeCode”, DLITypeInfo.CHAR, 1, 2),<br />

new DLITypeInfo (“CarMake”, DLITypeInfo.CHAR, 3, 10),<br />

new DLITypeInfo (“CarModel”, DLITypeInfo.CHAR, 13, 10),<br />

new DLITypeInfo (“CarYear”, DLITypeInfo.CHAR, 23, 4)<br />

};<br />

// This defines the fields needed to stored a list of 100 cars that<br />

// are individually instantiated as “DLITypeInfo[]” above.<br />

final static DLITypeInfo[] fieldListInfo = {<br />

new DLITypeInfo (“Count”, DLITypeInfo.INTEGER, 1, 4),<br />

new DLITypeInfoList (“Cars”, fieldInfo, 5, 26, 100)<br />

};<br />

// Constructor.<br />

public ModelList() {<br />

super(fieldListInfo, 2604, false);<br />

}<br />

}<br />

Appendix I. Dealership sample application 381


I.19 RecordASaleInput class<br />

I.20 SalesRecord class<br />

package dealership.application;<br />

import com.ibm.ims.base.*;<br />

import com.ibm.ims.application.*;<br />

/**<br />

* This is an Input Message class. It defines the fields in the<br />

* input message to the <strong>IMS</strong>Auto dealership application specifying<br />

* the information of a car sale.<br />

*/<br />

public class RecordASaleInput extends <strong>IMS</strong>FieldMessage {<br />

final static DLITypeInfo[] fieldInfo = {<br />

new DLITypeInfo(“Comm<strong>and</strong>Code”, DLITypeInfo.CHAR, 1, 20),<br />

new DLITypeInfo(“DealerNumber”, DLITypeInfo.CHAR, 21, 4),<br />

new DLITypeInfo(“ModelTypeCode”, DLITypeInfo.CHAR, 25, 2),<br />

new DLITypeInfo(“Date”, DLITypeInfo.CHAR, 27, 8),<br />

new DLITypeInfo(“BuyerLastName”, DLITypeInfo.CHAR, 35, 25),<br />

new DLITypeInfo(“BuyerFirstName”, DLITypeInfo.CHAR, 60, 25),<br />

new DLITypeInfo(“BuyerAddress”, DLITypeInfo.CHAR, 85, 25),<br />

new DLITypeInfo(“SoldBy”, DLITypeInfo.CHAR, 110, 10),<br />

new DLITypeInfo(“StockVINumber”, DLITypeInfo.CHAR, 120, 20),<br />

};<br />

// Constructor.<br />

public RecordASaleInput(InputMessage inputMessage) {<br />

super(inputMessage, fieldInfo);<br />

}<br />

}<br />

package dealership.application;<br />

import com.ibm.ims.base.*;<br />

import com.ibm.ims.application.*;<br />

/**<br />

* Result of recording a sale.<br />

*/<br />

public class SalesRecord extends <strong>IMS</strong>FieldMessage {<br />

final static DLITypeInfo[] fieldInfo = {<br />

new DLITypeInfo (“ShortMessage”, DLITypeInfo.CHAR, 21, 80)<br />

};<br />

382 <strong>IMS</strong> <strong>Version</strong> 7 <strong>and</strong> <strong>Java</strong> <strong>Application</strong> <strong>Programming</strong>


Constructor.<br />

public SalesRecord() {<br />

super(fieldInfo, 256, false);<br />

}<br />

}<br />

I.21 ShowModelDetailsInput class<br />

I.22 ModelDetails class<br />

package dealership.application;<br />

import com.ibm.ims.base.*;<br />

import com.ibm.ims.application.*;<br />

/**<br />

* This is an Input Message class. It defines the fields in the<br />

* input message to the <strong>IMS</strong>Auto dealership application requesting<br />

* the details of a specified car model.<br />

*/<br />

public class ShowModelDetailsInput extends <strong>IMS</strong>FieldMessage {<br />

final static DLITypeInfo[] fieldInfo = {<br />

new DLITypeInfo(“Comm<strong>and</strong>Code”, DLITypeInfo.CHAR, 1, 20),<br />

new DLITypeInfo(“ModelTypeCode”, DLITypeInfo.CHAR, 21, 2),<br />

};<br />

// Constructor.<br />

public ShowModelDetailsInput(InputMessage inputMessage) {<br />

super(inputMessage, fieldInfo);<br />

}<br />

}<br />

package dealership.application;<br />

import com.ibm.ims.base.*;<br />

import com.ibm.ims.application.*;<br />

/**<br />

* Results after show details request.<br />

*/<br />

public class ModelDetails extends <strong>IMS</strong>FieldMessage {<br />

final static DLITypeInfo[] fieldInfo = {<br />

new DLITypeInfo (“ModelTypeCode”, DLITypeInfo.CHAR,<br />

1, 2),<br />

new DLITypeInfo (“CarMake”, DLITypeInfo.CHAR,<br />

Appendix I. Dealership sample application 383


3, 10),<br />

new DLITypeInfo (“CarModel”, DLITypeInfo.CHAR,<br />

13, 10),<br />

new DLITypeInfo (“CarYear”, DLITypeInfo.CHAR,<br />

23, 4),<br />

new DLITypeInfo (“Price”, DLITypeInfo.ZONEDDECIMAL,<br />

27, 5),<br />

new DLITypeInfo (“Price”, DLITypeInfo.CHAR,<br />

27, 5),<br />

new DLITypeInfo (“EPACityMilage”, DLITypeInfo.CHAR,<br />

32, 4),<br />

new DLITypeInfo (“EPAHighwayMilage”, DLITypeInfo.CHAR,<br />

36, 4),<br />

new DLITypeInfo (“Horsepower”, DLITypeInfo.CHAR,<br />

40, 4)<br />

};<br />

// Constructor.<br />

public ModelDetails() {<br />

super(fieldInfo, 43, false);<br />

}<br />

}<br />

384 <strong>IMS</strong> <strong>Version</strong> 7 <strong>and</strong> <strong>Java</strong> <strong>Application</strong> <strong>Programming</strong>


Appendix J. Options for the hpj comm<strong>and</strong><br />

Table 6 outlines the options available for the hpj comm<strong>and</strong> on the OS/390.<br />

Table 6. Options for the hpj comm<strong>and</strong><br />

Option Description Default<br />

-- arg The double dash (--) option specifies<br />

that any associated argument that<br />

follows the double dash should be<br />

treated as a filename, even if the<br />

argument begins with a dash (-).<br />

-architecture arch Generate optimized code for the<br />

specified hardware architecture. This<br />

option directs the compiler to only<br />

generate code with machine instructions<br />

that will run on the specified hardware<br />

architecture.<br />

-Boption Pass the specified linker option to the<br />

linker. The valid linker options are both<br />

linker-specific <strong>and</strong> operating<br />

system-specific. Note that there cannot<br />

be a space between the -B option <strong>and</strong> its<br />

associated option.<br />

-[no]c Specify -c to compile source or<br />

bytecode files into object files without<br />

linking. Specify -noc to compile source<br />

or bytecode files into object files <strong>and</strong> to<br />

link the objects into a load module.<br />

-check args Controls whether normal <strong>Java</strong> run-time<br />

checks are performed.<br />

-classpath path Set the classpath to a specified path that<br />

will be used to search for the <strong>Java</strong><br />

classes that you want to compile.<br />

AIX: com<br />

WIN: 486<br />

© Copyright <strong>IBM</strong> Corp. 2001 385<br />

-noc<br />

-check all<br />

Information<br />

about the<br />

defaults is<br />

found in the<br />

detailed<br />

information for<br />

this option.


Option Description Default<br />

-[no]collapse [Do not] Put all object files <strong>and</strong> list files in<br />

one directory. The default directory is the<br />

current directory unless the -d option is<br />

specified. The -collapse option is not<br />

recommended if the -jlc option is<br />

specified.<br />

-[no]compact [Do not] Reduce code size at the<br />

expense of execution speed. This option<br />

has the following syntax:<br />

386 <strong>IMS</strong> <strong>Version</strong> 7 <strong>and</strong> <strong>Java</strong> <strong>Application</strong> <strong>Programming</strong><br />

-compact | -nocompact<br />

-d dir Deposit object <strong>and</strong> list files in the<br />

specified directory <strong>and</strong> its<br />

subdirectories, rather than in the<br />

directory in which the source or class<br />

files are found. If -d is not specified, the<br />

object <strong>and</strong> list files are written to the<br />

same location as their .class files. If the<br />

-jlc option is specified, simple DLLs (.jlc<br />

files) are deposited in the same location<br />

as the object <strong>and</strong> list files. Related<br />

information is found in the description for<br />

the -[no]collapse option.<br />

-encoding codepage Specify the encoding of any <strong>Java</strong> source<br />

files. This option is similar to the<br />

-encoding option of the JDK javac<br />

comm<strong>and</strong>.<br />

-exclude prefix Exclude all classes, packages, or sets of<br />

packages from the compile that begin<br />

with the specified prefix.<br />

-nocollapse<br />

-nocompact


Option Description Default<br />

-exe Compile all classes into a single<br />

executable. This is the default action<br />

unless the -c, -jll, or -jlc option is<br />

specified. If the <strong>Java</strong> executable is not<br />

explicitly named with the -o option, the<br />

executable is written to the current<br />

directory under one of the following<br />

default names (where filename is the<br />

base name of the main class):<br />

AIX: a.out<br />

WIN: filename.exe<br />

You may also want to explicitly name the<br />

entry point for your executable by using<br />

the -main option.<br />

-[no]follow [Do not] Recursively compile all classes<br />

that are referenced from those classes<br />

initially supplied to the compiler.<br />

-[no]g [Do not] Emit debugging information.<br />

This option has the following syntax:<br />

-g | -nog<br />

Local variables are only visible if the<br />

class file contains a LocalVariableTable<br />

attribute. This means that your .java file<br />

must be compiled with debug<br />

information (for example, using javac<br />

with the -g option). The<br />

LocalVariableTable is an optional<br />

attribute <strong>and</strong> there is no guarantee that<br />

all <strong>Java</strong> source compilers generate it.<br />

This is also true for the<br />

LineNumberTable attribute <strong>and</strong><br />

SourceFileInfo attribute.<br />

-[no]gui WIN: [Do Not] Suppress the DOS<br />

window that normally appears when you<br />

run an executable. This option has the<br />

following syntax:<br />

-gui | -nogui<br />

-exe<br />

-follow<br />

-nog<br />

-nogui<br />

Appendix J. Options for the hpj comm<strong>and</strong> 387


Option Description Default<br />

-help or -? If the hpj comm<strong>and</strong> is specified with<br />

either the -help or -? option (<strong>and</strong> no<br />

other options or arguments are<br />

specified), usage information is<br />

displayed for the hpj comm<strong>and</strong>.<br />

-include prefix Include all classes, packages, or sets of<br />

packages in the compile that begin with<br />

the specified prefix.<br />

-jlc Compile each class into a corresponding<br />

simple DLL that has a .jlc extension.<br />

388 <strong>IMS</strong> <strong>Version</strong> 7 <strong>and</strong> <strong>Java</strong> <strong>Application</strong> <strong>Programming</strong><br />

If the -main option is specified with the<br />

-jlc option, the -main option is ignored<br />

<strong>and</strong> a warning message is displayed.<br />

Note that if you specify the -jlc option,<br />

the -collapse option is not<br />

recommended.<br />

-jll Compile all classes into a single<br />

compound DLL that has a .jll extension.<br />

If -jll is specified <strong>and</strong> -c is not specified,<br />

so that a link is performed, the -o option<br />

must also be specified to name the DLL.<br />

If the -main option is specified with the<br />

-jll option, the -main option is ignored<br />

<strong>and</strong> a warning message is displayed.<br />

-[no]list [Do not] Produce an object code listing<br />

file for each .class file. This option has<br />

the following syntax:<br />

-list | -nolist<br />

When -list is specified, one listing file is<br />

created for each class <strong>and</strong> is named<br />

after the class. The listing files are<br />

placed in the same location as the object<br />

files. The -d <strong>and</strong> -collapse options<br />

affect the naming <strong>and</strong> placement of<br />

these files. Listing files have the<br />

following extension:<br />

AIX: .lst<br />

WIN: .asm<br />

-nolist


Option Description Default<br />

-main classname Specify the base name of the class that<br />

contains the main startup method to be<br />

used in the building of a <strong>Java</strong><br />

executable. If -main is not specified, the<br />

first class found during processing that<br />

contains main() is used. This option is<br />

not valid when -jll or -jlc is specified.<br />

The classname is a fully qualified class<br />

name, for example:<br />

-main abc.staff.queryDB.queryMain<br />

If -main is not specified when building a<br />

<strong>Java</strong> executable, the system looks in all<br />

the input files for a class with a main<br />

method. When the first main method is<br />

found, then its class is used as the entry<br />

point for the executable. If a main<br />

method is not found, the system<br />

searches through the dependency list of<br />

classes. If no main method is found, the<br />

build is aborted <strong>and</strong> an error message is<br />

displayed.<br />

-[no]make [Do not] Rebuild out-of-date or missing<br />

program objects when building <strong>Java</strong><br />

executables or DLLs.<br />

If you specify -make, you cannot specify<br />

the -partial option.<br />

-maxmem size AIX: Restrict optimizations to a<br />

maximum of size kilobytes of memory<br />

storage. The range of valid entries is 1<br />

to 2097151. Values of either 0 or<br />

2097152 are equivalent to specifying<br />

-nomaxmem.<br />

-nomaxmem Use all available memory storage for<br />

optimizations up to a maximum of<br />

2147483647 bytes.<br />

-nomake<br />

2048<br />

Appendix J. Options for the hpj comm<strong>and</strong> 389


Option Description Default<br />

-o file Name of the executable file, compound<br />

DLL (.jll), or simple DLL (.jlc). There is no<br />

default name for compound DLLs, so<br />

you must use the -o option when<br />

building a compound DLL. Although you<br />

can specify -o in conjunction with the<br />

-jlc option, this is generally not<br />

recommended.<br />

390 <strong>IMS</strong> <strong>Version</strong> 7 <strong>and</strong> <strong>Java</strong> <strong>Application</strong> <strong>Programming</strong><br />

WIN: When building an executable, the<br />

.exe extension is appended if the file<br />

argument does not end in “.exe”.<br />

-[no]O [Do not] Generate optimized code. This<br />

option has the following syntax:<br />

-O | -noO<br />

Using -O will increase compile time <strong>and</strong><br />

may have greater storage requirements.<br />

-partial prefix Compile only those classes that begin<br />

with the specified prefix <strong>and</strong>, if the -c<br />

option is not specified, rebuild the <strong>Java</strong><br />

executable or DLL. If you specify<br />

-partial, you cannot specify -make.<br />

-spill size AIX: Restrict the spill area to size bytes.<br />

The -spill option defines the number of<br />

bytes of stack space to reserve in each<br />

subprogram, in case there are too many<br />

variables to hold in registers <strong>and</strong> the<br />

program needs temporary storage for<br />

register contents.<br />

When too many registers are in use, the<br />

compiler stores the contents of some of<br />

them into temporary storage called the<br />

spill area. You may have to exp<strong>and</strong> the<br />

spill area; if so, you will receive a<br />

compiler message telling you the size to<br />

which you should increase the spill area.<br />

Typically, you will only need to specify<br />

this maximum spill area when compiling<br />

very large programs with optimization.<br />

Information<br />

about the<br />

default is found<br />

in the detailed<br />

information for<br />

this option.<br />

-noO<br />

-spill 512


Option Description Default<br />

-tune arch Generate optimized code for a particular<br />

architecture to take advantage of such<br />

architectural differences as the<br />

scheduling of instructions.<br />

-verbose Lists the .java files, .class files,<br />

executables, <strong>and</strong> DLLs as they are<br />

compiled.<br />

AIX: pwr (if the<br />

-architecture<br />

option is<br />

specified)<br />

WIN: blend<br />

Appendix J. Options for the hpj comm<strong>and</strong> 391


392 <strong>IMS</strong> <strong>Version</strong> 7 <strong>and</strong> <strong>Java</strong> <strong>Application</strong> <strong>Programming</strong>


Appendix K. Special notices<br />

This publication is intended to help <strong>IMS</strong> system programmers <strong>and</strong> application<br />

developers who plan to implement <strong>IMS</strong> <strong>Java</strong> in their <strong>IMS</strong> V7 environment.<br />

The information in this publication is not intended to replace any of the <strong>IMS</strong><br />

<strong>Version</strong> or <strong>IMS</strong> <strong>Java</strong> publications. See the PUBLICATIONS section of the <strong>IBM</strong><br />

<strong>Programming</strong> Announcement for <strong>IMS</strong> <strong>Version</strong> 7. for more information about<br />

what publications are considered to be product documentation.<br />

References in this publication to <strong>IBM</strong> products, programs or services do not<br />

imply that <strong>IBM</strong> intends to make these available in all countries in which <strong>IBM</strong><br />

operates. Any reference to an <strong>IBM</strong> product, program, or service is not<br />

intended to state or imply that only <strong>IBM</strong>'s product, program, or service may be<br />

used. Any functionally equivalent program that does not infringe any of <strong>IBM</strong>'s<br />

intellectual property rights may be used instead of the <strong>IBM</strong> product, program<br />

or service.<br />

Information in this book was developed in conjunction with use of the<br />

equipment specified, <strong>and</strong> is limited in application to those specific hardware<br />

<strong>and</strong> software products <strong>and</strong> levels.<br />

<strong>IBM</strong> may have patents or pending patent applications covering subject matter<br />

in this document. The furnishing of this document does not give you any<br />

license to these patents. You can send license inquiries, in writing, to the <strong>IBM</strong><br />

Director of Licensing, <strong>IBM</strong> Corporation, North Castle Drive, Armonk, NY<br />

10504-1785.<br />

Licensees of this program who wish to have information about it for the<br />

purpose of enabling: (i) the exchange of information between independently<br />

created programs <strong>and</strong> other programs (including this one) <strong>and</strong> (ii) the mutual<br />

use of the information which has been exchanged, should contact <strong>IBM</strong><br />

Corporation, Dept. 600A, Mail Drop 1329, Somers, NY 10589 USA.<br />

Such information may be available, subject to appropriate terms <strong>and</strong><br />

conditions, including in some cases, payment of a fee.<br />

The information contained in this document has not been submitted to any<br />

formal <strong>IBM</strong> test <strong>and</strong> is distributed AS IS. The use of this information or the<br />

implementation of any of these techniques is a customer responsibility <strong>and</strong><br />

depends on the customer's ability to evaluate <strong>and</strong> integrate them into the<br />

customer's operational environment. While each item may have been<br />

reviewed by <strong>IBM</strong> for accuracy in a specific situation, there is no guarantee<br />

that the same or similar results will be obtained elsewhere. Customers<br />

© Copyright <strong>IBM</strong> Corp. 2001 393


attempting to adapt these techniques to their own environments do so at their<br />

own risk.<br />

Any pointers in this publication to external Web sites are provided for<br />

convenience only <strong>and</strong> do not in any manner serve as an endorsement of<br />

these Web sites.<br />

The following terms are trademarks of the International Business Machines<br />

Corporation in the United States <strong>and</strong>/or other countries:<br />

<strong>IBM</strong> � <strong>Redbooks</strong><br />

<strong>Redbooks</strong> Logo<br />

IAFP<br />

AIX<br />

AS/400<br />

AT<br />

CICS<br />

CT<br />

Current<br />

DB2<br />

DFSMS/MVS<br />

Domino<br />

Hummingbird<br />

<strong>IBM</strong><br />

<strong>IMS</strong>/ESA<br />

Language Environment<br />

Lotus<br />

Manage. Anything. Anywhere.<br />

MVS/ESA<br />

Netfinity<br />

The following terms are trademarks of other companies:<br />

Tivoli, Manage. Anything. Anywhere.,The Power To Manage., Anything.<br />

Anywhere.,TME, NetView, Cross-Site, Tivoli Ready, Tivoli Certified, Planet<br />

Tivoli, <strong>and</strong> Tivoli Enterprise are trademarks or registered trademarks of Tivoli<br />

Systems Inc., an <strong>IBM</strong> company, in the United States, other countries, or both.<br />

In Denmark, Tivoli is a trademark licensed from Kjøbenhavns Sommer - Tivoli<br />

A/S.<br />

C-bus is a trademark of Corollary, Inc. in the United States <strong>and</strong>/or other<br />

countries.<br />

<strong>Java</strong> <strong>and</strong> all <strong>Java</strong>-based trademarks <strong>and</strong> logos are trademarks or registered<br />

trademarks of Sun Microsystems, Inc. in the United States <strong>and</strong>/or other<br />

countries.<br />

394 <strong>IMS</strong> <strong>Version</strong> 7 <strong>and</strong> <strong>Java</strong> <strong>Application</strong> <strong>Programming</strong><br />

OpenEdition<br />

OS/2<br />

OS/390<br />

Parallel Sysplex<br />

RACF<br />

RS/6000<br />

SAA<br />

S/390<br />

SP<br />

System/36<br />

System/360<br />

System/390<br />

VisualAge<br />

VTAM<br />

WebExplorer<br />

WebSphere<br />

XT<br />

400


Microsoft, Windows, Windows NT, <strong>and</strong> the Windows logo are trademarks of<br />

Microsoft Corporation in the United States <strong>and</strong>/or other countries.<br />

PC Direct is a trademark of Ziff Communications Company in the United<br />

States <strong>and</strong>/or other countries <strong>and</strong> is used by <strong>IBM</strong> Corporation under license.<br />

ActionMedia, LANDesk, MMX, Pentium <strong>and</strong> ProShare are trademarks of Intel<br />

Corporation in the United States <strong>and</strong>/or other countries.<br />

UNIX is a registered trademark in the United States <strong>and</strong> other countries<br />

licensed exclusively through The Open Group.<br />

SET, SET Secure Electronic Transaction, <strong>and</strong> the SET Logo are trademarks<br />

owned by SET Secure Electronic Transaction LLC.<br />

Other company, product, <strong>and</strong> service names may be trademarks or service<br />

marks of others.<br />

Appendix K. Special notices 395


396 <strong>IMS</strong> <strong>Version</strong> 7 <strong>and</strong> <strong>Java</strong> <strong>Application</strong> <strong>Programming</strong>


Appendix L. Related publications<br />

L.1 <strong>IBM</strong> <strong>Redbooks</strong><br />

The publications listed in this section are considered particularly suitable for a<br />

more detailed discussion of the topics covered in this redbook.<br />

For information on ordering these publications see “How to get <strong>IBM</strong><br />

<strong>Redbooks</strong>” on page 401.<br />

<strong>IMS</strong> e-business Connect Using the <strong>IMS</strong> Connectors, SG24-5427<br />

<strong>IMS</strong> Primer, SG24-5352<br />

L.2 <strong>IBM</strong> <strong>Redbooks</strong> collections<br />

L.3 Other resources<br />

<strong>Redbooks</strong> are also available on the following CD-ROMs. Click the CD-ROMs<br />

button at ibm.com/redbooks for information about all the CD-ROMs offered,<br />

updates <strong>and</strong> formats.<br />

CD-ROM Title Collection Kit<br />

Number<br />

<strong>IBM</strong> System/390 <strong>Redbooks</strong> Collection SK2T-2177<br />

<strong>IBM</strong> Networking <strong>Redbooks</strong> Collection SK2T-6022<br />

<strong>IBM</strong> Transaction Processing <strong>and</strong> Data Management <strong>Redbooks</strong> Collection SK2T-8038<br />

<strong>IBM</strong> Lotus <strong>Redbooks</strong> Collection SK2T-8039<br />

Tivoli <strong>Redbooks</strong> Collection SK2T-8044<br />

<strong>IBM</strong> AS/400 <strong>Redbooks</strong> Collection SK2T-2849<br />

<strong>IBM</strong> Netfinity Hardware <strong>and</strong> Software <strong>Redbooks</strong> Collection SK2T-8046<br />

<strong>IBM</strong> RS/6000 <strong>Redbooks</strong> Collection SK2T-8043<br />

<strong>IBM</strong> <strong>Application</strong> Development <strong>Redbooks</strong> Collection SK2T-8037<br />

<strong>IBM</strong> Enterprise Storage <strong>and</strong> Systems Management Solutions SK3T-3694<br />

These publications are also relevant as further information sources:<br />

<strong>IMS</strong> Administration Guide: Database Manager, SC26-9419<br />

<strong>IMS</strong> Administration Guide: System, SC26-9420<br />

<strong>IMS</strong> Administration Guide: Transaction Manager, SC26-9421<br />

<strong>IMS</strong> <strong>Application</strong> <strong>Programming</strong>: Design Guide, SC26-9423<br />

<strong>IMS</strong> <strong>Application</strong> <strong>Programming</strong>: EXEC DLI Comm<strong>and</strong>s for CICS <strong>and</strong> <strong>IMS</strong>,<br />

SC26-9424<br />

© Copyright <strong>IBM</strong> Corp. 2001 397


<strong>IMS</strong> <strong>Application</strong> <strong>Programming</strong>: Transaction Manager, SC26-9425<br />

<strong>IMS</strong> Common Queue Server <strong>and</strong> Base Primitive Environment Guide <strong>and</strong><br />

Reference, SC26-9426<br />

<strong>IMS</strong> Customization Guide, SC26-9427<br />

<strong>IMS</strong> Database Recovery Control (DBRC) Guide <strong>and</strong> Reference,<br />

SC26-9428<br />

<strong>IMS</strong> Diagnosis Guide <strong>and</strong> Reference, LY37-3738<br />

<strong>IMS</strong> Failure Analysis Structure Tables (FAST) for Dump Analysis,<br />

LY37-3739<br />

<strong>IMS</strong> Installation Volume 1: Installation <strong>and</strong> Verification, GC26-9429<br />

<strong>IMS</strong> Installation Volume 2: System Definition <strong>and</strong> Tailoring, GC26-9430<br />

<strong>IMS</strong> Licensed Program Specifications, GC26-9431<br />

<strong>IMS</strong> Master Index, SC26-9432<br />

<strong>IMS</strong> Message <strong>and</strong> Codes, GC26-9433<br />

<strong>IMS</strong> Open Transaction Manager Access Guide, SC26-9434<br />

<strong>IMS</strong> Operations Guide, SC26-9435<br />

<strong>IMS</strong> Operator’s Reference, SC26-9436<br />

<strong>IMS</strong> Release Planning Guide, GC26-9437<br />

<strong>IMS</strong> Sample Operation Procedures, SC26-9438<br />

<strong>IMS</strong> Summary of Operator Comm<strong>and</strong>s, SC26-9439<br />

<strong>IMS</strong> Utilities Reference: Database <strong>and</strong> Transaction Manager, SC26-9440<br />

<strong>IMS</strong> Utilities Reference: System, SC26-9441<br />

<strong>IMS</strong>/ESA MRQ User’s Guide <strong>and</strong> Reference, SC26-8856<br />

<strong>IMS</strong>/ESA Performance Analyzer Report Analysis, SC27-0705<br />

<strong>IMS</strong>/ESA Performance Analyzer User’s Guide, SC26-9869<br />

<strong>IMS</strong> Connect Guide <strong>and</strong> Reference, SC27-0946<br />

398 <strong>IMS</strong> <strong>Version</strong> 7 <strong>and</strong> <strong>Java</strong> <strong>Application</strong> <strong>Programming</strong>


L.4 Referenced Web sites<br />

These Web sites are also relevant as further information sources:<br />

http://www.ibm.com/ <strong>IBM</strong> Home Page<br />

http://www.redbooks.ibm.com/ ITSO Home Page<br />

http://w3.itso.ibm.com <strong>IBM</strong> ITSO intranet Web site<br />

http://www.elink.ibmlink.ibm.com/pbl/pbl Ordering <strong>IBM</strong> <strong>Redbooks</strong><br />

http://www.ibm.com/s390/java <strong>Java</strong> on the OS/390 platform<br />

http://www.ibm.com/s390/java/javainst.html#prer<br />

Download <strong>and</strong> install instructions: <strong>Java</strong> for OS/390 at JDK 1.1.8 level<br />

http://www.ibm.com/s390/java/register.html Register to get <strong>Java</strong> code<br />

Appendix L. Related publications 399


400 <strong>IMS</strong> <strong>Version</strong> 7 <strong>and</strong> <strong>Java</strong> <strong>Application</strong> <strong>Programming</strong>


How to get <strong>IBM</strong> <strong>Redbooks</strong><br />

This section explains how both customers <strong>and</strong> <strong>IBM</strong> employees can find out about <strong>IBM</strong> <strong>Redbooks</strong>,<br />

redpieces, <strong>and</strong> CD-ROMs. A form for ordering books <strong>and</strong> CD-ROMs by fax or e-mail is also provided.<br />

<strong>Redbooks</strong> Web Site ibm.com/redbooks<br />

Search for, view, download, or order hardcopy/CD-ROM <strong>Redbooks</strong> from the <strong>Redbooks</strong> Web site.<br />

Also read redpieces <strong>and</strong> download additional materials (code samples or diskette/CD-ROM images)<br />

from this <strong>Redbooks</strong> site.<br />

Redpieces are <strong>Redbooks</strong> in progress; not all <strong>Redbooks</strong> become redpieces <strong>and</strong> sometimes just a few<br />

chapters will be published this way. The intent is to get the information out much quicker than the<br />

formal publishing process allows.<br />

E-mail Orders<br />

Send orders by e-mail including information from the <strong>IBM</strong> <strong>Redbooks</strong> fax order form to:<br />

In United States or Canada<br />

Outside North America<br />

Telephone Orders<br />

United States (toll free)<br />

Canada (toll free)<br />

Outside North America<br />

Fax Orders<br />

United States (toll free)<br />

Canada<br />

Outside North America<br />

e-mail address<br />

pubscan@us.ibm.com<br />

Contact information is in the “How to Order” section at this site:<br />

http://www.elink.ibmlink.ibm.com/pbl/pbl<br />

1-800-879-2755<br />

1-800-<strong>IBM</strong>-4YOU<br />

Country coordinator phone number is in the “How to Order”<br />

section at this site:<br />

http://www.elink.ibmlink.ibm.com/pbl/pbl<br />

This information was current at the time of publication, but is continually subject to change. The latest<br />

information may be found at the <strong>Redbooks</strong> Web site.<br />

<strong>IBM</strong> Intranet for Employees<br />

1-800-445-9269<br />

1-403-267-4455<br />

Fax phone number is in the “How to Order” section at this site:<br />

http://www.elink.ibmlink.ibm.com/pbl/pbl<br />

<strong>IBM</strong> employees may register for information on workshops, residencies, <strong>and</strong> <strong>Redbooks</strong> by accessing<br />

the <strong>IBM</strong> Intranet Web site at http://w3.itso.ibm.com/ <strong>and</strong> clicking the ITSO Mailing List button.<br />

Look in the Materials repository for workshops, presentations, papers, <strong>and</strong> Web pages developed<br />

<strong>and</strong> written by the ITSO technical professionals; click the Additional Materials button. Employees<br />

may access MyNews at http://w3.ibm.com/ for redbook, residency, <strong>and</strong> workshop announcements.<br />

© Copyright <strong>IBM</strong> Corp. 2001 401


<strong>IBM</strong> <strong>Redbooks</strong> fax order form<br />

Please send me the following:<br />

Title Order Number Quantity<br />

First name Last name<br />

Company<br />

Address<br />

City Postal code<br />

Telephone number Telefax number VAT number<br />

Invoice to customer number<br />

Credit card number<br />

We accept American Express, Diners, Eurocard, Master Card, <strong>and</strong> Visa. Payment by credit card not<br />

available in all countries. Signature m<strong>and</strong>atory for credit card payment.<br />

402 <strong>IMS</strong> <strong>Version</strong> 7 <strong>and</strong> <strong>Java</strong> <strong>Application</strong> <strong>Programming</strong><br />

Country<br />

Credit card expiration date Card issued to<br />

Signature


Glossary<br />

A<br />

API. See application program interface.<br />

applet. An applet is a piece of <strong>Java</strong> bytecode<br />

that is executed on the workstation, under<br />

control of the Web browser’s <strong>Java</strong>Virtual<br />

Machine. The applet is downloaded when the<br />

browser accesses a page containing an<br />

tag.<br />

application. (1)Theusetowhichan<br />

information processing system is put; for<br />

example, a payroll application or an order-entry<br />

application. (2) A collection of defined <strong>and</strong><br />

extended classes that provides a reusable piece<br />

of functionality. An application contains <strong>and</strong><br />

organizes functionally related classes. It also<br />

can contain subapplications <strong>and</strong> specify<br />

prerequisites.<br />

application program interface (API). An<br />

architected functional interface supplied by an<br />

operating system or other software system. The<br />

interface enables an application program written<br />

in a high-level language to use specific data or<br />

functions of the underlying system.<br />

ASCII. (American St<strong>and</strong>ard Code for<br />

Information Interchange), this is the world-wide<br />

st<strong>and</strong>ard for the code numbers used by<br />

computers to represent all the upper <strong>and</strong><br />

lower-case Latin letters, numbers, punctuation,<br />

etc. There are 128 st<strong>and</strong>ard ASCII codes each<br />

of which can be represented by a 7-digit binary<br />

number, 0000000 through 1111111.<br />

authority. Therighttodosomethingonthe<br />

system or to use an object, such as a file or<br />

document, in the system.<br />

B<br />

Base Primitive Environment (BPE). Asystem<br />

service component that underlies the HWS<br />

address space.<br />

bit. (binary digit) A single digit number in base<br />

2, in other words, either a 1 or a zero. The<br />

smallest unit of computerized data. B<strong>and</strong>width is<br />

usually measured in bits per second. See also<br />

b<strong>and</strong>width, bps, byte, kilobyte, megabyte.<br />

browser. Software that enables users to browse<br />

through the cyberspace of the World Wide Web.<br />

SeealsoClient,URL,WWW.<br />

byte. A set of bits that represent a single<br />

character. Usually there are 8 bits in a byte,<br />

sometimes more, depending on how the<br />

measurement is being made.<br />

© Copyright <strong>IBM</strong> Corp. 2001 403<br />

C<br />

client. A software program that is used to<br />

contact <strong>and</strong> obtain data from a server software<br />

program on another computer, often across a<br />

great distance. Each client program is designed<br />

to work with one or more specific kinds of server<br />

programs, <strong>and</strong> each server requires a specific<br />

kind of client. A Web browser is a specific kind<br />

of client. See also browser, server.<br />

client/server. The model of interaction in<br />

distributed data processing in which a program<br />

at one location sends a request to a program at<br />

another location <strong>and</strong> awaits a response. The<br />

requesting program is called a client, <strong>and</strong> the<br />

answering program is called a server.<br />

Common Gateway Interface. A st<strong>and</strong>ard<br />

protocol through which a Web server can<br />

execute programs running on the server<br />

machine. CGI programs are executed in<br />

response to requests from Web client browsers.<br />

configuration. A description of a group of<br />

components that identifies, for each component,<br />

the component edition or version that is part of<br />

the group.<br />

D<br />

database manager. other word for a database<br />

management system.<br />

datastore. An <strong>IMS</strong> TM system that provides<br />

transaction <strong>and</strong> database processing.<br />

domain name. The unique name that identifies<br />

an Internet site. Domain names always have


two or more parts, separated by dots. The part on<br />

the left is the most specific, <strong>and</strong> the part on the<br />

right is the most general. A given machine may<br />

have more than one domain name but a given<br />

domain name points to only one machine.<br />

Usually, all of the machines on a given network<br />

will have the same thing as the right-h<strong>and</strong> portion<br />

of their domain names, for example,<br />

gateway.mynetwork.com.br,<br />

mail.mynetwork.com.br, www.mynetwork.com.br,<br />

<strong>and</strong> so on. It is also possible for a domain name<br />

to exist but not be connected to an actual<br />

machine. This is often done so that a group or<br />

business can have an Internet e-mail address<br />

without having to establish a real Internet site. In<br />

these cases, some real Internet machine must<br />

h<strong>and</strong>le the mail on behalf of the listed domain<br />

name. See also IP Number.<br />

dynamic link library (DLL). A file containing<br />

data <strong>and</strong> code objects that can be used by<br />

programs or applications during loading or at run<br />

timebutarenotpartoftheprogram’sexecutable (.EXE) file.<br />

E<br />

F<br />

feature. A major component of a software<br />

product that can be ordered separately.<br />

field. A group of related bytes (such as name or<br />

amount) that are treated as a unit in a record.<br />

FTP. (File Transfer Protocol) The basic Internet<br />

function that enables files to be transferred<br />

between computers. You can use it to download<br />

files from a remote, host computer, as well as to<br />

upload files from your computer to a remote, host<br />

computer. (See Anonymous FTP).<br />

G<br />

graphical user interface (GUI). Atypeof<br />

interface that enables users to communicate with<br />

a program by manipulating graphical elements<br />

rather than by entering comm<strong>and</strong>s. Typically, a<br />

graphical user interface includes a combination of<br />

404 <strong>IMS</strong> <strong>Version</strong> 7 <strong>and</strong> <strong>Java</strong> <strong>Application</strong> <strong>Programming</strong><br />

graphics, pointing devices, menu bars,<br />

overlapping windows, <strong>and</strong> icons.<br />

H<br />

host. (1) A computer that “hosts” outside<br />

computer users by providing files, services or<br />

sharing its resources. (2) Any computer on a<br />

network that is a repository for services available<br />

to other computers on the network. It is quite<br />

common to have one host machine provide<br />

several services, such as WWW <strong>and</strong> USENET.<br />

See also Node, Network.<br />

I<br />

index. A set of pointers that are logically<br />

arranged by the values of a key. Indexes provide<br />

quick access <strong>and</strong> can enforce uniqueness on the<br />

rows in a table.<br />

IP. (Internet Protocol) The rules that provide basic<br />

Internet functions. See TCP/IP.<br />

IP Number. An Internet address that is a unique<br />

number consisting of four parts separated by<br />

dots, sometimes called a dotted quad. (For<br />

example: 198.204.112.1). Every Internet<br />

computer has an IP number <strong>and</strong> most computers<br />

also have one or more domain names that are<br />

plain language substitutes for the dotted quad.<br />

J<br />

<strong>Java</strong>. <strong>Java</strong> is a programming language invented<br />

by Sun Microsystems that is specifically designed<br />

for writing programs that can be safely<br />

downloaded to your computer through the<br />

Internet <strong>and</strong> immediately run without fear of<br />

viruses or other harm to your computer or files.<br />

Using small <strong>Java</strong> programs (called applets, Web<br />

pages can include functions such as animations,<br />

calculators, <strong>and</strong> other fancy tricks. We can expect<br />

to see a huge variety of features added to the<br />

Web using <strong>Java</strong>, since you can write a <strong>Java</strong><br />

program to do almost anything a regular<br />

computer program can do, <strong>and</strong> then include that<br />

<strong>Java</strong> program in a Web page.<br />

<strong>Java</strong> Bytecode. The solution that the <strong>Java</strong><br />

system adopts to solve the binary distribution<br />

problem is a "binary code format" that is


independent of hardware architectures, operating<br />

system interfaces, <strong>and</strong> window systems. The<br />

format of this system-independent binary code is<br />

architecture neutral.<br />

<strong>Java</strong> Classes. Aclassisasoftwareconstruct<br />

that defines the data (state) <strong>and</strong> methods<br />

(behavior) of the specific concrete objects that<br />

are subsequently constructed from that class. In<br />

<strong>Java</strong> terminology, a class is built out of members,<br />

which are either fields or methods.<br />

<strong>Java</strong> Packages. <strong>Java</strong> packages are collections<br />

of classes <strong>and</strong> interfaces that are related to each<br />

other in some useful way. Such classes need to<br />

be able to access each other's instance variables<br />

<strong>and</strong> methods directly.<br />

K<br />

L<br />

LAN. Local area network. A computer network<br />

located on a user’s establishment within a limited<br />

geographical area. A LAN typically consists of<br />

one or more server machines providing services<br />

to a number of client workstations. See also<br />

Ethernet.<br />

Login. Theaccountnameusedtogainaccessto<br />

a computer system. Not kept secret (unlike<br />

password).<br />

M<br />

megabyte. A million bytes. A thous<strong>and</strong> kilobytes.<br />

Seealsobyte,bit,kilobyte.<br />

N<br />

O<br />

object-oriented programming. A programming<br />

methodology built around objects <strong>and</strong> based on<br />

sending messages back <strong>and</strong> forth between those<br />

objects. The basic concepts of object-oriented<br />

programming are encapsulation, inheritance, <strong>and</strong><br />

polymorphism.<br />

P<br />

parameter. A data element included as part of a<br />

message to provide information that the object<br />

might need. In Smalltalk, generally referred to as<br />

an argument.<br />

password. Acodeusedtogainaccesstoa<br />

locked system. Good passwords contain letters<br />

<strong>and</strong> nonletters <strong>and</strong> are not simple combinations.<br />

PATH_INFO. A CGI variable, usually transmitted<br />

to the CGI program in the form of an environment<br />

variable. The PATH_INFO variable contains all<br />

path information from the URL following the name<br />

of the CGI executable. For a Web Connection<br />

application, this information is the same as the<br />

VisualAge part name.<br />

Port. (1) A place where information goes into or<br />

out of a computer, or both. For example, the<br />

serial port on a personal computer is where a<br />

modem would be connected. (2) On the Internet<br />

port often refers to a number that is part of a<br />

URL, appearing after a colon (:) right after the<br />

domain name. Every service on an Internet<br />

server listens on a particular port number on that<br />

server. Most services have st<strong>and</strong>ard port<br />

numbers; Web servers normally listen on port 80.<br />

Services can also listen on nonst<strong>and</strong>ard ports, in<br />

which case the port number must be specified in<br />

a URL when accessing the server. (3) Refers to<br />

translating a piece of software to bring it from one<br />

type of computer system to another. See also<br />

domain name, server, URL. (4) In the case of<br />

ITOC, HWS address space represents several<br />

port numbers; each port will provide access to<br />

one of a number of sockets associated with the<br />

<strong>IMS</strong> Transaction Manager systems HWS is<br />

connected to.<br />

protocol. (1) The set of all messages to which an<br />

object will respond. (2) Specification of the<br />

structure <strong>and</strong> meaning (the semantics) of<br />

messages that are exchanged between a client<br />

<strong>and</strong> a server. (3) Computer rules that provide<br />

uniform specifications so that computer hardware<br />

<strong>and</strong> operating systems can communicate. It’s<br />

similar to the way that mail, in countries around<br />

the world, is addressed in the same basic format<br />

so that postal workers know where to find the<br />

recipient’s address, the sender’s return address<br />

<strong>and</strong> the postage stamp. Regardless of the<br />

405


underlying language, the basic protocols remain<br />

the same.<br />

R<br />

record. A group of related data, fields, or words,<br />

treated as a unit, such as name, address, <strong>and</strong><br />

telephone number.<br />

repository. (1) An organized, shared body of<br />

information that can support business <strong>and</strong><br />

data-processing activities.<br />

return value. An object or data type that a<br />

receiver object passes to a sender object in<br />

response to a message.<br />

S<br />

script. A series of comm<strong>and</strong>s that define the<br />

sequenceinwhichtheywillhavetobe<br />

processed.<br />

server. (1) A computer that provides services to<br />

multiple users or workstations in a network; for<br />

example, a file server, print server, or mail server.<br />

(2) An object that performs one or more tasks on<br />

behalf of a client. The server can be a computer<br />

(a file server), a specific process on a server, or a<br />

distributed object. A single server machine could<br />

have several different server software packages<br />

running on it, thus providing many different<br />

serverstoclientsonthenetwork.Seealsoclient,<br />

network.<br />

service. A specific behavior that an object is<br />

responsible for exhibiting.<br />

servlet. A servlet is a piece of <strong>Java</strong> code that<br />

runs inside a <strong>Java</strong>-enabled Web server, such as<br />

the Lotus Domino Go Webserver Release 4.6.1or<br />

<strong>IBM</strong> HTTP Server 1.3.3 with <strong>IBM</strong> WebSphere<br />

<strong>Application</strong> Server V2.0, <strong>and</strong> extends the<br />

functions of the server. The server h<strong>and</strong>s<br />

requests to the servlet, which replies to them.<br />

Servlets are a good substitute for CGI programs<br />

because they are faster <strong>and</strong> more easily<br />

manageable.<br />

session. A series of comm<strong>and</strong>s that come from<br />

the same client <strong>and</strong> belong to the same logical<br />

sequence <strong>and</strong> period. A session is identified by a<br />

unique session key, which is generated by<br />

406 <strong>IMS</strong> <strong>Version</strong> 7 <strong>and</strong> <strong>Java</strong> <strong>Application</strong> <strong>Programming</strong><br />

VisualAge. A session begins when a client<br />

initially connects (without a session key) <strong>and</strong><br />

ends when a specified timeout period has<br />

elapsed since the last connection.<br />

structured query language (SQL). A language<br />

used to access relational databases.<br />

T<br />

TCP/IP. (Transmission Control Protocol/Internet<br />

Protocol) The basic programming foundation that<br />

carries computer messages around the globe via<br />

the Internet. The suite of protocols that defines<br />

the Internet. Originally designed for the UNIX<br />

operating system, TCP/IP software is now<br />

available for every major kind of computer<br />

operating system. To be truly on the Internet,<br />

your computer must have TCP/IP software.<br />

Telnet. An Internet protocol that lets you connect<br />

your PC as a remote workstation to a host<br />

computer anywhere in the world <strong>and</strong> to use that<br />

computer as if you were logged on locally. You<br />

often have the ability to use all of the software<br />

<strong>and</strong> capability on the host computer, even if it’s a<br />

huge mainframe.<br />

U<br />

uniform resource locator (URL). A st<strong>and</strong>ard<br />

identifier for a resource on the World Wide Web,<br />

used by a Web browser to initiate a connection.<br />

The URL includes the communications protocol<br />

to use, the name of the server, <strong>and</strong> path<br />

information identifying the object to be retrieved<br />

on the server. A URL looks like:<br />

http://www.ibm.com, ortelnet://well.sf.ca.us.br, or<br />

news:new.newusers.questions.br<br />

V<br />

variable. A storage place within an object for a<br />

data element. The data element is an object,<br />

such as a number or date, stored as an attribute<br />

of the containing object.<br />

W<br />

Web Browser. As many other Internet facilities,<br />

the Web uses a client-server processing model.<br />

The Web browser is the client component.


Examples of Web browsers include Mosaic,<br />

Netscape <strong>and</strong> the <strong>IBM</strong> WebExplorer. The Web<br />

browser is responsible for formatting <strong>and</strong><br />

displaying information, interacting with the user<br />

<strong>and</strong> invoking external viewers for data types that<br />

it doesn’t support directly.<br />

Web Server. Web servers are responsible for<br />

servicing requests for information from Web<br />

browsers. The information can be a file retrieved<br />

from the servers local disk or generated by a<br />

program called by the server to perform a specific<br />

application function.<br />

window. A rectangular area of the screen with<br />

visible boundaries in which information is<br />

displayed. Windows can overlap on the screen,<br />

giving the appearance of one window being on<br />

top of another.<br />

World Wide Web. (WWW) (W3) (the Web) An<br />

Internet client-server distributed information <strong>and</strong><br />

retrieval system based upon HTTP that transfers<br />

hypertext documents across a varied array of<br />

computer systems. The Web was created by the<br />

CERN High-Energy Physics Laboratories in<br />

Geneva, Switzerl<strong>and</strong> in 1991. CERN boosted the<br />

Web into international prominence on the<br />

Internet.<br />

407


408 <strong>IMS</strong> <strong>Version</strong> 7 <strong>and</strong> <strong>Java</strong> <strong>Application</strong> <strong>Programming</strong>


Abbreviations <strong>and</strong> acronyms<br />

ACB Access Control Block<br />

AIB <strong>Application</strong> Interface<br />

Block<br />

API <strong>Application</strong> Program<br />

Interface<br />

BIN BINary<br />

BMP Batch Message<br />

Processing Region<br />

COBOL Common Business<br />

Oriented Language<br />

DB DataBase<br />

DBD Database Descriptor<br />

Block<br />

DB2 DataBase 2<br />

DD Data Definition JCL<br />

statement<br />

DLISAS Data Language I<br />

Separate Address<br />

Space<br />

DLI See DL/1<br />

DL/I Data Language 1<br />

<strong>IBM</strong> International Business<br />

Machines Corporation<br />

<strong>IMS</strong> Information<br />

Management System<br />

<strong>IMS</strong>/ESA Information<br />

Management<br />

System/Enterprise<br />

Systems Architecture<br />

INTERNET a worldwide network of<br />

TCP/IP-based networks<br />

ITSO International Technical<br />

Support Organization<br />

ISO International<br />

Organization for<br />

St<strong>and</strong>ardization<br />

ITSO International Technical<br />

Support Organization<br />

JCL Job Control Language<br />

(MVS <strong>and</strong> VSE)<br />

MFS Message Format<br />

Services<br />

MPP Message Processing<br />

Program<br />

MPR Message Processing<br />

Region<br />

MVS Multiple Virtual Storage<br />

(<strong>IBM</strong> System 370 &<br />

390)<br />

MVS/ESA Multiple Virtual<br />

Storage/Enterprise<br />

Systems Architecture<br />

(<strong>IBM</strong>)<br />

NT Microsoft Windows NT<br />

OS/390 Operating System 390<br />

PCB Program<br />

Communication Block<br />

PROC PROCedure<br />

PROCLIB PROCedure LIBrary<br />

(<strong>IBM</strong> System/360)<br />

PSB Program Specification<br />

Block<br />

PTF Program Temporary Fix<br />

RACF Resource Access<br />

Control Facility<br />

RBA Relative Byte Address<br />

REXX Restructured Extended<br />

eXecutor Language<br />

SPA Scratch Pad Area<br />

SSA Segment Search<br />

Argument<br />

TCPIP Transmission Control<br />

Protocol / Internet<br />

Protocol<br />

© Copyright <strong>IBM</strong> Corp. 2001 409


TM Transaction Manager<br />

TP Transaction<br />

Program/process (OSI)<br />

TSO Time Sharing Option<br />

USERID USER IDentification<br />

VTAM Virtual<br />

Telecommunications<br />

Access Method (<strong>IBM</strong>)<br />

(runs<br />

410 <strong>IMS</strong> <strong>Version</strong> 7 <strong>and</strong> <strong>Java</strong> <strong>Application</strong> <strong>Programming</strong>


Index<br />

Symbols<br />

/START <strong>IMS</strong>BMPx 354<br />

/START <strong>IMS</strong>MSGx 354<br />

A<br />

abbreviations 409<br />

Abends 305<br />

AcceptOrderInput class 377<br />

Accessing messages 46<br />

ACID 7<br />

acronyms 409<br />

Adding trace statements 308<br />

AIB 169<br />

AIB interface 305<br />

Alternate PCB program switching 10<br />

API 9<br />

APPLET 21<br />

Applets 21<br />

<strong>Application</strong> programming with DLIConnection 3<br />

B<br />

BPXBATCH 79, 83, 142<br />

C<br />

C 13, 23<br />

C++ 13<br />

CancelOrderInput class 378<br />

Carfound class 380<br />

CEEDUMP 163<br />

CEETDLI interface 169<br />

character-special files 74<br />

Class libraries 18<br />

Classes <strong>and</strong> field names 53<br />

CLASSPATH 27<br />

classpath path 89<br />

COBOL 10, 23<br />

COBOL code 70<br />

com.ibm.ims.application 169<br />

com.ibm.ims.base 169<br />

Commit failure 305<br />

connection to OS/390 30<br />

Conversational transactions 3, 10<br />

CORBA 11, 13<br />

Creating a DLIConnection object 3<br />

D<br />

Data Link Library 23<br />

DB2 V5 with APAR PQ19814 23<br />

DBD Gen Input 149<br />

DBPCB 169<br />

Dealer Class 358<br />

Dealer class 358<br />

DealerDatabaseView class 362<br />

dealership.application 357<br />

dealership.database 357<br />

debug tracing 160<br />

Debugging 160<br />

DEDB 10<br />

DFSMS/MVS NFS 25<br />

Diagnosing LE 163<br />

Diagnosing problems 163<br />

Directory structure 24<br />

distributed client-server model 13<br />

DL/I database 42, 52<br />

DL/I ROLL 306<br />

DLIConnection 42<br />

DLIConnection access of databases 3<br />

DLIConnection interface 70<br />

DLIDatabaseView 44, 49<br />

DLIException 299<br />

DLIRecord 43<br />

DLISegment 43, 44, 49<br />

DLISegmentInfo 43, 51<br />

DLITypeInfo 43, 52<br />

DLITypeInfo objects 44<br />

DLITypeInfoList 44<br />

DLL 23<br />

DLLs 104<br />

Downloading the JDK 25<br />

E<br />

EBCDIC character data 39<br />

editing your program 126<br />

EEE floating point notation 14<br />

enabling tracing 157<br />

encapsulating data 8<br />

eNetwork Communications Server facilities 23<br />

Enterprise ToolKit 104<br />

Enterprise Toolkit for OS/390 5<br />

error management 161<br />

ErrorMessage class 376<br />

ET/390 5, 69, 119, 136<br />

© Copyright <strong>IBM</strong> Corp. 2001 411


F<br />

Fast Path databases 10<br />

FindACarInput class 379<br />

FTP 119<br />

FTP client 23<br />

FTP links 30<br />

FTP server 23<br />

Full-Function databases 10<br />

Functional Recovery Routines 161<br />

G<br />

Get Unique 306<br />

GUI <strong>Java</strong> 69<br />

H<br />

HALDB 10<br />

H<strong>and</strong>ling exceptions 161<br />

HFS file system 71<br />

HFS files 83<br />

HIDAM 10<br />

High availability large databases 10<br />

High Performance <strong>Java</strong> 9<br />

HPJ 9, 354<br />

hpj comm<strong>and</strong> 104<br />

HPJ compiler 26, 27, 69<br />

HTML 9<br />

HTML format 135<br />

I<br />

<strong>IBM</strong> Domino 9<br />

IDL 13<br />

Import 120<br />

importing/exporting 126<br />

<strong>IMS</strong> Auto Dealership 131<br />

<strong>IMS</strong> Client for <strong>Java</strong> 8, 9, 151<br />

<strong>IMS</strong> Connect 23<br />

<strong>IMS</strong> Connector 151<br />

<strong>IMS</strong> <strong>Java</strong> 3, 157<br />

<strong>IMS</strong> <strong>Java</strong> Class Libraries 119<br />

<strong>IMS</strong> <strong>Java</strong> install 351<br />

<strong>IMS</strong> message queue 70<br />

<strong>IMS</strong> message region 151<br />

<strong>IMS</strong> MTO 354<br />

<strong>IMS</strong> V7 393<br />

<strong>IMS</strong> V7 Transaction Manager 23<br />

<strong>IMS</strong>_<strong>Java</strong>_Classes 121<br />

<strong>IMS</strong>Auto 131<br />

412 <strong>IMS</strong> <strong>Version</strong> 7 <strong>and</strong> <strong>Java</strong> <strong>Application</strong> <strong>Programming</strong><br />

<strong>IMS</strong>Auto class 363<br />

<strong>IMS</strong>Auto transaction 151<br />

<strong>IMS</strong>ErrorMessages 169<br />

<strong>IMS</strong><strong>Java</strong>PGM 127<br />

<strong>IMS</strong>Trace 157<br />

Initiating <strong>IMS</strong>Tracing 307<br />

input LTERM 41<br />

InputMessage class 313, 375<br />

Installation verification 3<br />

Installation Verification Program 316<br />

IOPCB 169<br />

ISHELL 73<br />

ISPF menu 72<br />

IVP <strong>Java</strong> programs 351<br />

IVP PGMLIB 351<br />

IVP Phone application 351<br />

IVPDatabaseView class 312<br />

J<br />

<strong>Java</strong> API to <strong>IMS</strong> xvii<br />

<strong>Java</strong> coding skills xvii<br />

<strong>Java</strong> Database Connectivity 10<br />

<strong>Java</strong> Development ToolKit 23<br />

<strong>Java</strong> programmers 9<br />

<strong>Java</strong> Run Time Library 26<br />

<strong>Java</strong> sample tracing 160<br />

<strong>Java</strong> Virtual Machine 11<br />

java.awt, java.jfc 18<br />

java.lang 18<br />

java.lang.Thread 18<br />

java.servlet 18<br />

java.sql.CallableStatement 59<br />

java.sql.Connection 57<br />

java.sql.DatabaseMetaData 58<br />

java.sql.Driver 58<br />

java.sql.PreparedStatement 59<br />

java.sql.ResultSet 58<br />

java.sql.ResultSetMetaData 59<br />

java.sql.Statement 58<br />

<strong>Java</strong>Bean 19<br />

javac compiler 70<br />

<strong>Java</strong>Development Toolkit for OS/390 24<br />

<strong>Java</strong>doc HTML files 14<br />

JAVADUMP 163<br />

<strong>Java</strong>ToDLI 70<br />

<strong>Java</strong>ToDLI example 3<br />

JDBC 3, 10, 53<br />

JDBC application 54


JDBC <strong>IMS</strong> 70<br />

JDBC interface xvii<br />

JDBC package 42<br />

JDK 70, 71<br />

JDK 1.1.1 for OS/390 16<br />

JDK 1.1.4 16<br />

JDK 1.1.8 24, 91<br />

JIT compiler 17<br />

JNI 10<br />

JVM 11, 16<br />

L<br />

Language Environment 163<br />

levels of tracing 160<br />

LIBPATH 27<br />

Logical relationships 10<br />

M<br />

Mapping 49<br />

MFS 10<br />

Model Class 359<br />

ModelList class 381<br />

MS Batch job 306<br />

MS BMP 353<br />

MS MPR 353<br />

MS PDSE PGMLIB 71<br />

MS<strong>Application</strong> 169<br />

MS-DOS prompt 29<br />

MSFieldMessage 51, 169<br />

MSMessageQueue 169<br />

MSTransaction 169<br />

Multi-segment messages 3, 10<br />

multi-segment messages 42<br />

MVS BPXBATCH 352<br />

MVS Unix System Services 119<br />

MVS USS HFS 138<br />

N<br />

Network Access Suite 28<br />

NFS 119<br />

NFS client 23, 28<br />

NFS connections 28, 138<br />

NFS server 23<br />

non-conversational transactions 10<br />

O<br />

object server 7<br />

OBROWSE 78, 86<br />

OCOPY 87<br />

ODBA 8<br />

OEDIT 78, 86<br />

OGET 88<br />

OGETX 88<br />

OMVS 81, 351<br />

OO programming language 10<br />

OpenEdition 8<br />

OPUT 88<br />

Order class 360<br />

OS/390 LE V1 R7 23<br />

OS/390 R2.6 23<br />

OS/390 shell 5<br />

OSHELL 79<br />

OTMA 8, 9<br />

output message 41<br />

OutputMessage class 314, 375<br />

P<br />

PATH 27<br />

PATHMODE 88<br />

PCB 10<br />

PDSE 23, 165<br />

Performance Analyzer 6<br />

PhoneBookSegment class 312<br />

PL/1 23<br />

POSIX 10<br />

Prerequisites 28<br />

problem detection 160<br />

program argument 160<br />

<strong>Programming</strong> Interfaces 70<br />

Providing an array 3<br />

PSB gen 49<br />

PSB Gen Input 150<br />

PSBGE 10<br />

pseudoabends 305<br />

R<br />

RACF 74<br />

RACF profile 74<br />

RecordASaleInput class 382<br />

Recoverable Resource Management Services 8<br />

repeating structures 44<br />

Required software 28<br />

REXX 24<br />

413


S<br />

Sales class 360<br />

Secondary indexes 10<br />

setDefaultEncoding 39<br />

ShowModelDetailsInput class 383<br />

SmartGuide 121, 128<br />

SNA 8<br />

SPA 39<br />

SPAMessage class 315<br />

SQL 3<br />

SQL92 query 53<br />

SQLJ 10<br />

SSA 43<br />

SSAList 43<br />

SSAList Object. 44<br />

SSAQualificationStatement 43<br />

Stock class 361<br />

StringWriter 158<br />

Subclassing DLIDatabaseView 46<br />

Subclassing <strong>IMS</strong>Segment 3<br />

T<br />

Tar file 24<br />

Tarball file 24<br />

TCP/IP 8, 23<br />

TFORMAT 354<br />

thread synchronization 160<br />

transaction code 42<br />

TSO/E 71<br />

TSO/E storage 28<br />

U<br />

UNIX System Services 26, 70<br />

UNIX Systems Services 6<br />

Use of AIB 165<br />

V<br />

VA-JAVA 131, 135<br />

VAJAVA/390-DEBUG feature 25<br />

Verifying the installation 25<br />

Visual Age for <strong>Java</strong> 25<br />

Visual Age for <strong>Java</strong> Enterprise Edition for OS/390<br />

23<br />

VisualAge for <strong>Java</strong> 5, 30, 69, 119<br />

VTCC DISPLAY Query 355<br />

414 <strong>IMS</strong> <strong>Version</strong> 7 <strong>and</strong> <strong>Java</strong> <strong>Application</strong> <strong>Programming</strong><br />

W<br />

WebSphere <strong>Application</strong> Server 11<br />

Windows NT 28, 30<br />

Workbench 124<br />

Workload Manager 6<br />

Workstation environment 28


<strong>IBM</strong> <strong>Redbooks</strong> review<br />

Your feedback is valued by the Redbook authors. In particular we are interested in situations where a<br />

Redbook "made the difference" in a task or problem you encountered. Using one of the following<br />

methods, please review the Redbook, addressing value, subject matter, structure, depth <strong>and</strong><br />

quality as appropriate.<br />

Use the online Contact us review redbook form found at ibm.com/redbooks<br />

Fax this form to: USA International Access Code + 1 914 432 8264<br />

Send your comments in an Internet note to redbook@us.ibm.com<br />

Document Number<br />

Redbook Title<br />

Review<br />

What other subjects would you<br />

like to see <strong>IBM</strong> <strong>Redbooks</strong><br />

address?<br />

Please rate your overall<br />

satisfaction:<br />

Please identify yourself as<br />

belonging to one of the<br />

following groups:<br />

Your email address:<br />

The data you provide here may<br />

be used to provide you with<br />

information from <strong>IBM</strong> or our<br />

business partners about our<br />

products, services or activities.<br />

Questions about <strong>IBM</strong>’s privacy<br />

policy?<br />

SG24-6123-00<br />

<strong>IMS</strong> <strong>Version</strong> 7 <strong>and</strong> <strong>Java</strong> <strong>Application</strong> <strong>Programming</strong><br />

O Very Good O Good O Average O Poor<br />

O Customer O Business Partner O Solution Developer<br />

O <strong>IBM</strong>, Lotus or Tivoli Employee<br />

O None of the above<br />

O Please do not use the information collected here for future<br />

marketing or promotional contacts or other communications beyond<br />

the scope of this transaction.<br />

The following link explains how we protect your personal information.<br />

ibm.com/privacy/yourprivacy/<br />

© Copyright <strong>IBM</strong> Corp. 2001 415


<strong>IMS</strong> <strong>Version</strong> 7 <strong>and</strong> <strong>Java</strong> <strong>Application</strong> <strong>Programming</strong><br />

(0.5” spine)<br />

0.475”0.875”<br />

250 459 pages


<strong>IMS</strong> <strong>Version</strong> 7 <strong>and</strong> <strong>Java</strong><br />

<strong>Application</strong> <strong>Programming</strong><br />

Learn to develop <strong>IMS</strong><br />

<strong>Java</strong> applications by<br />

following examples<br />

Create <strong>Java</strong> control<br />

<strong>and</strong> execution<br />

statements<br />

Gain practical<br />

experience in using<br />

<strong>Java</strong><br />

This <strong>IBM</strong> Redbook is intended for customers who wish to<br />

exploit the <strong>Java</strong> language support provided by <strong>IMS</strong> <strong>Version</strong><br />

7.1. Its prime audience are <strong>IMS</strong> <strong>and</strong> <strong>Java</strong> application<br />

programmers, who can now use <strong>Java</strong> to develop <strong>IMS</strong><br />

application transactions, <strong>and</strong> <strong>IMS</strong> system programmers, who<br />

support <strong>IMS</strong> applications development. This book will be<br />

helpful to any organization that would like to access <strong>IMS</strong><br />

databases by using <strong>Java</strong> application programming.<br />

As <strong>Java</strong> coding skills have become more readily available in<br />

the IT employment marketplace, application development<br />

with <strong>Java</strong> has become the de facto coding st<strong>and</strong>ard. This<br />

book assumes a certain level of knowledge of <strong>IMS</strong>, <strong>Java</strong>, <strong>and</strong><br />

UNIX. It covers the base concepts of the <strong>Java</strong> environment,<br />

the S/390 software <strong>and</strong> hardware requirements which enable<br />

<strong>Java</strong> on the Enterprise platform, <strong>and</strong> how to download, install,<br />

<strong>and</strong> configure the <strong>Java</strong> related application development<br />

environment for your workstation, <strong>IMS</strong>/ESA, <strong>and</strong> OS/390.<br />

We discuss two <strong>IMS</strong> applications that were developed within<br />

<strong>IBM</strong>, using the <strong>Java</strong> API to <strong>IMS</strong>. The Telephone Directory IVP<br />

application uses the <strong>Java</strong> Native DL/I interface, <strong>and</strong> the <strong>IMS</strong><br />

Auto Dealership application employs the JDBC interface from<br />

<strong>Java</strong> to <strong>IMS</strong>. We also provide guidance on debugging,<br />

problem determination, <strong>and</strong> some of the development<br />

limitations you may encounter.<br />

SG24-6123-00 ISBN 0738418277<br />

INTERNATIONAL<br />

TECHNICAL<br />

SUPPORT<br />

ORGANIZATION<br />

®<br />

BUILDING TECHNICAL<br />

INFORMATION BASED ON<br />

PRACTICAL EXPERIENCE<br />

<strong>IBM</strong> <strong>Redbooks</strong> are developed by<br />

the <strong>IBM</strong> International Technical<br />

Support Organization. Experts<br />

from <strong>IBM</strong>, Customers <strong>and</strong><br />

Partners from around the world<br />

create timely technical<br />

information based on realistic<br />

scenarios. Specific<br />

recommendations are provided<br />

to help you implement IT<br />

solutions more effectively in<br />

your environment.<br />

For more information:<br />

ibm.com/redbooks

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!