467
IMS Version 10 Application Programming Guide SC18-9698-02

IMS Application Programming.pdf

Embed Size (px)

Citation preview

Page 1: IMS Application Programming.pdf

IMSVersion 10

Application Programming Guide

SC18-9698-02

���

Page 2: IMS Application Programming.pdf
Page 3: IMS Application Programming.pdf

IMSVersion 10

Application Programming Guide

SC18-9698-02

���

Page 4: IMS Application Programming.pdf

NoteBefore using this information and the product it supports, read the information in “Notices” on page 417.

This edition applies to IMS Version 10 (program number 5635-A01) and to all subsequent releases and modificationsuntil otherwise indicated in new editions. This edition replaces SC18-9698-01.

© Copyright IBM Corporation 1974, 2010.US Government Users Restricted Rights – Use, duplication or disclosure restricted by GSA ADP Schedule Contractwith IBM Corp.

Page 5: IMS Application Programming.pdf

Contents

Figures . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . vii

Tables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ix

About this information . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xiPrerequisite knowledge . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xiIBM product names used in this information . . . . . . . . . . . . . . . . . . . . . . . . xiiIMS function names used in this information . . . . . . . . . . . . . . . . . . . . . . . . xiiiHow to read syntax diagrams . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xiiiAccessibility features for IMS Version 10 . . . . . . . . . . . . . . . . . . . . . . . . . xvHow to send your comments . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xvi

Changes to the IMS library for IMS Version 10 . . . . . . . . . . . . . . . . . . xvii

Part 1. Application programming for IMS DB . . . . . . . . . . . . . . . . . . 1

Chapter 1. Writing your application programs for IMS DB . . . . . . . . . . . . . . 3Programming guidelines . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3Segment search arguments (SSAs) . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4Considerations for coding DL/I calls and data areas. . . . . . . . . . . . . . . . . . . . . . 12Preparing to run your Java application program . . . . . . . . . . . . . . . . . . . . . . . 13Preparing to run your CICS DL/I call program . . . . . . . . . . . . . . . . . . . . . . . 14Examples of how to code DL/I calls and data areas . . . . . . . . . . . . . . . . . . . . . . 14

Chapter 2. Defining application program elements for IMS DB . . . . . . . . . . . . 39Formatting DL/I calls for language interfaces . . . . . . . . . . . . . . . . . . . . . . . . 39Assembler language application programming. . . . . . . . . . . . . . . . . . . . . . . . 40C language application programming. . . . . . . . . . . . . . . . . . . . . . . . . . . 42COBOL application programming . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45Java application programming for IMS . . . . . . . . . . . . . . . . . . . . . . . . . . 48Pascal application programming . . . . . . . . . . . . . . . . . . . . . . . . . . . . 48Application programming for PL/I . . . . . . . . . . . . . . . . . . . . . . . . . . . 51Specifying the I/O PCB mask . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 53Specifying the DB PCB mask . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 56Specifying the AIB mask . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 59Specifying the AIB mask for ODBA applications . . . . . . . . . . . . . . . . . . . . . . . 61Specifying the UIB (CICS online programs only) . . . . . . . . . . . . . . . . . . . . . . . 63Specifying the I/O areas . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 66Formatting segment search arguments (SSAs) . . . . . . . . . . . . . . . . . . . . . . . . 66Data areas in GSAM databases . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 72The AIBTDLI interface. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 72Language specific entry points . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 73Program communication block (PCB) lists . . . . . . . . . . . . . . . . . . . . . . . . . 76The AERTDLI interface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 77Language environments . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 78Special DL/I situations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 79

Chapter 3. Establishing a DL/I interface from COBOL or PL/I . . . . . . . . . . . . 81CBLTDLI . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 81PLITDLI . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 81

Chapter 4. Current position in the database after each call . . . . . . . . . . . . . 83Current position after successful calls. . . . . . . . . . . . . . . . . . . . . . . . . . . 83

© Copyright IBM Corp. 1974, 2010 iii

||

||

||

Page 6: IMS Application Programming.pdf

Current position after unsuccessful calls . . . . . . . . . . . . . . . . . . . . . . . . . . 88Multiple processing. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 93

Chapter 5. Using IMS application program sync points . . . . . . . . . . . . . . 101The commit process . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 101Two-phase commit in the synchronization process . . . . . . . . . . . . . . . . . . . . . . 103Sync-point log records . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 105Sync points with a data-propagation manager . . . . . . . . . . . . . . . . . . . . . . . 106

Chapter 6. Recovering databases and maintaining database integrity . . . . . . . . 107Issuing checkpoints . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 107Restarting your program from the latest checkpoint . . . . . . . . . . . . . . . . . . . . . 107Maintaining database integrity (IMS batch, BMP, and IMS online regions) . . . . . . . . . . . . . . 108Reserving segments for the exclusive use of your program . . . . . . . . . . . . . . . . . . . 115

Chapter 7. Secondary indexing and logical relationships. . . . . . . . . . . . . . 117How secondary indexing affects your program . . . . . . . . . . . . . . . . . . . . . . . 117Processing segments in logical relationships . . . . . . . . . . . . . . . . . . . . . . . . 121

Chapter 8. HALDB selective partition processing . . . . . . . . . . . . . . . . . 125Control Statements for HALDB selective partition processing . . . . . . . . . . . . . . . . . . 125Parameter descriptions for HALDB selective partition processing . . . . . . . . . . . . . . . . . 125Examples of HALDB selective partition processing statements . . . . . . . . . . . . . . . . . . 126Report generated for HALDB selective partition processing . . . . . . . . . . . . . . . . . . . 126

Chapter 9. Processing GSAM databases . . . . . . . . . . . . . . . . . . . . . 131Accessing GSAM databases. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 131GSAM record formats . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 136GSAM I/O areas . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 136GSAM status codes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 137Symbolic CHKP and XRST with GSAM . . . . . . . . . . . . . . . . . . . . . . . . . 137GSAM coding considerations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 138Origin of GSAM data set characteristics . . . . . . . . . . . . . . . . . . . . . . . . . 139

Chapter 10. Processing Fast Path databases . . . . . . . . . . . . . . . . . . . 145Fast Path database calls . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 145Main storage databases (MSDBs) . . . . . . . . . . . . . . . . . . . . . . . . . . . . 146Data entry databases (DEDBs) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 147Processing MSDBs and DEDBs . . . . . . . . . . . . . . . . . . . . . . . . . . . . 147Restrictions on using calls for MSDBs . . . . . . . . . . . . . . . . . . . . . . . . . . 154Processing DEDBs (IMS and CICS with DBCTL). . . . . . . . . . . . . . . . . . . . . . . 154Calls with dependent segments for DEDBs . . . . . . . . . . . . . . . . . . . . . . . . 163DEDB DL/I calls to extract DEDB information . . . . . . . . . . . . . . . . . . . . . . . 164Fast Path coding considerations . . . . . . . . . . . . . . . . . . . . . . . . . . . . 171

Chapter 11. Writing ODBA application programs . . . . . . . . . . . . . . . . . 173General application program flow . . . . . . . . . . . . . . . . . . . . . . . . . . . 174Server program structure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 177DB2 for z/OS Stored Procedures use of ODBA . . . . . . . . . . . . . . . . . . . . . . . 178

Part 2. Application programming for IMS TM . . . . . . . . . . . . . . . . . 181

Chapter 12. Defining application program elements for IMS TM . . . . . . . . . . . 183Formatting DL/I calls for language interfaces . . . . . . . . . . . . . . . . . . . . . . . 183Application programming for assembler language . . . . . . . . . . . . . . . . . . . . . . 184Application programming for C language . . . . . . . . . . . . . . . . . . . . . . . . . 186Application programming for COBOL . . . . . . . . . . . . . . . . . . . . . . . . . . 189Application programming for Java . . . . . . . . . . . . . . . . . . . . . . . . . . . 192

iv Application Programming Guide

||||

||

||

||

Page 7: IMS Application Programming.pdf

Application programming for Pascal . . . . . . . . . . . . . . . . . . . . . . . . . . 192Application programming for PL/I . . . . . . . . . . . . . . . . . . . . . . . . . . . 195Relationship of calls to PCB types . . . . . . . . . . . . . . . . . . . . . . . . . . . 197Specifying the I/O PCB mask . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 198Specifying the alternate PCB mask . . . . . . . . . . . . . . . . . . . . . . . . . . . 202Specifying the AIB mask . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 203Specifying the I/O areas. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 205AIBTDLI interface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 205Specifying language-specific entry points . . . . . . . . . . . . . . . . . . . . . . . . . 206Program communication block (PCB) lists . . . . . . . . . . . . . . . . . . . . . . . . . 208Language environments . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 209Special DL/I situations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 210

Chapter 13. Message processing . . . . . . . . . . . . . . . . . . . . . . . . 213How your program processes messages . . . . . . . . . . . . . . . . . . . . . . . . . 213How IMS TM edits messages . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 219Message processing considerations for DB2 . . . . . . . . . . . . . . . . . . . . . . . . 227Sending messages to other terminals and programs . . . . . . . . . . . . . . . . . . . . . 228Communicating with other IMS TM systems using MSC . . . . . . . . . . . . . . . . . . . . 233IMS conversations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 236Processing conversations with APPC . . . . . . . . . . . . . . . . . . . . . . . . . . 246Processing conversations with OTMA . . . . . . . . . . . . . . . . . . . . . . . . . . 250Backing out to a prior commit point: ROLL, ROLB, and ROLS calls . . . . . . . . . . . . . . . . 250Backing out to an intermediate backout point: SETS/SETU and ROLS . . . . . . . . . . . . . . . 254Writing message-driven programs . . . . . . . . . . . . . . . . . . . . . . . . . . . 257Coding DC calls and data areas . . . . . . . . . . . . . . . . . . . . . . . . . . . . 257

Chapter 14. Spool API. . . . . . . . . . . . . . . . . . . . . . . . . . . . . 269Understanding parsing errors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 269Understanding allocation errors . . . . . . . . . . . . . . . . . . . . . . . . . . . . 273Understanding dynamic output for print data sets . . . . . . . . . . . . . . . . . . . . . . 273Sample program using the Spool API . . . . . . . . . . . . . . . . . . . . . . . . . . 274

Chapter 15. Introduction to Message Format Service (MFS) . . . . . . . . . . . . 279Advantages of using MFS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 279MFS control blocks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 281Overview of MFS components and operation. . . . . . . . . . . . . . . . . . . . . . . . 287Devices and logical units that operate with MFS. . . . . . . . . . . . . . . . . . . . . . . 290Using distributed presentation management (DPM) . . . . . . . . . . . . . . . . . . . . . 292

Chapter 16. Callout requests for external services or data . . . . . . . . . . . . . 293Callout request approaches . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 294OTMA destination descriptors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 294Resume tpipe protocol . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 295Implementing the synchronous callout function . . . . . . . . . . . . . . . . . . . . . . . 296Implementing the asynchronous callout function . . . . . . . . . . . . . . . . . . . . . . 299

Part 3. Application programming for EXEC DLI . . . . . . . . . . . . . . . . 301

Chapter 17. Writing your application programs for EXEC DLI . . . . . . . . . . . . 303Programming guidelines . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 303Preparing your EXEC DLI program for execution . . . . . . . . . . . . . . . . . . . . . . 321

Chapter 18. Defining application program elements . . . . . . . . . . . . . . . . 323Specifying an application interface block (AIB) . . . . . . . . . . . . . . . . . . . . . . . 323Specifying the DL/I interface block (DIB) . . . . . . . . . . . . . . . . . . . . . . . . . 323Defining a key feedback area . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 327Defining I/O areas . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 327

Contents v

||||||||||||

Page 8: IMS Application Programming.pdf

Chapter 19. EXEC DLI commands for an application program . . . . . . . . . . . 329PCBs and PSB . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 329

Chapter 20. Recovering databases and maintaining database integrity. . . . . . . . 333Issuing checkpoints in a batch or BMP program . . . . . . . . . . . . . . . . . . . . . . . 333Restarting your program and checking for position. . . . . . . . . . . . . . . . . . . . . . 334Backing out database updates dynamically: the ROLL and ROLB commands . . . . . . . . . . . . . 334Using intermediate backout points: the SETS and ROLS commands . . . . . . . . . . . . . . . . 335

Chapter 21. Processing Fast Path databases . . . . . . . . . . . . . . . . . . . 337Processing DEDBs with subset pointers. . . . . . . . . . . . . . . . . . . . . . . . . . 337The POS command . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 347

Chapter 22. Comparing command-level and call-level programs . . . . . . . . . . 351DL/I calls for IMS and CICS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 351Comparing EXEC DLI commands and DL/I calls . . . . . . . . . . . . . . . . . . . . . . 352Comparing command codes and options . . . . . . . . . . . . . . . . . . . . . . . . . 353

Chapter 23. Data availability enhancements . . . . . . . . . . . . . . . . . . . 355Accepting database availability status codes . . . . . . . . . . . . . . . . . . . . . . . . 355Obtaining information about database availability . . . . . . . . . . . . . . . . . . . . . . 355

Part 4. Java application development for IMS . . . . . . . . . . . . . . . . 357

Chapter 24. Where to find more information about IMS solutions for Javadevelopment. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 359

Chapter 25. Introduction to the Java class libraries for IMS . . . . . . . . . . . . 361JDBC driver for IMS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 363Java API for IMS DB . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 364Java API for IMS TM . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 364J2EE platform access to IMS DB . . . . . . . . . . . . . . . . . . . . . . . . . . . . 365

Chapter 26. Developing Java applications that work with IMS . . . . . . . . . . . 367IMS IVP jobs, tasks, and sample applications . . . . . . . . . . . . . . . . . . . . . . . . 367Developing JMP and JBP applications . . . . . . . . . . . . . . . . . . . . . . . . . . 368Developing DB2 for z/OS stored procedures that access IMS . . . . . . . . . . . . . . . . . . 397Developing CICS applications that access IMS . . . . . . . . . . . . . . . . . . . . . . . 399Developing enterprise applications that access IMS . . . . . . . . . . . . . . . . . . . . . . 400

Chapter 27. Problem determination . . . . . . . . . . . . . . . . . . . . . . . 409Exceptions thrown from IMS DL/I calls . . . . . . . . . . . . . . . . . . . . . . . . . 409XML tracing for the Java class libraries for IMS . . . . . . . . . . . . . . . . . . . . . . . 410

Notices . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 417Programming interface information . . . . . . . . . . . . . . . . . . . . . . . . . . . 419Trademarks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 419

Bibliography. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 421IMS Version 10 library . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 421Supplementary publications . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 421Publication collections . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 422Accessibility titles cited in the IMS Version 10 library . . . . . . . . . . . . . . . . . . . . . 422

Index . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 423

vi Application Programming Guide

||||||||||

||||

Page 9: IMS Application Programming.pdf

Figures

1. Organization of the IMS Version 10 library in the information center. . . . . . . . . . . . . . xviii2. Segment with a noncontiguous sequence field . . . . . . . . . . . . . . . . . . . . . . 73. D command code example . . . . . . . . . . . . . . . . . . . . . . . . . . . . 114. Sample assembler language program . . . . . . . . . . . . . . . . . . . . . . . . . 165. Sample call-level assembler language program (CICS online) . . . . . . . . . . . . . . . . . 186. Sample C language program . . . . . . . . . . . . . . . . . . . . . . . . . . . . 207. Sample COBOL program . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 238. Sample COBOL program that can run in CICS . . . . . . . . . . . . . . . . . . . . . . 259. Sample call-level OS/VS COBOL program for CICS online (obsolete with Enterprise COBOL) . . . . . . 28

10. Sample JDBC application . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3011. Sample PL/I program . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3312. Sample call-level PL/I program (CICS online) . . . . . . . . . . . . . . . . . . . . . . 3613. Defining the UIB, PCB address list, and the PCB mask for VS COBOL II . . . . . . . . . . . . . 6414. The COBOL COPY DLIUIB copy book . . . . . . . . . . . . . . . . . . . . . . . . 6515. Defining the UIB, PCB address list, and the PCB mask for PL/I . . . . . . . . . . . . . . . . 6616. Defining the UIB, PCB address list, and the PCB mask for assembler language . . . . . . . . . . . 6617. Example code: * CONSTANT AREA . . . . . . . . . . . . . . . . . . . . . . . . . 6818. Current position hierarchy . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8419. Example code: deleting segment C11 . . . . . . . . . . . . . . . . . . . . . . . . . 8520. Hierarchy after deleting a segment . . . . . . . . . . . . . . . . . . . . . . . . . . 8621. Hierarchy after deleting a segment and dependents . . . . . . . . . . . . . . . . . . . . 8722. Hierarchy after adding new segments and dependents . . . . . . . . . . . . . . . . . . . 8823. DL/I positions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9024. Multiple processing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9325. Multiple positioning hierarchy . . . . . . . . . . . . . . . . . . . . . . . . . . . 9426. Single and multiple positioning hierarchy . . . . . . . . . . . . . . . . . . . . . . . 9527. Independence of system checkpoints and application sync points . . . . . . . . . . . . . . . 10228. Two-phase commit process . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10429. SETS and ROLS calls working together . . . . . . . . . . . . . . . . . . . . . . . . 11230. Example of using the dependent AND . . . . . . . . . . . . . . . . . . . . . . . . 11931. Example of using the independent AND . . . . . . . . . . . . . . . . . . . . . . . 11932. Patient and item hierarchies. . . . . . . . . . . . . . . . . . . . . . . . . . . . 12233. Concatenated segment . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12234. DFSHALDB for single partition restriction . . . . . . . . . . . . . . . . . . . . . . . 12635. DFSHALDB for range partition restriction . . . . . . . . . . . . . . . . . . . . . . . 12636. DFSHALDB for independent processing of partitions . . . . . . . . . . . . . . . . . . . 12637. Example of GSAM or BSAM where the records are variable . . . . . . . . . . . . . . . . . 14238. //IMS DD statement example . . . . . . . . . . . . . . . . . . . . . . . . . . . 14339. Sample PCB specifying View=MSDB . . . . . . . . . . . . . . . . . . . . . . . . . 15340. Processing a long chain of segment occurrences with subset pointers . . . . . . . . . . . . . . 15541. Examples of setting subset pointers . . . . . . . . . . . . . . . . . . . . . . . . . 15542. Additional examples of setting subset pointers . . . . . . . . . . . . . . . . . . . . . 15643. How subset pointers divide a chain into subsets . . . . . . . . . . . . . . . . . . . . . 15644. z/OS application region's connection to IMS DB . . . . . . . . . . . . . . . . . . . . . 17345. DRA uses one TCB per thread . . . . . . . . . . . . . . . . . . . . . . . . . . . 17746. DB2 for z/OS Stored Procedures connection to IMS DB . . . . . . . . . . . . . . . . . . 17847. DB2 for z/OS Stored Procedures relationships . . . . . . . . . . . . . . . . . . . . . 17948. Message segments . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21449. Transaction message flow . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21750. Inventory inquiry MPP example . . . . . . . . . . . . . . . . . . . . . . . . . . 21851. Terminal screen for MFS example . . . . . . . . . . . . . . . . . . . . . . . . . . 22352. MSC example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23553. Directed routing bit in I/O PCB . . . . . . . . . . . . . . . . . . . . . . . . . . 23554. General format of a modified DL/I application program . . . . . . . . . . . . . . . . . . 24955. General format of a CPI-C driven application program. . . . . . . . . . . . . . . . . . . 250

© Copyright IBM Corp. 1974, 2010 vii

||

||||||||

||

||||||

||

Page 10: IMS Application Programming.pdf

56. SETS and ROLS calls working together . . . . . . . . . . . . . . . . . . . . . . . . 25557. Skeleton MPP written in C . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26058. Skeleton MPP written in COBOL . . . . . . . . . . . . . . . . . . . . . . . . . . 26259. Skeleton MPP written in Pascal . . . . . . . . . . . . . . . . . . . . . . . . . . 26460. Skeleton MPP written in PL/I . . . . . . . . . . . . . . . . . . . . . . . . . . . 26661. Issuing a GU call to the I/O PCB . . . . . . . . . . . . . . . . . . . . . . . . . . 27562. Issuing a CHNG call to the alternate modifiable PCB . . . . . . . . . . . . . . . . . . . 27663. Issuing an ISRT call to the alternate modifiable PCB . . . . . . . . . . . . . . . . . . . 27664. Message formatting using MFS . . . . . . . . . . . . . . . . . . . . . . . . . . 28065. MFS control block relationships . . . . . . . . . . . . . . . . . . . . . . . . . . 28266. PAYDAY screen, formatted by DOF . . . . . . . . . . . . . . . . . . . . . . . . . 28367. PAYDAY screen, with filled input fields . . . . . . . . . . . . . . . . . . . . . . . . 28368. PAYDAY screen, output formatted by DOF and displayed . . . . . . . . . . . . . . . . . 28469. Sample MFS control block coding . . . . . . . . . . . . . . . . . . . . . . . . . . 28770. Message flow of the synchronous callout function . . . . . . . . . . . . . . . . . . . . 29771. Processing a long chain of segment occurrences with subset pointers . . . . . . . . . . . . . . 33872. Examples of setting multiple subset pointers . . . . . . . . . . . . . . . . . . . . . . 33873. More examples of setting subset pointers . . . . . . . . . . . . . . . . . . . . . . . 33974. How subset pointers divide a chain into subsets . . . . . . . . . . . . . . . . . . . . . 33975. Processing performed for the sample passbook example when the passbook is unavailable . . . . . . 34176. Processing performed for the sample passbook example when the passbook is available . . . . . . . 34177. Retrieving the first segment in a chain of segments . . . . . . . . . . . . . . . . . . . . 34278. Moving the subset pointer to the next segment after your current position . . . . . . . . . . . . 34479. Unconditionally setting the subset pointer to your current position . . . . . . . . . . . . . . 34580. Conditionally setting the subset pointer to your current position . . . . . . . . . . . . . . . 34681. Deploying Java applications in dependent regions and external development environments . . . . . . 36282. JMP or JBP application that is using the Java class libraries for IMS . . . . . . . . . . . . . . 36983. Subclass IMSFieldMessage: input message sample code . . . . . . . . . . . . . . . . . . 37084. Subclass IMSFieldMessage: output message sample code . . . . . . . . . . . . . . . . . . 37185. main method sample code . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37286. main method sample code . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37387. Defining a SPA message . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37588. Reading a SPA message . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37589. Writing a SPA message . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37690. Sample output message with repeating structures . . . . . . . . . . . . . . . . . . . . 37891. Defining the primary input message . . . . . . . . . . . . . . . . . . . . . . . . . 37892. Defining separate input messages for each request . . . . . . . . . . . . . . . . . . . . 37993. Message-reading logic . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 38094. DB2 for z/OS stored procedure that uses Java class libraries for IMS DB. . . . . . . . . . . . . 39895. CICS application that uses the Java class libraries for IMS DB . . . . . . . . . . . . . . . . 39996. WebSphere Application Server for z/OS EJB using IMS DB resource adapter . . . . . . . . . . . 40197. IMS DB distributed resource adapter and WebSphere Application Server components . . . . . . . . 40298. IMSException class example . . . . . . . . . . . . . . . . . . . . . . . . . . . 41099. Setting a trace within a static method . . . . . . . . . . . . . . . . . . . . . . . . 412

viii Application Programming Guide

||

||||||||||||||||||||||||||

||

Page 11: IMS Application Programming.pdf

Tables

1. Licensed program full names and short names. . . . . . . . . . . . . . . . . . . . . . xii2. High-level user tasks and the IMS Version 10 books that supports those tasks . . . . . . . . . . . xix3. Qualified SSA structure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 54. Unqualified SSA with command code . . . . . . . . . . . . . . . . . . . . . . . . . 115. Qualified SSA with command code. . . . . . . . . . . . . . . . . . . . . . . . . . 116. I/O PCB mask . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 537. DB PCB mask . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 578. AIB fields . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 599. AIB fields for use of ODBA applications . . . . . . . . . . . . . . . . . . . . . . . . 61

10. Relational operators . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6711. I/O PCB and alternate PCB information summary . . . . . . . . . . . . . . . . . . . . 7712. Using LANG= option in a Language Environment for PL/I compatibility . . . . . . . . . . . . . 7913. Results of single and multiple positioning with DL/I calls . . . . . . . . . . . . . . . . . . 9514. Comparison of ROLB, ROLL, and ROLS . . . . . . . . . . . . . . . . . . . . . . . 10915. Messages provided in the report generated for HALDB selective partition processing . . . . . . . . 12616. Messages provided in the report generated for syntactically incorrect HALDB statements . . . . . . . 12717. GSAM DB PCB mask . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13218. Format of the RSA for basic format data sets . . . . . . . . . . . . . . . . . . . . . . 13419. Format of the RSA for large format data sets . . . . . . . . . . . . . . . . . . . . . . 13420. Summary of GSAM calls . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13821. BSAM and VSAM logical record lengths for GSAM data sets by record format. . . . . . . . . . . 13922. Summary of Fast Path database calls . . . . . . . . . . . . . . . . . . . . . . . . . 14523. Subset pointer command codes and calls . . . . . . . . . . . . . . . . . . . . . . . 14624. FSA structure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14925. Unqualified SSA with subset pointer command code . . . . . . . . . . . . . . . . . . . 15726. Qualified SSA with subset pointer command code . . . . . . . . . . . . . . . . . . . . 15727. Qualified POS call: keywords and map of I/O area returned. . . . . . . . . . . . . . . . . 16028. DEDB DL/I Calls . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16429. Field initialization for DEDB DL/I calls . . . . . . . . . . . . . . . . . . . . . . . . 16530. Fields initialized for specific DEDB DL/I calls . . . . . . . . . . . . . . . . . . . . . 16631. Fields updated by IMS for all DL/I call types. . . . . . . . . . . . . . . . . . . . . . 16632. Fields updated by specific DL/I calls . . . . . . . . . . . . . . . . . . . . . . . . 16633. Status codes for specific DEDB DL/I calls . . . . . . . . . . . . . . . . . . . . . . . 17034. Call relationship to PCBs and AIBs . . . . . . . . . . . . . . . . . . . . . . . . . 19835. I/O PCB mask . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19936. Alternate PCB mask . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20237. AIB fields . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20338. Using LANG= option in a Language Environment for PL/I compatibility . . . . . . . . . . . . 21039. Input message format . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21540. Input message format for the PLITDLI interface . . . . . . . . . . . . . . . . . . . . . 21541. Output message format . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21642. Output message format for PLITDLI . . . . . . . . . . . . . . . . . . . . . . . . . 21643. Four-segment message . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22244. MFS option 1 message format . . . . . . . . . . . . . . . . . . . . . . . . . . . 22345. MFS option 2 message format . . . . . . . . . . . . . . . . . . . . . . . . . . . 22546. MFS option 3 message format . . . . . . . . . . . . . . . . . . . . . . . . . . . 22647. Message Format for program-to-program message switch for AIBTDLI, ASMTDLI, CBLTDLI, CEETDLI,

CTDLI, and PASTDLI interfaces . . . . . . . . . . . . . . . . . . . . . . . . . . 23248. Message format for program-to-program message switch for the PLITDLI interface . . . . . . . . . 23249. Directed routing output message format for AIBTDLI, ASMTDLI, CBLTDLI, CEETDLI, CTDLI, and

PASTDLI interfaces . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23650. Directed routing output message format for the PLITDLI interface . . . . . . . . . . . . . . . 23651. SPA format for AIBTDLI, ASMTDLI, CBLTDLI, CEETDLI, CTDLI, and PASTDLI interfaces . . . . . . 24052. SPA format for the PLITDLI interface . . . . . . . . . . . . . . . . . . . . . . . . 24053. Comparison of ROLB, ROLL, and ROLS . . . . . . . . . . . . . . . . . . . . . . . 251

© Copyright IBM Corp. 1974, 2010 ix

||

||

||||||

||

||||||||||||

Page 12: IMS Application Programming.pdf

54. Terminal devices that operate with MFS . . . . . . . . . . . . . . . . . . . . . . . 29055. Summary of differences between synchronous and asynchronous callout requests. . . . . . . . . . 29356. Summary of PCB information . . . . . . . . . . . . . . . . . . . . . . . . . . . 33057. DL/I calls available to IMS and CICS command-level application programs . . . . . . . . . . . 35158. Comparing call-level and command-level programs: commands and calls . . . . . . . . . . . . 35259. Comparing call-level and command-level programs: command codes and options . . . . . . . . . 35360. Relationship between the transaction context and the transaction semantics . . . . . . . . . . . . 407

x Application Programming Guide

||

Page 13: IMS Application Programming.pdf

About this information

This information is a guide to application programming for any of the followingenvironments:v IMS™ Database Manager (IMS DB), including IMS Database Control (DBCTL)v IMS Transaction Manager (IMS TM)v CICS® EXEC DLIv Java class libraries for IMS

This book provides guidance information for writing application programs thataccess IMS databases or process IMS messages. It also describes how to usedifferent programming languages to make DL/I, EXEC DLI, or JDBC calls thatinteract with IMS. API (application programming interface) information is in theIMS Version 10 Application Programming API Reference.

Information about IMS solutions for Java Development is also available from theIMS Web site. Go to www.ibm.com/ims and link to the IMS solutions for Javadevelopment page.

This information is available as part of the Information Management Software forz/OS Solutions Information Center at http://publib.boulder.ibm.com/infocenter/imzic. A PDF version of this information is available in the information center.

Prerequisite knowledgeBefore using this book, you should understand the concepts of application designdescribed in IMS Version 10: Application Programming Planning Guide, whichassumes you understand basic IMS concepts and the IMS environments. Youshould also know how to use assembler language, C language, COBOL, Pascal, orPL/I. CICS programs can be written in assembler language, C language, COBOL,PL/I, and C++.

This book assumes you are a CICS programmer familiar with the functions,facilities, hardware, and software in CICS Family: General Information and from theLibrary page of the IMS home page on the Web: www.ibm.com/ims. This bookalso assumes that, if you plan to write a CICS program, you are familiar with theprinciples covered in CICS Transaction Server for z/OS CICS Application Programmingand in other CICS documentation.

To write Java applications, you must thoroughly understand the Java language andJDBC. This book assumes that you know Java and JDBC. It does not explain anyJava or JDBC concepts.

To create metadata classes for Java in IMS, which is a required step in writing Javaapplications, you must understand IMS databases. IMS database concepts aredescribed in IMS Version 10: Database Administration Guide.

To write applications that store or retrieve XML, you must understand XML and itsrelated technologies, such as XML schemas.

You can gain an understanding of basic IMS concepts by reading An Introduction toIMS, an IBM® Press publication written by Dean H. Meltz, Rick Long, Mark

© Copyright IBM Corp. 1974, 2010 xi

Page 14: IMS Application Programming.pdf

Harrington, Robert Hain, and Geoff Nicholls (ISBN number 0-13-185671-5). Anexcerpt from this publication is available in the Information Management Softwarefor z/OS Solutions Information Center.

IBM offers a wide variety of classroom and self-study courses to help you learnIMS. For a complete list of courses available, go to the IMS home page atwww.ibm.com/ims and link to the Training and Certification page.

IBM product names used in this informationIn this information, the licensed programs shown in the following table arereferred to by their short names.

Table 1. Licensed program full names and short names

Licensed program full name Licensed program short name

IBM Application Recovery Tool for IMS andDB2®

Application Recovery Tool

IBM CICS Transaction Server for OS/390® CICS

IBM CICS Transaction Server for z/OS® CICS

IBM DB2 for z/OS DB2 for z/OS

IBM Data Facility Storage ManagementSubsystem Data Facility Product

Data Facility Product (DFSMSdfp)

IBM Data Facility Storage ManagementSubsystem Data Set Services

Data Set Services (DFSMSdss)

IBM Enterprise COBOL for z/OS andOS/390

Enterprise COBOL

IBM Enterprise PL/I for z/OS and OS/390 Enterprise PL/I

IBM High Level Assembler for MVS™ & VM& VSE

High Level Assembler

IBM IMS Advanced ACB Generator IMS Advanced ACB Generator

IBM IMS Batch Backout Manager IMS Batch Backout Manager

IBM IMS Batch Terminal Simulator IMS Batch Terminal Simulator

IBM IMS Buffer Pool Analyzer IMS Buffer Pool Analyzer

IBM IMS Command Control Facility forz/OS

IMS Command Control Facility

IBM IMS Connect for z/OS IMS Connect

IBM IMS Database Control Suite IMS Database Control Suite

IBM IMS Database Recovery Facility forz/OS

Database Recovery Facility

IBM IMS Database Repair Facility IMS Database Repair Facility

IBM IMS DataPropagator for z/OS IMS DataPropagator

IBM IMS DEDB Fast Recovery IMS DEDB Fast Recovery

IBM IMS Extended Terminal Option Support IMS ETO Support

IBM IMS Fast Path Basic Tools IMS Fast Path Basic Tools

IBM IMS Fast Path Online Tools IMS Fast Path Online Tools

IBM IMS Hardware DataCompression-Extended

IMS Hardware Data Compression-Extended

xii Application Programming Guide

Page 15: IMS Application Programming.pdf

Table 1. Licensed program full names and short names (continued)

Licensed program full name Licensed program short name

IBM IMS High Availability Large Database(HALDB) Conversion Aid for z/OS

IBM IMS HALDB Conversion Aid

IBM IMS High Performance ChangeAccumulation Utility for z/OS

IMS High Performance ChangeAccumulation Utility

IBM IMS High Performance Load for z/OS IMS HP Load

IBM IMS High Performance Pointer Checkerfor OS/390

IMS HP Pointer Checker

IBM IMS High Performance Prefix Resolutionfor z/OS

IMS HP Prefix Resolution

IBM Tivoli® NetView® for z/OS Tivoli NetView for z/OS

IBM WebSphere® Application Server forz/OS and OS/390

WebSphere Application Server for z/OS

IBM WebSphere MQ for z/OS WebSphere MQ

IBM WebSphere Studio ApplicationDeveloper Integration Edition

WebSphere Studio

IBM z/OS z/OS

IMS function names used in this informationIn this information, the term HALDB Online Reorganization refers to theintegrated HALDB Online Reorganization function that is part of IMS Version 10,unless otherwise indicated.

IMS provides an integrated IMS Connect function, which offers a functionalreplacement for the IMS Connect tool (program number 5655-K52). In thisinformation, the term IMS Connect refers to the integrated IMS Connect functionthat is part of IMS Version 10, unless otherwise indicated.

How to read syntax diagramsThe following rules apply to the syntax diagrams that are used in this information:v Read the syntax diagrams from left to right, from top to bottom, following the

path of the line. The following conventions are used:– The >>--- symbol indicates the beginning of a syntax diagram.– The ---> symbol indicates that the syntax diagram is continued on the next

line.– The >--- symbol indicates that a syntax diagram is continued from the

previous line.– The --->< symbol indicates the end of a syntax diagram.

v Required items appear on the horizontal line (the main path).

�� required_item ��

v Optional items appear below the main path.

�� required_itemoptional_item

��

About this information xiii

Page 16: IMS Application Programming.pdf

If an optional item appears above the main path, that item has no effect on theexecution of the syntax element and is used only for readability.

��optional_item

required_item ��

v If you can choose from two or more items, they appear vertically, in a stack.If you must choose one of the items, one item of the stack appears on the mainpath.

�� required_item required_choice1required_choice2

��

If choosing one of the items is optional, the entire stack appears below the mainpath.

�� required_itemoptional_choice1optional_choice2

��

If one of the items is the default, it appears above the main path, and theremaining choices are shown below.

�� required_itemdefault_choice

optional_choiceoptional_choice

��

v An arrow returning to the left, above the main line, indicates an item that can berepeated.

�� required_item � repeatable_item ��

If the repeat arrow contains a comma, you must separate repeated items with acomma.

�� required_item �

,

repeatable_item ��

A repeat arrow above a stack indicates that you can repeat the items in thestack.

v Sometimes a diagram must be split into fragments. The syntax fragment isshown separately from the main syntax diagram, but the contents of thefragment should be read as if they are on the main path of the diagram.

�� required_item fragment-name ��

fragment-name:

xiv Application Programming Guide

Page 17: IMS Application Programming.pdf

required_itemoptional_item

v In IMS, a b symbol indicates one blank position.v Keywords, and their minimum abbreviations if applicable, appear in uppercase.

They must be spelled exactly as shown. Variables appear in all lowercase italicletters (for example, column-name). They represent user-supplied names orvalues.

v Separate keywords and parameters by at least one space if no interveningpunctuation is shown in the diagram.

v Enter punctuation marks, parentheses, arithmetic operators, and other symbols,exactly as shown in the diagram.

v Footnotes are shown by a number in parentheses, for example (1).

Accessibility features for IMS Version 10Accessibility features help a user who has a physical disability, such as restrictedmobility or limited vision, to use information technology products successfully.

Accessibility featuresThe following list includes the major accessibility features in z/OS products,including IMS Version 10. These features support:v Keyboard-only operation.v Interfaces that are commonly used by screen readers and screen magnifiers.v Customization of display attributes such as color, contrast, and font size.

Note: The Information Management Software for z/OS Solutions InformationCenter (which includes information for IMS Version 10) and its relatedpublications are accessibility-enabled for the IBM Home Page Reader. Youcan operate all features by using the keyboard instead of the mouse.

Keyboard navigationYou can access IMS Version 10 ISPF panel functions by using a keyboard orkeyboard shortcut keys.

For information about navigating the IMS Version 10 ISPF panels using TSO/E orISPF, refer to the z/OS TSO/E Primer, the z/OS TSO/E User’s Guide, and the z/OSISPF User’s Guide. These guides describe how to navigate each interface, includingthe use of keyboard shortcuts or function keys (PF keys). Each guide includes thedefault settings for the PF keys and explains how to modify their functions.

Related accessibility informationOnline documentation for IMS Version 10 is available in the InformationManagement Software for z/OS Solutions Information Center.

IBM and accessibilitySee the IBM Accessibility Center at www.ibm.com/able for more information aboutthe commitment that IBM has to accessibility.

About this information xv

Page 18: IMS Application Programming.pdf

How to send your commentsYour feedback is important in helping us provide the most accurate and highestquality information. If you have any comments about this or any other IMSinformation, you can take one of the following actions:v From any topic in the information center at http://publib.boulder.ibm.com/

infocenter/imzic, click the Feedback link at the bottom of the topic andcomplete the Feedback form.

v Send your comments by e-mail to [email protected]. Be sure to include thetitle, the part number of the title, the version of IMS, and, if applicable, thespecific location of the text on which you are commenting (for example, a pagenumber in the PDF or a heading in the information center).

xvi Application Programming Guide

Page 19: IMS Application Programming.pdf

Changes to the IMS library for IMS Version 10

The organization of the IMS Version 10 library is significantly different from that ofearlier versions. The library has been reorganized and streamlined, and includesnew and changed titles. Also, none of the IMS Version 10 information is licensed.

The reasons for reorganizing and rearchitecting the IMS library so dramatically areto achieve the following goals:v Group similar information together in a more intuitive organization. For

example, in the IMS Version 10 library, all messages and codes are in themessages and codes books, rather than distributed across multiple books, and allappear in the information center under Troubleshooting for IMS. As anotherexample, all exit routines are now in one book, the IMS Version 10: Exit RoutineReference, and appear in the information center under IMS referenceinformation ->Exit routines, rather than being distributed across six books asthey were in the IMS Version 9 library.

v Rewrite information to better support user tasks. Table 2 on page xix describesthe high-level user tasks and the IMS Version 10 books that support those tasks.

v Separate information into three basic types of topics: task, concept, and reference.v Utilize the DITA (Darwin Information Type Architecture) open source tagging

language.

Because IBM's strategy is to deliver product information in Eclipse informationcenters, IMS Version 10 is the final version of the IMS library that will be availablein BookManager format. Information centers provide the following advantagesover PDF and BookManager formats:v Improved retrievability: Users can search across the entire information center, or

set filters to search categories of information (for example, search only IMSVersion 10 information, or search only IMS Version 9 information). Users canalso search for information center content via a search engine such as Google, orfrom www.ibm.com.

v Improved information currency: Users can subscribe to information updates byusing RSS feeds.

v Accessibility support.v Multi-language support.

There are known limitations with BookManager output. If you encounter problemsin the BookManager information with Web addresses, syntax diagrams, wideexamples, or tables, refer to the information in the information center or in a PDFbook.

The following figure illustrates the organization of the IMS Version 10 library,including how that information is organized within the information center, whichis available at http://publib.boulder.ibm.com/infocenter/imzic.

© Copyright IBM Corp. 1974, 2010 xvii

|

|

|||

||

||||||||

||

|

||

||||

|||||

||

|

|

||||

||||

Page 20: IMS Application Programming.pdf

The following table describes high-level user tasks and the IMS Version 10 booksthat support those tasks. The IMS library also includes the IMS Version 10: MasterIndex and Glossary, which provides a central index for all of the IMS Versioná10information, as well as a glossary of IMS terms. The combined IMS Version 10:Master Index and Glossary is available only in PDF format. The master index forIMS Version 10 and the IMS glossary are included in the information center.

Figure 1. Organization of the IMS Version 10 library in the information center

xviii Application Programming Guide

|

|||||||||

Page 21: IMS Application Programming.pdf

Table 2. High-level user tasks and the IMS Version 10 books that supports those tasks

Task PDF title Contents

IMS overview IMS Version 10: LicensedProgramming Specifications

Summarizes the functions and capabilities of IMS, lists hardwareand software requirements, and provides licensing and warrantydetails.

IMS Version 10: Fact Sheet Provides an overview of the IMS Version 10 features.

Introduction to IMS Provides the first five chapters of a retail publication thatintroduces the IMS product and its features.

Release planningfor IMS

IMS Version 10: ReleasePlanning Guide (GC18-9717)

Provides general information to help you evaluate and plan forIMS Version 10. It describes the new features and enhancements forIMS Version 10, the hardware and software requirements for thesenew features and enhancements, considerations for migration andcoexistence for IMS Version 10, and an overview of the IMS Toolsthat are enhanced to work with IMS Version 10. It also includes anoverview of the features and enhancements for IMS Version 9 andIMS Version 8.

Installing IMS Program Directory forInformation ManagementSystem Transaction andDatabase Servers (GI10-8754)

Provides information about the material and procedures that areassociated with the installation of IMS Version 10.

IMS Version 10: InstallationGuide (GC18-9710)

Provides guidance information for preparing for an IMSinstallation and running the IMS installation verification program(IVP). It also provides information about the sample applicationsthat are provided with IMS.

IMS Version 10: SystemDefinition Guide (GC18-9998)

Provides guidance information for designing your IMS system,including information for defining and tailoring the IMS system,IMS Common Queue Server (CQS), IMS Common Service Layer(CSL), integrated IMS Connect, and IMS Transport ManagerSubsystem (TMS). Reference information for IMS system definitionis in IMS Version 10: System Definition Reference.

IMS Version 10: SystemDefinition Reference(GC18-9966)

Provides reference information for defining and tailoring an IMSsystem, including descriptions of the IMS macros, procedures, andmembers of the IMS.PROCLIB data set. Guidance information forIMS system definition is in the IMS Version 10: System DefinitionGuide.

Changes to the IMS library for IMS Version 10 xix

||

|||

||||||

||

|||

||||||||||||

|||||

||

||||||

||||||||

||||

|||||

Page 22: IMS Application Programming.pdf

Table 2. High-level user tasks and the IMS Version 10 books that supports those tasks (continued)

Task PDF title Contents

IMSadministration

IMS Version 10:Communications andConnections Guide (SC18-9703)

Describes the administration of IMS communications andconnections: CPI Communications and APPC/IMS, facilities forattaching to external subsystems, IMS Extended Terminal Option(ETO), integrated IMS Connect function, external Java applicationenvironments, Multiple Systems Coupling (MSC), IMS OpenTransaction Manager Access (OTMA), SLU P and Financecommunication systems, TCP/IP communications, and VTAM®

networking.

IMS Version 10: DatabaseAdministration Guide(SC18-9704)

Describes IMS database types and concepts, and also describeshow to design, implement, maintain, modify, back up, and recoverIMS databases.

IMS Version 10: IMSplexAdministration Guide(SC18-9709)

Provides guidance information to manage the administration andoperations of one or more IMS systems working as a unit (anIMSplex). It includes conceptual information about the IMS BasePrimitive Environment (BPE), IMS Common Queue Server (CQS),and IMS Common Service Layer (CSL), all of which can be part ofan IMSplex, as well as task information for sharing data andqueues in an IMSplex.

IMS Version 10: Operations andAutomation Guide (SC18-9716)

Provides guidance information for selecting tools and options foroperating an IMS system, for recovering an IMS system, and forautomating IMS operations and recovery tasks. It also describeshow to develop procedures for the master terminal operator andthe end user.

IMS Version 10: SystemAdministration Guide(SC18-9718)

Provides guidance information for designing, documenting,operating, maintaining, and recovering a single IMS system. It alsoprovides information about: the Database Recovery Control(DBRC) facility; Remote Site Recovery (RSR); and the ExtendedRecovery Facility (XRF). Guidance information for administeringan IMSplex is in the IMS Version 10: IMSplex Administration Guide.

Programmingfor IMS

IMS Version 10: ApplicationProgramming Planning Guide(SC18-9697)

Provides guidance and planning information for applicationprograms that access IMS databases or messages. It also describeshow to gather and analyze program requirements, and how todesign, test, and document an IMS application program.

IMS Version 10: ApplicationProgramming Guide(SC18-9698)

Provides guidance information for writing application programsthat access IMS databases or IMS messages. It describes how to usedifferent programming languages to issue DL/I calls, and includesusage information about the Java class libraries and the JDBCdriver for IMS. It also describes how to use different programminglanguages to issue EXEC DL/I calls. Application programminginterface (API) information is in the IMS Version 10: ApplicationProgramming API Reference.

IMS Version 10: ApplicationProgramming API Reference(SC18-9699)

Provides reference information for the IMS applicationprogramming interfaces (APIs), including DL/I, EXEC DLI, andthe Java class libraries for IMS. It also provides referenceinformation for the IMS Adapter for REXX, the DL/I test program(DFSDDLT0), and the IMS Message Format Service (MFS).Guidance information for writing IMS application programs is inthe IMS Version 10: Application Programming Guide.

IMS Version 10: SystemProgramming API Reference(SC18-9967)

Provides reference information for IMS system applicationprogramming interface (API) calls for IMS Common Queue Server(CQS); IMS Common Service Layer (CSL); IMS data propagationwith IMS DataPropagator for z/OS; IMS Database ResourceAdapter (DRA); the IMS Database Recovery Control (DBRC)facility.

xx Application Programming Guide

|

|||

|||||

||||||||

|||

|||

|||

|||||||

|||||||

|||

||||||

|||||

||||

|||

||||||||

|||

|||||||

|||

||||||

Page 23: IMS Application Programming.pdf

Table 2. High-level user tasks and the IMS Version 10 books that supports those tasks (continued)

Task PDF title Contents

Troubleshootingfor IMS

IMS Version 10: DiagnosisGuide (GC18-9706)

Provides guidance information for setting up an IMS system fordiagnosis, collecting information to help diagnose IMS problems,and searching problem-reporting databases, such as the IBMElectronic Incident Submission (EIS) Web site. It also describes howto use keywords to develop a failure description that you can useto search problem-reporting databases and communicate with theIBM Support Line (or equivalent services for your geography).Reference information for IMS diagnosis service aids is in the IMSVersion 10: Diagnosis Reference.

IMS Version 10: DiagnosisReference (GC18-9707)

Provides reference information for diagnosis service aids that applyto all aspects of IMS. Guidance information for IMS diagnosis tasksis in the IMS Version 10: Diagnosis Guide.

IMS: Messages and CodesReference, Volume 1: DFSMessages (GC18-9712)

Provides reference information for the IMS messages that have the“DFS” prefix, along with their associated return codes. It alsoprovides diagnostic information that helps programmers, operators,and system-support personnel diagnose problems in IMS. IMSmessages with other prefixes are in the IMS: Messages and CodesReference, Volume 2: Non-DFS Messages.

IMS: Messages and CodesReference, Volume 2: Non-DFSMessages (GC18-9713)

Provides reference information for non-DFS prefixed IMS messagesthat are associated with IMS Base Primitive Environment (BPE);IMS Common Queue Server (CQS); IMS Common Service Layer(CSL); Database Recovery Control (DBRC); and integrated IMSConnect. It also provides diagnostic reference information thathelps programmers, operators, and system-support personneldiagnose problems in IMS. IMS messages that have the “DFS”prefix are in the IMS: Messages and Codes Reference, Volume 1: DFSMessages.

IMS: Messages and CodesReference, Volume 3: IMSAbend Codes (GC18-9714)

Provides reference information for all IMS abnormal termination(abend) codes, including analysis, explanation, possible causes, andAPAR processing instructions.

IMS: Messages and CodesReference, Volume 4: IMSComponent Codes (GC18-9715)

Provides return, reason, sense, function, and status codes for IMSBase Primitive Environment (BPE); IMS Common Queue Server(CQS); IMS Common Service Layer (CSL); Database RecoveryControl (DBRC) facility; and integrated IMS Connect. It alsoprovides diagnostic reference information that helps programmers,operators, and system-support personnel diagnose problems inIMS. IMS abend codes are in the IMS: Messages and Codes Reference,Volume 3: IMS Abend Codes.

IRLM Messages and Codes(GC19-2666)

Provides reference information for the IRLM messages and codesthat are issued by the internal resource lock manager (IRLM) toIMS.

IMS referenceinformation

IMS Version 10: CommandReference, Volume 1(SC18-9700)

Provides reference information for the IMS type-1 and type-2commands (/ACTIVATE through /MONITOR), including commandsyntax and usage. It also describes the IMS command languageand how to send commands to IMS in different environments.Information about all non-type 1 and non-type 2 IMS commands isin the IMS Version 10: Command Reference, Volume 3.

IMS Version 10: CommandReference, Volume 2(SC18-9701)

Provides reference information for the IMS type-1 and type-2commands (/MSACCESS through /VUNLOAD), including commandsyntax and usage. It also describes the IMS command languageand how to send commands to IMS in different environments.Information about all non-type 1 and non-type 2 IMS commands isin the IMS Version 10: Command Reference, Volume 3.

Changes to the IMS library for IMS Version 10 xxi

|

|||

|||||||||||||

|||||

|||

||||||

|||

|||||||||

|||

|||

|||

||||||||

||||||

|||||

||||||

||||

||||||

Page 24: IMS Application Programming.pdf

Table 2. High-level user tasks and the IMS Version 10 books that supports those tasks (continued)

Task PDF title Contents

IMS Version 10: CommandReference, Volume 3(SC18-9702)

Provides reference information, including command syntax andusage, for the following IMS commands: Base PrimitiveEnvironment (BPE); Common Service Layer (CSL); DatabaseRecovery Control (DBRC) facility; IMS Transport ManagerSubsystem (TMS); integrated IMS Connect; and the z/OScommands for IMS. Information about IMS type-1 and type-2commands is in the IMS Version 10: Command Reference, Volume 1and the IMS Version 10: Command Reference, Volume 2.

IMS Version 10: Exit RoutineReference (SC18-9708)

Provides reference information for the exit routines that you canuse to customize IMS database, system, transaction management,IMSplex, Base Primitive Environment (BPE), Common QueueServer (CQS), and integrated IMS Connect environments.

IMS Version 10: DatabaseUtilities Reference (SC18-9705)

Provides reference information for the utilities that you can usewith IMS databases. The utilities can help you migrate, reorganize,and recover a database. IMS system utilities are described in theIMS Version 10: System Utilities Reference.

IMS Version 10: SystemUtilities Reference (SC18-9968)

Provides reference information for the utilities that you can usewith the IMS system. The utilities can help you generate IMSresources, analyze IMS activity, manage IMS logging, run the IMSDatabase Recovery Control (DBRC) facility, maintain IMSnetworking services, convert Security Maintenance utility (SMU)source, and maintain the resource definition data sets (RDDSs).IMS database utilities are described in the IMS Version 10: DatabaseUtilities Reference.

IMS Version 10: Master Indexand Glossary (SC18-9711)

Provides a central index for all of the IMS Version 10 information,as well as a glossary of IMS terms. The combined IMS Version 10:Master Index and Glossary is available only in PDF format. Themaster index is included in the information center under IMSVersion 10 ->Index for IMS Version 10. The IMS glossary termsare included in the information center under IMS glossary.

xxii Application Programming Guide

|

|||

||||

||||||||

|||||||

|||||||

|||||||||||

||||||||||

Page 25: IMS Application Programming.pdf

Part 1. Application programming for IMS DB

Chapter 1. Writing your application programs forIMS DB . . . . . . . . . . . . . . . . 3Programming guidelines . . . . . . . . . . 3Segment search arguments (SSAs) . . . . . . . 4

Unqualified SSAs . . . . . . . . . . . . 5Qualified SSAs . . . . . . . . . . . . 5SSA guidelines. . . . . . . . . . . . . 7Multiple qualification statements . . . . . . 8SSAs and command codes . . . . . . . . 10

Considerations for coding DL/I calls and data areas 12Preparing to run your Java application program . . 13Preparing to run your CICS DL/I call program . . 14Examples of how to code DL/I calls and data areas 14

Coding a batch program in assembler language 15Coding a CICS online program in assemblerlanguage . . . . . . . . . . . . . . 18Coding a batch program in C language . . . . 20Coding a batch program in COBOL . . . . . 22Coding a CICS online program in COBOL . . . 25Coding a program in Java . . . . . . . . 30Coding a batch program in Pascal . . . . . . 31Coding a batch program in PL/I . . . . . . 32Coding a CICS online program in PL/I . . . . 36

Chapter 2. Defining application programelements for IMS DB . . . . . . . . . . . 39Formatting DL/I calls for language interfaces . . . 39Assembler language application programming. . . 40

Format . . . . . . . . . . . . . . . 40Parameters . . . . . . . . . . . . . 41Example of a DL/I call format . . . . . . . 42

C language application programming. . . . . . 42Format . . . . . . . . . . . . . . . 42Parameters . . . . . . . . . . . . . 43I/O area . . . . . . . . . . . . . . 45Example of a DL/I call format . . . . . . . 45

COBOL application programming . . . . . . . 45Format . . . . . . . . . . . . . . . 45Parameters . . . . . . . . . . . . . 46Example of a DL/I call format . . . . . . . 48

Java application programming for IMS . . . . . 48Pascal application programming . . . . . . . 48

Format . . . . . . . . . . . . . . . 48Parameters . . . . . . . . . . . . . 49Example of a DL/I call format . . . . . . . 50

Application programming for PL/I . . . . . . 51Format . . . . . . . . . . . . . . . 51Parameters . . . . . . . . . . . . . 52Example of a DL/I call format . . . . . . . 53

Specifying the I/O PCB mask . . . . . . . . 53Specifying the DB PCB mask . . . . . . . . 56Specifying the AIB mask . . . . . . . . . . 59Specifying the AIB mask for ODBA applications . . 61Specifying the UIB (CICS online programs only) . . 63Specifying the I/O areas . . . . . . . . . . 66Formatting segment search arguments (SSAs) . . . 66

SSA coding rules . . . . . . . . . . . 67SSA coding formats. . . . . . . . . . . 68

Data areas in GSAM databases . . . . . . . . 72The AIBTDLI interface. . . . . . . . . . . 72Language specific entry points . . . . . . . . 73

Assembler language entry point . . . . . . 73C language entry point . . . . . . . . . 73COBOL entry point . . . . . . . . . . . 74Pascal entry point . . . . . . . . . . . 74PL/I entry point. . . . . . . . . . . . 75CEETDLI, AIBTDLI, and AERTDLI interfaceconsiderations . . . . . . . . . . . . 75

Program communication block (PCB) lists . . . . 76PCB list format . . . . . . . . . . . . 76Format of a GPSB PCB list . . . . . . . . 76PCB summary . . . . . . . . . . . . 76

The AERTDLI interface . . . . . . . . . . 77Language environments . . . . . . . . . . 78

The CEETDLI interface to IMS . . . . . . . 78Specifying LANG= option for PL/I compatibility 78

Special DL/I situations . . . . . . . . . . 79Application program scheduling againstHALDBs . . . . . . . . . . . . . . 79Mixed-language programming . . . . . . . 79Language Environment routine retention . . . 80Extended addressing capabilities of z/OS . . . 80Preloaded programs . . . . . . . . . . 80

Chapter 3. Establishing a DL/I interface fromCOBOL or PL/I . . . . . . . . . . . . . 81CBLTDLI . . . . . . . . . . . . . . . 81PLITDLI . . . . . . . . . . . . . . . 81

Chapter 4. Current position in the database aftereach call . . . . . . . . . . . . . . . 83Current position after successful calls. . . . . . 83

Position after retrieval calls . . . . . . . . 85Position after DLET. . . . . . . . . . . 85Position after REPL. . . . . . . . . . . 87Position after ISRT . . . . . . . . . . . 87

Current position after unsuccessful calls . . . . . 88Position after an unsuccessful DLET or REPL call 89Position after an unsuccessful retrieval or ISRTcall . . . . . . . . . . . . . . . . 90

Multiple processing. . . . . . . . . . . . 93Multiple positioning . . . . . . . . . . 93Advantages of using multiple positioning . . . 96Multiple DB PCBs . . . . . . . . . . . 99

Chapter 5. Using IMS application program syncpoints . . . . . . . . . . . . . . . 101The commit process . . . . . . . . . . . 101

Relationship between checkpoints and syncpoints . . . . . . . . . . . . . . . 101

© Copyright IBM Corp. 1974, 2010 1

|

||

||

||

||||

Page 26: IMS Application Programming.pdf

Synchronization point processing in CPICommunications-driven programs . . . . . 102

Two-phase commit in the synchronization process 103Unit of recovery . . . . . . . . . . . 104DBCTL single-phase commit . . . . . . . 105

Sync-point log records . . . . . . . . . . 105Sync points with a data-propagation manager . . 106

Chapter 6. Recovering databases andmaintaining database integrity . . . . . . . 107Issuing checkpoints . . . . . . . . . . . 107Restarting your program from the latest checkpoint 107Maintaining database integrity (IMS batch, BMP,and IMS online regions) . . . . . . . . . . 108

Backing out to a prior commit point: ROLL,ROLB, and ROLS . . . . . . . . . . . 108Backing out to an intermediate backout point:SETS, SETU, and ROLS . . . . . . . . . 112

Reserving segments for the exclusive use of yourprogram . . . . . . . . . . . . . . . 115

Chapter 7. Secondary indexing and logicalrelationships . . . . . . . . . . . . . 117How secondary indexing affects your program . . 117

SSAs with secondary indexes . . . . . . . 117Multiple qualification statements with secondaryindexes . . . . . . . . . . . . . . 118DL/I returns with secondary indexes . . . . 120Status codes for secondary indexes . . . . . 120

Processing segments in logical relationships . . . 121How logical relationships affect yourprogramming . . . . . . . . . . . . 123Status codes for logical relationships . . . . 123

Chapter 8. HALDB selective partitionprocessing . . . . . . . . . . . . . . 125Control Statements for HALDB selective partitionprocessing . . . . . . . . . . . . . . 125Parameter descriptions for HALDB selectivepartition processing . . . . . . . . . . . 125Examples of HALDB selective partition processingstatements . . . . . . . . . . . . . . 126Report generated for HALDB selective partitionprocessing . . . . . . . . . . . . . . 126

Chapter 9. Processing GSAM databases . . . 131Accessing GSAM databases. . . . . . . . . 131

PCB masks for GSAM databases . . . . . . 132Retrieving and Inserting GSAM Records . . . 134Resetting the Position in a GSAM Database . . 135Explicit open and close calls to GSAM . . . . 135

GSAM record formats . . . . . . . . . . 136GSAM I/O areas . . . . . . . . . . . . 136GSAM status codes . . . . . . . . . . . 137Symbolic CHKP and XRST with GSAM . . . . 137GSAM coding considerations . . . . . . . . 138Origin of GSAM data set characteristics . . . . 139

DD statement DISP parameter for GSAM datasets. . . . . . . . . . . . . . . . 140Using extended checkpoint restart for GSAMdata sets . . . . . . . . . . . . . . 140

Copying GSAM Data Sets Between Checkpointand Restart . . . . . . . . . . . . . 141Converting Data Sets From Non-Striped DataSets to Striped Data Sets. . . . . . . . . 141Concatenated data sets used by GSAM . . . . 141Suggested method for specifying GSAM data setattributes . . . . . . . . . . . . . . 142DLI, DBB, and BMP region types and GSAM 142

Chapter 10. Processing Fast Path databases 145Fast Path database calls . . . . . . . . . . 145Main storage databases (MSDBs) . . . . . . . 146Data entry databases (DEDBs) . . . . . . . . 147Processing MSDBs and DEDBs . . . . . . . 147

Updating segments: REPL, DLET, ISRT, andFLD . . . . . . . . . . . . . . . 147Commit-point processing in MSDBs and DEDBs 152VSO considerations . . . . . . . . . . 153Data locking for MSDBs and DEDBs . . . . 153

Restrictions on using calls for MSDBs . . . . . 154Processing DEDBs (IMS and CICS with DBCTL) 154

Processing DEDBs with subset pointers. . . . 154Retrieving location with the POS call (for DEDBonly) . . . . . . . . . . . . . . . 159Commit-point processing in a DEDB . . . . 161P processing option . . . . . . . . . . 162H processing option . . . . . . . . . . 162Data locking. . . . . . . . . . . . . 163

Calls with dependent segments for DEDBs . . . 163Direct dependent segments . . . . . . . . 163Sequential dependent segments . . . . . . 163

DEDB DL/I calls to extract DEDB information . . 164AL_LEN Call . . . . . . . . . . . . 167DI_LEN Call . . . . . . . . . . . . 167DS_LEN Call . . . . . . . . . . . . 167AREALIST Call. . . . . . . . . . . . 168DEDBINFO Call . . . . . . . . . . . 168DEDSTR Call . . . . . . . . . . . . 169

Fast Path coding considerations . . . . . . . 171

Chapter 11. Writing ODBA application programs 173General application program flow . . . . . . 174

Establishing the application executionenvironment. . . . . . . . . . . . . 174Allocating a PSB . . . . . . . . . . . 175Performing DB calls . . . . . . . . . . 176Commit changes . . . . . . . . . . . 176Deallocating the PSB . . . . . . . . . . 176Terminating the connection . . . . . . . . 176

Server program structure . . . . . . . . . 177DB2 for z/OS Stored Procedures use of ODBA . . 178

2 Application Programming Guide

||||||

||||

||||||

||||||||||||||

||

Page 27: IMS Application Programming.pdf

Chapter 1. Writing your application programs for IMS DB

This topic contains information that will help you write application programs. Itcontains guidelines for writing efficient application programs and using segmentsearch arguments (SSAs) and command codes. A checklist of coding considerationsand skeleton programs in High Level Assembler language, C language, COBOL,Java, Pascal, and PL/I are also available to help you.

The following topics provide additional information:v “Programming guidelines”v “Segment search arguments (SSAs)” on page 4v “Considerations for coding DL/I calls and data areas” on page 12v “Preparing to run your CICS DL/I call program” on page 14v “Preparing to run your Java application program” on page 13v “Examples of how to code DL/I calls and data areas” on page 14

Programming guidelinesThe number, type, and sequence of the IMS requests your program issues affectsthe efficiency of your program. A program that is poorly designed can still run if itis coded correctly. IMS will not find design errors for you. The suggestions thatfollow will help you develop the most efficient design possible for your applicationprogram. When you have a general sequence of calls mapped out for yourprogram, look over the guidelines on sequence to see if you can improve it. Anefficient sequence of requests results in efficient internal IMS processing. As youwrite your program, keep in mind the guidelines explained in this section. Thefollowing list offers programming guidelines that will help you write efficient anderror-free programs.v Use the most simple call. Qualify your requests to narrow the search for IMS.v Use the request or sequence of requests that will give IMS the shortest path to

the segment you want.v Use as few requests as possible. Each DL/I call your program issues uses system

time and resources. You may be able to eliminate unnecessary calls by:– Using path requests when you are replacing, retrieving, or inserting more

than one segment in the same path. If you are using more than one request todo this, you are issuing unnecessary requests.

– Changing the sequence so that your program saves the segment in a separateI/O area, and then gets it from that I/O area the subsequent times it needsthe segment. If your program retrieves the same segment more than onceduring program execution, you are issuing unnecessary requests.

– Anticipating and eliminating needless and nonproductive requests, such asrequests that result in GB, GE, and II status codes. For example, if you areissuing GN calls for a particular segment type, and you know how manyoccurrences of that segment type exist, do not issue the GN that results in a GEstatus code. Keep track of the number of occurrences your program retrieves,and then continue with other processing when you know you have retrievedall the occurrences of that segment type.

– Issuing an insert request with a qualification for each parent, rather thanissuing Get requests for the parents to make sure that they exist. If IMS

© Copyright IBM Corp. 1974, 2010 3

|||||

|

Page 28: IMS Application Programming.pdf

returns a GE status code, at least one of the parents does not exist. When youare inserting segments, you cannot insert dependent segments unless theparent segments exist.

v Commit your updates regularly. IMS limits full-function databases so that only300 databases at a time can have uncommitted updates. Logically relateddatabases, secondary indexes, and HALDB partitions are counted towards thislimit. The number of partitions in HALDB databases is the most common reasonfor approaching the 300 database limit for uncommitted updates. If thePROCOPT values allow a BMP application to insert, replace, or delete segmentsin the databases, ensure that the BMP application does not update a combinedtotal of more than 300 databases and HALDB partitions without committing thechanges.

v Keep the main section of the program logic together. For example, branch toconditional routines, such as error and print routines in other parts of theprogram, instead of branching around them to continue normal processing.

v Use call sequences that make good use of the physical placement of the data.Access segments in hierarchic sequence as often as possible, and avoid movingbackward in the hierarchy.

v Process database records in order of the key field of the root segments. (ForHDAM and PHDAM databases, this order depends on the randomizing routinethat is used. Check with your DBA for this information.)

v Avoid constructing the logic of the program and the structure of commands orcalls in a way that depends heavily on the database structure. Depending on thecurrent structure of the hierarchy reduces the program's flexibility.

v Minimize the number of segments your program locks. You may need to takecheckpoints to release the locks on updated segments and the lock on thecurrent database record for each PCB your program uses. Each PCB used byyour program has the current database record locked at share or update level. Ifthis lock is no longer required, issuing the GU call, qualified at the root level witha greater-than operator for a key of X'FF' (high values), releases the current lockwithout acquiring a new lock.Do not use the minimization technique if you use a randomizer that puts highvalues at the end of the database and you use secondary indexes. If there isanother root beyond the supposed high value key, IMS returns a GE to allow theapplication to determine the next step. A secondary index might not workbecause the hierarchical structure is inverted, and although the key is past thelast root in the index, it might not be past the last root in the database.Using PCBs with a processing option of get (G) results in locks for the PCB atshare level. This allows other programs that use the get processing option toconcurrently access the same database record. Using a PCB with a processingoption that allows updates (I, R, or D) results in locks for the PCB at updatelevel. This does not allow any other program to concurrently access the samedatabase record.Related reading: For more information about segment locking, see “Reservingsegments for the exclusive use of your program” on page 115.

Segment search arguments (SSAs)Segment search arguments (SSAs) specify information for IMS to use in processinga DL/I call. A DL/I call with one or more SSAs is a qualified call, and a DL/I callwithout SSAs is an unqualified call.

Definitions:

4 Application Programming Guide

|||||||||

Page 29: IMS Application Programming.pdf

Unqualified SSAs Contains only a segment name.

Qualified SSAs Includes one or more qualification statements thatname a segment occurrence. The C command anda segment occurrence's concatenated key can besubstituted for a qualification statement.

You can use SSA to select segments by name and to specify search criteria forspecific segments. Specific segments are described by adding qualificationstatements to the DL/I call. You can further qualify your calls by using commandcodes.

Table 3 shows the structure of a qualified SSA. Table 4 on page 11 shows thestructure of an unqualified SSA using command codes. Finally, Table 5 on page 11shows the structure of a qualified SSA that uses command codes.

Unqualified SSAsAn unqualified SSA gives the name of the segment type that you want to access.In an unqualified SSA, the segment name field is 8 bytes and must be followed bya 1-byte blank. If the actual segment name is fewer than 8 bytes long, it must bepadded to the right with blanks. An example of an unqualified SSA follows:PATIENT��

Qualified SSAsTo qualify an SSA, you can use either a field or the sequence field of a virtualchild. A qualified SSA describes the segment occurrence that you want to access.This description is called a qualification statement and has three parts. Table 3shows the structure of a qualified SSA.

Table 3. Qualified SSA structure

SSA Component Field Length

Seg Name 8

( 1

Fld Name 8

R.O. 2

Fld Value Variable

) 1

Using a qualification statement enables you to give IMS information about theparticular segment occurrence that you are looking for. You do this by giving IMSthe name of a field within the segment and the value of the field you are lookingfor. The field and the value are connected by a relational operator (R.O. in Table 3)which tells IMS how you want the two compared. For example, to access thePATIENT segment with the value 10460 in the PATNO field, you could use thisSSA:PATIENT�(PATNO���=�10460)

The qualification statement is enclosed in parentheses. The first field contains thename of the field (Fld Name in Table 3) that you want IMS to use in searching forthe segment. The second field contains a relational operator. The relational operatorcan be any one of the following:v Equal, represented as

Chapter 1. Writing your application programs for IMS DB 5

Page 30: IMS Application Programming.pdf

=��=EQ

v Greater than, represented as>��>GT

v Less than, represented as<��<LT

v Greater than or equal to, represented as>==>GE

v Less than or equal to, represented as<==<LE

v Not equal to, represented as¬==¬NE

The third field (Fld Value in Table 3 on page 5) contains the value that you wantIMS to use as the comparative value. The length of Fld Value must be the samelength as the field specified by Fld Name.

You can use more than one qualification statement in an SSA. Special cases exist,such as in a virtual logical child segment when the sequence field consists ofmultiple fields.

Related reading: For more information on multiple qualification statements, see“Multiple qualification statements” on page 8.

Sequence fields of a virtual logical childAs a general rule, a segment can have only one sequence field. However, in thecase of the virtual logical-child segment type, multiple FIELD statements can beused to define a noncontiguous sequence field.

When specifying the sequence field for a virtual logical child segment, if the fieldis not contiguous, the length of the field named in the SSA is the concatenatedlength of the specified field plus all succeeding sequence fields. Figure 2 on page 7shows a segment with a noncontiguous sequence field.

6 Application Programming Guide

Page 31: IMS Application Programming.pdf

If the first sequence field is not included in a “scattered” sequence field in an SSA,IMS treats the argument as a data field specification, rather than as a sequencefield.

Related reading: For more information on the virtual logical child segment, referto IMS Version 10: Database Administration Guide.

SSA guidelinesUsing SSAs can simplify your programming, because the more information youcan give IMS to do the searching for you, the less program logic you need toanalyze and compare segments in your program.

Using SSAs does not necessarily reduce system overhead, such as internal logicand I/Os, required to obtain a specific segment. To locate a particular segmentwithout using SSAs, you can issue DL/I calls and include program logic toexamine key fields until you find the segment you want. By using SSAs in yourDL/I calls, you can reduce the number of DL/I calls that are issued and theprogram logic needed to examine key fields. When you use SSAs, IMS does thiswork for you.

Recommendations:

v Use qualified calls with qualified SSAs whenever possible. SSAs act as filters,returning only the segments your program requires. This reduces the number ofcalls your program makes, which provides better performance. It also providesbetter documentation of your program. Qualified SSAs are particularly usefulwhen adding segments with insert calls. They ensure that the segments areinserted where you want them to go.

v For the root segment, specify the key field and an equal relational operator, ifpossible. Using a key field with an equal-to, equal-to-or-greater-than, orgreater-than operator lets IMS go directly to the root segment.

v For dependent segments, it is desirable to use the key field in the SSA, althoughit is not as important as at the root level. Using the key field and an equal-tooperator lets IMS stop the search at that level when a higher key value isencountered. Otherwise IMS must search through all occurrences of the segmenttype under its established parent in order to determine whether a particularsegment exists.

v If you often must search for a segment using a field other than the key field,consider putting a secondary index on the field. For more information onsecondary indexing, see Chapter 7, “Secondary indexing and logicalrelationships,” on page 117.

Example: Suppose you want to find the record for a patient by the name of EllenCarter. As a reminder, the patient segment in the examples contains three fields:the patient number, which is the key field; the patient name; and the patientaddress. The fact that patient number is the key field means that IMS stores the

Sequence field Sequence fieldA B

10 bytes 11 bytes

Segment

AB=21 bytes

Figure 2. Segment with a noncontiguous sequence field

Chapter 1. Writing your application programs for IMS DB 7

Page 32: IMS Application Programming.pdf

patient segments in order of their patient numbers. The best way to get the recordfor Ellen Carter is to supply her patient number in the SSA. If her number is 09000,your program uses this call and SSA:GU&$tab;PATIENT�(PATNO���=�09000)

If your program supplies an invalid number, or if someone has deleted EllenCarter's record from the database, IMS does not need to search through all thePATIENT occurrences to determine that the segment does not exist.

However, if your program does not have the number and must give the nameinstead, IMS must search through all the patient segments and read each patientname field until it finds Ellen Carter or until it reaches the end of the patientsegments.

Multiple qualification statementsWhen you use a qualification statement, you can do more than give IMS a fieldvalue with which to compare the fields of segments in the database. You can giveseveral field values to establish limits for the fields you want IMS to compare.

You can use a maximum of 1024 qualification statements on a call.

Connect the qualification statements with one of the Boolean operators. You canindicate to IMS that you are looking for a value that, for example, is greater than Aand less than B, or you can indicate that you are looking for a value that is equalto A or greater than B. The Boolean operators are:

Logical AND For a segment to satisfy this request, the segment must satisfy bothqualification statements that are connected with the logical AND(coded * or &).

Logical OR For a segment to satisfy this request, the segment can satisfy eitherof the qualification statements that are connected with the logicalOR (coded + or |).

One more Boolean operator exists and is called the independent AND. Use it onlywith secondary indexes. “Multiple qualification statements with secondaryindexes” on page 118 describes its use.

For a segment to satisfy multiple qualification statements, the segment must satisfya set of qualification statements. A set is a number of qualification statements thatare joined by an AND. To satisfy a set, a segment must satisfy each of thequalification statements within that set. Each OR starts a new set of qualificationstatements. When processing multiple qualification statements, IMS reads them leftto right and processes them in that order.

When you include multiple qualification statements for a root segment, the fieldsyou name in the qualification statements affect the range of roots that IMSexamines to satisfy the call. DL/I examines the qualification statements todetermine the minimum acceptable key value.

If one or more of the sets do not include at least one statement that is qualified onthe key field with an operator of equal-to, greater-than, or equal-to-or-greater-than,IMS starts at the first root of the database and searches for a root that meets thequalification.

8 Application Programming Guide

Page 33: IMS Application Programming.pdf

If each set contains at least one statement that is qualified on the key field with anequal-to, greater-than, or equal-to-or-greater-than operator, IMS uses the lowest ofthese keys as the starting place for its search. After establishing the startingposition for the search, IMS processes the call by searching forward sequentially inthe database, similar to the way it processes GN calls. IMS examines each root itencounters to determine whether the root satisfies a set of qualification statements.IMS also examines the qualification statements to determine the maximumacceptable key value.

If one or more of the sets do not include at least one statement that is qualified onthe key field with an operator of equal-to, less-than-or-equal-to, or less-than, IMSdetermines that no maximum key value exists. If each set contains at least onestatement that is qualified on the key field with an equal-to, less-than, orequal-to-or-less-than operator, IMS uses the maximum of these keys to determinewhen the search stops.

IMS continues the search until it satisfies the call, encounters the end of thedatabase, or finds a key value that exceeds the maximum. If no maximum keyvalue is found, the search continues until IMS satisfies the call or encounters theend of the database.

Examples: Shown below are cases of SSAs used at the root level:ROOTKEY�=�10&FIELDB��=XYZ+ROOTKEY��=10&FIELDB��=ABC

In this case, the minimum and maximum key is 10. This means that IMS startssearching with key 10 and stops when it encounters the first key greater than 10.To satisfy the SSA, the ROOTKEY field must be equal to 10, and FIELDB must beequal to either ABC or XYZ.ROOTKEY�=>10&ROOTKEY�=<20

In this case, the minimum key is 10 and the maximum key is 20. Keys in the rangeof 10 to 20 satisfy the SSA. IMS stops the search when it encounters the first keygreater than 20.ROOTKEY�=>10&ROOTKEY�=<20+ROOTKEY�=>110&ROOTKEY�=<120

In this case, the minimum key is 10 and the maximum key is 120. Keys in therange of 10 to 20 and 110 to 120 satisfy the call. IMS stops the search when itencounters the first key greater than 120. IMS does not scan from 20 to 110 butskips forward (using the index for HIDAM or PHIDAM) from 20 to 110. Becauseof this, you can use ranges for more efficient program operation.

When you use multiple qualification statement segments that are part of logicalrelationships, additional considerations exist. See “How logical relationships affectyour programming” on page 123 for more information about these considerations.

Example of how to use multiple qualification statementsThe easiest way to understand multiple qualification statements is to look at anexample:

Did we see patient number 04120 during 1992?

To find the answer to this question, you need to give IMS more than the patient’sname; you want IMS to search through the ILLNESS segments for that patient,read each one, and return any that have a date in 1992. The call you would issueto do this is:

Chapter 1. Writing your application programs for IMS DB 9

Page 34: IMS Application Programming.pdf

GU PATIENT�(PATNO���EQ04120)ILLNESS�(ILLDATE�>=19920101&ILLDATE�<=19921231)

In other words, you want IMS to return any ILLNESS segment occurrences underpatient number 04120 that have a date on or after January 1, 1992, and on or beforeDecember 31, 1992, joined with an AND connector. Suppose you wanted to answerthe following request:

Did we see Judy Jennison during January of 1992 or during July of 1992? Herpatient number is 05682.

You could issue a GU call with the following SSAs:GU PATIENT�(PATNO���EQ05682)

ILLNESS�(ILLDATE�>=19920101&ILLDATE�<=19920131|ILLDATE�>=19920701&ILLDATE�<=19920731)

To satisfy this request, the value for ILLDATE must satisfy either of the two sets.IMS returns any ILLNESS segment occurrences for the month of January 1992, orfor the month of July 1992.

Multiple qualification statements for HDAM, PHDAM, or DEDBFor HDAM (Hierarchical Direct Access Method ), PHDAM (partioned HDAM), ordata entry database (DEDB) organizations, a randomizing exit routine usually doesnot store the root keys in ascending key sequence. For these organizations, IMSdetermines the minimum and maximum key values. The minimum key value ispassed to the randomizing exit routine, which determines the starting anchorpoint.

The first root off this anchor is the starting point for the search. When IMSencounters a key that exceeds the maximum key value, IMS terminates the searchwith a GE status code. If the randomizing routine randomized so that the keys arestored in ascending key sequence, a call for a range of keys will return all of thekeys in the range. However, if the randomizing routine did not randomize into keysequence, the call does not return all keys in the requested range. Therefore, usecalls for a range of key values only when the keys are in ascending sequence(when the organization is HDAM, PHDAM, or DEDB).

Recommendation: When the organization is HDAM or DEDB, do not use calls thatallow a range of values at the root level.

For more details about HDAM or PHDAM databases, see IMS Version 10: DatabaseAdministration Guide.

SSAs and command codesSSAs can also include one or more command codes, which can change and extendthe functions of DL/I calls. For information on command codes, see the topic"General Command Codes for DL/I Calls" in IMS Version 10: ApplicationProgramming API Reference.

IMS always returns the lowest segment in the path to your I/O area. If yourprogram codes a D command code in an SSA, IMS also returns the segmentdescribed by that SSA. A call that uses the D command code is called a path call.

Example: Suppose your program codes a D command code on a GU call thatretrieves segment F and all segments in the path to F in the hierarchy shown in

10 Application Programming Guide

Page 35: IMS Application Programming.pdf

Figure 3.

The call function and the SSAs for the call look like this:GU A�������*D

C�������*DE�������*DF�������

A command code consists of one letter. Code the command codes in the SSA afterthe segment name field. Separate the segment name field and the command codewith an asterisk, as shown in Table 4.

Table 4. Unqualified SSA with command code

SSA Component Field Length

Seg Name 8

* 1

Cmd Code Variable

b 1

Your program can use command codes in both qualified and unqualified SSAs.However, command codes cannot be used by MSDB calls. If the command codesare not followed by qualification statements, they must each be followed by a1-byte blank. If the command codes are followed by qualification statements, donot use the blank. The left parenthesis of the qualification statement follows thecommand code instead, as indicated in Table 5.

Table 5. Qualified SSA with command code

SSA Component Field Length

Seg Name 8

* 1

Cmd Code Variable

( 1

Fld Name 8

A

B C

D E

F

Figure 3. D command code example

Chapter 1. Writing your application programs for IMS DB 11

Page 36: IMS Application Programming.pdf

Table 5. Qualified SSA with command code (continued)

SSA Component Field Length

R.O. 2

Fld Value Variable

) 1

If your program uses command codes to manage subset pointers in a DEDB, enterthe number of the subset pointer immediately after the command code. Subsetpointers are a means of dividing a chain of segment occurrences under the sameparent into two or more groups or subsets. Your program can define as many aseight subset pointers for any segment type. Using an application program, yourprogram can then manage these subset pointers. This process is described in detailin “Processing DEDBs with subset pointers” on page 154.

Considerations for coding DL/I calls and data areasIf you have made all the design decisions about your program, coding theprogram is a matter of implementing the decisions that you have made. Before youstart coding, make sure you have the information described in this section.

In addition to knowing the design and processing logic for your program, youneed to know about the data that your program is processing, the PCBs itreferences, and the segment formats in the hierarchies your program processes. Youcan use the following list as a checklist to make sure you are not missing anyinformation. If you are missing information about data, IMS options being used inthe application program, or segment layouts and the application program's datastructures, obtain this information from the DBA or the equivalent specialist atyour installation. Be aware of the programming standards and conventions thathave been established at your installation.

Program design considerations:v The sequence of calls for your program.v The format of each call:

– Does the call include any SSAs?– If so, are they qualified or unqualified?– Does the call contain any command codes?

v The processing logic for the program.v The routine the program uses to check the status code after each call.v The error routine the program uses.

Checkpoint considerations:v The type of checkpoint call to use (basic or symbolic).v The identification to assign to each checkpoint call, regardless of whether the

Checkpoint call is basic or symbolic.v If you are going to use the symbolic checkpoint call, which areas of your

program to checkpoint.

Segment considerations:v Whether the segment is fixed length or variable length.

12 Application Programming Guide

Page 37: IMS Application Programming.pdf

v The length of the segment (the maximum length, if the segment is variablelength).

v The names of the fields that each segment contains.v Whether the segment has a key field. If it does, is the key field unique or non

unique? If it does not, what sequencing rule has been defined for it? (Asegment's key field is defined in the SEQ keyword of the FIELD statement in theDBD. The sequencing rule is defined in the RULES keyword of the SEGMstatement in the DBD.)

v The segment's field layouts:– The byte location of each field.– The length of each field.– The format of each field.

Data structure considerations:v Each data structure your program processes has been defined in a DB PCB. All

of the PCBs your program references are part of a PSB for your applicationprogram. You need to know the order in which the PCBs are defined in the PSB.

v The layout of each of the data structures your program processes.v Whether multiple or single positioning has been specified for each data

structure. This is specified in the POS keyword of the PCB statement during PSBgeneration.

v Whether any data structures use multiple DB PCBs.

Preparing to run your Java application programTo run your Java application program in a dependent region or an IMS externalenvironment, you must first install the FMID JMK1616 (IMS Java On Demandfeatures), configure your environment so that it can run Java applications, and runthe corresponding IMS IVP for your environment. In addition, you might need toupdate your IMS system definition with a new APPLCTN macro statement.

Prerequisite: You must have installed and configured the required z/OS softwarefor the Java class libraries for IMS

To prepare to run your Java application with IMS:1. Install IMS Java On Demand features. For information about the FMIDs

delivered with IMS Version 10, see the IMS Version 10: Release Planning Guide.2. Configure your environment, if necessary:v JMP and JBP regions: see “IMS IVP jobs, tasks, and sample applications” on

page 367.v WebSphere Application Server for z/OS: see the topic “Configuring

WebSphere Application Server for z/OS to run Java applications that accessIMS databases" in the IMS Version 10: Communications and Connections Guide.

v WebSphere Application Server on a non-z/OS platform: see the topic"Configuring WebSphere Application Server to run distributed Javaapplications that access IMS databases" in the IMS Version 10: Communicationsand Connections Guide.

v DB2 for z/OS stored procedure: see the topic "Configuring DB2 for z/OS torun Java stored procedures that access IMS databases" in the IMS Version 10:Communications and Connections Guide

v CICS: see the topic "Configuring CICS to run Java applications that accessIMS databases" in the IMS Version 10: Communications and Connections Guide.

Chapter 1. Writing your application programs for IMS DB 13

|||||

|

||

|||

||||

|||

||

Page 38: IMS Application Programming.pdf

3. Run the IVP for your external environment:v JMP and JBP regions: see “IMS IVP jobs, tasks, and sample applications” on

page 367.v WebSphere Application Server for z/OS: see the topic “Enterprise

applications running in WebSphere Application Server for z/OS” on page401.

v WebSphere Application Server on a non-z/OS platform: see thetopic“Enterprise applications running in WebSphere Application Server” onpage 402 and "Running the IMS IVP application for the WebSphereApplication Server Java environment" in the IMS Version 10: Communicationsand Connections Guide.

v DB2 for z/OS stored procedure: see the topic “Java applications running inDB2 for z/OS stored procedures” on page 397.

v CICS: see the topic “Java applications running on CICS Transaction Serverfor z/OS” on page 399.

4. Provide the Java metadata classes, the DLIModel Java Report, which providesthe information about the IMS database, and, optionally, the generated XMLschema to the Java application developer.

5. Update the IMS system definition with a new APPLCTN macro statement forthe Java application. See the topic "APPLCTN macro" in the IMS Version 10:System Definition Guide.

Note: Java applications cannot run in an IMS batch environment.

Preparing to run your CICS DL/I call programYou must perform several steps before you run your CICS DL/I call program.Refer to the appropriate CICS reference information:v For information on translating, compiling, and binding your CICS online

program, see the description of installing application programs in CICSTransaction Server for z/OS V3.2 CICS System Definition Guide.

v For information on which compiler options should be used for a CICS onlineprogram, as well as for CICS considerations when converting a CICS onlineCOBOL program with DL/I calls to Enterprise COBOL, see CICS TransactionServer for z/OS V3.2 CICS Application Programming Guide.

Examples of how to code DL/I calls and data areasThis section contains sample programs written in assembler language, C language,COBOL, Pascal, and PL/I. The programs are examples of how to code DL/I callsand data areas. They are not complete programs. Before running them, you mustmodify them to suit the requirements of your installation.

The following topics provide additional:v “Coding a batch program in assembler language” on page 15v “Coding a CICS online program in assembler language” on page 18v “Coding a batch program in C language” on page 20v “Coding a batch program in COBOL” on page 22v “Coding a CICS online program in COBOL” on page 25v “Coding a program in Java” on page 30v “Coding a batch program in Pascal” on page 31v “Coding a batch program in PL/I” on page 32

14 Application Programming Guide

|||

|||

Page 39: IMS Application Programming.pdf

v “Coding a CICS online program in PL/I” on page 36

Coding a batch program in assembler languageFigure 4 on page 16 is a skeleton program that shows how the parts of an IMSprogram written in assembler language fit together. The numbers to the right ofthe program refer to the notes that follow the program. This kind of program canrun as a batch program or as a batch-oriented BMP.

Chapter 1. Writing your application programs for IMS DB 15

Page 40: IMS Application Programming.pdf

PGMSTART CSECT NOTES* EQUATE REGISTERS 1* USEAGE OF REGISTERSR1 EQU 1 ORIGINAL PCBLIST ADDRESSR2 EQU 2 PCBLIST ADDRESS1R5 EQU 5 PCB ADDRESSSR12 EQU 12 BASE ADDRESSR13 EQU 13 SAVE AREA ADDRESSR14 EQU 14R15 EQU 15*

USING PGMSTART,R12 BASE REGISTER ESTABLISHED 2SAVE (14,12) SAVE REGISTERSLR 12,15 LOAD REGISTERSST R13,SAVEAREA+4 SAVE AREA CHAININGLA R13,SAVEAREA NEW SAVE AREAUSING PCBLIST,R2 MAP INPUT PARAMETER LISTUSING PCBNAME,R5 MAP DB PCBLR R2,R1 SAVE INPUT PCB LIST IN REG 2L R5,PCBDETA LOAD DETAIL PCB ADDRESSLA R5,0(R5) REMOVE HIGH ORDER END OF LIST FLAG 3CALL ASMTDLI,(GU,(R5),DETSEGIO,SSANAME),VL 4

**

L R5,PCBMSTA LOAD MASTER PCB ADDRESSCALL ASMTDLI,(GHU,(R5),MSTSEGIO,SSAU),VL 5

**

CALL ASMTDLI,(GHN,(R5),MSTSEGIO),VL 6**

CALL ASMTDLI,(REPL,(R5),MSTSEGIO),VL**

L R13,4(R13) RESTORE SAVE AREARETURN (14,12) RETURN BACK 7

** FUNCTION CODES USED*GU DC CL4’GU’GHU DC CL4’GHU’GHN DC CL4’GHN’REPL DC CL4’REPL’ 8** SSAS*SSANAME DS 0C

DC CL8’ROOTDET’DC CL1’(’DC CL8’KEYDET’ 9DC CL2’ =’

NAME DC CL5’ ’DC C’)’

*

Figure 4. Sample assembler language program (Part 1 of 2)

16 Application Programming Guide

Page 41: IMS Application Programming.pdf

Notes to Figure 4 on page 16:

1. The entry point to an assembler language program can have any name. Also,you can substitute CBLTDLI for ASMTDLI in any of the calls.

2. When IMS passes control to the application program, register 1 contains theaddress of a variable-length fullword parameter list. Each word in this listcontains the address of a PCB that the application program must save. Thehigh-order byte of the last word in the parameter list has the 0 bit set to avalue of 1 which indicates the end of the list. The application programsubsequently uses these addresses when it executes DL/I calls.

3. The program loads the address of the DETAIL DB PCB.4. The program issues a GU call to the DETAIL database using a qualified SSA

(SSANAME).5. The program loads the address of the HALDB master PCB.6. The next three calls that the program issues are to the HALDB master. The

first is a GHU call that uses an unqualified SSA. The second is an unqualifiedGHN call. The REPL call replaces the segment retrieved using the GHN call withthe segment in the MSTSEGIO area.You can use the parmcount parameter in DL/I calls in assembler languageinstead of the VL parameter, except for in the call to the sample status-codeerror routine.

7. The RETURN statement loads IMS registers and returns control to IMS.8. The call functions are defined as four-character constants.9. The program defines each part of the SSA separately so that it can modify the

SSA's fields.10. The program must define an I/O area that is large enough to contain the

largest segment it is to retrieve or insert (or the largest path of segments if theprogram uses the D command code). This program's I/O areas are 100 byteseach.

11. A fullword must be defined for each PCB. The assembler language programcan access status codes after a DL/I call by using the DB PCB base addresses.This example assumes that an I/O PCB was passed to the applicationprogram. If the program is a batch program, CMPAT=YES must be specifiedon the PSBGEN statement of PSBGEN so that the I/O PCB is included.

SSAU DC CL9’ROOTMST’*MSTSEGIO DC CL100’ ’DETSEGIO DC CL100’ ’SAVEAREA DC 18F’0’* 10PCBLIST DSECTPCBIO DS A ADDRESS OF I/O PCBPCBMSTA DS A ADDRESS OF MASTER PCBPCBDETA DS A ADDRESS OF DETAIL PCB 11*PCBNAME DSECTDBPCBDBD DS CL8 DBD NAMEDBPCBLEV DS CL2 LEVEL FEEDBACKDBPCBSTC DS CL2 STATUS CODESDBPCBPRO DS CL4 PROC OPTIONSDBPCBRSV DS F RESERVEDDBPCBSFD DS CL8 SEGMENT NAME FEEDBACKDBPCBMKL DS F LENGTH OF KEY FEEDBACKDBPCBNSS DS F NUMBER OF SENSITIVE SEGMENTS IN PCBDBPCBKFD DS C KEY FEEDBACK AREA

END PGMSTART

Figure 4. Sample assembler language program (Part 2 of 2)

Chapter 1. Writing your application programs for IMS DB 17

Page 42: IMS Application Programming.pdf

Because the I/O PCB is required for a batch program to make system servicecalls, CMPAT=YES should always be specified.

Binding assembler code to the IMS language interface moduleThe IMS language interface module (DFSLI000) must be bound to the compiledassembler language program.

Coding a CICS online program in assembler languageFigure 5 is a skeleton program in assembler language. It shows how you defineand establish addressability to the UIB. The numbers to the right of the programrefer to the notes that follow the program. This program can run in a CICSenvironment using DBCTL.

PGMSTART DSECT NOTESUIBPTR DS FIOAREA DS 0CL40 1AREA1 DS CL3AREA2 DS CL37

DLIUIBUSING UIB,8 2

PCBPTRS DSECT* PSB ADDRESS LISTPCB1PTR DS FPCB1 DSECT

USING PCB1,6 3DBPC1DBD DS CL8DBPC1LEV DS CL2DBPC1STC DS CL2DBPC1PRO DS CL4DBPC1RSV DS FDBPC1SFD DS CL8DBPC1MKL DS FDBPC1NSS DS FDBPC1KFD DS 0CL256DBPC1NM DS 0CL12DBPC1NMA DS 0CL14DBPC1NMP DS CL17ASMUIB CSECT

B SKIPPSBNAME DC CL8’ASMPSB’PCBFUN DC CL4’PCB’REPLFUN DC CL4’REPL’TERMFUN DC CL4’TERM’GHUFUN DC CL4’GHU’SSA1 DC CL9’AAAA4444’GOODRC DC XL1’00’GOODSC DC CL2’ ’SKIP DS 0H 4* SCHEDULE PSB AND OBTAIN PCB ADDRESSES

Figure 5. Sample call-level assembler language program (CICS online) (Part 1 of 2)

18 Application Programming Guide

Page 43: IMS Application Programming.pdf

Notes to the example:

1. The program must define an I/O area that is large enough to contain thelargest segment it is to retrieve or insert (or the largest path of segments if theprogram uses the D command code).

2. The DLIUIB statement copies the UIB DSECT, which is expanded as shownunder “Specifying the UIB (CICS online programs only)” on page 63.

3. A fullword must be defined for each DB PCB. The assembler languageprogram can access status codes after a DL/I call by using the DB PCB baseaddresses.

4. This is an unqualified SSA. For qualified SSA, define each part of the SSAseparately so that the program can modify the fields of the SSA.

5. This call schedules the PSB and obtains the PSB address.6. This call retrieves a segment from the database.

CICS online assembler language programs use the CALLDLI macro, instead ofthe call statement, to access DL/I databases. This macro is similar to the callstatement. It looks like this:

CALLDLI ASMTDLI,(PCBFUN,PSBNAME,UIBPTR)L 8,UIBPTR 5CLC UIBFCTR,X’00’BNE ERROR1

* GET PSB ADDRESS LISTL 4,UIBPCBALUSING PCBPTRS,4

* GET ADDRESS OF FIRST PCB IN LISTL 6,PCB1PTR

* ISSUE DL/I CALL: GET A UNIQUE SEGMENTCALLDLI ASMTDLI,(GHUFUN,PCB1,IOAREA,SSA1) 6CLC UIBFCTR,GOODRCBNE ERROR2CLC DBPC1STC,GOODSCBNE ERROR3 7

* PERFORM SEGMENT UPDATE ACTIVITYMVC AREA1,.......MVC AREA2,.......

* ISSUE DL/I CALL: REPLACE SEGMENT AT CURRENT POSITIONCALLDLI ASMTDLI,(REPLFUN,PCB1,IOAREA,SSA1) 8CLC UIBFCTR,GOODRCBNE ERROR4CLC DBPC1STC,GOODSCB TERM

ERROR1 DS 0H* INSERT ERROR DIAGNOSTIC CODE

B TERMERROR2 DS 0H* INSERT ERROR DIAGNOSTIC CODE

B TERMERROR3 DS 0H* INSERT ERROR DIAGNOSTIC CODE

B TERMERROR4 DS 0H* INSERT ERROR DIAGNOSTIC CODEERROR5 DS 0H* INSERT ERROR DIAGNOSTIC CODE

B TERMTERM DS 0H* RELEASE THE PSB

CALLDLI ASMDLI, (TERMFUN)EXEC CICS RETURNEND ASMUIB 9,10

Figure 5. Sample call-level assembler language program (CICS online) (Part 2 of 2)

Chapter 1. Writing your application programs for IMS DB 19

Page 44: IMS Application Programming.pdf

CALLDLI ASMTDLI,(function,PCB-name,ioarea, SSA1,...SSAn),VL

7. CICS online programs must check the return code in the UIB before checkingthe status code in the DB PCB.

8. The REPL call replaces the data in the segment that was retrieved by the mostrecent Get Hold call. The data is replaced by the contents of the I/O areareferenced in the call.

9. This call releases the PSB.10. The RETURN statement loads IMS registers and returns control to IMS.

Related reading: For more information on installing CICS application programs,see CICS Transaction Server for z/OS V3.2 CICS Application Programming Reference.

Coding a batch program in C languageFigure 6 is a skeleton batch program that shows you how the parts of an IMSprogram that is written in C fit together. The numbers to the right of the programrefer to the notes that follow the program.

#pragma runopts(env(IMS),plist(IMS)) NOTES#include <ims.h>#include <stdio.h> 1main() { 2/* *//* descriptive statements *//* */IO_PCB_TYPE *IO_PCB = (IO_PCB_TYPE*)PCBLIST[0];struct {PCB_STRUCT(10)} *mast_PCB = __pcblist[1];

struct {PCB_STRUCT(20)} *detail_PCB = __pcblist[2]; 3const static char func_GU[4] = "GU ";const static char func_GN[4] = "GN ";const static char func_GHU[4] = "GHU ";const static char func_GHN[4] = "GHN ";const static char func_GNP[4] = "GNP "; 4const static char func_GHNP[4] = "GHNP";const static char func_ISRT[4] = "ISRT";const static char func_REPL[4] = "REPL";const static char func_DLET[4] = "DLET";char qual_ssa[8+1+8+2+6+1+1]; /* initialized by sprintf 5

/*below. See the *//*explanation for *//*sprintf in note 7 for the *//*meanings of 8,1,8,2,6,1 ——*//*the final 1 is for the *//*trailing ’\0’ of string */

static const char unqual_ssa[]= "NAME ");/* 12345678_ */

struct {—————————

} mast_seg_io_area;

struct {—————— 6———

} det_seg_io_area;

Figure 6. Sample C language program (Part 1 of 2)

20 Application Programming Guide

Page 45: IMS Application Programming.pdf

Notes to Figure 6:

1. The env(IMS) establishes the correct operating environment and theplist(IMS) establishes the correct parameter list when invoked under IMS. Theims.h header file contains declarations for PCB layouts, __pcblist, and thectdli routine. The PCB layouts define masks for the PCBs that the programuses as structures. These definitions make it possible for the program to checkfields in the PCBs.The stdio.h header file contains declarations for sprintf (used to build up theSSA).

2. After IMS has loaded the application program's PSB, IMS gives control to theapplication program through this entry point.

3. The C run-time sets up the __pcblist values. The order in which you refer tothe PCBs must be the same order in which they have been defined in the PSB.(Values other than “10” and “20” can be used, according to the actual keylengths needed.) These declarations can be done using macros, such as:#define IO_PCB (IO_PCB_TYPE *) (__pcblist[0])#define mast_PCB (__pcblist[1])#define detail_PCB (__pcblist[2])

This example assumes that an I/O PCB was passed to the applicationprogram. When the program is a batch program, CMPAT=YES must bespecified on the PSBGEN statement of PSBGEN so that the I/O PCB isincluded. Because the I/O PCB is required for a batch program to makesystem service calls, CMPAT=YES should always be specified for batchprograms.

4. Each of these areas defines one of the call functions used by the batchprogram. Each character string is defined as four alphanumeric characters,with a value assigned for each function. (If the [4]s had been left out, 5 byteswould have been reserved for each constant.) You can define other constantsin the same way. Also, you can store standard definitions in a source libraryand include them by using a #include directive.Instead, you can define these by macros, although each string would have atrailing null ('\0').

/* *//* Initialize the qualifier *//* */

sprintf(qual_ssa,"%—8.8s(%—8.8s%2.2s%—6.6s)","ROOT", "KEY", "=", "vvvvv"); 7

/* *//* Main part of C batch program *//* */

ctdli(func_GU, detail_PCB,&det_seg_io_area,qual_ssa); 8

ctdli(func_GHU, mast_PCB,&mast_seg_io_area,qual_ssa); 9

ctdli(func_GHN, mast_PCB,&mast_seg_io_area); 10

ctdli(func_REPL, mast_PCB,&mast_seg_io_area; 11

} 12

Figure 6. Sample C language program (Part 2 of 2)

Chapter 1. Writing your application programs for IMS DB 21

Page 46: IMS Application Programming.pdf

5. The SSA is put into a string (see note 7). You can define a structure, as inCOBOL, PL/I, or Pascal, but using sprintf is more convenient. (Rememberthat C strings have trailing nulls that cannot be passed to IMS.) Note that thestring is 1 byte longer than required by IMS to contain the trailing null, whichis ignored by IMS. Note also that the numbers in brackets assume that sixfields in the SSA are equal to these lengths.

6. The I/O areas that will be used to pass segments to and from the database aredefined as structures.

7. The sprintf function is used to fill in the SSA. The “%-8.8s” format means “aleft-justified string of exactly eight positions”. The “%2.2s” format means “aright-justified string of exactly two positions”.Because the ROOT and KEY parts do not change, this can also be coded:sprintf(qual_ssa,

"ROOT (KEY =%-6.6s)", "vvvvv");/* 12345678 12345678 */

8. This call retrieves data from the database. It contains a qualified SSA. Beforeyou can issue a call that uses a qualified SSA, initialize the data field of theSSA. Before you can issue a call that uses an unqualified SSA, initialize thesegment name field. Unlike the COBOL, PL/I, and Pascal interface routines,ctdli also returns the status code as its result. (Blank is translated to 0.) So,you can code:switch (ctdli(....)) {

case 0: ... /* everything ok */

break;case ’AB’: ....

break;case ’IX’: ...

break;default:

}

You can pass only the PCB pointer for DL/I calls in a C program.9. This is another call with a qualified SSA.

10. This call is an unqualified call that retrieves data from the database. Because itis a Get Hold call, it can be followed by REPL or DLET.

11. The REPL call replaces the data in the segment that was retrieved by the mostrecent Get Hold call. The data is replaced by the contents of the I/O area thatis referenced in the call.

12. The end of the main routine (which can be done by a return statement or exitcall) returns control to IMS.

Binding C code to the language interface moduleIMS provides a language interface module (DFSLI000) that is an interface betweenIMS and the C language. This module must be made available to the applicationprogram at bind time.

Coding a batch program in COBOLThe program in Figure 7 is a skeleton batch program that shows you how the partsof an IMS program, written in COBOL, fit together. The numbers to the right ofthe program refer to the notes that follow the program. This kind of program canrun as a batch program or as a batch-oriented BMP.

22 Application Programming Guide

Page 47: IMS Application Programming.pdf

Identification Division.Program-ID. BATCOBOL.Environment Division.Data Division.Working-Storage Section.

01 Func-Codes.05 Func-GU Picture XXXX Value ’GU ’.05 Func-GHU Picture XXXX Value ’GHU ’.05 Func-GN Picture XXXX Value ’GHN ’.05 Func-GHN Picture XXXX Value ’GHN ’.05 Func-GNP Picture XXXX Value ’GNP ’.05 Func-GHNP Picture XXXX Value ’GHNP’.05 Func-REPL Picture XXXX Value ’REPL’.05 Func-ISRT Picture XXXX Value ’ISRT’.05 Func-DLET Picture XXXX Value ’DLET’.05 Parmcount Picture S9(5) Value +4 Comp-5.

01 Unqual-SSA.05 Seg-Name Picture X(08) Value ’ ’.05 Filler Picture X Value ’ ’.

01 Qual-SSA-Mast.05 Seg-Name-M Picture X(08) Value ’ROOTMast’.05 Begin-Paren-M Picture X Value ’(’.05 Key-Name-M Picture X(08) Value ’KeyMast ’.05 Kel-Oper-M Picture X(05) Value ’ =’.05 Key-Value-M Picture X(06) Value ’VVVVVV’.05 End-Paren-M Picture X Value ’)’.

01 Qual-SSA-Det.05 Seg-Name-D Picture X(08) Value ’ROOTDET ’.05 Begin-Paren-D Picture X Value ’(’.05 Key-Name-D Picture X(08) Value ’KEYDET ’.05 Rel-Oper-D Picture X(05) Value ’ =’.05 Key-Value-D Picture X(06) Value ’VVVVVV’.05 End-Paren-D Picture X Value ’)’.

01 Det-Seg-In.05 Data1 Picture X.05 Data2 Picture X.

01 Mast-Seg-In.05 Data1 Picture X.05 Data2 Picture X.

linkage section.01 IO-PCB.

05 Filler Picture X(10).05 IO-Status-Code Picture XX.05 Filler Picture X(20).

01 DB-PCB-Mast.05 Mast-Dbd-Name Picture X(8).05 Mast-Seg-Level Picture XX.05 Mast-Status-Code Picture XX.05 Mast-Proc-Opt Picture XXXX.05 Filler Picture S9(5) Comp-5.05 Mast-Seg-Name Picture X(8).05 Mast-Len-KFB Picture S9(5) Comp-5.05 Mast-Nu-Senseg Picture S9(5) Comp-5.05 Mast-Key-FB Picture X(256).

01 DB-PCB-Detail.05 Det-Dbd-Name Picture X(8).05 Det-Seg-Level Picture XX.05 Det-Status-Code Picture XX.05 Det-Proc-Opt Picture XXXX.05 Filler Picture S9(5) Comp-5.05 Det-Seg-Name Picture X(8).05 Det-Len-KFB Picture S9(5) Comp-5.05 Det-Nu-Senseg Picture S9(5) Comp-5.05 Det-Key-FB Picture X(256).

Figure 7. Sample COBOL program (Part 1 of 2)

Chapter 1. Writing your application programs for IMS DB 23

|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||

Page 48: IMS Application Programming.pdf

Notes to Figure 7:

1. You define each of the DL/I call functions the program uses with a 77-level or01-level working storage entry. Each picture clause is defined as fouralphanumeric characters and has a value assigned for each function. If youwant to include the optional parmcount field, you can initialize count valuesfor each type of call. You can also use a COBOL COPY statement to includethese standard descriptions in the program.

2. A 9-byte area is set up for an unqualified SSA. Before the program issues acall that requires an unqualified SSA, it moves the segment name to this area.If a call requires two or more SSAs, you may need to define additional areas.

3. A 01-level working storage entry defines each qualified SSA that theapplication program uses. Qualified SSAs must be defined separately, becausethe values of the fields are different.

4. A 01-level working storage entry defines I/O areas that are used for passingsegments to and from the database. You can further define I/O areas withsub-entries under the 01-level. You can use separate I/O areas for eachsegment type, or you can define one I/O area that you use for all segments.

5. A 01-level linkage section entry defines a mask for each of the PCBs that theprogram requires. The DB PCBs represent both input and output databases.After issuing each DL/I call, the program checks the status code through thislinkage. You define each field in the DB PCB so that you can reference it inthe program.

6. This is the standard procedure division statement of a batch program. AfterIMS has loaded the PSB for the program, IMS passes control to the applicationprogram. The PSB contains all the PCBs that are defined in the PSB. Thecoding of USING on the procedure division statement references each of thePCBs by the names that the program has used to define the PCB masks in thelinkage section. The PCBs must be listed in the order in which they aredefined in the PSB.The example in Figure 7 assumes that an I/O PCB was passed to theapplication program. When the program is a batch program, CMPAT=YESmust be specified on the PSBGEN statement of PSBGEN so that the I/O PCBis included. Because the I/O PCB is required for a batch program to makesystem service calls, CMPAT=YES should always be specified for batchprograms.

Procedure Division using IO-PCB DB-PCB-Mast DB-PCB-Detail.Call ’CBLTDLI’ using Func-GU DB-PCB-Detail

Det-seg-in Qual-SSA-Det...Call ’CBLTDLI’ using Parmcount Func-ghu DB-PCB-Mast

Mast-seg-in Qual-SSA-Mast...Call ’CBLTDLI’ using Func-GHN DB-PCB-Mast

Mast-seg-in...Call ’CBLTDLI’ using Func-REPL DB-PCB-Mast

Mast-seg-in...Goback.

Figure 7. Sample COBOL program (Part 2 of 2)

24 Application Programming Guide

||||||||||||||||||

|||

||||

Page 49: IMS Application Programming.pdf

The entry DLITCBL statement is only used in the main program. Do not use itin called programs.

7. This call retrieves data from the database by using a qualified SSA. Beforeissuing the call, the program must initialize the key or data value of the SSAso that it specifies the particular segment to be retrieved. The program shouldtest the status code in the DB PCB that was referenced in the call immediatelyafter issuing the call. You can include the parmcount parameter in DL/I calls inCOBOL programs, except in the call to the sample status-code error routine. Itis never required in COBOL.

8. This is another retrieval call that contains a qualified SSA.9. This is an unqualified retrieval call.

10. The REPL call replaces the segment that was retrieved in the most recent GetHold call. The segment is replaced with the contents of the I/O area that isreferenced in the call (MAST-SEG-IN).

11. The program issues the GOBACK statement when it has finished processing.

Binding COBOL code to the IMS language interface moduleIMS supplies a language interface module (DFSLI000). This module must be boundto the batch program after the program has been compiled. It gives a commoninterface to IMS.

If you use the IMS-supplied procedures (IMSCOBOL or IMSCOBGO), IMS bindsthe language interface with the application program. IMSCOBOL is a two-stepprocedure that compiles and binds your program. IMSCOBGO is a three-stepprocedure that compiles, binds, and executes your program in an IMS batchregion.

Related reading: For information on how to use these procedures, see IMS Version10: System Definition Reference.

Coding a CICS online program in COBOLThe programs in this section are skeleton online programs in Enterprise COBOL.They show examples of how to define and set up addressability to the UIB. Thenumbers to the right of the programs refer to the notes that follow them. This kindof program can run in a CICS environment using DBCTL.

Identification Division.Program-ID. CBLUIB.Environment Division.Data Division.Working-Storage Section.

01 Func-Codes.05 Psb-Name Picture X(8) Value ’CBLPSB ’.05 Func-PCB Picture X(4) Value ’PCB ’.05 Func-TERM Picture X(4) Value ’TERM’. 105 Func-GHU Picture X(4) Value ’GHU ’.05 Func-REPL Picture X(4) Value ’REPL’.05 SSA1 Picture X(9) Value ’AAAA4444 ’.05 Success-Message Picture X(40).05 Good-Status-Code Picture XX Value ’ ’. 205 good-return-code Picture X Value low-Value.

01 Message0.05 Message1 Picture X(38). 305 Message2 Picture XX.

01 Dli-IO-Area.

Figure 8. Sample COBOL program that can run in CICS

Chapter 1. Writing your application programs for IMS DB 25

||||||||||||||||||||||

Page 50: IMS Application Programming.pdf

05 Area1 Picture X(3).05 Area2 Picture X(37).

Procedure Division.* Schedule the psb and address the uib

Call ’CBLTDli’ using Func-PCB Psb-Name 4address of Dliuib.

If Uibfctr is not equal low-Values then* Insert error diagnostic code

Exec CICS return end-execEnd-if.Set address of pcb-addresses to pcbaddr.

* Issue DL/I Call: get a unique segmentSet address of pcb1 to pcb-address-list(1).Call ’CBLTDli’ using Func-GHU Pcb1 5

Dli-io-area ssa1.If uibfctr is not equal good-return-code then

* Insert error diagnostic code 6Exec CICS return end-Exec

End-if.If pcb1-status-code is not equal good-status-code then

* Insert error diagnostic codeExec CICS return end-Exec

End-if.* Perform segment update activity

Move ’aaa’ to area1.Move ’bbb’ to area2.

* Issue DL/I Call: replace segment at current position 7Call ’CBLTDli’ using Func-REPL Pcb1

Dli-io-area ssa1If uibfctr is not equal good-return-code then

* Insert error diagnostic codeExec CICS return end-Exec

End-if.If pcb1-status-code is not equal good-status-code then

* Insert error diagnostic codeExec CICS return end-Exec

End-if.* Release the psb

Call ’CBLTDli’ using Func-TERM.* Other application Function 8,9

Exec CICS return end-Exec.Goback.

Notes to example:

1. You define each of the DL/I call functions the program uses with a 77-level or01-level working storage entry. Each picture clause is defined as fouralphanumeric characters and has a value assigned for each function. If youwant to include the optional parmcount field, initialize count values for eachtype of call. You can also use the COBOL COPY statement to include thesestandard descriptions in the program.

2. A 9-byte area is set up for an unqualified SSA. Before the program issues a callthat requires an unqualified SSA, it can either initialize this area with thesegment name or move the segment name to this area. If a call requires two ormore SSAs, you may need to define additional areas.

3. An 01-level working storage entry defines I/O areas that are used for passingsegments to and from the database. You can further define I/O areas withsub-entries under the 01-level. You can use separate I/O areas for each segmenttype, or you can define one I/O area that you use for all segments.

4. One PCB layout is defined in the linkage section. The PCB-ADDRESS-LISToccurs n times, where n is greater than or equal to the number of PCBs in thePSB.

26 Application Programming Guide

||||||||||||||||||||||||||||||||||||||||||

||||

Page 51: IMS Application Programming.pdf

5. The PCB call schedules a PSB for your program to use. The address of theDLIUIB parameter returns the address of DLIUIB.

6. This unqualified GHU call retrieves a segment from the database and places it inthe I/O area that is referenced by the call. Before issuing the call, the programmust initialize the key or data value of the SSA so that it specifies theparticular segment to be retrieved.

7. CICS online programs should test the return code in the UIB before testing thestatus code in the DB PCB.

8. The REPL call replaces the segment that was retrieved in the most recent GetHold call with the data that the program has placed in the I/O area.

9. The TERM call terminates the PSB the program scheduled earlier. This call isoptional and is only issued if a sync point is desired prior to continuedprocessing. The program issues the EXEC CICS RETURN statement when it hasfinished its processing. If this is a RETURN from the highest-level CICSprogram, a TERM call and sync point are internally generated by CICS.

Chapter 1. Writing your application programs for IMS DB 27

Page 52: IMS Application Programming.pdf

Identification Division. NOTESProgram-ID. CBLUIB.

Environment Division.Data Division.Working-Storage Section.

01 Func-Codes.05 Psb-Name Picture X(8) Value ’CBLPSB ’. 105 Func-PCB Picture X(4) Value ’PCB ’.05 Func-TERM Picture X(4) Value ’TERM’.05 Func-GHU Picture X(4) Value ’GHU ’.05 Func-REPL Picture X(4) Value ’REPL’.05 SSA1 Picture X(9) Value ’AAAA4444 ’. 205 Success-Message Picture X(40).05 Good-Status-Code Picture XX Value ’ ’.05 Good-Return-Code Picture X Value low-Value.

01 Message0.05 Message1 Picture X(38).05 Message2 Picture XX.

01 Dli-IO-Area. 305 Area1 Picture X(3).05 Area2 Picture X(37).

Linkage Section. 401 BllCells.

05 FIller Picture S9(8) Comp-5.05 Uib-Ptr Picture S9(8) Comp-5.05 B-Pcb-Ptrs Picture S9(8) Comp-5.05 Pcb1-Ptr Picture S9(8) Comp-5.Copy DliUib. 5,6

01 Overlay-Dliuib Redefines Dliuib.05 Pcbaddr usage is pointer.05 Filler Picture XX.

01 Pcb-Ptrs.05 B-Pcb1-Ptr Picture 9(8) Comp-5.

01 Pcb1. 705 Pcb1-Dbd-Name Picture X(8).05 Pcb1-Seg-Level Picture XX.05 Pcb1-Status-Code Picture XX.05 Pcb1-PROC-OPT Picture XXXX.05 FIller Picture S9(5) Comp-5.05 Pcb1-Seg-Name Picture X(8).05 Pcb1-Len-KFB Picture S9(5) Comp-5.05 Pcb1-NU-ENSeg Picture S9(5) Comp-5.05 Pcb1-KEY-FB Picture X(256).

Procedure Division. 8Call ’CBLTDLI’ using Func-PCB Psb-Name Uib-ptr.If Uibfctr is not equal low-values then

* Insert error diagnostic CodeExec CICS Return end-Exec

End-if.Move Uibpcbal to B-Pcb-Ptrs.Move B-Pcb1-Ptr to Pcb1-Ptr.

* Issue DL/I Call: get a unique segment 9Call ’CBLTDLI’ using Func-GHU Pcb1

Dli-io-area ssa1.Service reload Uib-ptrIf Uibfctr is not equal Good-Return-Code then 10

* Insert error diagnostic CodeExec CICS Return end-Exec

End-if.

If Pcb1-Status-Code is not equal Good-Status-Code then* Insert error diagnostic Code

Exec CICS Return end-ExecEnd-if.

Figure 9. Sample call-level OS/VS COBOL program for CICS online (obsolete with Enterprise COBOL) (Part 1 of 2)

28 Application Programming Guide

||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||

Page 53: IMS Application Programming.pdf

Notes to Figure 9:

1. You define each of the DL/I call functions the program uses with a 77-level or01-level working storage entry. Each picture clause is defined as fouralphanumeric characters and has a value assigned for each function. If youwant to include the optional parmcount field, you can initialize count valuesfor each type of call. You can also use the COBOL COPY statement to includethese standard descriptions in the program.

2. A 9-byte area is set up for an unqualified SSA. Before the program issues acall that requires an unqualified SSA, it can either initialize this area with thesegment name or move the segment name to this area. If a call requires twoor more SSAs, you may need to define additional areas.

3. An 01-level working storage entry defines I/O areas that are used for passingsegments to and from the database. You can further define I/O areas with02-level entries. You can use separate I/O areas for each segment type, or youcan define one I/O area to use for all segments.

4. The linkage section must start with a definition of this type to provideaddressability to a parameter list that will contain the addresses of storagethat is outside the working storage of the application program. The first02-level definition is used by CICS to provide addressability to the other fieldsin the list. A one-to-one correspondence exists between the other 02-levelnames and the 01-level data definitions in the linkage section.

5. The COPY DLIUIB statement will be expanded as shown in Figure 14 on page65.

6. The UIB returns the address of an area that contains the PCB addresses. Thedefinition of PCB pointers is necessary to obtain the actual PCB addresses. Donot alter the addresses in the area.

7. The PCBs are defined in the linkage section.8. The PCB call schedules a PSB for your program to use.9. This unqualified GHU call retrieves a segment from the database and places it

in the I/O area that is referenced by the call. Before issuing the call, theprogram must initialize the key or data value of the SSA so that it specifiesthe particular segment to be retrieved.

10. CICS online programs should test the return code in the UIB before testing thestatus code in the DB PCB.

* Perform segment update activityMove ’aaa’ to area1.Move ’bbb’ to area2.

* Issue DL/I Call: replace segment at current position 11Call ’CBLTDLI’ using Func-REPL Pcb1

Dli-io-area ssa1.If Uibfctr is not equal Good-Return-Code then

* Insert error diagnostic CodeExec CICS Return end-Exec

End-if.

If Pcb1-Status-Code is not equal Good-Status-Code then* Insert error diagnostic Code

Exec CICS Return end-ExecEnd-if.

* Release the PSBCall ’CBLTDLI’ using Func-TERM. 12,13

Exec CICS Return end-Exec.

Figure 9. Sample call-level OS/VS COBOL program for CICS online (obsolete with Enterprise COBOL) (Part 2 of 2)

Chapter 1. Writing your application programs for IMS DB 29

|

Page 54: IMS Application Programming.pdf

11. The REPL call replaces the segment that was retrieved in the most recent GetHold call with the data that the program has placed in the I/O area.

12. The TERM call terminates the PSB that the program scheduled earlier. This callis optional and is only issued if a sync point is desired prior to continuedprocessing.

13. The program issues the EXEC CICS RETURN statement when it has finishedits processing. If this is a return from the highest-level CICS program, a TERMcall and sync point are internally generated by CICS.

Related reading: For more information about installing application programs, seeCICS Transaction Server for z/OS V3.2 CICS Application Programming Reference.

Coding a program in JavaThe following code sample is part of a sample method showModelDetails after theDLIDriver class has been loaded. The code obtains a Connection object, retrieves aPreparedStatement object, makes SQL calls to the database, and then iteratesthe ResultSet object that is returned from the PreparedStatement object.

Notes to Figure 10:1. Retrieves a Connection object from the DriverManager object that is

implemented in the java.sql package.2. Stores results from the Connection object in a ResultSet object.3. Retrieves specific field results, as defined elsewhere in the DLIDatabaseView

object4. Iteratively stores the output in the ResultSet object

public ModelDetailsOutput showModelDetails(ModelDetailsInput input)throws NamingException, SQLException, IMSException {

// Extract the key from the inputString modelKey = input.getModelKey();ModelDetailsOutput output = new ModelDetailsOutput();

// Validate the keyif (modelKey != null && !modelKey.trim().equals("")) {

// Build the SQL query.String query = "SELECT * FROM Dealer.ModelSegment WHERE "

+ "ModelSegment.ModelKey = ’" + input.getModelKey() + "’";

// Execute the queryStatement statement = connection.createStatement(); 1ResultSet results = statement.executeQuery(query); 2

// Store the results in the output object and send it// back to the caller of this method.if (results.next()) {

output.setMake(results.getString("Make"));output.setModelType(results.getString("ModelType")); 3output.setModel(results.getString("Model"));output.setYear(results.getString("Year"));output.setPrice(results.getString("MSRP"));output.setCount(results.getString("Counter"));

}}return output; 4

}

Figure 10. Sample JDBC application

30 Application Programming Guide

||||||||||||||||||||||||||||||||||

|

|||||

|

||

|

||

|

Page 55: IMS Application Programming.pdf

Coding a batch program in PascalThe following code sample is a skeleton batch program in Pascal. It shows youhow the parts of an IMS program that is written in Pascal fit together. Thenumbers to the right of the program refer to the notes that follow the program.

Restriction: Pascal is not supported by CICS.segment PASCIMS; NOTES

1type 2

CHAR2 = packed array [1..2] of CHAR;CHAR4 = packed array [1..4] of CHAR;CHAR6 = packed array [1..6] of CHAR;CHARn = packed array [1..n] of CHAR;

DB_PCB_TYPE = record 3DB_NAME : ALFA;DB_SEG_LEVEL : CHAR2;DB_STAT_CODE : CHAR2;DB_PROC_OPT : CHAR4;FILLER : INTEGER;DB_SEG_NAME : ALFA;DB_LEN_KFB : INTEGER;DB_NO_SENSEG : INTEGER;DB_KEY_FB : CHARn;

end;procedure PASCIMS (var SAVE: INTEGER; 4

var DB_PCB_MAST: DB_PCB_TYPE;var DB_PCB_DETAIL : DB_PCB_TYPE);

REENTRANT;procedure PASCIMS;type 5

QUAL_SSA_TYPE = recordSEG_NAME : ALFA;

SEQ_QUAL : CHAR;SEG_KEY_NAME : ALFA;SEG_OPR : CHAR2;SEG_KEY_VALUE: CHAR6;SEG_END_CHAR : CHAR;end;

MAST_SEG_IO_AREA_TYPE = record(* Field declarations *)

end;DET_SEG_IO_AREA_TYPE = record

(* Field declarations *)end;

var 6MAST_SEG_IO_AREA : MAST_SEG_IO_AREA_TYPE;DET_SEG_IO_AREA : DET_SEG_IO_AREA_TYPE;

const 7GU = ’GU ’;GN = ’GN ’;GHU = ’GHU ’;GHN = ’GHN ’;GHNP = ’GHNP’;ISRT = ’ISRT’;REPL = ’REPL’;DLET = ’DLET’;QUAL_SSA = QUAL_SSA_TYPE(’ROOT’,’(’,’KEY’,’ =’,

’vvvvv’,’)’);UNQUAL_SSA = ’NAME ’;procedure PASTDLI; GENERIC; 8

begin

PASTDLI(const GU, 9var DB_PCB_DETAIL;var DET_SEG_IO_AREA;const QUAL_SSA);

Chapter 1. Writing your application programs for IMS DB 31

Page 56: IMS Application Programming.pdf

PASTDLI(const GHU, 10var DB_PCB_MAST,var MAST_SEG_IO_AREA,const QUAL_SSA);

PASTDLI(const GHN, 11var DB_PCB_MAST,var MAST_SEG_IO_AREA);

PASTDLI(const REPL, 12var DB_PCB_MAST,var MAST_SEG_IO_AREA);

end; 13

Notes:

1. Define the name of the Pascal compile unit.2. Define the data types that are needed for the PCBs used in your program.3. Define the PCB data type that is used in your program.4. Declare the procedure heading for the REENTRANT procedure that is called

by IMS. The first word in the parameter list should be an INTEGER, which isreserved for VS Pascal's usage. The rest of the parameters are the addresses ofthe PCBs that are received from IMS.

5. Define the data types that are needed for the SSAs and I/O areas.6. Declare the variables used for the I/O areas.7. Define the constants, such as function codes and SSAs that are used in the

PASTDLI DL/I calls.8. Declare the IMS interface routine by using the GENERIC directive. GENERIC

identifies external routines that allow multiple parameter list formats. AGENERIC routine's parameters are “declared” only when the routine is called.

9. This call retrieves data from the database. It contains a qualified SSA. Beforeyou can issue a call that uses a qualified SSA, you must initialize the datafield of the SSA. Before you can issue a call that uses an unqualified SSA, youmust initialize the segment name field.

10. This is another call that has a qualified SSA.11. This call is an unqualified call that retrieves data from the database. Because it

is a Get Hold call, it can be followed by a REPL or DLET call.12. The REPL call replaces the data in the segment that was retrieved by the most

recent Get Hold call; the data is replaced by the contents of the I/O area thatis referenced in the call.

13. You return control to IMS by exiting from the PASCIMS procedure. You canalso code a RETURN statement to exit at another point.

Binding Pascal code to the IMS language interface moduleYou must bind your program to the IMS language interface module (DFSLI000)after compiling your program.

Coding a batch program in PL/IFigure 11 is a skeleton batch program in PL/I. It shows you how the parts of anIMS program that is written in PL/I fit together. The numbers to the right of theprogram refer to the notes that follow. This kind of program can run as a batchprogram or as a batch-oriented BMP.

Restriction: IMS application programs cannot use PL/I multitasking. This isbecause all tasks operate as subtasks of a PL/I control task when you usemultitasking.

32 Application Programming Guide

Page 57: IMS Application Programming.pdf

/* */ NOTES/* ENTRY POINT *//* */DLITPLI: PROCEDURE (IO_PTR_PCB,DB_PTR_MAST,DB_PTR_DETAIL) 1

OPTIONS (MAIN);/* *//* DESCRIPTIVE STATEMENTS *//* */DCL IO_PTR_PCB POINTER;DCL DB_PTR_MAST POINTER;DCL DB_PTR_DETAIL POINTER;DCL FUNC_GU CHAR(4) INIT(’GU ’); 2DCL FUNC_GN CHAR(4) INIT(’GN ’);DCL FUNC_GHU CHAR(4) INIT(’GHU ’);DCL FUNC_GHN CHAR(4) INIT(’GHN ’);DCL FUNC_GNP CHAR(4) INIT(’GNP ’);DCL FUNC_GHNP CHAR(4) INIT(’GHNP’);DCL FUNC_ISRT CHAR(4) INIT(’ISRT’);DCL FUNC_REPL CHAR(4) INIT(’REPL’);DCL FUNC_DLET CHAR(4) INIT(’DLET’);DCL 1 QUAL_SSA STATIC UNALIGNED, 3

2 SEG_NAME CHAR(8) INIT(’ROOT ’),2 SEG_QUAL CHAR(1) INIT(’(’),2 SEG_KEY_NAME CHAR(8) INIT(’KEY ’),2 SEG_OPR CHAR(2) INIT(’ =’),2 SEG_KEY_VALUE CHAR(6) INIT(’vvvvv’),2 SEG_END_CHAR CHAR(1) INIT(’)’);

DCL 1 UNQUAL SSA STATIC UNALIGNED,2 SEG_NAME_U CHAR(8) INIT(’NAME ’),2 BLANK CHAR(1) INIT(’ ’);

DCL 1 MAST_SEG_IO_AREA, 42 ———2 ———2 ———

DCL 1 DET_SEG_IO_AREA,2 ———2 ———2 ———

DCL 1 IO_PCB BASED (IO_PTR_PCB), 52 FILLER CHAR(10),2 STAT CHAR(2);

Figure 11. Sample PL/I program (Part 1 of 2)

Chapter 1. Writing your application programs for IMS DB 33

Page 58: IMS Application Programming.pdf

Notes to Figure 11:

1. After IMS has loaded the PSB of the application program, IMS gives control tothe application program through this entry point. PL/I programs must passthe pointers to the PCBs, not the names, in the entry statement. The entrystatement lists the PCBs that the program uses by the names that it hasassigned to the definitions for the PCB masks. The order in which you refer tothe PCBs in the entry statement must be the same order in which they havebeen defined in the PSB.

DCL 1 DB_PCB_MAST BASED (DB_PTR_MAST),2 MAST_DB_NAME CHAR(8),2 MAST_SEG_LEVEL CHAR(2),2 MAST_STAT_CODE CHAR(2),2 MAST_PROC_OPT CHAR(4),2 FILLER FIXED BINARY (31,0),2 MAST_SEG_NAME CHAR(8),2 MAST_LEN_KFB FIXED BINARY (31,0),2 MAST_NO_SENSEG FIXED BINARY (31,0),2 MAST_KEY_FB CHAR(*);

DCL 1 DB_PCB_DETAIL BASE (DB_PTR_DETAIL),2 DET_DB_NAME CHAR(8),2 DET_SEG_LEVEL CHAR(2),2 DET_STAT_CODE CHAR(2),2 DET_PROC_OPT CHAR(4),2 FILLER FIXED BINARY (31,0),2 DET_SEG_NAME CHAR(8),2 DET_LEN_KFB FIXED BINARY (31,0),2 DET_NO_SENSEG FIXED BINARY (31,0),2 DET_KEY_FB CHAR(*);

DCL THREE FIXED BINARY (31,0) INITIAL(3); 6DCL FOUR FIXED BINARY (31,0) INITIAL(4);DCL FIVE FIXED BINARY (31,0) INITIAL(5);DCL SIX FIXED BINARY (31,0) INITIAL(6);/* *//* MAIN PART OF PL/I BATCH PROGRAM *//* */CALL PLITDLI (FOUR,FUNC_GU,DB_PCB_DETAIL,DET_SEG_IO_AREA, QUAL_SSA); 7

IF DET_STAT_CODE = GOOD_STATUS_CODE THEN DO;CALL PLITDLI (FOUR,FUNC_GHU,DB_PCB_MAST,MAST_SEG_IO_AREA,QUAL_SSA); 8IF MAST_STAT_CODE = GOOD_STATUS_CODE THEN DO;

CALL PLITDLI (THREE,FUNC_GHN,DB_PCB_MAST,MAST_SEG_IO_AREA); 9IF MAST_STAT_CODE = GOOD_STATUS_CODE THEN DO;

CALL PLITDLI (THREE,FUNC_REPL,DB_PCB_MAST,MAST_SEG_IO_AREA); 10IF MAST_STAT_CODE ^= GOOD_STATUS_CODE THEN DO;

/* INSERT REPLACE DIAGNOSTIC MESSAGE */END;

END;ELSE DO;

/* INSERT GHN DIAGNOSTIC MESSAGE */END;

END;ELSE DO;

/* INSERT GHU DIAGNOSTIC MESSAGE */END;

END;ELSE DO;

/* INSERT GU DIAGNOSTIC MESSAGE */END;RETURN; 11END DLITPLI;

Figure 11. Sample PL/I program (Part 2 of 2)

34 Application Programming Guide

|||||||||||||||||||||||||||||||||||||||||||||||||||

Page 59: IMS Application Programming.pdf

The example in Figure 11 on page 33 assumes that an I/O PCB was passed tothe application program. When the program is a batch program, CMPAT=YESmust be specified on the PSBGEN statement of PSBGEN so that the I/O PCBis included. Because the I/O PCB is required for a batch program to makesystem service calls, CMPAT=YES should always be specified for batchprograms.

2. Each of these areas defines one of the call functions used by the batchprogram. Each character string is defined as four alphanumeric characters,with a value assigned for each function. You can define other constants in thesame way. Also, you can store standard definitions in a source library andinclude them by using a %INCLUDE statement.

3. A structure definition defines each SSA the program uses. The unalignedattribute is required for SSAs. The SSA character string must residecontiguously in storage. You should define a separate structure for eachqualified SSA, because the value of the data field for each SSA is different.

4. The I/O areas that are used to pass segments to and from the database aredefined as structures.

5. Level-01 declaratives define masks for the PCBs that the program uses asstructures. These definitions make it possible for the program to check fieldsin the PCBs.

6. This statement defines the parmcount that is required in DL/I calls that areissued from PL/I programs (except for the call to the sample status-code errorroutine, where it is not allowed). The parmcount is the address of a 4-byte fieldthat contains the number of subsequent parameters in the call. The parmcountis required only in PL/I programs. It is optional in the other languages. Thevalue in parmcount is binary. This example shows how you can code theparmcount parameter when three parameters follow in the call:DCL THREE FIXED BINARY (31,0) INITIAL(3);

7. This call retrieves data from the database. It contains a qualified SSA. Beforeyou can issue a call that uses a qualified SSA, initialize the data field of theSSA. Before you can issue a call that uses an unqualified SSA, initialize thesegment name field. Check the status code after each DL/I call that you issue.Although you must declare the PCB parameters that are listed in the entrystatement to a PL/I program as POINTER data types, you can pass either thePCB name or the PCB pointer in DL/I calls in a PL/I program.

8. This is another call that has a qualified SSA.9. This is an unqualified call that retrieves data from the database. Because it is a

Get Hold call, it can be followed by REPL or DLET.10. The REPL call replaces the data in the segment that was retrieved by the most

recent Get Hold call; the data is replaced by the contents of the I/O areareferenced in the call.

11. The RETURN statement returns control to IMS.

Binding PL/I code to the IMS language interface moduleIMS provides a language interface module (DFSLI000) which gives a commoninterface to IMS. This module must be bound to the program.

If you use the IMS-supplied procedures (IMSPLI or IMSPLIGO), IMS binds thelanguage interface module to the application program. IMSPLI is a two-stepprocedure that compiles and binds your program. IMSPLIGO is a three-stepprocedure that compiles, binds, and executes your program in a DL/I batch region.For information on how to use these procedures, see IMS Version 10: SystemDefinition Reference.

Chapter 1. Writing your application programs for IMS DB 35

Page 60: IMS Application Programming.pdf

Coding a CICS online program in PL/IThe program in Figure 12 is a skeleton CICS online program in PL/I. It shows youhow to define and establish addressability to the UIB. The numbers to the right ofthe program refer to the notes that follow. This kind of program can run in a CICSenvironment using DBCTL.

PLIUIB: PROC OPTIONS(MAIN); NOTESDCL PSB_NAME CHAR(8) STATIC INIT(’PLIPSB ’); 1DCL PCB_FUNCTION CHAR(4) STATIC INIT(’PCB ’);DCL TERM_FUNCTION CHAR(4) STATIC INIT(’TERM’);DCL GHU_FUNCTION CHAR(4) STATIC INIT(’GHU ’);DCL REPL_FUNCTION CHAR(4) STATIC INIT(’REPL’);DCL SSA1 CHAR(9) STATIC INIT(’AAAA4444 ’); 2DCL PARM_CT_1 FIXED BIN(31) STATIC INIT(1);DCL PARM_CT_3 FIXED BIN(31) STATIC INIT(3);DCL PARM_CT_4 FIXED BIN(31) STATIC INIT(4);DCL GOOD_RETURN_CODE BIT(8) STATIC INIT(’0’B);DCL GOOD_STATUS_CODE CHAR(2) STATIC INIT(’ ’);%INCLUDE DLIUIB; 3DCL 1 PCB_POINTERS BASED(UIBPCBAL), 4

2 PCB1_PTR POINTER;DCL 1 DLI_IO_AREA, 5

2 AREA1 CHAR(3),2 AREA2 CHAR(37);

DCL 1 PCB1 BASED(PCB1_PTR), 62 PCB1_DBD_NAME CHAR(8),2 PCB1_SEG_LEVEL CHAR(2),2 PCB1_STATUS_CODE CHAR(2),2 PCB1_PROC_OPTIONS CHAR(4),2 PCB1_RESERVE_DLI FIXED BIN (31,0),2 PCB1_SEGNAME_FB CHAR(8),2 PCB1_LENGTH_FB_KEY FIXED BIN(31,0),2 PCB1_NUMB_SENS_SEGS FIXED BIN(31,0),2 PCB1_KEY_FB_AREA CHAR(17);

/* SCHEDULE PSB AND OBTAIN PCB ADDRESSES */CALL PLITDLI (PARM_CT_3,PCB_FUNCTION,PSB_NAME,UIBPTR); 7IF UIBFCTR = GOOD RETURN CODE THEN DO;

/* ISSUE DL/I CALL: GET A UNIQUE SEGMENT */CALL PLITDLI (PARM_CT_4,GHU_FUNCTION,PCB1,DLI_IO_AREA,SSA1); 8IF UIBFCTR = GOOD_RETURN_CODE& PCB1_STATUS_CODE = GOOD_STATUS_CODE THEN DO; 9

/* PERFORM SEGMENT UPDATE ACTIVITY */AREA1 = ......;AREA2 = ......;/* ISSUE DL/I: REPLACE SEGMENT AT CURRENT POSITION */

PLITDLI (PARM_CT_3,REPL_FUNCTION,PCB1,DLI_IO_AREA); 10IF UIBFCTR ^= GOOD_RETURN_CODE| PCB1_STATUS_CODE ^= GOOD_STATUS_CODE THEN DO;/* INSERT REPL ERROR DIAGNOSTIC CODE */END;END;ELSE DO;

/* INSERT GHU ERROR DIAGNOSTIC CODE */END;

END;ELSE DO;

/* ANALYZE UIB PROBLEM *//* ISSUE UIB DIAGNOSTIC MESSAGE */

END;/* RELEASE THE PSB */CALL PLITDLI(PARM_CT_1,TERM_FUNCTION); 11EXEC CICS RETURN; 12END PLIUIB;

Figure 12. Sample call-level PL/I program (CICS online)

36 Application Programming Guide

|

Page 61: IMS Application Programming.pdf

Notes to Figure 12:

1. Each of these areas defines the DL/I call functions the program uses. Eachcharacter string is defined as four alphanumeric characters and has a valueassigned for each function. You can define other constants in the same way.You can store standard definitions in a source library and include them byusing a %INCLUDE statement.

2. A structure definition defines each SSA the program uses. The unalignedattribute is required for SSA. The SSA character string must residecontiguously in storage. If a call requires two or more SSA, you may need todefine additional areas.

3. The %INCLUDE DLIUIB statement will be expanded as shown in Figure 15on page 66.

4. The UIB returns the address of an area containing the PCB addresses. Thedefinition of PCB pointers is necessary to obtain the actual PCB addresses. Donot alter the addresses in the area.

5. The I/O areas that are used to pass segments to and from the database aredefined as structures.

6. The PCBs are defined based on the addresses that are passed in the UIB.7. The PCB call schedules a PSB for your program to use.8. This unqualified GHU call retrieves a segment from the database. The segment

is placed in the I/O area that is referenced in the call. Before issuing the call,the program must initialize the key or data value of the SSA so that itspecifies the particular segment to be retrieved.

9. CICS online programs must test the return code in the UIB before testing thestatus code in the DB PCB.

10. The REPL call replaces the segment that was retrieved in the most recent GetHold call. The I/O area that is referenced in the call contains the segment tobe replaced.

11. The TERM call terminates the PSB that the program scheduled earlier.12. The program issues the EXEC CICS RETURN statement when it has finished

processing.

Related reading: For more information about installing application programs, seeCICS Transaction Server for z/OS V3.2 CICS Application Programming Reference.

Chapter 1. Writing your application programs for IMS DB 37

Page 62: IMS Application Programming.pdf

38 Application Programming Guide

Page 63: IMS Application Programming.pdf

Chapter 2. Defining application program elements for IMS DB

This chapter describes the elements of your application program that are used withIMS. Your application program must define these elements. This section describesformatting DL/I calls for language interfaces and provides language callsinformation for assembler language, C language, COBOL, Java, Pascal, and PL/I.

The following topics provide additional information:v “Formatting DL/I calls for language interfaces”v “Assembler language application programming” on page 40v “C language application programming” on page 42v “COBOL application programming” on page 45v “Java application programming for IMS” on page 48v “Pascal application programming” on page 48v “Application programming for PL/I” on page 51v “Specifying the I/O PCB mask” on page 53v “Specifying the DB PCB mask” on page 56v “Specifying the AIB mask” on page 59v “Specifying the AIB mask for ODBA applications” on page 61v “Specifying the UIB (CICS online programs only)” on page 63v “Specifying the I/O areas” on page 66v “Formatting segment search arguments (SSAs)” on page 66v “Data areas in GSAM databases” on page 72v “The AIBTDLI interface” on page 72v “Language specific entry points” on page 73v “Program communication block (PCB) lists” on page 76v “The AERTDLI interface” on page 77v “Language environments” on page 78v “Special DL/I situations” on page 79

Related reading: For detailed information on specific parameters for the DL/Icalls, see the topic "DL/I Calls for Transaction Management" in IMS Version 10:Application Programming API Reference and the topic "DL/I Calls for SystemServices" in IMS Version 10: Application Programming API Reference.

Formatting DL/I calls for language interfacesWhen you use DL/I calls in a programming language supported by IMS (HighLevel Assembler, C language, COBOL, Java, Pascal, and PL/I), you must call theDL/I language interface to initiate the functions specified with the DL/I calls. IMSoffers several interfaces for DL/I calls:v A language-independent interface for any programs that are Language

Environment® conforming (CEETDLI)v A nonspecific language interface for all supported languages (AIBTDLI)v Language-specific interfaces for all supported languages (xxxTDLI)

© Copyright IBM Corp. 1974, 2010 39

||||

Page 64: IMS Application Programming.pdf

Note: Java makes use of the all three DL/I language interfaces, but the use ismasked and no calls are necessary to initiate the functions specified with theDL/I calls.

Related reading: Not every DL/I call uses all the parameters shown. Fordescriptions of the call functions and the parameters they use, see the IMS Version10: Application Programming API Reference. For more information about mappingJava to IMS DL/I calls, see the base package of the Java API specification for IMS.

Because each programming language uses a different syntax, the format for callingthe language interfaces varies.

Assembler language application programmingThis section contains the format, parameters, and DL/I call sample formats for IMSapplication programs in assembler language. In such programs, all DL/I callparameters that are passed as addresses can be passed in a register which, if used,must be enclosed in parentheses.

Format

�� CALL �

�(2)

ASMTDLI,( function(1) ,db pcb A

parmcount, ,tp pcbAB

C(2)

AIBTDLI,( function, aib(1) A

parmcount, B

�(1)

),VL

��

A:

,i/o area,

,ssa,token,stat function,rsa,rootssa

B:

,i/o area length, i/o area,

,area length,area

40 Application Programming Guide

|||

||||

Page 65: IMS Application Programming.pdf

C:

,psb name, uibptr,sysserve

Notes:

1 Assembler language must use either parmcount or VL.

2 See the topic "DL/I Calls for Transaction Management" in IMS Version 10:Application Programming API Reference and the topic "DL/I Calls for SystemServices" in IMS Version 10: Application Programming API Reference fordescriptions of call functions and parameters.

Parametersparmcount

Specifies the address of a 4-byte field in user-defined storage that contains thenumber of parameters in the parameter list that follows parmcount. Assemblerlanguage application programs must use either parmcount or VL.

functionSpecifies the address of a 4-byte field in user-defined storage that contains thecall function. The call function must be left-justified and padded with blanks(such as GU��).

db pcbSpecifies the address of the database PCB to be used for the call. The PCBaddress must be one of the PCB addresses passed on entry to the applicationprogram in the PCB list.

tp pcbSpecifies the address of the I/O PCB or alternate PCB to be used for the call.The PCB address must be one of the PCB addresses passed on entry to theapplication program in the PCB list.

aib Specifies the address of the application interface block (AIB) in user-definedstorage. For more information on AIB, see “The AIBTDLI interface” on page72.

i/o areaSpecifies the address of the I/O area in user-defined storage that is used forthe call. The I/O area must be large enough to contain the returned data.

i/o area lengthSpecifies the address of a 4-byte field in user-defined storage that contains theI/O area length (specified in binary).

area lengthSpecifies the address of a 4-byte field in user-defined storage that contains thelength (specified in binary) of the area immediately following it in theparameter list. Up to seven area lengths or area pairs can be specified.

areaSpecifies the address of the area in user-defined storage to be checkpointed. Upto seven area lengths or area pairs can be specified.

tokenSpecifies the address of a 4-byte field in user-defined storage that contains auser token.

Chapter 2. Defining application program elements for IMS DB 41

Page 66: IMS Application Programming.pdf

stat functionSpecifies the address of a 9-byte field in user-defined storage that contains thestat function to be performed.

ssa Specifies the address in user-defined storage that contains the SSAs to be usedfor the call. Up to 15 SSAs can be specified, one of which is rootssa.

rootssaSpecifies the address of a root segment search argument in user-definedstorage.

rsa Specifies the address of the area in user-defined storage that contains therecord search argument.

psb nameSpecifies the address in user-defined storage of an 8-byte PSB name to be usedfor the call.

uibptrSpecifies the address in user-defined storage of the user interface block (UIB).

sysserveSpecifies the address of an 8-byte field in user-defined storage to be used forthe call.

VLSignifies the end of the parameter list. Assembler language programs must useeither parmcount or VL.

Example of a DL/I call formatUsing the DL/I AIBTDLI interface:CALL AIBTDLI,(function,aib,i/o area,ssa1),VL

Using the DL/I language-specific interface:CALL ASMTDLI,(function,db pcb,i/o area,ssa1),VL

C language application programmingThis section contains the format, parameters, and DL/I sample call formats for IMSapplication programs in C language.

Format

42 Application Programming Guide

Page 67: IMS Application Programming.pdf

��(1)

rc=CTDLI( functionparmcount, ,db pcb A

,tp pcbAB

C(2) (1)

rc=AIBTDLI( parmcount , function, aibAB

(1)CEETDLI( function

parmcount, ,db pcb A,i/o pcb

AB

,aibAB

); ��

A:

,i/o area,

,ssa,token,stat function,rsa,rootssa

B:

,i/o area length, i/o area,

,area length,area

C:

,psb name, uibptr,sysserve

Notes:

1 See the topic "DL/I Calls for Transaction Management" in IMS Version 10:Application Programming API Reference and the topic "DL/I Calls for SystemServices" in IMS Version 10: Application Programming API Reference fordescriptions of call functions and parameters.

2 For AIBTDLI, parmcount is required for C applications.

Parametersrc This parameter receives the DL/I status or return code. It is a two-character

field shifted into the 2 low-order bytes of an integer variable (int). If the status

Chapter 2. Defining application program elements for IMS DB 43

Page 68: IMS Application Programming.pdf

code is two blanks, 0 is placed in the field. You can test the rc parameter withan if statement. For example, if (rc == 'IX'). You can also use rc in a switchstatement. You can choose to ignore the value placed in rc and use the statuscode returned in the PCB instead.

parmcountSpecifies the name of a fixed binary (31) variable in user-defined storage thatcontains the number of parameters in the parameter list that followsparmcount.

functionSpecifies the name of a character (4) variable, left justified in user-definedstorage, that contains the call function to be used. The call function must beleft-justified and padded with blanks (such as GU��).

db pcbSpecifies the name of a pointer variable that contains the address of thedatabase to be used for the call. The PCB address must be one of the PCBaddresses passed on entry to the application program in the PCB list.

tp pcbSpecifies the name of a pointer variable that contains the address of the I/OPCB or alternate PCB to be used for the call. The PCB address must be one ofthe PCB addressed passed on entry to the application program in the PCB list.

aib Specifies the name of the pointer variable that contains the address of thestructure that defines the application interface block (AIB) in user-definedstorage. For more information on the AIB, see “The AIBTDLI interface” onpage 72.

i/o areaSpecifies the name of a pointer variable to a major structure, array, or characterstring that defines the I/O area in user-defined storage used for the call. TheI/O area must be large enough to contain all of the returned data.

i/o area lengthSpecifies the name of a fixed binary (31) variable in user-defined storage thatcontains the I/O area length.

area lengthSpecifies the name of a fixed binary (31) variable in user-defined storage thatcontains the length of the area immediately following it in the parameter list.Up to seven area lengths or area pairs can be specified.

areaSpecifies the name of the pointer variable that contains the address of thestructure that defines the user-defined storage to be checkpointed. Up to sevenarea lengths or area pairs can be specified.

tokenSpecifies the name of a character (4) variable in user-defined storage thatcontains a user token.

stat functionSpecifies the name of a character (9) variable in user-defined storage thatcontains the stat function to be performed.

ssa Specifies the name of a character variable in user-defined storage that containsthe SSAs to be used for the call. Up to 15 SSAs can be specified, one of whichis rootssa.

44 Application Programming Guide

Page 69: IMS Application Programming.pdf

rootssaSpecifies the name of a character variable that defines the root segment searchargument in user-defined storage.

rsa Specifies the name of a character variable that contains the record searchargument for a GU call or where IMS should return the rsa for an ISRT or GNcall.

psb nameSpecifies the name of a character (8) variable containing the PSB name to beused for the call.

uibptrSpecifies the name of a pointer variable that contains the address of thestructure that defines the user interface block (UIB) that is used in user-definedstorage.

sysserveSpecifies the name of a character (8) variable string in user-defined storage tobe used for the call.

I/O areaIn C, the I/O area can be of any type, including structures or arrays. The ctdlideclarations in ims.h do not have any prototype information, so no type checkingof the parameters is done. The area may be auto, static, or allocated (with mallocor calloc). You need to give special consideration to C-strings because DL/I doesnot recognize the C convention of terminating strings with nulls ('\0') Instead ofthe usual strcpy and strcmp functions, you may want to use memcpy andmemcmp.

Example of a DL/I call formatUsing the DL/I CEETDLI interface:#include <leawi.h>...CEETDLI (function,db pcb,i/o area,ssa1);

Using the DL/I AIBTDLI interface:int rc;...rc=AIBTDLI (parmcount,function,aib,i/o area,ssa1);

Using the DL/I language-specific interface:#include <ims.h>int rc;...rc=CTDLI (function,db pcb,i/o area,ssa1);

COBOL application programmingThis section contains the format, parameters, and DL/I sample call formats for IMSapplication programs in Enterprise COBOL.

Format

�� CALL �

Chapter 2. Defining application program elements for IMS DB 45

||

Page 70: IMS Application Programming.pdf

�(1)

'CBLTDLI' USING functionparmcount db pcb A

tp pcbAB

C(1)

'AIBTDLI' USING function aibparmcount A

B(1)

'CEETDLI' USING functionparmcount db pcb A

tp pcbAB

aibAB

. ��

A:

i/o area,

ssatokenstat functionrsarootssa

B:

i/o area length i/o area,

area lengtharea

C:

psb name uibptrsysserve

Notes:

1 See the topic "DL/I Calls for Transaction Management" in IMS Version 10:Application Programming API Reference and the topic "DL/I Calls for SystemServices" in IMS Version 10: Application Programming API Reference fordescriptions of call functions and parameters.

Note: All apostrophes (') can be replaced by quotes (") and can be done regardlessof the APOST/QUOTE compiler (or CICS translator) option.

Parametersparmcount

Specifies the identifier of a usage binary (4) byte data item in user-definedstorage that contains the number of parameters in the parameter list that

46 Application Programming Guide

|||

||

||

Page 71: IMS Application Programming.pdf

follows parmcount. If you define this field as COMP-5 rather than COMP,COMP-4, or BINARY, then it can contain the maximum possible valuesregardless of the COBOL TRUNC compiler option setting.

functionSpecifies the identifier of a usage display (4) byte data item, left justified inuser-defined storage that contains the call function to be used. The callfunction must be left-justified and padded with blanks (such as GU��).

db pcbSpecifies the identifier of the database PCB group item from the PCB list that ispassed to the application program on entry. This identifier will be used for thecall.

tp pcbSpecifies the identifier of the I/O PCB or alternate PCB group item from thePCB list that is passed to the application program on entry. This identifier willbe used for the call.

aib Specifies the identifier of the group item that defines the application interfaceblock (AIB) in user-defined storage. For more information on the AIB, see “TheAIBTDLI interface” on page 72.

i/o areaSpecifies the identifier of a major group item, table, or usage display data itemthat defines the I/O area length in user-defined storage used for the call. TheI/O area must be large enough to contain all of the returned data.

i/o area lengthSpecifies the identifier of a usage binary (4) byte data item in user-definedstorage that contains the I/O area length (specified in binary). If you definethis field as COMP-5 rather than COMP, COMP-4, or BINARY, then it cancontain the maximum possible values regardless of the COBOL TRUNCcompiler option setting.

area lengthSpecifies the identifier of a usage binary (4) byte data item in user-definedstorage that contains the length (specified in binary) of the area immediatelyfollowing it in the parameter list. Up to seven area lengths or area pairs can bespecified. If you define this field as COMP-5 rather than COMP, COMP-4, orBINARY, then it can contain the maximum possible values regardless of theCOBOL TRUNC compiler option setting.

areaSpecifies the identifier of the group item that defines the user-defined storageto be checkpointed. Up to seven area lengths or area pairs can be specified.

tokenSpecifies the identifier of a usage display (4) byte data item in user-definedstorage that contains a user token.

stat functionSpecifies the identifier of a usage display (9) byte data item in user-definedstorage that contains the stat function to be performed.

ssa Specifies the identifier of a usage display data item in user-defined storage thatcontains the SSAs to be used for the call. Up to 15 SSAs can be specified, oneof which is rootssa.

rootssaSpecifies the identifier of a usage display data item that defines the rootsegment search argument in user-defined storage.

Chapter 2. Defining application program elements for IMS DB 47

|||

|||||

||||||

Page 72: IMS Application Programming.pdf

rsa Specifies the identifier of a usage display data item that contains the recordsearch argument.

psb nameSpecifies the identifier of a usage display (8) byte data item containing the PSBname to be used for the call.

uibptrSpecifies the identifier of the group item that defines the user interface block(UIB) that is used in user-defined storage.

sysserveSpecifies the identifier of a usage display (8) byte data item in user-definedstorage to be used for the call.

Example of a DL/I call formatUsing the DL/I CEETDLI interface:CALL 'CEETDLI' USING function,db pcb,i/o area,ssa1.

Using the DL/I AIBTDLI interface:CALL 'AIBTDLI' USING function,aib,i/o area,ssa1.

Using the DL/I language-specific interface:CALL 'CBLTDLI' USING function,db pcb,i/o area,ssa1.

Java application programming for IMSFor information regarding Java application programming for IMS, see Chapter 25,“Introduction to the Java class libraries for IMS,” on page 361.

Pascal application programmingThissection contains the format, parameters, and DL/I sample call formats for IMSapplication programs in Pascal.

Format

�� PASTDLI ( A,VAR db pcb B,VAR tp pcb

BC

DAIBTDLI ( A , VAR aib,

BC

); ��

A:

(1)CONST function

CONST parmcount ,

48 Application Programming Guide

|

||

Page 73: IMS Application Programming.pdf

B:

,VAR i/o area,

,VAR ssa,CONST token,CONST stat function,VAR rsa,VAR rootssa

C:

,VAR i/o area length, VAR i/o area,

,VAR area length,VAR area

D:

,VAR psb name, VAR uibptr,VAR sysserve

Notes:

1 See the topic "DL/I Calls for Transaction Management" in IMS Version 10:Application Programming API Reference and the topic "DL/I Calls for SystemServices" in IMS Version 10: Application Programming API Reference fordescriptions of call functions and parameters.

Parametersparmcount

Specifies the name of a fixed binary (31) variable in user-defined storage thatcontains the number of parameters in the parameter list that followsparmcount.

functionSpecifies the name of a character (4) variable, left justified in user-definedstorage, that contains the call function to be used. The call function must beleft-justified and padded with blanks (such as GU��).

db pcbSpecifies the name of a pointer variable that contains the address of thedatabase PCB defined in the call procedure statement.

tp pcbSpecifies the name of a pointer variable that contains the address of the I/OPCB or alternate PCB defined in the call procedure statement.

aib Specifies the name of the pointer variable that contains the address of thestructure that defines the application interface block (AIB) in user-definedstorage. For more information on the AIB, see “The AIBTDLI interface” onpage 72.

i/o areaSpecifies the name of a pointer variable to a major structure, array, or character

Chapter 2. Defining application program elements for IMS DB 49

Page 74: IMS Application Programming.pdf

string that defines the I/O area in user-defined storage used for the call. TheI/O area must be large enough to contain all of the returned data.

i/o area lengthSpecifies the name of a fixed binary (31) variable in user-defined storage thatcontains the I/O area length.

area lengthSpecifies the name of a fixed binary (31) variable in user-defined storage thatcontains the length of the area immediately following it in the parameter list.Up to seven area lengths or area pairs can be specified.

areaSpecifies the name of the pointer variable that contains the address of thestructure that defines the user-defined storage to be checkpointed. Up to sevenarea lengths or area pairs can be specified.

tokenSpecifies the name of a character (4) variable in user-defined storage thatcontains a user token.

stat functionSpecifies the name of a character (9) variable in user-defined storage thatcontains the stat function to be performed.

ssa Specifies the name of a character variable in user-defined storage that containsthe SSAs to be used for the call. Up to 15 SSAs can be specified, one of whichis rootssa.

rootssaSpecifies the name of a character variable that defines the root segment searchargument in user-defined storage.

rsa Specifies the name of a character variable that contains the record searchargument.

psb nameSpecifies the name of a character (8) variable containing the PSB name to beused for the call.

uibptrSpecifies the name of a pointer variable that contains the address of thestructure that defines the user interface block (UIB) that is used in user-definedstorage.

sysserveSpecifies the name of a character (8) variable string in user-defined storage tobe used for the call.

Example of a DL/I call formatUsing the DL/I AIBTDLI interface:AIBTDLI(CONST function,

VAR aib,VAR i/o area,VAR ssa1);

Using the DL/I language-specific interface:PASTDLI(CONST function,

VAR db pcb,VAR i/o area,VAR ssa1);

50 Application Programming Guide

Page 75: IMS Application Programming.pdf

Application programming for PL/IThis section contains the format, parameters, and DL/I sample call formats for IMSapplication programs in PL/I.

Exception: For the PLITDLI interface, all parameters except parmcount are indirectpointers; for the AIBTDLI interface, all parameters are direct pointers.

Format

�� CALL PLITDLI ( parmcount, function,db pcb A,tp pcb

AB

CAIBTDLI ( parmcount, function, aib

AB

(1)CEETDLI ( parmcount, function

,db pcb A,tp pcb

AB

,aibAB

� ); ��

A:

,i/o area,

,ssa,token,stat function,rsa,rootssa

B:

,i/o area length, i/o area,

,area length,area

C:

,psb name, uibptr,sysserve

Chapter 2. Defining application program elements for IMS DB 51

Page 76: IMS Application Programming.pdf

Notes:

1 See the topic "DL/I Calls for Transaction Management" in IMS Version 10:Application Programming API Reference and the topic "DL/I Calls for SystemServices" in IMS Version 10: Application Programming API Reference fordescriptions of call functions and parameters.

Parametersparmcount

Specifies the name of a fixed binary (31-byte) variable that contains the numberof arguments that follow parmcount.

functionSpecifies the name of a fixed-character (4-byte) variable left-justified, blankpadded character string containing the call function to be used (such as GU��).

db pcbSpecifies the structure associated with the database PCB to be used for the call.This structure is based on a PCB address that must be one of the PCBaddresses passed on entry to the application program.

tp pcbSpecifies the structure associated with the I/O PCB or alternate PCB to be usedfor the call.

aib Specifies the name of the structure that defines the AIB in your applicationprogram. For more information on the AIB, see “The AIBTDLI interface” onpage 72.

i/o areaSpecifies the name of the I/O area used for the call. The I/O area must belarge enough to contain all the returned data.

i/o area lengthSpecifies the name of a fixed binary (31) variable that contains the I/O arealength.

area lengthSpecifies the name of a fixed binary (31) variable that contains the length of thearea immediately following it in the parameter list. Up to seven area lengths orarea pairs can be specified.

areaSpecifies the name of the area to be checkpointed. Up to seven area lengths orarea pairs can be specified.

tokenSpecifies the name of a character (4) variable that contains a user token.

stat functionSpecifies the name of a character (9) variable string containing the stat functionto be performed.

ssa Specifies the name of a character variable that contains the SSAs to be used forthe call. Up to 15 SSAs can be specified, one of which is rootssa.

rootssaSpecifies the name of a character variable that contains a root segment searchargument.

rsa Specifies the name of a character variable that contains the record searchargument.

52 Application Programming Guide

Page 77: IMS Application Programming.pdf

psb nameSpecifies the name of a character (8) containing the PSB name to be used forthe call.

uibptrSpecifies the name of the user interface block (UIB).

sysserveSpecifies the name of a character (8) variable character string to be used for thecall.

Example of a DL/I call formatUsing the DL/I CEETDLI interface:CALL CEETDLI (parmcount,function,db pcb,i/o area,ssa1);

Using the DL/I AIBTDLI interface:CALL AIBTDLI (parmcount,function,aib,i/o area,ssa1);

Using the DL/I language-specific interface:%INCLUDE CEEIBMAW;CALL PLITDLI (parmcount,function,db pcb,i/o area,ssa1);

Specifying the I/O PCB maskAfter your program issues a call with the I/O Program Communications Block(I/O PCB), IMS returns information about the results of the call to the I/O PCB. Todetermine the results of the call, your program must check the information thatIMS returns.

Issuing a system service call requires an I/O PCB. Because the I/O PCB residesoutside your program, you must define a mask of the PCB in your program tocheck the results of IMS calls. The mask must contain the same fields, in the sameorder, as the I/O PCB. Your program can then refer to the fields in the PCBthrough the PCB mask.

Table 6 shows the fields that the I/O PCB contains, their lengths, and theapplicable environment for each field.

Table 6. I/O PCB mask

Descriptor ByteLength

DB/DC DBCTL DCCTL DBBatch

TMBatch

Logical terminal name 1 8 X X

Reserved for IMS 2 2 X X

Status code 3 2 X X X X X

4-Byte Local date andtime 4

Date 4 X X

Time 4 X X

Input message sequencenumber 5

4 X X

Message output descriptorname 6

8 X X

Userid 7 8 X X

Chapter 2. Defining application program elements for IMS DB 53

|

|

Page 78: IMS Application Programming.pdf

Table 6. I/O PCB mask (continued)

Descriptor ByteLength

DB/DC DBCTL DCCTL DBBatch

TMBatch

Group name 8 8 X X

12-Byte Time Stamp 9

Date 4 X X

Time 6 X X

UTC Offset 2 X X

Userid Indicator10 1 X X

Reserved for IMS2 3

Notes:

1. Logical Terminal Name

This field contains the name of the terminal that sent the message. When yourprogram retrieves an input message, IMS places the name of the logicalterminal that sent the message in this field. When you want to send a messageback to this terminal, you refer to the I/O PCB when you issue the ISRT call,and IMS takes the name of the logical terminal from the I/O PCB as thedestination.

2. Reserved for IMS

These fields are reserved.3. Status Code

IMS places the status code describing the result of the DL/I call in this field.IMS updates the status code after each DL/I call that the program issues. Yourprogram should always test the status code after issuing a DL/I call.The three status code categories are:v Successful status codes or status codes with exceptional but valid

conditions. This category does not contain errors. If the call was completelysuccessful, this field contains blanks. Many of the codes in this category arefor information only. For example, a QC status code means that no moremessages exist in the message queue for the program. When your programreceives this status code, it should terminate.

v Programming errors. The errors in this category are usually ones that youcan correct. For example, an AD status code indicates an invalid functioncode.

v I/O or system errors.For the second and third categories, your program should have an errorroutine that prints information about the last call that was issued beforeprogram termination. Most installations have a standard error routine that allapplication programs at the installation use.

4. Local Date and Time

The current local date and time are in the prefix of all input messages exceptthose originating from non-message-driven BMPs. The local date is apacked-decimal, right-aligned date, in the format yyddd. The local time is apacked-decimal time in the format hhmmsst. The current local date and timeindicate when IMS received the entire message and enqueued it as input forthe program, rather than the time that the application program received themessage. To obtain the application processing time, you must use the timefacility of the programming language you are using.

54 Application Programming Guide

Page 79: IMS Application Programming.pdf

For a conversation, for an input message originating from a program, or for amessage received using Multiple System Coupling (MSC), the time and dateindicate when the original message was received from the terminal.

5. Input Message Sequence Number

The input message sequence number is in the prefix of all input messagesexcept those originating from non-message-driven BMPs. This field containsthe sequence number IMS assigned to the input message. The number isbinary. IMS assigns sequence numbers by physical terminal, which arecontinuous since the time of the most recent IMS startup.

6. Message Output Descriptor Name

You only use this field when you use MFS. When you issue a GU call with amessage output descriptor (MOD), IMS places its name in this area. If yourprogram encounters an error, it can change the format of the screen and sendan error message to the terminal by using this field. To do this, the programmust change the MOD name by including the MOD name parameter on anISRT or PURG call.Although MFS does not support APPC, LU 6.2 programs can use an interfaceto emulate MFS. For example, the application program can use the MODname to communicate with IMS to specify how an error message is to beformatted.Related reading: For more information on the MOD name and the LTERMinterface, see IMS Version 10: Communications and Connections Guide.

7. Userid

The use of this field is connected with RACF® signon security. If signon is notactive in the system, this field contains blanks.If signon is active in the system, the field contains one of the following:v The user's identification from the source terminal.v The LTERM name of the source terminal if signon is not active for that

terminal.v The authorization ID. For batch-oriented BMPs, the authorization ID is

dependent on the value specified for the BMPUSID= keyword in theDFSDCxxx PROCLIB member:– If BMPUSID=USERID is specified, the value from the USER= keyword

on the JOB statement is used.– If USER= is not specified on the JOB statement, the program's PSB name

is used.– If BMPUSID=PSBNAME is specified, or if BMPUSID= is not specified at

all, the program's PSB name is used.8. Group Name

The group name, which is used by DB2 to provide security for SQL calls, iscreated through IMS transactions.Three instances that apply to the group name are:v If you use RACF and SIGNON on your IMS system, the RACROUTE SAF

(extract) call returns an eight-character group name.v If you use your own security package on your IMS system, the RACROUTE

SAF call returns any eight-character name from the package and treats it asa group name. If the RACROUTE SAF call returns a return code of 4 or 8, agroup name was not returned, and IMS blanks out the group name field.

v If you use LU 6.2, the transaction header can contain a group name.

Chapter 2. Defining application program elements for IMS DB 55

Page 80: IMS Application Programming.pdf

Related reading: For more information about LU 6.2, see IMS Version 10:Communications and Connections Guide.

9. 12-Byte Time Stamp

This field contains the current date and time fields, but in the IMS internalpacked-decimal format. The time stamp has the following parts:

Date yyyydddf

This packed-decimal date contains the year (yyyy), day of theyear (ddd), and a valid packed-decimal + sign such as (f).

Time hhmmssthmiju

This packed-decimal time consists of hours, minutes, andseconds (hhmmss) and fractions of the second to themicrosecond (thmiju). No packed-decimal sign is affixed tothis part of the time stamp.

UTC Offset aqq$

The packed-decimal UTC offset is prefixed by 4 bits ofattributes (a). If the 4th bit of (a) is 0, the time stamp is UTC;otherwise, the time stamp is local time. The control regionparameter, TSR=(U/L), specified in the DFSPBxxx PROCLIBmember, controls the representation of the time stamp withrespect to local time versus UTC time.

The offset value (qq$) is the number of quarter hours of offsetto be added to UTC or local time to convert to local or UTCtime respectively.

The offset sign ($) follows the convention for apacked-decimal plus or minus sign.

Field 4 on page 54 always contains the local date and time.Related reading: For a more detailed description of the internalpacked-decimal time-format, see IMS Version 10: Operations and AutomationGuide.

10. Userid Indicator

The Userid Indicator is provided in the I/O PCB and in the response to theINQY call. The Userid Indicator contains one of the following:v U - The user's identification from the source terminal during signonv L - The LTERM name of the source terminal if signon is not activev P - The PSBNAME of the source BMP or transactionv O - Other nameThe value contained in the Userid Indicator field indicates the contents of theuserid field.

Specifying the DB PCB maskIMS describes the results of the calls your program issues in the DB PCB that isreferenced in the call. To determine the success or failure of the DL/I call, theapplication program includes a mask of the DB PCB and then references the fieldsof the DB PCB through the mask.

A DB PCB mask must contain the fields shown in Table 7. (Your program can lookat, but not change, the fields in the DB PCB.) The fields in your DB PCB maskmust be defined in the same order and with the same length as the fields shown

56 Application Programming Guide

Page 81: IMS Application Programming.pdf

here. When you code the DB PCB mask, you also give it a name, but the name isnot part of the mask. You use the name (or the pointer, for PL/I) when youreference each of the PCBs your program processes. A GSAM DB PCB mask isslightly different from other DB PCB masks.

Related Reading: For more information about GSAM DB PCB Masks, see “Dataareas in GSAM databases” on page 72.

Of the nine fields, only five are important to you as you construct the program.These are the fields that give information about the results of the call. They are thesegment level number, status code, segment name, length of the key feedback area,and key feedback area. The status code is the field your program uses most oftento find out whether the call was successful. The key feedback area contains thedata from the segments you have specified; the level number and segment namehelp you determine the segment type you retrieved after an unqualified GN or GNPcall, or they help you determine your position in the database after an error orunsuccessful call.

Table 7. DB PCB mask

Descriptor ByteLength

DB/DC DBCTL DCCTL DBBatch

TMBatch

Database name 1 8 X X X

Segment level number 2 2 X X X

Status code 3 2 X X X

Processing options 4 4 X X X

Reserved for IMS 5 4 X X X

Segment name 6 8 X X X

Length of keyfeedback area 7

4 X X X

Number of sensitivesegments 8

4 X X X

Key feedback area 9 var length X X X

Notes:

1. Database Name

This contains the name of the database. This field is 8 bytes long and containscharacter data.

2. Segment Level Number

This field contains numeric character data. It is 2 bytes long and right-justified.When IMS retrieves the segment you have requested, IMS places the levelnumber of that segment in this field. If you are retrieving several segments in ahierarchic path with one call, IMS places the number of the lowest-levelsegment retrieved. If IMS is unable to find the segment that you request, itgives you the level number of the last segment it encounters that satisfied yourcall.

3. Status Code

After each DL/I call, this field contains the two-character status code thatdescribes the results of the DL/I call. IMS updates this field after each call anddoes not clear it between calls. The application program should test this fieldafter each call to find out whether the call was successful.

Chapter 2. Defining application program elements for IMS DB 57

Page 82: IMS Application Programming.pdf

When the program is initially scheduled, this field contains a data-availabilitystatus code, which indicates any possible access constraint based on segmentsensitivity and processing options.Related Reading: For more information on these status codes, see the topic"INIT Call" in IMS Version 10: Application Programming API Reference.During normal processing, four categories of status codes exist:v Successful or exceptional but valid conditions. If the call was completely

successful, this field contains blanks. Many of the codes in this category arefor information only. For example, GB means that IMS has reached the endof the database without satisfying the call. This situation is expected insequential processing and is not usually the result of an error.

v Errors in the program. For example, AK means that you have included aninvalid field name in a segment search argument (SSA). Your programshould have error routines available for these status codes. If IMS returns anerror status code to your program, your program should terminate. You canthen find the problem, correct it, and restart your program.

v I/O or system error. For example, an AO status code means that there hasbeen an I/O error concerning OSAM, BSAM, or VSAM. If your programencounters a status code in this category, it should terminate immediately.This type of error cannot normally be fixed without a system programmer,database administrator, or system administrator.

v Data-availability status codes. These are returned only if your program hasissued the INIT call indicating that it is prepared to handle such status codes.“Status Code Explanations” in IMS: Messages and Codes Reference, Volume 4:IMS Component Codes describes possible causes and corrections in moredetail.

4. Processing Options

This is a 4-byte field containing a code that tells IMS what type of calls thisprogram can issue. It is a security mechanism in that it can prevent a particularprogram from updating the database, even though the program can read thedatabase. This value is coded in the PROCOPT parameter of the PCB statementwhen the PSB for the application program is generated. The value does notchange.

5. Reserved for IMS

This 4-byte field is used by IMS for internal linkage. It is not used by theapplication program.

6. Segment Name

After each successful call, IMS places in this field the name of the last segmentthat satisfied the call. When a retrieval is successful, this field contains thename of the retrieved segment. When a retrieval is unsuccessful, this fieldcontains the last segment along the path to the requested segment that wouldsatisfy the call. The segment name field is 8 bytes long.When a program is initially scheduled, the name of the database type is put inthe SEGNAME field. For example, the field contains DEDB when the databasetype is DEDB; GSAM when the database type is GSAM; HDAM, or PHDAMwhen the database type is HDAM or PHDAM.

7. Length of Key Feedback Area

This is a 4-byte binary field that gives the current length of the key feedbackarea. Because the key feedback area is not usually cleared between calls, theprogram needs to use this length to determine the length of the relevantcurrent concatenated key in the key feedback area.

8. Number of Sensitive Segments

58 Application Programming Guide

Page 83: IMS Application Programming.pdf

This is a 4-byte binary field that contains the number of segment types in thedatabase to which the application program is sensitive.

9. Key Feedback Area

At the completion of a retrieval or ISRT call, IMS places the concatenated key ofthe retrieved segment in this field. The length of the key for this request isgiven in the 4-byte 7 on page 58 field. If IMS is unable to satisfy the call, thekey feedback area contains the key of the segment at the last level that wassatisfied. A segment's concatenated key is made up of the keys of each of itsparents and its own key. Keys are positioned left to right, starting with the keyof the root segment and following the hierarchic path. IMS does not normallyclear the key feedback area. IMS sets this length of the key feedback area toindicate the portion of the area that is valid at the completion of each call. Yourprogram should not use the content of the key feedback area that is notincluded in the key feedback area length.

Specifying the AIB maskThe application interface block (AIB) is used by your program to communicatewith IMS, when your application does not have a PCB address or the call functiondoes not use a PCB. The AIB mask enables your program to interpret the controlblock defined. The AIB structure must be defined in working storage, on afullword boundary, and initialized according to the order and byte length of thefields as shown in Table 8. The table’s notes describe the contents of each field.

Table 8. AIB fields

Descriptor Byte Length DB/DC DBCTL DCCTL DBBatch

TMBatch

AIB identifier 1 8 X X X X X

DFSAIB allocatedlength 2

4 X X X X X

Subfunction code 3 8 X X X X X

Resource name 4 8 X X X X X

Reserved 5 16

Maximum output arealength 6

4 X X X X X

Output area lengthused 7

4 X X X X X

Reserved 8 12

Return code 9 4 X X X X X

Reason code 10 4 X X X X X

Error code extension 11 4 X X

Resource address 12 4 X X X X X

Reserved 13 48

Notes:

1. AIB Identifier (AIBID)

This 8-byte field contains the AIB identifier. You must initialize AIBID in yourapplication program to the value DFSAIB �� before you issue DL/I calls. Thisfield is required. When the call is completed, the information returned in thisfield is unchanged.

Chapter 2. Defining application program elements for IMS DB 59

Page 84: IMS Application Programming.pdf

2. DFSAIB Allocated Length (AIBLEN)

This field contains the actual 4-byte length of the AIB as defined by yourprogram. You must initialize AIBLEN in your application program before youissue DL/I calls. The minimum length required is 128 bytes. When the call iscompleted, the information returned in this field is unchanged. This field isrequired.

3. Subfunction Code (AIBSFUNC)

This 8-byte field contains the subfunction code for those calls that use asubfunction. You must initialize AIBSFUNC in your application programbefore you issue DL/I calls. When the call is completed, the informationreturned in this field is unchanged.

4. Resource Name (AIBRSNM1)

This 8-byte field contains the name of a resource. The resource variesdepending on the call. You must initialize AIBRSNM1 in your applicationprogram before you issue DL/I calls. When the call is complete, theinformation returned in this field is unchanged. This field is required.For PCB related calls where the AIB is used to pass the PCB name instead ofpassing the PCB address in the call list, this field contains the PCB name. ThePCB name for the I/O PCB is IOPCB��. The PCB name for other types ofPCBs is defined in the PCBNAME= parameter in PSBGEN.

5. Reserved

This 16-byte field is reserved.6. Maximum Output Area Length (AIBOALEN)

This 4-byte field contains the length of the output area in bytes that wasspecified in the call list. You must initialize AIBOALEN in your applicationprogram for all calls that return data to the output area. When the call iscompleted, the information returned in this area is unchanged.

7. Used Output Area Length (AIBOAUSE)

This 4-byte field contains the length of the data returned by IMS for all callsthat return data to the output area. When the call is completed this fieldcontains the length of the I/O area used for this call.

8. Reserved

This 12-byte field is reserved.9. Return code (AIBRETRN)

When the call is completed, this 4-byte field contains the return code.10. Reason Code (AIBREASN)

When the call is completed, this 4-byte field contains the reason code.11. Error Code Extension (AIBERRXT)

This 4-byte field contains additional error information depending on thereturn code in AIBRETRN and the reason code in AIBREASN.

12. Resource Address (AIBRSA1)

When the call is completed, this 4-byte field contains call-specific information.For PCB related calls where the AIB is used to pass the PCB name instead ofpassing the PCB address in the call list, this field returns the PCB address.

13. Reserved

This 48-byte field is reserved.

The application program can use the returned PCB address, when available, toinspect the status code in the PCB and to obtain any other information needed bythe application program.

60 Application Programming Guide

Page 85: IMS Application Programming.pdf

Related reading: For more information about the return and reason codes, see IMS:Messages and Codes Reference, Volume 4: IMS Component Codes.

Specifying the AIB mask for ODBA applicationsTable 9 describes the fields for specifying the application interface block (AIB)mask for ODBA applications. The notes that follow describe the contents of eachfield.

Table 9. AIB fields for use of ODBA applications

AIB Fields ByteLength

DB/DC IMS DB DCCTL DBBatch

TMBatch

AIB identifier¹ 8 X X X X X

DFSAIB allocated length² 4 X X X X X

Subfunction code³ 8 X X X X X

Resource name #1⁴ 8 X X X X X

Resource name #2⁵ 8

Reserved⁶ 8 X

Maximum output arealength⁷

4 X X X X X

Output area length used⁸ 4 X X X X X

Reserved⁹ 12

Return code¹⁰ 4 X X X X X

Reason code¹¹ 4 X X X X X

Error code extension¹² 4 X

Resource address #1 ¹³ 4 X X X X X

Resource address #2¹⁴ 4

Resource address #3¹⁵ 4

Reserved¹⁶ 40

Reserved for ODBA¹⁷ 136

Notes for AIB Fields for Use of ODBA Applications:

1. AIB Identifier (AIBID)

This 8-byte field contains the AIB identifier. You must initialize AIBID in yourapplication program to the value DFSAIB�� before you issue DL/I calls. Thisfield is required. When the call is completed, the information returned in thisfield is unchanged.

2. DFSAIB Allocated Length (AIBLEN)

This field contains the actual 4-byte length of the AIB as defined by yourprogram. You must initialize AIBLEN in your application program before youissue DL/I calls. The minimum length required is 264 bytes for ODBA. Whenthe call is completed, the information returned in this field is unchanged. Thisfield is required.

3. Subfunction Code (AIBSFUNC)

This 8-byte field contains the subfunction code for those calls that use asubfunction. You must initialize AIBSFUNC in your application programbefore you issue DL/I calls. When the call is completed, the informationreturned in this field is unchanged.

Chapter 2. Defining application program elements for IMS DB 61

|||

Page 86: IMS Application Programming.pdf

4. Resource Name (AIBRSNM1) #1

This 8-byte field contains the name of a resource. The resource variesdepending on the call. You must initialize AIBRSNM1 in your applicationprogram before you issue DL/I calls. When the call is complete, theinformation returned in this field is unchanged. This field is required.For PCB related calls where the AIB is used to pass the PCB name instead ofpassing the PCB address in the call list, this field contains the PCB name. ThePCB name for the I/O PCB is IOPCB��. The PCB name for other types ofPCBs is defined in the PCBNAME= parameter in PSBGEN.

5. Resource Name (AIBRSNM2) #2

Specify a 4-character ID of ODBA startup table DFSxxxx0, where xxxx is afour-character ID.

6. Reserved

This 8-byte field is reserved.7. Maximum Output Area Length (AIBOALEN)

This 4-byte field contains the length of the output area in bytes that wasspecified in the call list. You must initialize AIBOALEN in your applicationprogram for all calls that return data to the output area. When the call iscompleted, the information returned in this area is unchanged.

8. Used Output Area Length (AIBOAUSE) This 4-byte field contains the lengthof the data returned by IMS for all calls that return data to the output area.When the call is completed this field contains the length of the I/O area usedfor this call.

9. Reserved

This 12-byte field is reserved.10. Return code (AIBRETRN)

When the call is completed, this 4-byte field contains the return code.11. Reason Code (AIBREASN)

When the call is completed, this 4-byte field contains the reason code.12. Error Code Extension (AIBERRXT)

This 4-byte field contains additional error information depending on thereturn code in AIBRETRN and the reason code in AIBREASN.

13. Resource Address (AIBRSA1) #1

When the call is completed, this 4-byte field contains call-specific information.For PCB related calls where the AIB is used to pass the PCB name instead ofpassing the PCB address in the call list, this field returns the PCB address.

14. Resource Address (AIBRSA2) #2

This 4-byte field is reserved for ODBA.15. Resource Address (AIBRSA3) #3

This 4-byte token, returned on the APSB call, is required for subsequent DLIcalls and the DPSB call related to this thread.

16. Reserved

This 40-byte field is reserved.17. Reserved for ODBA

This 136-byte field is reserved for ODBA

The application program can use the returned PCB address, when available, toinspect the status code in the PCB and to obtain any other information needed bythe application program.

62 Application Programming Guide

Page 87: IMS Application Programming.pdf

COBOL AIB Mask Example01 AIB

02 AIBRID PIC x(8).02 AIBRLEN PIC 9(9) USAGE BINARY.02 AIBRSFUNC PIC x(8).02 AIBRSNM1 PIC x(8).02 AIBRSNM2 PIC x(8).02 AIBRESV1 PIC x(8).02 AIBOALEN PIC 9(9) USAGE BINARY.02 AIBOAUSE PIC 9(9) USAGE BINARY.02 AIBRESV2 PIC x(12).02 AIBRETRN PIC 9(9) USAGE BINARY.02 AIBREASN PIC 9(9) USAGE BINARY.02 AIBERRXT PIC 9(9) USAGE BINARY.02 AIBRESA1 USAGE POINTER.02 AIBRESA2 USAGE POINTER.02 AIBRESA3 USAGE POINTER.02 AIBRESV4 PIC x(40).02 AIBRSAVE OCCURS 18 TIMES USAGE POINTER.02 AIBRTOKN OCCURS 6 TIMES USAGE POINTER.02 AIBRTOKC PIC x(16).02 AIBRTOKV PIC x(16).02 AIBRTOKA OCCURS 2 TIMES PIC 9(9) USAGE BINARY.

Assembler AIB Mask ExampleDFSAIB DSECTAIBID DS CL8’DFSAIB’AIBLEN DS FAIBSFUNC DS CL8AIBRSNM1 DS CL8AIBRSVM2 DS CL8

DS 2FAIBOALEN DS FAIBOAUSE DS F

DS 2FDS HDS H

AIBRETRN DS FAIBREASN DS FAIBRRXT DS FAIBRSA1 DS AAIBRSA2 DS AAIBRSA3 DS A

DS 10FAIBLL EQU *-DFSAIBAIBSAVE DS 18FAIBTOKN DS 6FAIBTOKC DS CL16AIBTOKV DS XL16AIBTOKA DS 2FAIBAERL EQU *-DFSAIB

Specifying the UIB (CICS online programs only)The interface between your CICS online program and DL/I passes additionalinformation to your program in a user interface block (UIB). The UIB contains theaddress of the PCB list and any return codes your program must examine beforechecking the status code in the DB PCB.

When you issue the PCB call to obtain a PSB for your program, a UIB is created foryour program. As with any area outside your program, you must include adefinition of the UIB and establish addressability to it. CICS provides a definitionof the UIB for all programming languages:

Chapter 2. Defining application program elements for IMS DB 63

Page 88: IMS Application Programming.pdf

v In COBOL programs, use the COPY DLIUIB statement (Figure 13 for VS COBOLII). “Coding a CICS online program in COBOL” on page 25 shows how toestablish addressability to the UIB.

v In PL/I programs, use a %INCLUDE DLIUIB statement (Figure 15 on page 66).“Coding a CICS online program in PL/I” on page 36 shows how to establishaddressability to the UIB.

v In assembler language programs, use the DLIUIB macro (Figure 16 on page 66).“Coding a CICS online program in assembler language” on page 18 shows howto establish addressability to the UIB.

Three fields in the UIB are important to your program: UIBPCBAL, UIBFCTR, andUIBDLTR. UIBPCBAL contains the address of the PCB address list. Through it youcan obtain the address of the PCB you want to use. Your program must check thereturn code in UIBFCTR (and possibly UIBDLTR) before checking the status codein the DB PCB. If the contents of UIBFCTR and UIBDLTR are not null, the contentof the status code field in the DB PCB is not meaningful. The return codes aredescribed in the topic "CICS-DL/I User Interface Block Return Codes" in IMS:Messages and Codes Reference, Volume 4: IMS Component Codes.

Immediately after the statement that defines the UIB in your program, you mustdefine the PCB address list and the PCB mask.

Figure 13 provides an example of using the COPY DLIUIB statement in a VSCOBOL II program:

Figure 14 on page 65 provides an example of using the COBOL COPY DLIUIBstatement.

LINKAGE SECTION.

COPY DLIUIB.01 OVERLAY-DLIUIB REDEFINES DLIUIB.

02 PCBADDR USAGE IS POINTER.02 FILLER PIC XX.

01 PCB-ADDRESSES.02 PCB-ADDRESS-LIST

USAGE IS POINTER OCCURS 10 TIMES.01 PCB1.

02 PCB1-DBD-NAME PIC X(8).02 PCB1-SEG-LEVEL PIC XX.

.

.

.

Figure 13. Defining the UIB, PCB address list, and the PCB mask for VS COBOL II

64 Application Programming Guide

|||

Page 89: IMS Application Programming.pdf

The values placed in level 88 entries are not printable. They are described in thetopic "CICS-DL/I User Interface Block Return Codes" in IMS: Messages and CodesReference, Volume 4: IMS Component Codes. The meanings of the field names andtheir hexadecimal values are shown below:

FCNORESPNormal response Value X'00'

FCNOTOPENNot open Value X'0C'

FCINVREQInvalid request Value X'08'

FCINVPCBInvalid PCB Value X'10'

DLPSBNFPSB not found Value X'01'

DLTASKNATask not authorized Value X'02'

DLPSBSCHPSB already scheduled Value X'03'

DLLANGCONLanguage conflict Value X'04'

DLPSBFAILPSB initialization failed Value X'05'

DLPSBNAPSB not authorized Value X'06'

DLTERMNSTermination not successful Value X'07'

DLFUNCNSFunction unscheduled Value X'08'

01 DLIUIB.* Address of the PCB addr list

02 UIBPCBAL PIC S9(8) COMP.* DL/I return codes

02 UIBRCODE.* Return codes

03 UIBFCTR PIC X.88 FCNORESP VALUE ’ ’.88 FCNOTOPEN VALUE ’ ’.88 FCINVREQ VALUE ’ ’.88 FCINVPCB VALUE ’ ’.

* Additional information03 UIBDLTR PIC X.

88 DLPSBNF VALUE ’ ’.88 DLTASKNA VALUE ’ ’.88 DLPSBSCH VALUE ’ ’.88 DLLANGCON VALUE ’ ’.88 DLPSBFAIL VALUE ’ ’.88 DLPSBNA VALUE ’ ’.88 DLTERMNS VALUE ’ ’.88 DLFUNCNS VALUE ’ ’.88 DLINA VALUE ’ ’.

Figure 14. The COBOL COPY DLIUIB copy book

Chapter 2. Defining application program elements for IMS DB 65

|||||||||||||||||||||||||

||

||

||

||

||

||

||

||

||

||

||

||

Page 90: IMS Application Programming.pdf

DLINADL/I not active Value X'FF'

Figure 15 shows you how to define the UIB, PCB address list, and PCB mask forPL/I.

Figure 16 shows you how to define the UIB, PCB address list, and PCB mask forassembler language.

Specifying the I/O areasUse an I/O area to pass segments between your program and IMS. What the I/Oarea contains depends on the type of call you are issuing:v When you retrieve a segment, IMS DB places the segment you requested in the

I/O area.v When you add a new segment, you first build the new segment in the I/O area.v Before modifying a segment, your program must first retrieve it. When you

retrieve the segment, IMS DB places the segment in an I/O area.

The format of the record segments you pass between your program and IMS canbe fixed length or variable length. Only one difference is important to theapplication program: a message segment containing a 2-byte length field (or 4bytes for the PLITDLI interface) at the beginning of the data area of the segment.

The I/O area for IMS calls must be large enough to hold the largest segment yourprogram retrieves from or adds to the database. If your program issues any Get orISRT calls that use the D command code, the I/O area must be large enough tohold the largest path of segments that the program retrieves or inserts.

Formatting segment search arguments (SSAs)This section describes the coding rules and provides coding formats and examplesfor defining SSAs in assembler language, C language, COBOL, Java, Pascal, andPL/I.

DCL UIBPTR PTR; /* POINTER TO UIB */DCL 1 DLIUIB UNALIGNED BASED(UIBPTR),

/* EXTENDED CALL USER INTFC BLK*/2 UIBPCBAL PTR, /* PCB ADDRESS LIST */2 UIBRCODE, /* DL/I RETURN CODES */

3 UIBFCTR BIT(8) ALIGNED, /* RETURN CODES */3 UIBDLTR BIT(8) ALIGNED; /* ADDITIONAL INFORMATION */

Figure 15. Defining the UIB, PCB address list, and the PCB mask for PL/I

DLIUIB DSECTUIB DS 0F EXTENDED CALL USER INTFC BLKUIBPCBAL DS A PCB ADDRESS LISTUIBRCODE DS 0XL2 DL/I RETURN CODESUIBFCTR DS X RETURN CODEUIBDLTR DS X ADDITIONAL INFORMATION

DS 2X RESERVEDDS 0F LENGTH IS FULLWORD MULTIPLE

UIBLEN EQU *-UIB LENGTH OF UIB

Figure 16. Defining the UIB, PCB address list, and the PCB mask for assembler language

66 Application Programming Guide

||

Page 91: IMS Application Programming.pdf

SSA coding rules

The rules for coding an SSA are as follows:v Define the SSA in the data area of your program.v The segment name field must:

– Be 8 bytes long. If the name of the segment you are specifying is less than 8bytes long, it should be left justified and padded on the right with blanks.

– Contain a segment name that has been defined in the DBD that yourapplication program uses. In other words, make sure you use the exactsegment name, or your SSA will be invalid.

v If the SSA contains only the segment name, byte 9 must contain a blank.v If the SSA contains one or more command codes:

– Byte 9 must contain an asterisk (*).– The last command code must be followed by a blank unless the SSA contains

a qualification statement. If the SSA contains a qualification statement, thecommand code must be followed by the left parenthesis of the qualificationstatement.

v If the SSA contains a qualification statement:– The qualification statement must begin with a left parenthesis and end with a

right parenthesis.– There must not be any blanks between the segment name or command codes,

if used, and the left parenthesis.– The field name must be 8 bytes long. If the field name is less than 8 bytes, it

must be left justified and padded on the right with blanks. The field namemust have been defined for the specified segment type in the DBD theapplication program is using.

– The relational operator follows the field name. It must be 2 bytes long andcan be represented alphabetically or symbolically. Table 10 lists the relationaloperators.

Table 10. Relational operators

Symbolic Alphabetic Meaning

=�= EQ Equal to

>= or => GE Greater than or equal to

<= or =< LE Less than or equal to

>�> GT Greater than

<�< LT Less than

¬= or =¬ NE Not equal to

– The comparative value follows the relational operator. The length of thisvalue must be equal to the length of the field that you specified in the fieldname. This length is defined in the DBD. The comparative value must includeleading zeros for numeric values or trailing blanks for alphabetic values asnecessary.

v If you are using multiple qualification statements within one SSA (Booleanqualification statements), the qualification statements must be separated by oneof these symbols:

* or & Dependent AND

+ or | Logical OR

Chapter 2. Defining application program elements for IMS DB 67

Page 92: IMS Application Programming.pdf

# Independent ANDOne of these symbols must appear between the qualification statements that thesymbol connects.

v The last qualification statement must be followed by a right parenthesis.

An SSA created by the application program must not exceed the space allocated forthe SSA in the PSB.

Related reading: For additional information about defining the PSB SSA size, seethe explanation of the PSBGEN statement in IMS Version 10: Database UtilitiesReference.

SSA coding formatsThis section shows examples of coding formats for assembler language, Clanguage, COBOL, Pascal, and PL/I.

Assembler language SSA definition examplesFigure 17 shows how you would define a qualified SSA without command codes.If you want to use command codes with this SSA, code the asterisk (*) andcommand codes between the 8-byte segment name field and the left parenthesisthat begins the qualification statement.

This SSA looks like this:ROOT����(KEY������=vv...v)

C language SSA definition examplesAn unqualified SSA that does not use command codes looks like this in C:

const struct {char seg_name_u[8];char blank[1];

} unqual_ssa = {"NAME ", " "};

You can use an SSA that is coded like this for each DL/I call that needs anunqualified SSA by supplying the name of the segment type you want duringprogram execution. Note that the string size declarations are such that the C nullterminators do not appear within the structure.

You can, of course, declare this as a single string:const char unqual_ssa[] = "NAME "; /* 8 chars + 1 blank */

DL/I ignores the trailing null characters.

You can define SSAs in any of the ways explained for the I/O area.

* CONSTANT AREA...SSANAME DS 0CL26ROOT DC CL8'ROOT '

DC CL1'('DC CL8'KEY 'DC CL2' ='

NAME DC CLn'vv...v'DC CL1')'

Figure 17. Example code: * CONSTANT AREA

68 Application Programming Guide

Page 93: IMS Application Programming.pdf

The easiest way to create a qualified SSA is using the sprintf function. However,you can also define it using a method similar to that used by COBOL or PL/I.

The following is an example of a qualified SSA without command codes. To usecommand codes with this SSA, code the asterisk (*) and command codes betweenthe 8-byte segment name field and the left parenthesis that begins the qualificationstatement.struct {

seg_name char[8];seg_qual char[1];seg_key_name char[8];seg_opr char[2];seg_key_value char[n];seg_end_char char[1];

} qual_ssa = {"ROOT ", "(", "KEY ", " =", "vv...vv", ")"};

Another way is to define the SSA as a string, using sprintf. Remember to use thepreprocessor directive #include <stdio.h>.char qual_ssa[8+1+8+2+6+1+1]; /* the final 1 is for the */

/* trailing ’\0’ of string */sprintf(qual_ssa,

"%-8.8s(%-8.8s%2.2s%-6.6s)","ROOT", "KEY", "=", "vvvvv");

Alternatively, if only the value were changing, the sprintf call can be:sprintf(qual_ssa,

"ROOT (KEY =%-6.6s)", "vvvvv");/* 12345678 12345678 */

In both cases, the SSA looks like this:ROOT����(KEY������=vv...v)

These SSAs are both taken from the C skeleton program shown in Figure 6 on page20. To see how SSAs are used in DL/I calls, refer to that program.

COBOL SSA definition examplesAn unqualified SSA that does not use command codes looks like this in COBOL:DATA DIVISION.WORKING-STORAGE SECTION....01 UNQUAL-SSA.

02 SEG-NAME PICTURE X(08) VALUE '........'.02 FILLER PICTURE X VALUE ' '.

By supplying the name of the segment type you want during program execution,you can use an SSA coded like the one in this example for each DL/I call thatneeds an unqualified SSA.

Use a 01 level working storage entry to define each SSA that the program is to use.Then use the name you have given the SSA as the parameter in the DL/I call, inthis case:UNQUAL-SSA,

The following SSA is an example of a qualified SSA that does not use commandcodes. If you use command codes in this SSA, code the asterisk (*) and thecommand code between the 8-byte segment name field and the left parenthesisthat begins the qualification statement.

Chapter 2. Defining application program elements for IMS DB 69

||||||||

Page 94: IMS Application Programming.pdf

DATA DIVISION.WORKING-STORAGE SECTION....01 QUAL-SSA-MAST.

02 SEG-NAME-M PICTURE X(08) VALUE 'ROOT '.02 BEGIN-PAREN-M PICTURE X VALUE '('.02 KEY-NAME-M PICTURE X(08) VALUE 'KEY '.02 REL-OPER-M PICTURE X(02) VALUE ' ='.02 KEY-VALUE-M PICTURE X(n) VALUE 'vv...v'.02 END-PAREN-M PICTURE X VALUE ')'.

The SSA looks like this:ROOT����(KEY������=vv...v)

These SSAs are both taken from the COBOL skeleton program in Figure 7 on page23. To see how they are used in a DL/I call, refer to that program.

Java SSA definition examplesAn unqualified SSA that uses command codes looks like this in Java:// Construct an unqualified SSA for the Dealer segmentSSA dealerSSA = SSA.createInstance("Dealer");

You can use an SSA that is coded like the previous example for each DL/I call thatneeds an unqualified SSA by supplying the name of the segment type you wantduring program execution.

The following SSA is an example of a qualified SSA that does not use commandcodes. This SSA looks for all "Alpha" cars that were made in 1989. To usecommand codes with this SSA, use the method addCommandCode of the SSA class.// Construct a qualified SSA for the Model segmentSSA modelSSA = SSA.createInstance("Model", "CarMake", SSA.EQUALS, "Alpha");// Add an additional qualification statementmodelSSA.addQualification(SSA.AND, "CarYear", SSA.EQUALS, "1989");

These SSAs are taken from the section "IMS hierarchical database interface forJava" in the IMS Version 10: Application Programming API Reference. See the detailsabout how SSAs are used with DL/I calls in that section and see the Java APIspecification for IMS for a list of classes and methods available for creating SSAs inthe com.ibm.ims.db package.

Pascal SSA definition examplesAn unqualified SSA that does not use command codes looks like this in Pascal:type

STRUCT = recordSEG_NAME : ALFA;BLANK : CHAR;

end;const

UNQUAL_SSA = STRUCT('NAME',' ');

You can also declare this SSA as a single string:const

UNQUAL_SSA = 'NAME ';

The SSA shown in the following example is a qualified SSA that does not usecommand codes. If you use command codes in this SSA, code the asterisk (*) andthe command code between the 8-byte segment name field and the left parenthesisthat begins the qualification statement.

70 Application Programming Guide

||

||

|||

|||

||||

|||||

Page 95: IMS Application Programming.pdf

typeSTRUCT = record

SEG_NAME : ALFA;SEG_QUAL : CHAR;SEG_KEY_NAME : ALFA;SEG_OPR : CHAR;SEG_KEY_VALUE : packed array[1..n] of CHAR;SEG_END_CHAR : CHAR;

end;const

QUAL_SSA = STRUCT('ROOT','(','KEY',' =','vv...v',')');

This SSA looks like this:ROOT����(KEY������=vv...v)

PL/I SSA definition examplesAn unqualified SSA that does not use command codes looks like this in PL/I:DCL 1 UNQUAL_SSA STATIC UNALIGNED,

2 SEG_NAME_U CHAR(8) INIT('NAME '),2 BLANK CHAR(1) INIT(' ');

You can use a SSA that is coded like this for each DL/I call that needs anunqualified SSA by supplying the name of the segment type you want duringprogram execution.

In PL/I you define SSAs in structure declarations. The unaligned attribute isrequired for SSA data interchange with IMS. The SSA character string must residecontiguously in storage. For example, assignment of variable key values mightcause IMS to construct an invalid SSA if the key value has changed the alignedattribute.

A separate SSA structure is required for each segment type that the programaccesses because the value of the key fields differs among segment types. After youhave initialized the fields (other than the key values), the SSA should not need tobe changed again. You can define SSAs in any of the ways explained for the I/Oarea.

The following is an example of a qualified SSA without command codes. If youuse command codes in this SSA, code the asterisk (*) and command codes betweenthe 8-byte segment name field and the left parenthesis that begins the qualificationstatement.DCL 1 QUAL_SSA STATIC UNALIGNED,

2 SEG_NAME CHAR(8) INIT('ROOT '),2 SEG_QUAL CHAR(1) INIT('('),2 SEG_KEY_NAME CHAR(8) INIT('KEY '),2 SEG_OPR CHAR(2) INIT(' ='),2 SEG_KEY_VALUE CHAR(n) INIT('vv...v'),2 SEG_END_CHAR CHAR(1) INIT(')');

This SSA looks like this:ROOT����(KEY������=vv...v)

Both of these SSAs are taken from the PL/I skeleton program shown in Figure 11on page 33. To see how they are used in DL/I calls, refer to that program.

Chapter 2. Defining application program elements for IMS DB 71

Page 96: IMS Application Programming.pdf

Data areas in GSAM databasesThis section shows how to code data areas in GSAM databases. GSAM databasesare only available to application programs that can run as batch programs,batch-oriented BMPs, transaction-oriented BMPs, and JBPs. The PCB mask and therecord search argument (RSA) that you use in a GSAM database call have specialformats.

Generalized Sequential Access Method (GSAM) DB PCB masks are slightlydifferent from other DB PCB masks. The fields that are different are the length ofthe key feedback area and the key feedback area. Also, an additional field existsthat gives the length of the record being retrieved or inserted when usingundefined-length records.

The RSA is an 8-byte token for basic format data sets or 12-byte token for largeformat data sets that can be returned on GN and ISRT calls. The applicationprogram can save the RSA for use in a subsequent GU call.

Related Reading: For more information on RSAs for GSAM databases, seeChapter 9, “Processing GSAM databases,” on page 131. For more information onRSAs for GSAM databases as they are used with IMS Solutions for Javadevelopment, see the base package of the Java API specification for IMS.

The AIBTDLI interfaceThis section explains how to use the application interface block (AIB), an interfacebetween your application program and IMS.

When you use the AIBTDLI interface, you specify the PCB that is requested for thecall by placing the PCB name (as defined by PSBGEN) in the resource name fieldof the AIB. You do not specify the PCB address. Because the AIB contains the PCBname, your application can refer to the PCB name rather than to the PCB address.The AIBTDLI call allows you to select PCBs directly by name rather than by apointer to the PCB. At completion of the call, the AIB returns the PCB address thatcorresponds to the PCB name that is passed by the application program.

For PCBs to be used in a AIBTDLI call, you must assign a name in PSBGEN, eitherwith PCBNAME= or with the name as a label on the PCB statement. PCBs thathave assigned names are also included in the positional pointer list, unless youspecify LIST=NO. During PSBGEN, you define the names of the DB PCBs andalternate PCBs. All I/O PCBs are generated with the PCB name IOPCB���. For agenerated program specification block (GPSB), the I/O PCB is generated with thePCB name IOPCB���, and the modifiable alternate PCB is generated with the PCBname TPPCB1�.

Because you can pass the PCB name, you do not need to know the relative PCBnumber in the PCB list. In addition, the AIBTDLI interface enables your applicationprogram to make calls on PCBs that do not reside in the PCB list. The LIST=keyword, which is defined in the PCB macro during PSBGEN, controls whether thePCB is included in the PCB list.

The AIB resides in user-defined storage that is passed to IMS for DL/I calls thatuse the AIBTDLI interface. When the call is completed, the AIB is updated by IMS.

Recommendation: Allocate at least 128 bytes of storage for the AIB.

72 Application Programming Guide

|

|||||

|||||

|||

||||

Page 97: IMS Application Programming.pdf

Restriction: No fields in the AIB can be used by the application program except asdefined by IMS.

Related reading: For more information about PSBGEN, see IMS Version 10: SystemUtilities Reference.

Language specific entry pointsIMS gives control to an application program through an entry point. The formatsfor coding entry statements in assembler language, C language, COBOL, Pascal,and PL/I are shown in these sections: “Assembler language entry point,” “Clanguage entry point,” “COBOL entry point” on page 74, “Pascal entry point” onpage 74, and “PL/I entry point” on page 75. Your entry point must refer to thePCBs in the order in which they have been defined in the PSB.

Leave the value blank if the application has been enabled for the IBM LanguageEnvironment® for z/OS & VM.

When you code each DL/I call, you must provide the PCB you want to use forthat call. In all cases except CICS online, the list of PCBs that the program canaccess is passed to the program at its entry point. For CICS online, you must firstschedule a PSB as described in the topic "System Service Call: PCB" in IMS Version10: Application Programming API Reference.

Application interfaces that use the AIB structure (AIBTDLI or CEETDLI), such asJava application interfaces, use the PCB name rather than the PCB structure and donot require the PCB list to be passed at entry to the application.

In a CICS online program, you do not obtain the address of the PCBs through anentry statement, but through the user interface block (UIB). For more information,see “Specifying the UIB (CICS online programs only)” on page 63.

Assembler language entry pointYou can use any name for the entry statement to an assembler language DL/Iprogram. When IMS passes control to the application program, register 1 containsthe address of a variable-length fullword parameter list. Each word in the listcontains the address of a PCB. Save the content of register 1 before you overwriteit. IMS sets the high-order byte of the last fullword in the list to X'80' to indicatethe end of the list. Use standard z/OS linkage conventions with forward andbackward chaining.

C language entry point

When IMS passes control to your program, it passes the addresses, in the form ofpointers, for each of the PCBs that your program uses. The usual argc and argvarguments are not available to a program that is invoked by IMS. The IMSparameter list is made accessible by using the __pcblist macro. You can directlyreference the PCBs by __pcblist[0], __pcblist[1], or you can define macros to givethese more meaningful names. Note that I/O PCBs must be cast to get the propertype:(IO_PCB_TYPE *)(__pcblist[0])

The entry statement for a C language program is the main statement.

Chapter 2. Defining application program elements for IMS DB 73

||

|||

Page 98: IMS Application Programming.pdf

#pragma runopts(env(IMS),plist(IMS))#include <ims.h>

main(){...}

The env option specifies the operating environment in which your C languageprogram is to run. For example, if your C language program is invoked under IMSand uses IMS facilities, specify env(IMS). The plist option specifies the format ofthe invocation parameters that is received by your C language program when it isinvoked. When your program is invoked by a system support services program,the format of the parameters passed to your main program must be converted intothe C language format: argv, argc, and envp. To do this conversion, you mustspecify the format of the parameter list that is received by your C languageprogram. The ims.h include file contains declarations for PCB masks.

You can finish in three ways:v End the main procedure without an explicit return statement.v Execute a return statement from main.v Execute an exit or an abort call from anywhere, or alternatively issue a longjmp

back to main, and then do a normal return.

One C language program can pass control to another by using the system function.The normal rules for passing parameters apply; in this case, the argc and argvarguments can be used to pass information. The initial __pcblist is made availableto the invoked program.

COBOL entry pointThe procedure statement must refer to the I/O PCB first, then to any alternate PCBit uses, and finally to the DB PCBs it uses. The alternate PCBs and DB PCBs mustbe listed in the order in which they are defined in the PSB.PROCEDURE DIVISION USING PCB-NAME-1 [,...,PCB-NAME-N]

In previous versions of IMS, USING might be coded on the entry statement toreference PCBs. However, IMS continues to accept such coding on the entrystatement.

Recommendation: Use the procedure statement rather than the entry statement toreference the PCBs.

Pascal entry point

The entry point must be declared as a REENTRANT procedure. When IMS passescontrol to a Pascal procedure, the first address in the parameter list is reserved forPascal's use, and the other addresses are the PCBs the program uses. The PCB typesmust be defined before this entry statement. The IMS interface routine PASTDLImust be declared with the GENERIC directive.procedure ANYNAME(var SAVE: INTEGER;

var pcb1-name: pcb1-name-type[;...var pcbn-name: pcbn-name-type]); REENTRANT;

procedure ANYNAME;(* Any local declarations *)

74 Application Programming Guide

Page 99: IMS Application Programming.pdf

procedure PASTDLI; GENERIC;begin

(* Code for ANYNAME *)end;

PL/I entry point

The entry statement must appear as the first executable statement in the program.When IMS passes control to your program, it passes the addresses of each of thePCBs your program uses in the form of pointers. When you code the entrystatement, make sure you code the parameters of this statement as pointers to thePCBs, and not the PCB names.anyname: PROCEDURE (pcb1_ptr [,..., pcbn_ptr]) OPTIONS (MAIN);...RETURN;

The entry statement can be any valid PL/I name.

CEETDLI, AIBTDLI, and AERTDLI interface considerationsThis section explains the interfaces: CEETDLI, AIBTDLI, and AERTDLI.

The considerations for CEETDLI are:v For PL/I programs, the CEETDLI entry point is defined in the CEEIBMAW

include file. Alternatively, you can declare it yourself, but it must be declared asan assembler language entry (DCL CEETDLI OPTIONS(ASM);).

v For C language application programs, you must specify env(IMS) andplist(IMS); these specifications enable the application program to accept the PCBlist of arguments. The CEETDLI function is defined in <leawi.h>; the CTDLIfunction is defined in <ims.h>.

The considerations for AIBTDLI are:v When using the AIBTDLI interface for C/MVS™, Enterprise COBOL, or PL/I

language application programs, the language run-time options for suppressingabend interception (that is, NOSPIE and NOSTAE) must be specified. However,for Language Environment-conforming application programs, the NOSPIE andNOSTAE restriction is removed.

v The AIBTDLI entry point for PL/I programs must be declared as an assemblerlanguage entry (DCL AIBTDLI OPTIONS(ASM);).

v For C language applications, you must specify env(IMS) and plist(IMS); thesespecifications enable the application program to accept the PCB list ofarguments.

The considerations for AERTDLI are:v When using the AERTDLI interface for C/MVS, COBOL, or PL/I language

application programs, the language run-time options for suppressing abendinterception (that is, NOSPIE and NOSTAE) must be specified. However, forLanguage Environment-conforming application programs, the NOSPIE andNOSTAE restriction is removed.

v The AERTDLI entry point for PL/I programs must be declared as an assemblerlanguage entry (DCL AERTDLI OPTIONS(ASM);).

v For C language applications, you must specify env(IMS) and plis(IMS). Thesespecifications enable the application program to accept the PCB list ofarguments.

Chapter 2. Defining application program elements for IMS DB 75

Page 100: IMS Application Programming.pdf

v AERTDLI must receive control with 31 bit addressability.

Program communication block (PCB) listsThis section describes the formats of PCB lists and GPSB PCB lists, and provides adescription of PCBs in various types of application programs.

PCB list formatThe following example shows the general format of a PCB list.[IOPCB][Alternate PCB ... Alternate PCB][DB PCB ... DB PCB][GSAM PCB ... GSAM PCB]

Each PSB must contain at least one PCB. An I/O PCB is required for most systemservice calls. An I/O PCB or alternate PCB is required for transaction managementcalls. (Alternate PCBs can exist in IMS TM.) DB PCBs for DL/I databases are usedonly with the IMS Database Manager under DCCTL. GSAM PCBs can be usedwith DCCTL.

Format of a GPSB PCB listA generated program specification block (GPSB) takes this format:[IOPCB][Alternate PCB]

A GPSB contains only an I/O PCB and one modifiable alternate PCB. (Amodifiable alternate PCB enables you to change the destination of the alternatePCB while the program is running.) A GPSB can be used by all transactionmanagement application programs, and permits access to the specified PCBswithout the need for a specific PSB for the application program.

The PCBs in a GPSB have predefined PCB names. The name of the I/O PCB isIOPCB. The name of the alternate PCB is TPPCB1��. The minimum size of the I/Owork area that IMS generates for GPSBs in a DBCTL environment is 600 bytes.

PCB summaryThis section summarizes the information concerning I/O PCBs and alternate PCBsin various types of application programs. You should read this section if youintend to issue system service requests.

DB Batch Programs If CMPAT=Y is specified in PSBGEN, the I/O PCB ispresent in the PCB list; otherwise, the I/O PCB isnot present, and the program cannot issue systemservice calls. Alternate PCBs are always included inthe list of PCBs that IMS supplies to the program.

BMPs, MPPs, and IFPs The I/O PCB and alternate PCBs are alwayspassed to BMPs, MPPs, and IFPs.

The PCB list always contains the address of theI/O PCB, followed by the addresses of anyalternate PCBs, followed by the addresses of theDB PCBs.

CICS Online Programs with DBCTLIf you specify the IOPCB option on the PCB call, thefirst PCB address in your PCB list is the I/O PCB,

76 Application Programming Guide

Page 101: IMS Application Programming.pdf

followed by any alternate PCBs, followed by theaddresses of the DB PCBs.

If you do not specify the I/O PCB option, the firstPCB address in your PCB list points to the first DBPCB.

Table 11 summarizes the I/O PCB and alternate PCB information.

Table 11. I/O PCB and alternate PCB information summary

Environment

CALL DL/I

I/O PCB address in PCB list Alternate PCB address inPCB list

MPP Yes Yes

IFP Yes Yes

BMP Yes Yes

DB Batch1 No Yes

DB Batch2 Yes Yes

TM Batch3 Yes Yes

CICS DBCTL4 No No

CICS DBCTL5 Yes Yes

Notes:

1. CMPAT = N specified.

2. CMPAT = Y specified.

3. CMPAT = Option. Default is always to Y, even when CMPAT = N is specified.

4. SCHD request issued without the IOPCB or SYSSERVE option.

5. SCHD request issued with the IOPCB or SYSSERVE for a CICS DBCTL request or for afunction-shipped request which is satisfied by a CICS system using DBCTL.

The AERTDLI interfaceThis section explains how to use the AIB with ODBA applications.

When you use the AERTDLI interface, the AIB used for database calls must be thesame AIB as used for the APSB call. Specify the PCB that is requested for the callby placing the PCB name (as defined by PSBGEN) in the resource name field ofthe AIB. You do not specify the PCB address. Because the AIB contains the PCBname, your application can refer to the PCB name rather than to the PCB address.The AERTDLI call allows you to select PCBs directly by name rather than by apointer to the PCB. At completion of the call, the AIB returns the PCB address thatcorresponds to the PCB name that is passed by the application program.

For PCBs to be used in a AERTDLI call, you must assign a name in PSBGEN,either with PCBNAME= or with the name as a label on the PCB statement. PCBsthat have assigned names are also included in the positional pointer list, unlessyou specify LIST=NO. During PSBGEN, you define the names of the DB PCBs andalternate PCBs. All I/O PCBs are generated with the PCB name IOPCB���.

Because you pass the PCB name, you do not need to know the relative PCBnumber in the PCB list. In addition, the AERTDLI interface enables yourapplication program to make calls on PCBs that do not reside in the PCB list. The

Chapter 2. Defining application program elements for IMS DB 77

Page 102: IMS Application Programming.pdf

LIST= keyword, which is defined in the PCB macro during PSBGEN, controlswhether the PCB is included in the PCB list.

The AIB resides in user-defined storage that is passed to IMS for DL/I calls thatuse the AERTDLI interface. When the call is completed, the AIB is updated byIMS. Because some of the fields in the AIB are used internally by IMS, the sameAPSB AIB must be used for all subsequent calls for that PSB.

Requirement: Allocate 264 bytes of storage for the AIB.

Language environmentsIBM z/OS Language Environment provides the strategic execution environment forrunning your application programs written in one or more high-level languages. Itprovides not only language-specific run-time support, but also cross-languagerun-time services for your application programs, such as support for initialization,termination, message handling, condition handling, storage management, andNational Language Support. Many of Language Environment services areaccessible explicitly through a set of Language Environment interfaces that arecommon across programming languages; these services are accessible from anyLanguage Environment-conforming program.

Language Environment-conforming programs can be compiled with:v IBM z/OS C/C++ Compilersv Enterprise COBOLv Enterprise PL/I

Related reading: For more information about Language Environment, see z/OSV1R9 Language Environment Programming Guide.

The CEETDLI interface to IMSThe language-independent CEETDLI interface to IMS is provided by LanguageEnvironment. It is the only IMS interface that supports the advanced errorhandling capabilities that Language Environment provides. The CEETDLI interfacesupports the same functionality as the other IMS application interfaces. Thecharacteristics are:v The parmcount variable is optional.v Length fields are 2 bytes long.v Direct pointers are used.

Related reading: For more information about Language Environment, see z/OSV1R9 Language Environment Programming Guide.

Specifying LANG= option for PL/I compatibilityFor IMS PL/I applications running in a compatibility mode that uses thePLICALLA entry point, you must specify LANG=PLI on the PSBGEN, or you canchange the entry point and add SYSTEM(IMS) to the EXEC PARM of the compilestep so that you can specify LANG=blank or LANG=PLI on the PSBGEN. Table 12on page 79 summarizes when you can use LANG=� and LANG=PLI.

78 Application Programming Guide

|||||||||

|

|

|

|

||

|

|||||

|

|

|

||

|

|||||

Page 103: IMS Application Programming.pdf

Table 12. Using LANG= option in a Language Environment for PL/I compatibility

Compile EXEC statement isPARM=(...,SYSTEM(IMS)...

and entry point name isPLICALLA

Then LANG= is

Yes Yes LANG=PLI

Yes No LANG= � or LANG=PLI

No No Not valid for IMS PL/I applications

No Yes LANG=PLI

Restriction: PLICALLA is only valid for PL/I compatibility with LanguageEnvironment. If a PL/I application program that uses the PLICALLA entry at bindtime is bound using Language Environment with the PLICALLA entry, the bindwill work; however, you must use LANG=PLI in the PSB. If you recompile theapplication program (without the PLICALLA entry) by using Enterprise PL/I, andthen attempt to bind using Language Environment Version 1 Release 2 or later, thebind will fail. To bind successfully, you first must remove the PLICALLA entrystatement from the bind.

Special DL/I situations

Application program scheduling against HALDBsApplication programs are scheduled against HALDBs the same way they areagainst non-HALDBs. Scheduling is based on the availability status of the HALDBmaster and is not affected by individual partition access and status.

The application programmer needs to be aware of changes to the handling ofunavailable data for HALDBs. The feedback on data availability at PSB scheduletime shows the availability of the HALDB master, not of the partitions. However,the error settings for data unavailability of a partition at the first reference to thepartition during the processing of a DL/I call are the same as those of anon-HALDB, namely status code BA or pseudo ABENDU3303.

Example: If you issue the IMS /DBR command to half of the partitions to take themoffline, the remaining partitions are available to the programs.

If you load a new HALDB that contains logical relationships, the logical childsegments are not loaded as part of the load step. Add logical children throughnormal update processing after the database is loaded.

When a program accesses a partition for the first time, an indicator records that thePSB accessed the partition. Commands can operate against a partition currently notin use. A DFS05651 message results if a BMP uses a partition and the commandwas against that partition. If an application attempts to access data from a stoppedpartition, a pseudo abend results or the application receives a BA status code. Ifthe partition starts before the application attempts to access data in that partitionagain, the DL/I call succeeds.

Mixed-language programmingWhen an application program uses the Language Environmentlanguage-independent interface, CEETDLI, IMS does not need to know thelanguage of the calling program.

Chapter 2. Defining application program elements for IMS DB 79

||

|||||

|||

|||

|||

||||

||||||||

Page 104: IMS Application Programming.pdf

When the application program calls IMS in a language-dependent interface, IMSdetermines the language of the calling program according to the entry name that isspecified in the CALL statement. That is, IMS assumes that the program is:v Assembler language when the application program uses CALL ASMTDLIv C language when the application program uses rc=CTDLIv COBOL when the application program uses CALL CBLTDLIv Pascal when the application program uses CALL PASTDLIv PL/I when the application program uses CALL PLITDLI

For example, if a PL/I program calls an assembler language subroutine and theassembler language subroutine makes DL/I calls by using CALL ASMTDLI, theassembler language subroutine should use the assembler language callingconvention, not the PL/I convention.

In this situation, where the I/O area uses the LLZZ format, LL is a halfword, notthe fullword that is used for PL/I.

Language Environment routine retentionIf you run programs in an IMS TM dependent region that requires LanguageEnvironment (such as an IMS message processing region), you can improveperformance if you use Language Environment library routine retention along withthe existing PREINIT feature of IMS TM.

Related Reading: For more information about Language Environment routineretention, see z/OS V1R9 Language Environment Programming Guide .

Extended addressing capabilities of z/OSThe two modes in z/OS with extended addressing capabilities are: the addressingmode (AMODE) and the residency mode (RMODE). IMS places no constraints onthe RMODE and AMODE of an application program. The program can reside inthe extended virtual storage area. The parameters that are referenced in the call canalso be in the extended virtual storage area.

Preloaded programsIf you compile your COBOL program with the VS COBOL II compiler and preloadit, you must use the COBOL compiler options RES and RENT.

80 Application Programming Guide

||

Page 105: IMS Application Programming.pdf

Chapter 3. Establishing a DL/I interface from COBOL or PL/I

To establish a DL/I interface from COBOL or PL/I, use either the CBLTDLIprocedure or the PLITDLI procedure.

The following topics provide additional information:v “CBLTDLI”v “PLITDLI”

CBLTDLIThe following control statements are necessary to establish a COBOL to DL/Iinterface. The block size of the following members must be less than or equal to3200.

LIBRARY SDFSRESL(CBLTDLI) DL/I LANGUAGE INTERFACELIBRARY SDFSRESL(DFHEI01) HLPI LANGUAGE INTERFACELIBRARY SDFSRESL(DFHEI1) HLPI LANGUAGE INTERFACE

PLITDLIThe following control statements are necessary to establish a PL/I to DL/Iinterface. The blocksize of the following members must be less than or equal to3200.

LIBRARY SDFSRESL(PLITDLI) DL/I LANGUAGE INTERFACELIBRARY SDFSRESL(DFHEI01) HLPI LANGUAGE INTERFACELIBRARY SDFSRESL(DFHEI1) HLPI LANGUAGE INTERFACEENTRY PLICALLA

PLITDLI is valid when using the PL/I Optimizing Compiler.

© Copyright IBM Corp. 1974, 2010 81

|||

|

Page 106: IMS Application Programming.pdf

82 Application Programming Guide

Page 107: IMS Application Programming.pdf

Chapter 4. Current position in the database after each call

Positioning means that DL/I tracks your place in the database after each call thatyou issue. By tracking your position in the database, DL/I enables you to processthe database sequentially.

The following topics provide additional information:v “Current position after successful calls”v “Current position after unsuccessful calls” on page 88v “Multiple processing” on page 93

Current position after successful callsPosition is important when you process the database sequentially by issuing GN,GNP, GHN, and GHNP calls. Current position is where IMS starts its search for thesegments that you specify in the calls.

This section explains current position for successful calls. Current position is alsoaffected by an unsuccessful retrieval or ISRT call. “Current position afterunsuccessful calls” on page 88 explains current position in the database after anunsuccessful call.

Before you issue the first call to the database, the current position is the placeimmediately before the first root segment occurrence in the database. This meansthat if you issue an unqualified GN call, IMS retrieves the first root segmentoccurrence. It is the next segment occurrence in the hierarchy that is defined by theDB PCB that you referenced.

Certain calls cancel your position in the database. You can reestablish this positionwith the GU call. Because the CHKP and SYNC (commit point) calls cancel position,follow either of these calls with a GU call. The ROLS and ROLB calls also cancel yourposition in the database.

When you issue a GU call, your current position in the database does not affect theway that you code the GU call or the SSA you use. If you issue the same GU call atdifferent points during program execution (when you have different positionsestablished), you will receive the same results each time you issue the call. If youhave coded the call correctly, IMS returns the segment occurrence you requestedregardless of whether the segment is before or after the current position.

Exception: If a GU call does not have SSAs for each level in the call, it is possiblefor IMS to return a different segment at different points in your program. This isbased on the position at each level.

Example: Suppose you issue the following call against the data structure shown inFigure 18 on page 84.GU A�������(AKEY����=�A1)

B�������(BKEY����=�B11)D�������(DKEY�����D111)

© Copyright IBM Corp. 1974, 2010 83

Page 108: IMS Application Programming.pdf

The structure in the figure contains six segment types: A, B, C, D, E, and F.Figure 18 shows one database record, the root of which is A1.

When you issue this call, IMS returns the D segment with the key D111, regardlessof where your position is when you issue the call. If this is the first call yourprogram issues (and if this is the first database record in the database), currentposition before you issue the call is immediately before the first segmentoccurrence in the database—just before the A segment with the key of A1. Even ifcurrent position is past segment D111 when you issue the call (for example, justbefore segment F111), IMS still returns the segment D111 to your program. This isalso true if the current position is in a different database record.

When you issue GN and GNP calls, current position in the database affects the waythat you code the call and the SSA. That is because when IMS searches for asegment described in a GN or GNP call, it starts the search from current position andcan only search forward in the database. IMS cannot look behind that segmentoccurrence to satisfy a GN or GNP. These calls can only move forward in thedatabase when trying to satisfy your call, unless you use the F command code, theuse of which is described in the topic "F Command Code" in IMS Version 10:Application Programming API Reference.

If you issue a GN call for a segment occurrence that you have already passed, IMSstarts searching at the current position and stops searching when it reaches the endof the database (resulting in a GB status code), or when it determines from yourSSA that it cannot find the segment you have requested (GE status code). “Currentposition after unsuccessful calls” on page 88 explains where your position is whenyou receive a GE status code.

Current position affects ISRT calls when you do not supply qualified SSAs for theparents of the segment occurrence that you are inserting. If you supply only the

B

BKEY = B11

C

CKEY = C111

BKEY = B13

BKEY = B12

CKEY = C112

D

DKEY = D111

F

FKEY = F111

E

EKEY = E11

A

AKEY = A1

Figure 18. Current position hierarchy

84 Application Programming Guide

Page 109: IMS Application Programming.pdf

unqualified SSA for the segment occurrence, you must be sure that your positionin the database is where you want the segment occurrence to be inserted.

Position after retrieval callsAfter you issue any kind of successful retrieval call, position immediately followsthe segment occurrence you just retrieved—or the lowest segment occurrence inthe path if you retrieved several segment occurrences using the D command code.When you use the D command code in a retrieval call, a successful call is one thatIMS completely satisfies.

Example: If you issue the following call against the database shown in Figure 18on page 84, IMS returns the C segment occurrence with the key of C111. Currentposition is immediately after C111. If you then issue an unqualified GN call, IMSreturns the C112 segment to your program.GU A(�������(AKEY����=�A1)

B�������(BKEY����=�B11)C�������(CKEY����=�C111)

Your current position is the same after retrieving segment C111, whether youretrieve it with GU, GN, GNP, or any of the Get Hold calls.

If you retrieve several segment occurrences by issuing a Get call with the Dcommand code, current position is immediately after the lowest segmentoccurrence that you retrieved. If you issue the GU call as shown in the exampleabove, but include the D command code in the SSA for segments A and B, thecurrent position is still immediately after segment C111. C111 is the last segmentthat IMS retrieves for this call. With the D command code, the call looks like this:GU A(�������(AKEY����=�A1)

B�������(BKEY����=�B11)C�������(CKEY����=�C111)

You do not need the D command code on the SSA for the C segment because IMSalways returns to your I/O area the segment occurrence that is described in thelast SSA.

Position after DLETAfter a successful DLET call, position immediately follows the segment occurrenceyou deleted. This is true when you delete a segment occurrence with or withoutdependents.

Example: If you issue the call shown Figure 19 to delete segment C111, currentposition is immediately after segment C111. Then, if you issue an unqualified GNcall, IMS returns segment C112.

Figure 20 on page 86 shows what the hierarchy looks like after this call. Thesuccessful DLETcall has deleted segment C111.

GHU A�������(AKEY����=�A1)B�������(BKEY����=�B11)C�������(CKEY����=�C111)

DLET

Figure 19. Example code: deleting segment C11

Chapter 4. Current position in the database after each call 85

|||

Page 110: IMS Application Programming.pdf

When you issue a successful DLET call for a segment occurrence that hasdependents, IMS deletes the dependents, and the segment occurrence. Currentposition still immediately follows the segment occurrence you deleted. Anunqualified GN call returns the segment occurrence that followed the segment youdeleted.

Example: If you delete segment B11 in the hierarchy shown in Figure 20, IMSdeletes its dependent segments, C112 and D111, as well. Current positionimmediately follows segment B11, just before segment B12. If you then issue anunqualified GN call, IMS returns segment B12. Figure 21 on page 87 shows what thehierarchy looks like after you issued this call.

BKEY = B13

C

CKEY = C112

BKEY = B12

D

DKEY = D111

E

EKEY = E11

A

AKEY = A1

B

BKEY = B11

F

FKEY = F111

Figure 20. Hierarchy after deleting a segment

86 Application Programming Guide

Page 111: IMS Application Programming.pdf

Because IMS deletes the segment's dependents, you can think of current positionimmediately following the last (lowest, right-most) dependent. In the example inFigure 20 on page 86, this immediately follows segment D111. But if you then issuean unqualified GN call, IMS still returns segment B12. You can think of position ineither place—the results are the same either way. An exception to this can occur fora DLET that follows a GU path call, which returned a GE status code. See “Currentposition after unsuccessful calls” on page 88 regarding position after unsuccessfulcalls.

Position after REPLA successful REPL call does not change your position in the database. Currentposition is just where it was before you issued the REPL call. It immediately followsthe lowest segment that is retrieved by the Get Hold call that you issued before theREPL call.

Example: If you retrieve segment B13 in Figure 21 using a GHU instead of a GU call,change the segment in the I/O area, and then issue a REPL call, current positionimmediately follows segment B13.

Position after ISRTAfter you add a new segment occurrence to the database, current positionimmediately follows the new segment occurrence.

Example: In Figure 22 on page 88, if you issue the following call to add segmentC113 to the database, current position immediately follows segment C113. Anunqualified GN call would retrieve segment D111.ISRT A�������(AKEY����=

If you are inserting a segment that has a unique key, IMS places the new segmentin key sequence. If you are inserting a segment that has either a non unique key orno key at all, IMS places the segment according to the rules parameter of the

BKEY = B13

A

AKEY = A1

B

BKEY = B12

E

EKEY = E11

F

FKEY = F111

Figure 21. Hierarchy after deleting a segment and dependents

Chapter 4. Current position in the database after each call 87

Page 112: IMS Application Programming.pdf

SEGM statement of the DBD for the database. the topic "ISRT Call" in IMS Version10: Application Programming API Reference explains these rules.

If you insert several segment occurrences using the D command code, currentposition immediately follows the lowest segment occurrence that is inserted.

Example: Suppose you insert a new segment B (this would be B14), and a new Csegment occurrence (C141), which is a dependent of B14. Figure 22 shows what thehierarchy looks like after these segment occurences are inserted. The call to do thislooks like this:ISRT A�������(AKEY����=

You do not need the D command code in the SSA for the C segment. On ISRT calls,you must include the D command code in the SSA for the only first segment youare inserting. After you issue this call, position immediately follows the C segmentoccurrence with the key of C141. Then, if you issue an unqualified GN call, IMSreturns segment E11.

If your program receives an II status code as a result of an ISRT call (which meansthat the segment you tried to insert already exists in the database), current positionis just before the duplicate of the segment that you tried to insert.

Current position after unsuccessful callsIMS establishes another kind of position when you issue retrieval and ISRT calls.This is position on one segment occurrence at each hierarchic level in the path tothe segment that you are retrieving or inserting. You need to know how IMSestablishes this position to understand the U and V command codes described inthe topic "General Command Codes for DL/I Calls" in IMS Version 10: Application

BKEY = B14

BKEY = B13

B

BKEY = B11

C

CKEY = C141

BKEY = B12

CKEY = C112

A

AKEY = A1

E

EKEY = E11

C

CKEY = C111

D

DKEY = D111

F

FKEY = F111

Figure 22. Hierarchy after adding new segments and dependents

88 Application Programming Guide

Page 113: IMS Application Programming.pdf

Programming API Reference. Also, you need to understand where your position inthe database is when IMS returns a not-found status code to a retrieval or ISRTcall.

In “Current position after successful calls” on page 83 you saw what currentposition is, why and when it is important, and how successful DL/I calls affect it.But chances are that not every DL/I call that your program issues will becompletely successful. When a call is unsuccessful, you should understand how todetermine your position in the database after that call.

Position after an unsuccessful DLET or REPL callDLET and REPL calls do not affect current position. Your position in the database isthe same as it was before you issued the call. However, an unsuccessful Get call orISRT call does affect your current position.

To understand where your position is in the database when IMS cannot find thesegment you have requested, you need to understand how DL/I determines that itcannot find your segment.

In addition to establishing current position after the lowest segment that isretrieved or inserted, IMS maintains a second type of position on one segmentoccurrence at each hierarchic level in the path to the segment you are retrieving orinserting.

Example: In Figure 23 on page 90, if you had just successfully issued the GU callwith the SSA shown below, IMS has a position established at each hierarchic level.GU A�������(AKEY����=b�A1)

B�������(BKEY�����B11)C�������(CKEY����=�C111)

Now DL/I has three positions, one on each hierarchic level in the call:v One on the A segment with the key A1v One on the B segment with the key B11v One on the C segment with the key C111

Chapter 4. Current position in the database after each call 89

Page 114: IMS Application Programming.pdf

When IMS searches for a segment occurrence, it accepts the first segmentoccurrence it encounters that satisfies the call. As it does so, IMS stores the key ofthat segment occurrence in the key feedback area.

Position after an unsuccessful retrieval or ISRT callCurrent position after a retrieval or ISRT call that receives a GE status codedepends on how far IMS got in trying to satisfy the SSA in the call. When IMSprocesses an ISRT call, it checks for each of the parents of the segment occurrenceyou are inserting. An ISRT call is similar to a retrieval call, because IMS processesthe call level by level, trying to find segment occurrences to satisfy each level ofthe call. When IMS returns a GE status code on a retrieval call, it means that IMSwas unable to find a segment occurrence to satisfy one of the levels in the call.When IMS returns a GE status code on an ISRT call, it means that IMS was unableto find one of the parents of the segment occurrence you are inserting. These arecalled not-found calls.

When IMS processes retrieval and ISRT calls, it tries to satisfy your call until itdetermines that it cannot. When IMS first tries to find a segment matching thedescription you have given in the SSA and none exists under the first parent, IMStries to search for your segment under another parent. How you code the SSA inthe call determines whether IMS can move forward and try again under anotherparent.

Example: Suppose you issue the following GN call to retrieve the C segment withthe key of C113 in the hierarchy shown in Figure 23.GN A�������(AKEY����=�A1)

B�������(BKEY����=�B11)C�������(CKEY����=�C113)

B

BKEY = B11

C

CKEY = C111

BKEY = B13

BKEY = B12

CKEY = C112

D

DKEY = D111

F

FKEY = F111

E

EKEY = E11

A

AKEY = A1

Figure 23. DL/I positions

90 Application Programming Guide

Page 115: IMS Application Programming.pdf

When IMS processes this call, it searches for a C segment with the key equal toC113. IMS can only look at C segments whose parents meet the qualifications forthe A and B segments. The B segment that is part of the path must have a keyequal to B11, and the A segment that is part of the path must have a key equal toA1. IMS then looks at the first C segment. Its key is C111. The next C segment hasa key of C112. IMS looks for a third C segment occurrence under the B11 segmentoccurrence. No more C segment occurrences exist under B11.

Because you have specified in the SSA that the A and B segment occurrences in C'spath must be equal to certain values, IMS cannot look for a C segment occurrencewith a key of C113 under any other A or B segment occurrence. No more Csegment occurrences exist under the parent B11; the parent of C must be B11, andthe parent of B11 must be A1. IMS determines that the segment you have specifieddoes not exist and returns a not-found (GE) status code.

When you receive the GE status code on this call, you can determine where yourposition is from the key feedback area, which reflects the positions that IMS has atthe levels it was able to satisfy—in this case, A1 and B11.

After this call, current position immediately follows the last segment occurrencethat IMS examined in trying to satisfy your call—in this case, C112. Then, if youissue an unqualified GN call, IMS returns D111.

The current position after this call is different if A and B have non unique keys.Suppose A's key is unique and B's is non unique. After IMS searches for a C113segment under B11 and is unable to find one, IMS moves forward from B11 to lookfor another B segment with a key of B11. When IMS does not find one, DL/Ireturns a GE status code. Current position is further in the database than it waswhen both keys were unique. Current position immediately follows segment B11.An unqualified GN call would return B12.

If A and B both have non unique keys, current position after the previous callimmediately follows segment A1. Assuming no more segment A1s exist, anunqualified GN call would return segment A2. If other A1s exist, IMS tries to find asegment C113 under the other A1s.

But suppose you issue the same call with a greater-than-or-equal-to relationaloperator in the SSA for segment B:GU A�������(AKEY����=>�A1)

B�������(BKEY����=>B11)C�������(CKEY����=>�C113)

IMS establishes position on segment A1 and segment B11. Because A1 and B11satisfy the first two SSAs in the call, IMS stores their keys in the key feedback area.IMS searches for a segment C113 under segment B11. None is found. But this time,IMS can continue searching, because the key of the B parent can be greater than orequal to B11. The next segment is B12. Because B12 satisfies the qualification forsegment B, IMS places B12's key in the key feedback area. IMS then looks for aC113 under B12 and does not find one. The same thing happens for B13: IMSplaces the key of B13 in the key feedback area and looks for a C113 under B13.

When IMS finds no more B segments under A1, it again tries to move forward tolook for B and C segments that satisfy the call under another A parent. But thistime it cannot; the SSA for the A segment specifies that the A segment must beequal to A1. (If the keys were non unique, IMS could look for another A1

Chapter 4. Current position in the database after each call 91

|||

Page 116: IMS Application Programming.pdf

segment.) IMS then knows that it cannot find a C113 under the parents you havespecified and returns a GE status code to your program.

In this example, you have not limited IMS's search for segment C113 to only one Bsegment, because you have used the greater-than-or-equal-to operator. IMS'sposition is further than you might have expected, but you can tell what theposition is from the key feedback area. The last key in the key feedback area is thekey of segment B13; The current position of IMS immediately follows segment B13.If you then issue an unqualified GN call, IMS returns segment E11.

Each of the B segments that IMS examines for this call satisfies the SSA for the Bsegment, so IMS places the key of each in the key feedback area. But if one ormore of the segments IMS examines does not satisfy the call, IMS does not placethe key of that segment in the key feedback area. This means that IMS's position inthe database might be further than the position reflected by the key feedback area.For example, suppose you issue the same call, but you qualify segment B on a datafield in addition to the key field. To do this, you use multiple qualificationstatements for segment B.

Assume the data field you are qualifying the call on is called BDATA. Assume thevalue you want is 14, but that only one of the segments, B11, contains a value inBDATA of 14:GN A�������(AKEY����=�A1)

B�������(BKEY����>=B11*BDATA���=�14)C�������(CKEY����=�C113)

After you issue this call, the key feedback area contains the key for segment B11. Ifyou continue issuing this call until you receive a GE status code, IMS's currentposition immediately follows segment B13, but the key feedback area still containsonly the key for segment B11. Of the B segments IMS examines, only one of them(B11) satisfies the SSA in the call.

When you use a greater-than or greater-than-or-equal-to relational operator, you donot limit IMS's search. If you get a GE status code on this kind of call, and if oneor more of the segments IMS examines does not satisfy an SSA, IMS's position inthe database may be further than the position reflected in the key feedback area. If,when you issue the next GN or GNP call, you want IMS to start searching from theposition reflected in the key feedback area instead of from its “real” position, youcan either:v Issue a fully qualified GU call to reestablish position to where you want it.v Issue a GN or GNP call with the U command code. Including a U command code

on an SSA tells IMS to use the first position it established at that level asqualification for the call. This is like supplying an equal-to relational operator forthe segment occurrence that IMS has positioned on at that level.

Example: Suppose that you first issue the GU call with the greater-than-or-equal-torelational operator in the SSA for segment B, and then you issue this GN call:GN A�������*U

B�������*UC��������

The U command code tells IMS to use segment A1 as the A parent, and segmentB11 as the B parent. IMS returns segment C111. But if you issue the same callwithout the U command code, IMS starts searching from segment B13 and movesforward to the next database record until it encounters a B segment. IMS returnsthe first B segment it encounters.

92 Application Programming Guide

Page 117: IMS Application Programming.pdf

Multiple processingThe order in which an application program accesses segments in a hierarchydepends on the purpose of the application program. Some programs accesssegments directly, others sequentially. Some application programs require that theprogram process segments in different hierarchic paths, or in different databaserecords, in parallel.

If your program must process segments from different hierarchic paths or fromdifferent database records in parallel, using multiple positioning or multiple PCBscan simplify the program's processing. For example:v Suppose your program must retrieve segments from different hierarchic paths

alternately: for example, in Figure 24, it might retrieve B11, then C11, then B12,then C12, and so on. If your program uses multiple positioning, IMS maintainspositions in both hierarchic paths. Then the program is not required to issue GUcalls to reset position each time it needs to retrieve a segment from a differentpath.

v Suppose your program must retrieve segments from different database recordsalternately: for example, it might retrieve a B segment under A1, and then a Bsegment under another A root segment. If your program uses multiple PCBs,IMS maintains positions in both database records. Then the program does nothave to issue GU calls to reset position each time it needs to access a differentdatabase record.

Multiple positioningWhen you define the PSB for your application program, you have a choice aboutthe kind of positioning you want to use: single or multiple. All of the examplesused so far, and the explanations about current position, have used singlepositioning. This section explains what multiple positioning is, why it is useful,and how it affects your programming.

Specify the kind of position you want to use for each PCB on the PCB statementwhen you define the PSB. The POS operand for a DEDB is disregarded. DEDBssupport multiple positioning only.

Definitions:

v Single positioning means that IMS maintains position in one hierarchic path forthe hierarchy that is defined by that PCB. When you retrieve a segment, IMSclears position for all dependents and all segments on the same level.

C12

B13

B12

A1

B11 C11

Figure 24. Multiple processing

Chapter 4. Current position in the database after each call 93

Page 118: IMS Application Programming.pdf

v Multiple positioning means that IMS maintains position in each hierarchic path inthe database record that is being accessed. When you retrieve a segment, IMSclears position for all dependents but keeps position for segments at the samelevel. You can process different segment types under the same parent in parallel.

Example: Suppose you issue these two calls using the hierarchy shown inFigure 25:GU A�������(AKEY����=�A1)

B�������(BKEYY����=�B11)C�������(CKEYY����=�C111)

GN E�������(EKEYY����=�E11)

After issuing the first call with single positioning, IMS has three positionsestablished: one on A1, one on B11, and one on C111. After issuing the second call,the positions on B11 and C111 are canceled. Then IMS establishes positions on A1and E11.

After issuing the first call with single and multiple positioning, IMS has threepositions established: one on A1, one on B11, and one on C111. However, afterissuing the second call, single positioning cancels positions on B11 and C111 whilemultiple positioning retains positions on B11 and C111. IMS then establishespositions on segments A1 and E11 for both single and multiple positioning.

After issuing the first call with multiple positioning, IMS has three positionsestablished (just as with single positioning): one on A1, one on B11, and one onC111. But after issuing the second call, the positions on B11 and C111 are retained.In addition to these positions, IMS establishes position on segments A1 and E11.

B

BKEY = B11

C

CKEY = C111

BKEY = B13

BKEY = B12

CKEY = C112

D

DKEY = D111

F

FKEY = F111

E

EKEY = E11

A

AKEY = A1

Figure 25. Multiple positioning hierarchy

94 Application Programming Guide

||||

Page 119: IMS Application Programming.pdf

The examples that follow compare the results of single and multiple positioningusing the hierarchy in Figure 26.

Table 13. Results of single and multiple positioning with DL/I calls

SequenceResult of SinglePositioning

Result of MultiplePositioning

Example 1GU (where AKEY equals A1) A1 A1GNP B B11 B11GNP C C11 C11GNP B Not found B12GNP C C12 C12GNP B Not found B13GNP C C13 C13GNP B Not found Not foundGNP C Not found Not foundExample 2GU A (where AKEY equals A1) A1 A1GN B B11 B11GN C C11 C11GN B B21 B12GN C C21 C12Example 3GU A (where AKEY equals A1) A1 A1GN C C11 C11GN B B21 B11GN B B22 B12GN C C21 C12Example 4GU A (where AKEY equals A1) A1 A1GN B B11 B11GN C C11 C11GN D D111 D111GN E E111 E111GN B B21 B12GN D D221 D112

E112D112

C13B13 B23

B12 B22C12

A1 A2

B11 C11 B21

D111 E111

C21

E121 D221 E221

Figure 26. Single and multiple positioning hierarchy

Chapter 4. Current position in the database after each call 95

|||

Page 120: IMS Application Programming.pdf

Table 13. Results of single and multiple positioning with DL/I calls (continued)

SequenceResult of SinglePositioning

Result of MultiplePositioning

GN C C under next A C12GN E E under next A E121

Multiple positioning is useful when you want to examine or compare segments intwo hierarchic paths. It lets you process different segment types under the sameparent in parallel. Without multiple positioning, you would have to issue GU callsto reestablish position in each path.

Advantages of using multiple positioningThe advantages of using multiple positioning are:v You might be able to design your program with greater data independence than

you would using single positioning. You can write application programs that useGN and GNP calls, and GU and ISRT calls with missing levels in their SSAs,independent of the relative order of the segment types being processed. If youimprove your program's performance by changing the relative order of segmenttypes and all of the application programs that access those segment types usemultiple positioning, you could make the change without affecting existingapplication programs. To do this without multiple positioning, the programwould have to use GN and GNP calls, and GU and ISRT calls with incompletelyspecified SSAs.

v Your program can process dependent segment types in parallel (it can switchback and forth between hierarchic paths without reissuing GU calls to resetposition) more efficiently than is possible with single positioning. You indicate toIMS the hierarchic path that contains the segments you want in your SSAs in thecall. IMS uses the position established in that hierarchic path to satisfy your call.The control blocks that IMS builds for each kind of positioning are the same.Multiple positioning does not require more storage, nor does it have a bigimpact on performance.

Keep in mind that multiple positioning might use more processor time than singlepositioning, and that multiple positioning cannot be used with HSAM databases.

How multiple positioning affects your programMultiple positioning affects the order and structure of your DL/I calls.

GU and ISRT: The only time multiple positioning affects GU and ISRT calls iswhen you issue these calls with missing SSAs in the hierarchic path. When youissue a GU or ISRT call that does not contain an SSA for each level in the hierarchicpath, IMS builds the SSA for the missing levels according to the current position:v If IMS has a position established at the missing level, the qualification IMS uses

is derived from that position, as reflected in the DB PCB.v If no position is established at the missing level, IMS assumes a segment type

for that level.v If IMS moves forward from a position that is established at a higher level, it

assumes a segment type for that level.

96 Application Programming Guide

Page 121: IMS Application Programming.pdf

Because IMS builds the missing qualification based on current position, multiplepositioning makes it possible for IMS to complete the qualification independent ofcurrent positions that are established for other segment types under the sameparent occurrence.

DLET and REPL with multiple positioning: Multiple positioning does not affectDLET or REPL calls; it only affects the Get Hold calls that precede them.

Qualified GN and GNP calls: When your program issues a GN or GNP call, IMStries to satisfy the call by moving forward from current position. When you usemultiple positioning, more than one current position exist: IMS maintains aposition at each level in all hierarchic paths, instead of at each level in onehierarchic path. To satisfy GN and GNP calls with multiple positioning, IMS movesforward from the current position in the path that is referred to in the SSA.

Mixing qualified and unqualified GN and GNP calls: Although multiplepositioning is intended to be used with qualified calls for parallel processing anddata independence, you may occasionally want to use unqualified calls withmultiple positioning. For example, you may want to sequentially retrieve all of thesegment occurrences in a hierarchy, regardless of segment type.

Recommendation: Limit unqualified calls to GNP calls in order to avoid inconsistentresults. Mixing qualified and unqualified SSAs may be valid for parallelprocessing, but doing so might also decrease the program's data independence.

There are three rules that apply to mixing qualified and unqualified GN and GNPcalls:1. When you issue an unqualified GN or GNP, IMS uses the position that is

established by the preceding call to satisfy the GN or GNP call. For example:

Your program issues these calls: DL/I returns these segments:

GU A (where AKEY = A1) A1

GN B B11

GN E E11

GN F111

When your program issues the unqualified GN call, IMS uses the position that isestablished by the last call, the call for the E segment, to satisfy the unqualifiedcall.

2. After you successfully retrieve a segment with an unqualified GN or GNP, IMSestablishes position in only one hierarchic path: the path containing thesegment just retrieved. IMS cancels positions in other hierarchic paths. IMSestablishes current position on the segment that is retrieved and sets parentageon the parent of the segment that is retrieved. If you issue a qualified call for asegment in a different hierarchic path after issuing an unqualified call, theresults are unpredictable. For example:

Your program issues these calls: DL/I returns these segments:

GU A (where AKEY = A1) A1

GN B B11

GN E E11

GN F111

GN B unpredictable

Chapter 4. Current position in the database after each call 97

Page 122: IMS Application Programming.pdf

When you issue the unqualified GN call, IMS no longer maintains a position inthe other hierarchic path, so the results of the GN call for the B segment areunpredictable.

3. If you issue an unqualified GN or GNP call and IMS has a position established ona segment that the unqualified call might encounter, the results of the call areunpredictable. Also, when you issue an unqualified call and you haveestablished position on the segment that the call “should” retrieve, the resultsare unpredictable.For example:

Your program issues these calls: DL/I returns these segments:

GU A (where AKEY = A1) A1

GN E E11

GN D D111

GN B B12

GN B B13

GN E11 (The only position IMS has is the oneestablished by the GN call.)

In this example, IMS has a position established on E11. An unqualified GN callmoves forward from the position that is established by the previous call.Multiple positions are lost; the only position IMS has is the position that isestablished by the GN call.

To summarize these rules:1. To satisfy an unqualified GN or GNP call, IMS uses the position established in the

last call for that PCB.2. If an unqualified GN or GNP call is successful, IMS cancels positions in all other

hierarchic paths. Position is maintained only within the path of the segmentretrieved.

Resetting position with multiple positioningTo reset position, your program issues a GU call for a root segment. If you want toreset position in the database record you are currently processing, you can issue aGU call for that root segment, but the GU call cannot be a path call.

Example: Suppose you have positions established on segments B11 and E11. Yourprogram can issue one of the calls below to reset position on the next databaserecord.

Issuing this call causes IMS to cancel all positions in database record A1:GU A�������(AKEY����=�A2)

Or, if you wanted to continue processing segments in record A1, you issue this callto cancel all positions in record A1:GU A�������(AKEY����=�A1)

Issuing this call as a path call does not cancel position.

98 Application Programming Guide

Page 123: IMS Application Programming.pdf

Multiple DB PCBsWhen a program has multiple PCBs, it usually means that you are defining viewsof several databases, but this also can mean that you need several positions in onedatabase record. Defining multiple PCBs for the same hierarchic view of a databaseis another way to maintain more than one position in a database record. Usingmultiple PCBs also extends what multiple positioning does, because with multiplePCBs you can maintain positions in two or more database records and within twoor more hierarchic paths in the same record.

Example: Suppose you were processing the database record for Patient A. Thenyou wanted to look at the record for Patient B and also be able to come back toyour position for Patient A. If your program uses multiple PCBs for the medicalhierarchy, you issue the first call for Patient A using PCB1 and then issue the nextcall, for Patient B, using PCB2. To return to Patient A's record, you issue the nextcall using PCB1, and you are back where you left off in that database record.

Using multiple PCBs can decrease the number of Get calls required to maintainposition and can sometimes improve performance. Multiple PCBs are particularlyuseful when you want to compare information from segments in two or moredatabase records. On the other hand, the internal control block requirementsincrease with each PCB that you define.

You can use the AIBTDLI interface with multiple PCBs by assigning differentPCBNAMEs to the PCBs during PSB generation. Just as multiple PCBs must havedifferent addresses in the PSB PCBLIST, multiple PCBs must have differentPCBNAMEs when using the AIBTDLI interface. For example, if your applicationprogram issues DL/I calls against two different PCBs in a list that identifies thesame database, you achieve the same effect with the AIBTDLI interface by usingdifferent PCBNAMEs on the two PCBs at PSB generation time.

Chapter 4. Current position in the database after each call 99

Page 124: IMS Application Programming.pdf

100 Application Programming Guide

Page 125: IMS Application Programming.pdf

Chapter 5. Using IMS application program sync points

As described in the topic "Synchronization Points" in IMS Version 10: SystemAdministration Guide, IMS application programs can (and should) take checkpoints.This chapter explains how these checkpoints and system sync points affect IMSoperations.

The following topics provide additional information:v “The commit process”v “Two-phase commit in the synchronization process” on page 103v “Sync-point log records” on page 105v “Sync points with a data-propagation manager” on page 106

The commit processDuring an application’s sync-point processing, IMS creates a log record to establishcommitment of database changes and availability of output messages. The commitprocess is not complete until IMS physically writes this log record to the OLDSbecause an incomplete set of database change and message records exist on the logfor system restart.

The commit processes work differently for DL/I and Fast Path applications. ForDL/I, IMS makes database changes in the buffer pool at the time of a DL/I call,and may or may not write them to disk before the commit point. If you restart thesystem, IMS backs out these uncommitted changes by using the log. IMS storesinserted message segments in the message queue and must similarly discard them.

For Fast Path, the approach is different. IMS keeps all changes in storage until itphysically logs the commit record. Only then does IMS write database changes toDASD and send output messages. Because no changes appear on external storage(except for the log) until the commit record is written, IMS does not need toperform backout processing for the database—IMS only needs to discard theupdates in storage. With Fast Path, system restart ensures that IMS writescommitted updates to DASD and sends output messages.

The following topics provide additional information:v “Relationship between checkpoints and sync points”v “Synchronization point processing in CPI Communications-driven programs” on

page 102

Relationship between checkpoints and sync pointsIMS keeps track of all checkpoints and sync points. IMS usually uses a sync pointduring recovery, but returns to the checkpoint in the following situations:v For a full recovery in the DB/DC environment, IMS returns to the earliest of

either the checkpoint prior to the current checkpoint or the checkpoint prior tothe first uncommitted application program update.

v For a full recovery in the DBCTL environment, IMS always returns to thecheckpoint before the first uncommitted application program update.

v For a full recovery in the DCCTL environment, IMS always returns to thecheckpoint before the latest system checkpoint.

© Copyright IBM Corp. 1974, 2010 101

Page 126: IMS Application Programming.pdf

v In the DB/DC or DCCTL environments, if a BUILDQ is requested on the restart,IMS returns to the last SNAPQ or DUMPQ checkpoint. IMS returns to thischeckpoint even if it is older than the checkpoint normally needed for therestart.

In Figure 27, for example, if a system-wide failure occurs in the DB/DCenvironment just after the MTO takes a system checkpoint but just before programBeta commits (assuming program Alpha has not made any updates since its lastcommit), IMS must return to the system checkpoint before Beta started.

Synchronization point processing in CPI Communications-driven programs

For CPI Communications-driven programs running under AdvancedProgram-to-Program Communications for IMS (APPC/IMS), the applicationprograms control their own sync-point processing. An application program canissue certain CPI Resource Recovery calls: SRRCMIT calls to commit data andSRRBACK calls to back out data. The IMS-managed (local) protected resourcesinclude:v IMS TM message-queue messagesv IMS DB databasesv DB2 for z/OS databases

The highest level of synchronization supported for a conversation is SYNCPT, soCPI Communications-driven applications can have protected conversations.

IMS can be either the sync-point manager or the resource manager, depending onthe setting of the sync-point level. For SYNC_LEVEL=NONE or CONFIRM, IMS isthe sync-point manager, but for SYNC_LEVEL=SYNCPT, RRS/MVS is thesync-point manager and IMS is the resource manager.

IMSstarts

ProgramA begins

ProgramA commits

IMS systemcheckpoints

ProgramB begins

Log

ProgramA ends

MTOrequests

checkpoint

IMSabends

Restart system from this checkpoint

Time

S P P S P P S

Figure 27. Independence of system checkpoints and application sync points

102 Application Programming Guide

Page 127: IMS Application Programming.pdf

Two-phase commit in the synchronization processApplication programs in a DBCTL, DCCTL, DB/DC, APPC/IMS, or OTMAenvironment can be involved in a two-phase commit process to record a syncpoint. At the completion of a two-phase commit, the resource manager commitsdatabase and message changes. The two phases are:1. Phase 1, in which the sync-point coordinator directs sync point preparation and

asks the connected resource managers whether updates to connected databasescan be committed.The sync-point coordinator can be:v An IMS DB/DC subsystem for its resource managers and attached databases.v An IMS DCCTL subsystem for attached databases.v A Coordinator Controller (CCTL) subsystem for units of work associated

with the CCTL region. IMS DB acts as a resource manager when connectedto a CCTL and also when accessed by ODBA application programs throughthe Open Database Access (ODBA) interface.

v z/OS Resource Recovery Services/MVS (RRS/MVS) for its protectedconversations with APPC/IMS applications programs or OTMA clients. IMSacts as a resource manager when connected to RRS/MVS.

2. Phase 2, in which the sync-point coordinator directs commit or abort processingand states that the resources must either be committed or aborted.In the DBCTL environment, if an application program makes no update DL/Icalls or makes only inquiry-type DL/I calls, the CCTL requests a “forget”response to Phase 1 (if forget processing has been enabled). This means thatonly a limited Phase 2 occurs for that application program because no databaseresources have been altered. See IMS Version 10: Exit Routine Reference fordetails on how to enable forget processing.The sync-point coordinator can request an abort without a Phase 1.

Figure 28 on page 104 shows the two phases of the sync-point cycle for an IMSDBCTL environment and describes the activities taking place.

Chapter 5. Using IMS application program sync points 103

Page 128: IMS Application Programming.pdf

The following topics provide additional information:v “Unit of recovery”v “DBCTL single-phase commit” on page 105

Unit of recoveryA unit of recovery (UOR) is the work done by a thread (connection between aresource-manager control region and a sync-point coordinator) during a sync-pointinterval, that is between two sync points.

In-flight unit of recoveryThe unit of recovery is said to be in-flight from its creation or its last sync pointuntil the resource manager logs the end of Phase 1. If a resource manager failsbefore or during Phase 1 and is subsequently restarted, IMS aborts all databaseupdates.

In-doubt unit of recovery for DBCTL connected to CCTLFrom the time that the resource manager issues its response to the PREPARErequest (the completion of Phase 1), to the time it receives a COMMIT or ABORT

Sync-point coordinator

Sync-point coordinatorreceives sync-pointrequest (Note 1)

Sync-point coordinatorwrites to a log

Sync-point coordinatorwrites to a log

Begins phase 1

Enters phase 1

Writes to a log

Writes to a log

Response toCOMMIT request

Response to PREPARErequest (Note 2)

COMMIT request

Retains locks

Releases locks

Begins phase 2

Enters phase 2

PREPARE requestFORGET (if CCTL issync-point coordinator)

in-flight unitof recovery

prepare

commit

in-doubt unitof recovery

commit

Resource manager

Notes:

1. If the resource manager indicates that it cannot commit the updates, thesync-point coordinator should abort the unit of recovery, and the rest of thisfigure does not apply.

2. If the sync-point coordinator tells the resource manager to commit the updates,then it must commit.

Figure 28. Two-phase commit process

104 Application Programming Guide

Page 129: IMS Application Programming.pdf

request from the CCTL, units of recovery are said to be in-doubt. When theresource manager is restarted after a failure, it tells the CCTL which in-doubtUORs exist, if any. The CCTL then takes action to resolve these in-doubt UORs.This is called resolve in-doubt processing, or resynchronization. If a CCTL cannotresolve all in-doubt UORs, you can use IMS or CCTL commands to display theunits of recovery and take appropriate actions for committing or aborting them.

Recovery tokens for DBCTL connected to CCTLA recovery token is a 16-byte identifier for each unit of recovery. The resourcemanager validates the recovery token to protect against duplication of units ofrecovery. In the DBCTL environment, you can display the recovery token using theIMS /DISPLAY CCTL command. The recovery token is the primary identifier used byDBRC, which performs unit-of-recovery management. DBRC keeps track ofbackouts that are appropriate for the Batch Backout utility to perform.

Recoverable in-doubt structure: An IMS DBCTL subsystem builds a recoverablein-doubt structure (RIS) for each in-doubt UOR when any of the following occurs:v A CCTL failsv A CCTL thread failsv A resource manager fails

The resource manager uses a recoverable in-doubt structure during reconnecting tothe CCTL if in-doubt UORs existed when either the CCTL or the resource managerfailed. IMS logs all recoverable in-doubt structures during system checkpoints.

A recoverable in-doubt structure contains the following information:v The recovery token in a residual recovery element (RRE)v Changed data records in an in-doubt extended error queue element (IEEQE)v An indication of data that is inaccessible because of unresolved in-doubt UORsv Links to other recoverable in-doubt structures using extended error queue

element (EEQE) queue elements (EQELs)

DBCTL single-phase commitA CCTL communicating with just one resource manager (IMS DBCTL subsystem)can request a sync point using just a single phase. If the CCTL communicates withmore than one resource manager, it must use the two-phase commit process.

When the CCTL decides to commit a UOR, it can request a single-phase syncpoint. Single-phase commit can affect the recoverability of in-doubt data. Atransaction is only in-doubt for the short time between the sync-point request andDBCTL’s commit. IMS can recover in-doubt data after a thread failure duringsingle-phase commit, but cannot recover in-doubt data after a subsystem failure.

Sync-point log recordsDuring the two-phase commit process, IMS creates log records to establish thecommitment of database changes (see “The commit process” on page 101). All ofthese log records can be used by the IMS Change Accumulation and recoveryutilities.

All online log records involving the sync-point cycle contain a recovery token. Thistoken ensures that IMS can recover and restart each unit of recovery. The sequenceof log records for a unit of recovery reveals the sync-point cycle that it followed.

Chapter 5. Using IMS application program sync points 105

Page 130: IMS Application Programming.pdf

IMS logs the following records during the sync-point process:

X'08' Schedule record

X'07' Unschedule (terminate) record

X'0A08' CPI Communications-driven application program schedule record

X'0A07' CPI Communications-driven application program unschedule(terminate) record

X'5937' Fast Path start commit

X'5938' Fast Path start abort

X'5610' Start of Phase 1

X'5611' End of Phase 1

X'3730' Start of Phase 2 Commit

X'5612' End of Phase 2 Commit

X'3801' Start of abort

X'4C01' End of abort

X'5607' Start unit of recovery

X'5613' Recoverable in-doubt structure created

X'5614' Recoverable in-doubt structure deleted

Sync points with a data-propagation managerWhen using a data-propagation manager (such as the IMS DataPropagator) toupdate DB2 for z/OS databases synchronously with IMS DL/I databases, theupdates to the DB2 for z/OS databases are committed (or aborted) at the sametime as the IMS updates. This provides consistency between the databasemanagement subsystems. IMS DB/DC, DCCTL, and DBCTL (BMP regions only)support the IMS Data Capture exit routine.

Restriction: In an IMS DBCTL environment, the data-propagation manager is onlyavailable for BMP regions.

For more information about the IMS DataPropagator, go to the following WebURL: http://www.ibm.com/software/data/db2imstools/imstools/imsdprop.html

106 Application Programming Guide

Page 131: IMS Application Programming.pdf

Chapter 6. Recovering databases and maintaining databaseintegrity

This chapter describes the programming tasks of issuing checkpoints, restartingprograms, and maintaining database integrity.

The following topics provide additional information:v “Issuing checkpoints”v “Restarting your program from the latest checkpoint”v “Maintaining database integrity (IMS batch, BMP, and IMS online regions)” on

page 108v “Reserving segments for the exclusive use of your program” on page 115

Issuing checkpointsTwo kinds of checkpoint (CHKP) calls exist: the basic CHKP and the symbolic CHKP.All IMS programs and CICS shared database programs can issue the basic CHKPcall; only BMPs and batch programs can use either call.

IMS Version 10: Application Programming API Reference explains when and why youshould issue checkpoints in your program. Both checkpoint calls cause a loss ofdatabase position when the call is issued, so you must reestablish position with aGU call or some other method. You cannot reestablish position in the middle of nonunique keys or nonkeyed segments.

Restriction: You must not specify CHKPT=EOV on any DD statement to take anIMS checkpoint.

Some differences exist if you issue the same call sequence against a full-functiondatabase or a DEDB, and an MSDB. For more information about the differences,see “Commit-point processing in MSDBs and DEDBs” on page 152.

Depending on the database organization, a CHKP call can result in the databaseposition for the PCB being reset. When the CHKP call is issued, the locks held by theprogram are released. Therefore, if locks are necessary for maintaining yourdatabase position, the position is reset by the CHKP call. Position is reset in all casesexcept those in which the organization is either GSAM (locks are not used) orDEDB, and the CHKP call is issued after a GC status code. For a DEDB, the positionis maintained at the unit-of-work boundary.

Issuing a CHKP resets the destination of the modifiable alternate PCB.

Related Reading: For more information on CHKP calls, see the topic "CHKP (Basic)Call" in IMS Version 10: Application Programming API Reference and the topic "CHKP(Symbolic) Call" in IMS Version 10: Application Programming API Reference.

Restarting your program from the latest checkpointIf you use basic checkpoints instead of symbolic checkpoints, provide the necessarycode to restart the program from the latest checkpoint if the program terminatesabnormally.

© Copyright IBM Corp. 1974, 2010 107

Page 132: IMS Application Programming.pdf

One way to restart the program from the latest checkpoint is to store repositioninginformation in a HDAM or PHDAM database. With this method, your programwrites a database record containing repositioning information to the database eachtime a checkpoint is issued. Before your program terminates, it should delete thedatabase record.

For more information on the XRST call, see the topic "XRST Call" in IMS Version 10:Application Programming API Reference.

Maintaining database integrity (IMS batch, BMP, and IMS onlineregions)

IMS uses these DL/I calls to back out database updates: ROLB, ROLL, ROLS, SETS, andSETU. The ROLB and ROLS calls can back out the database updates or cancel theoutput messages that the program has created since the program's most recentcommit point. A ROLL call backs out the database updates and cancels anynon-express output messages the program has created since the last commit point.It also deletes the current input message. SETS allows multiple intermediatebackout points to be noted during application program processing. SETU operateslike SETS except that it is not rejected by unsupported PCBs in the PSB. If yourprogram issues a subsequent ROLS call specifying one of these points, databaseupdates and message activity performed since that point are backed out.

CICS online programs with DBCTL can use the ROLS and SETS or SETU DL/I callsto back out database changes to a previous commit point or to an intermediatebackout point.

Backing out to a prior commit point: ROLL, ROLB, and ROLSWhen a program determines that some of its processing is invalid, some callsenable the program to remove the effects of its incorrect processing. These are theRoll Back calls: ROLL, ROLS using a DB PCB (or ROLS without an I/O area or token),and ROLB. When you issue one of these calls, IMS:v Backs out the database updates that the program has made since the program's

most recent commit point.v Cancels the non-express output messages that the program has created since the

program's most recent commit point.

The main difference between these calls is that ROLB returns control to theapplication program after backing out updates and canceling output messages,ROLS does not return control to the application program, and ROLL terminates theprogram with an abend code of U0778. ROLB can return the first message segmentto the program since the most recent commit point, but ROLL and ROLS cannot.

The ROLL and ROLB calls, and the ROLS call without a specified token, are validwhen the PSB contains PCBs for GSAM data sets. However, segments inserted inthe GSAM data sets since the last commit point are not backed out by these calls.An extended checkpoint-restart can be used to reposition the GSAM data setswhen restarting.

You can use a ROLS call either to back out to the prior commit point or to back outto an intermediate backout point that was established by a prior SETS call. Thissection refers only to the form of the ROLS call that backs out to the prior commitpoint. For information about the other form of ROLS, see “Backing out to anintermediate backout point: SETS, SETU, and ROLS” on page 112.

108 Application Programming Guide

Page 133: IMS Application Programming.pdf

Table 14 summarizes the similarities and the differences between the ROLB, ROLL,and ROLS calls.

Table 14. Comparison of ROLB, ROLL, and ROLS

Actions Taken: ROLB ROLL ROLS

Back out database updates since the last commit point. X X X

Cancel output messages created since the last commit point. X1 X1 X1

Delete from the queue the message in process. Previousmessages (if any) processed since the last commit point arereturned to the queue to be reprocessed.

X

Return the first segment of the first input message issuedsince the most recent commit point.

X2

U3303 abnormal termination. Returns the processed inputmessages to the message queue.

X3

U0778 abnormal termination. No dump. X

No abend. Program continues processing. X

Notes:

1. ROLB, ROLL, or ROLS calls cancel output messages that are sent with an express PCBunless the program issued a PURG. For example, if the program issues the call sequencethat follows, MSG1 would be sent to its destination because PURG tells IMS that MSG1 iscomplete and the I/O area now contains the first segment of the next message (which inthis example is MSG2). MSG2, however, would be canceled.

ISRT EXPRESS PCB, MSG1PURG EXPRESS PCB, MSG2ROLB I/O PCB

Because IMS has the complete message (MSG1) and because an express PCB is beingused, the message can be sent before a commit point.

2. Returned only if you supply the address of an I/O area as one of the call parameters.

3. The transaction is suspended and requeued for subsequent processing.

ROLLA ROLL call backs out the database updates and cancels any non-express outputmessages the program has created since the last commit point. It also deletes thecurrent input message. Any other input messages that were processed since thelast commit point are returned to the queue to be reprocessed. IMS then terminatesthe program with an abend code U0778. This type of abnormal terminationterminates the program without a storage dump.

When you issue a ROLL call, the only parameter you supply is the call function,ROLL.

You can use the ROLL call in a batch program. If your system log is on DASD, andif dynamic backout has been specified through the use of the BKO executionparameter, database changes made since the last commit point will be backed out;otherwise they will not. One reason for issuing ROLL in a batch program is forcompatibility.

After backout is complete, the original transaction is discarded if it can be, and it isnot re-executed. IMS issues the APPC/MVS verb, ATBCMTP TYPE(ABEND),specifying the TPI to notify remote transaction programs. Issuing the APPC/MVSverb causes all active conversations (including any that are spawned by theapplication program) to be DEALLOCATED TYP(ABEND_SVC).

Chapter 6. Recovering databases and maintaining database integrity 109

Page 134: IMS Application Programming.pdf

ROLBThe advantage of using a ROLB call is that IMS returns control to the program afterexecuting a ROLB call, so the program can continue processing. The parameters forthe ROLB call are:v The call function, ROLBv The name of the I/O PCB or AIB

The total effect of the ROLB call depends on the type of IMS application programthat issued it.v For current IMS application programs:

After IMS backout is complete, the original transaction is represented to the IMSapplication program. Any resources that cannot be rolled back by IMS areignored; for example, output that is sent to an express alternate PCB and a PURGcall that is issued before the ROLB call.

v For modified IMS application programs:The same consideration for the current IMS application program applies. Theapplication program must notify any spawned conversations that a ROLB wasissued.

v For CPI-C driven IMS application programs:Only IMS resources are affected. All database changes are backed out. Anymessages that are inserted to non-express alternate PCBs are discarded. Also,any messages that are inserted to express PCBs that have not had a PURG call arediscarded. The application program must notify the originating remote programand any spawned conversations that a ROLB call was issued.

MPPs and transaction-oriented BMPs: If the program supplies the address of anI/O area as one of the ROLB parameters, the ROLB call acts as a message retrievalcall and returns the first segment of the first input message issued since the mostrecent commit point. This is true only if the program has issued a GU call to themessage queue since the last commit point; it if has not, it was not processing amessage when it issued the ROLB call.

If the program issues GN call to the message queue after issuing a ROLB call, IMSreturns the next segment of the message that was being processed when the ROLBcall was issued. If no more segments exist for that message, IMS returns a QDstatus code.

If the program issues a GU call to the message queue after the ROLB call, IMSreturns the first segment of the next message to the application program. If nomore messages exist on the message queue for the program to process, IMS returnsa QC status code.

If you include the I/O area parameter, but you have not issued a successful GU callto the message queue since the last commit point, IMS returns a QE status code toyour program.

If you do not include the address of an I/O area in the ROLB call, IMS does thesame thing for you. If the program has issued a successful GU call in the commitinterval and then issues a GN call, IMS returns a QD status code. If the programissues a GU call after the ROLB call, IMS returns the first segment of the nextmessage or a QC status code, if no more messages exist for the program.

110 Application Programming Guide

Page 135: IMS Application Programming.pdf

If you have not issued a successful GU call since the last commit point, and you donot include an I/O area parameter on the ROLB call, IMS backs out the databaseupdates and cancels the output messages that were created since the last commitpoint.

Batch programs: If your system log is on DASD, and if dynamic backout hasbeen specified through the use of the BKO execution parameter, you can use theROLB call in a batch program. The ROLB call does not process messages as it does forMPPs; it backs out the database updates made since the last commit point andreturns control to your program. You cannot specify the address of an I/O area asone of the parameters on the call; if you do, an AD status code is returned to yourprogram. You must, however, have an I/O PCB for your program. SpecifyCMPAT=YES on the CMPAT keyword in the PSBGEN statement for yourprogram's PSB.

Related reading: For more information on using the CMPAT keyword, see IMSVersion 10: System Utilities Reference. For information on coding the ROLB call, seethe topic "ROLB command" in IMS Version 10: Application Programming APIReference.

ROLSYou can use the ROLS call in two ways to back out to the prior commit point andreturn the processed input messages to IMS for later reprocessing:v Have your program issue the ROLS call using the I/O PCB but without an I/O

area or token in the call. The parameters for this form of the ROLS call are:The call function, ROLSThe name of the I/O PCB or AIB

v Have your program issue the ROLS call using a database PCB that has receivedone of the data-unavailable status codes. This has the same result as ifunavailable data were encountered and the INIT call was not issued. A ROLS callmust be the next call for that PCB. Intervening calls using other PCBs arepermitted.

On a ROLS call with a TOKEN, message queue repositioning can occur for allnon-express messages, including all messages processed by IMS. The processinguses APPC/MVS calls, and includes the initial message segments. The originalinput transaction can be represented to the IMS application program. Input andoutput positioning is determined by the SETS call. This positioning applies tocurrent and modified IMS application programs but does not apply to CPI-Cdriven IMS programs. The IMS application program must notify all remotetransaction programs of the ROLS.

On a ROLS call without a TOKEN, IMS issues the APPC/MVS verb, ATBCMTPTYPE(ABEND), specifying the TPI. Issuing this verb causes all conversationsassociated with the application program to be DEALLOCATEDTYPE(ABEND_SVC). If the original transaction is entered from an LU 6.2 deviceand IMS receives the message from APPC/MVS, a discardable transaction isdiscarded rather than being placed on the suspend queue like a non-discardabletransaction. See IMS Version 10: Communications and Connections Guide for moreinformation on LU 6.2.

The parameters for this form of the ROLS call are:v The call function, ROLSv The name of the DB PCB that received the BA or BB status code

Chapter 6. Recovering databases and maintaining database integrity 111

Page 136: IMS Application Programming.pdf

In both of the these parameters, the ROLS call causes a U3303 abnormal terminationand does not return control to the application program. IMS keeps the inputmessage for future processing.

Backing out to an intermediate backout point: SETS, SETU,and ROLS

You can use a ROLS call either to back out to an intermediate backout point thatwas established by a prior SETS or SETU call, or to back out to the prior commitpoint. This section refers only to the form of ROLS that backs out to theintermediate backout point. For information about the other form of ROLS, see“Backing out to a prior commit point: ROLL, ROLB, and ROLS” on page 108.

The ROLS call that backs out to an intermediate point backs out only DL/I changes.This version of the ROLS call does not affect CICS changes that use CICS file controlor CICS transient data.

The SETS and ROLS calls set intermediate backout points within the call processingof the application program and then backout database changes to any of thesepoints. Up to nine intermediate backout points can be set. The SETS call specifies atoken for each point. IMS then associates this token with the current processingpoint. A subsequent ROLS call using the same token backs out all database changesand discards all non-express messages that were performed after the SETS call withthe same token. Figure 29 shows how the SETS and ROLS calls work together.

In addition, to assist the application program in managing other variables that itmay wish to reestablish after a ROLS call, user data can be included in the I/O areaof the SETS call. This data is then returned when the ROLS call is issued with thesame token.

Program starts

SETS Token=n

GHUREPLISTR MSG1-Segment 1 to I/O PCB

SETS Token=B

GHUDLETISRT MSG1-Segment 2 to I/O PCB

ROLS Token=B

Backs outprogram toSETS Token=B

Figure 29. SETS and ROLS calls working together

112 Application Programming Guide

Page 137: IMS Application Programming.pdf

SETS and SETU callsThe SETS call sets up to nine intermediate backout points or cancels all existingbackout points. With the SETS call, you can back out pieces of work. If thenecessary data to complete one piece of work is unavailable, you can complete adifferent piece of work and then return to the former piece.

To set an intermediate backout point, issue the call using the I/O PCB, and includean I/O area and a token. The I/O area has the format LLZZuser-data, where LL isthe length of the data in the I/O area including the length of the LLZZ portion.The ZZ field must contain binary zeros. The data in the I/O area is returned to theapplication program on the related ROLS call. If you do not want to save some ofthe data that is to be returned on the ROLS call, set the LL that defines the length ofthe I/O area to 4.

For PLITDLI, you must define the LL field as a fullword rather than a halfword, asit is for the other languages. The content of the LL field for PLITDLI is consistentwith the I/O area for other calls using the LLZZ format. The content is the totallength of the area, including the length of the 4-byte LL field, minus 2.

A 4-byte token associated with the current processing point is also required. Thistoken can be a new token for this program execution, or it can match a token thatwas issued by a preceding SETS call. If the token is new, no preceding SETS callsare canceled. If the token matches the token of a preceding SETS call, the currentSETS call assumes that position. In this case, all SETS calls that were issuedsubsequent to the SETS call with the matching token are canceled.

The parameters for this form of the SETS call are:v The call function, SETSv The name of the I/O PCB or AIBv The name of the I/O area containing the user datav The name of an area containing the token

For the SETS call format, see the topic "SETS/SETU Call" in IMS Version 10:Application Programming API Reference.

To cancel all previous backout points, the call is issued using the I/O PCB butdoes not include an I/O area or a token. When an I/O area is not included in thecall, all intermediate backout points that were set by prior SETS calls are canceled.

The parameters for this form of the SETS call are:v The call function, SETSv The name of the I/O PCB or AIB

Because it is not possible to back out committed data, commit-point processingcauses all outstanding SETS to be canceled.

If PCBs for DEDB, MSDB, and GSAM organizations are in the PSB, or if theprogram accesses an attached subsystem, a partial backout is not possible. In thatcase, the SETS call is rejected with an SC status code. If the SETU call is usedinstead, it is not rejected because of unsupported PCBs, but will return an SCstatus code as a warning that the PSB contains unsupported PCBs and that thefunction is not applicable to these unsupported PCBs.

Chapter 6. Recovering databases and maintaining database integrity 113

Page 138: IMS Application Programming.pdf

Related reading: For status codes that are returned after the SETS call, see IMSVersion 10: Application Programming API Reference. For explanations of those statuscodes and the response required, see IMS Version 10: Application Programming APIReference.

ROLSThe ROLS call backs out database changes to a processing point set by a previousSETS or SETU call, or to the prior commit point. The ROLS call then returns theprocessed input messages to the message queue.

To back out database changes and message activity that have occurred since aprior SETS call, issue the ROLS call using the I/O PCB, and specify an I/O area andtoken in the call. If the token does not match a token that was set by a precedingSETS call, an error status is returned. If the token matches the token of a precedingSETS call, the database updates made since this corresponding SETS call are backedout, and all non-express messages that were inserted since the corresponding SETSare discarded. SETS that are issued as part of processing that was backed out arecanceled. The existing database positions for all supported PCBs are reset.

If a ROLS call is in response to a SETU call, and if there are unsupported PCBs(DEDB, MSDB, or GSAM) in the PSB, the position of the PCBs is not affected. Thetoken specified by the ROLS call can be set by either a SETS or SETU call. If nounsupported PCBs exist in the PSB, and if the program has not used an attachedsubsystem, the function of the ROLS call is the same regardless of whether the tokenwas set by a SETS or SETU call.

If the ROLS call is in response to a SETS call, and if unsupported PCBs exist in thePSB or the program used an attached subsystem when the preceding SETS call wasissued, the SETS call is rejected with an SC status code. The subsequent ROLS call iseither rejected with an RC status code, indicating unsupported options, or it isrejected with an RA status code, indicating that a matching token that was set by apreceding successful SETS call does not exist.

If the ROLS call is in response to a SETU call, the call is not rejected because ofunsupported options. If unsupported PCBs exist in the PSB, this is not reflectedwith a status code on the ROLS call. If the program is using an attached subsystem,the ROLS call is processed, but an RC status is returned as a warning indicating thatif changes were made using the attached subsystem, those changes were notbacked out.

The parameters for this form of the ROLS call are:v The call function, ROLSv The name of the I/O PCB or AIBv The name of the I/O area to receive the user datav The name of an area containing the 4-byte token

Related reading: For status codes that are returned after the ROLS call, see IMS:Messages and Codes Reference, Volume 4: IMS Component Codes. For explanations ofthose status codes and the response required, see IMS: Messages and Codes Reference,Volume 4: IMS Component Codes.

114 Application Programming Guide

Page 139: IMS Application Programming.pdf

Reserving segments for the exclusive use of your programYou may want to reserve a segment and prohibit other programs from updatingthe segment while you are using it. To some extent, IMS does this for you throughresource lock management. The Q command code lets you reserve segments in adifferent way.

Restriction: The Q command code is not supported for MSDB organizations or fora secondary index that is processed as a database.

Resource lock management and the Q command code both reserve segments foryour program's use, but they work differently and are independent of each other.To understand how and when to use the Q command code and the DEQ call, youmust understand resource lock management.

The function of resource lock management is to prevent one program fromaccessing data that another program has altered until the altering program reachesa commit point. Therefore, you know that if you have altered a segment, no otherprogram (except those using the GO processing option) can access that segmentuntil your program reaches a commit point. For database organizations thatsupport the Q command code, if the PCB processing option allows updates andthe PCB holds position in a database record, no other program can access thedatabase record.

The Q command code allows you to prevent other programs from updating asegment that you have accessed, even when the PCB that accessed the segmentmoves to another database record.

Related reading: For more information on the Q command code, see the topic "QCommand Code" in IMS Version 10: Application Programming API Reference.

Chapter 6. Recovering databases and maintaining database integrity 115

Page 140: IMS Application Programming.pdf

116 Application Programming Guide

Page 141: IMS Application Programming.pdf

Chapter 7. Secondary indexing and logical relationships

This chapter describes two ways in which IMS can provide flexibility in how yourprogram views the data. Secondary indexing and logical relationships aretechniques that can change your application program's view of the data. The DBAmakes the decision about whether to use these options. Examples of when you usethese techniques are:v If an application program must access a segment type in a sequence other than

the sequence specified by the key field, secondary indexing can be used.Secondary indexing also can change the application program's access to or viewof the data based on a condition in a dependent segment.

v If an application program requires a logical structure that contains segmentsfrom different databases, logical relationships are used.

The following topics provide additional information:v “How secondary indexing affects your program”v “Processing segments in logical relationships” on page 121

How secondary indexing affects your programOne instance of using a secondary index occurs when an application programneeds to select database records in a sequence other than that defined by the rootkey. IMS stores root segments in the sequence of their key fields. A program thataccesses root segments out of the order of their key fields cannot operateefficiently.

You can index any field in a segment by defining an XDFLD statement for the fieldin the DBD for the database. If the Get call is not qualified on the key but usessome other field, IMS must search all the database records to find the correctrecord. With secondary indexing, IMS can go directly to a record based on a fieldvalue that is not in the key field. This section explains how secondary indexingaffects your programming.

For more information about secondary indexes and examples, see IMS Version 10:Database Administration Guide.

SSAs with secondary indexes

If your program uses a secondary index, you can use the name of an indexed fieldin your SSAs. When you do this, IMS goes directly to the secondary index andfinds the pointer segment with the value you specify. Then IMS locates thesegment that the index segment points to in the database and returns the segmentto your program.

To use an indexed field name in the SSA, follow these guidelines:v Define the indexed field, using the XDFLD statement, in the DBD for the

primary database during DBD generation.v Use the name that was given on the XDFLD statement as the field name in the

qualification statement.

© Copyright IBM Corp. 1974, 2010 117

Page 142: IMS Application Programming.pdf

v Specify the secondary index as the processing sequence during PSB generation.Do this by specifying the name of the secondary index database on thePROCSEQ parameter on the PCB during PSB generation.

Related reading: For more detailed information about generating a DBD and aPSB, refer to the IMS Version 10: System Utilities Reference.

If you modify the XDFLD of the indexed segment (using the REPL call), you loseany parentage that you had established before issuing the REPL call. The keyfeedback area is no longer valid after a successful REPL call.

Example: For you to index the PATIENT segment on the NAME field, the segmentmust have been defined on the XDFLD statement in the DBD for the medicaldatabase. If the name of the secondary index database is INDEX, you specifyPROCSEQ=INDEX in the PCB. To issue a qualification that identifies a PATIENTby the NAME field instead of by PATNO, use the name that you specified on theXDFLD statement. If the name of the XDFLD is XNAME, use XNAME in the SSA,as follows:

In the DBD: XDFLD NAME=XNAME

In the PSB: PROCSEQ=INDEX

In the program:GU PATIENT�(XNAME���=�JBBROKE���)

Multiple qualification statements with secondary indexesWhen you qualify a call using the name of an indexed field, you can includemultiple qualification statements. You can use two AND operators to connect thequalification statements:

* or & When used with secondary indexing, this AND is called thedependent AND. To satisfy the call, IMS scans the index once andsearches for one pointer segment in the index that satisfies bothqualification statements.

# This is called the independent AND. You use it only withsecondary indexing. When you use the independent AND tosatisfy the call, IMS scans the index twice and searches for two ormore different pointer segments in the index that point to the sametarget segment.

The distinction between the two ANDs applies only when the indexed field (theone defined as XDFLD in the DBD) is used in all qualifications. If one of thequalification statements uses another field, both ANDs work like the dependentAND.

The next two sections give examples of the dependent and independent AND.Although the examples show only two qualification statements in the SSA, you canuse more than two. No set limit exists for the number of qualification statementsyou can include in an SSA, but a limit on the maximum size of the SSA does exist.You specify this size on the SSASIZE parameter of the PSBGEN statement. Forinformation on this parameter, see IMS Version 10: System Utilities Reference.

The dependent ANDWhen you use the dependent AND, IMS scans the index only once. To satisfy thecall, it must find one pointer segment that satisfies both qualification statements.

118 Application Programming Guide

Page 143: IMS Application Programming.pdf

Example: Suppose you want to list patients whose bills are between $500 and$1000. To do this, you index the PATIENT segment on the BILLING segment, andspecify that you want IMS to use the secondary index as the processing sequence.Figure 30 shows the three secondary indexing segments.

You then use this call:GU PATIENT (XBILLING>=00500*XBILLING<=01000)

To satisfy this call, IMS searches for one pointer segment with a value between 500and 1000. IMS returns the PATIENT segment that is pointed to by that segment.

The independent ANDExample: Suppose you want a list of the patients who have had both tonsillitis andstrep throat. To get this information, you index the PATIENT segment on theILLNAME field in the ILLNESS segment, and specify that you want IMS to use thesecondary index as the processing sequence. In this example, you retrieve thePARENT segments based on a dependent's (the ILLNESS segment's) qualification.Figure 31 shows the four secondary indexing segments.

Targetsegment

Sourcesegment

INDEX

PATIENT

BILLING

Pointersegments

XDFLD=XBILLING

XBILLING=1200

XBILLING=700

XBILLING=450

Figure 30. Example of using the dependent AND

Targetsegment

Sourcesegment

INDEX

PATIENT

ILLNESS

Pointersegments XILLNAME=TONSILITIS

XILLNAME=STREPTHRT

XILLNAME=MEASLES

XILLNAME=FLU

Figure 31. Example of using the independent AND

Chapter 7. Secondary indexing and logical relationships 119

Page 144: IMS Application Programming.pdf

You want IMS to find two pointer segments in the index that point to the samePATIENT segment, one with ILLNAME equal to TONSILLITIS and one withILLNAME equal to STREPTHRT. Use this call:GU PATIENT�(XILLNAME=TONSILITIS#XILLNAME=�STREPTHRT)

This call retrieves the first PATIENT segment with ILLNESS segments of strepthroat and tonsillitis. When you issue the call, IMS searches for an index entry fortonsillitis. Then it searches for an index entry for strep throat that points to thesame PATIENT segment.

When you use the independent AND with GN and GNP calls, a special situation canoccur. If you repeat a GN or a GNP call using the same qualification, it is possible forIMS to return the same segment to your program more than once. You can checkto find out whether IMS has already returned a segment to you by checking thekey feedback area.

If you continue issuing a GN call until you receive a not-found (GE) status code,IMS returns a segment occurrence once for each independent AND group. WhenIMS returns a segment that is identical to one that was already returned, the PCBkey feedback area is different.

DL/I returns with secondary indexesThe PATIENT segment that IMS returns to the application program's I/O arealooks just as it would if you had not used secondary indexing. The key feedbackarea, however, contains something different. The concatenated key that IMS returnsis the same, except that, instead of giving you the key for the segment yourequested (the key for the PATIENT segment), IMS gives you the search portion ofthe key of the secondary index (the key for the segment in the INDEX database).

The term “key of the pointer segment” refers to the key as perceived by theapplication program. That is, the key does not include subsequent fields. IMSplaces this key in the position where the root key would be located if you had notused a secondary index—in the left-most bytes of the key feedback area. The IMSVersion 10: Application Programming Planning Guide gives some examples of this.

If you try to insert or replace a segment that contains a secondary index sourcefield that is a duplicate of one that is already reflected in the secondary index, IMSreturns an NI status code. An NI status code is returned only for batch programsthat log to direct-access storage. Otherwise, the application program is abnormallyterminated. You can avoid having your program terminated by making sure aduplicate index source field does not exist. Before inserting a segment, try toretrieve the segment using the secondary index source field as qualification.

Status codes for secondary indexesIf a secondary index is defined for a segment and if the definition specifies aunique key for the secondary index (most secondary indexes allow duplicate keys),your application program might receive the NI status code in addition to regularstatus codes. This status code can be received for a PCB that either uses or doesnot use the secondary index as a processing sequence. See IMS: Messages and CodesReference, Volume 4: IMS Component Codes for additional information about the NIstatus code.

120 Application Programming Guide

Page 145: IMS Application Programming.pdf

Processing segments in logical relationshipsSometimes an application program needs to process a hierarchy that is made up ofsegments that already exist in two or more separate database hierarchies. Logicalrelationships make it possible to establish hierarchic relationships between thesesegments. When you use logical relationships, the result is a new hierarchy—onethat does not exist in physical storage but that can be processed by applicationprograms as though it does exist. This type of hierarchy is called a logicalstructure.

One advantage of using logical relationships is that programs can access the dataas though it exists in more than one hierarchy, even though it is only stored in oneplace. When two application programs need to access the same segment throughdifferent paths, an alternative to using logical relationships is to store the segmentin both hierarchies. The problem with this approach is that you must update thedata in two places to keep it current.

Processing segments in logical relationships is not very different from processingother segments. This section uses the example about an inventory applicationprogram that processes data in a purchasing database, but which also needs accessto a segment in a patient database.

Related Reading:

v For more information about application programming requirements that logicalrelationships can satisfy, see IMS Version 10: Application Programming PlanningGuide.

v For a full description of the inventory application program example, see IMSVersion 10: Application Programming Planning Guide.

Example: The hierarchy that an inventory application program needs to processcontains four segment types:v An ITEM segment containing the name and an identification number of a

medication that is used at a medical clinicv A VENDOR segment that contains the name and address of the vendor who

supplies the itemv A SHIPMENT segment that contains information such as quantity and date for

each shipment of the item that the clinic receivesv A DISBURSE segment that contains information about the disbursement of the

item at the clinic, such as the quantity, the date, and the doctor who prescribedit

The TREATMNT segment in the medical database used throughout this sectioncontains the same information that the inventory application program needs toprocess in the DISBURSE segment. Rather than store this information in bothhierarchies, you can store the information in the TREATMNT segment, and definea logical relationship between the DISBURSE segment in the item hierarchy andthe TREATMNT segment in the patient hierarchy. Doing this makes it possible toprocess the TREATMNT segment through the item hierarchy as though it is a childof SHIPMENT. DISBURSE then has two parents: SHIPMENT is DISBURSE'sphysical parent, and TREATMNT is DISBURSE's logical parent.

Three segments are involved in this logical relationship: DISBURSE, SHIPMENT,and TREATMNT. Figure 32 on page 122 shows the item hierarchy on the right. TheDISBURSE segment points to the TREATMNT segment in the patient hierarchy

Chapter 7. Secondary indexing and logical relationships 121

Page 146: IMS Application Programming.pdf

shown on the left. (The patient hierarchy is part of the medical database.)

Three types of segments are found in a logical relationship:v TREATMNT is called the logical parent segment. It is a physical dependent of

ILLNESS, but it can be processed through the item hierarchy because a path isestablished by the logical child segment DISBURSE. The logical parent segmentcan be accessed through both hierarchies, but it is stored in only one place.

v SHIPMENT is called a physical parent segment. The physical parent is theparent of the logical child in the physical database hierarchy.

v DISBURSE is called a logical child segment. It establishes a path to theTREATMNT segment in the PATIENT hierarchy from the SHIPMENT segmentin the ITEM hierarchy.

Because a logical child segment points to its logical parent, two paths exist throughwhich a program can access the logical parent segment:v When a program accesses the logical parent segment through the physical path,

it reaches this logical parent segment through the segment's physical parent.Accessing the TREATMNT segment through ILLNESS is accessing the logicalparent segment through its physical path.

v When a program accesses the logical parent segment through the logical path, itreaches this logical parent segment through the segment's logical child.Accessing the TREATMNT segment through SHIPMENT is accessing the logicalparent segment through its logical path.

When a logical parent segment is accessed through the logical child, the logicalchild is concatenated with both the data from its logical parent segment and anydata the user has chosen to associate with this pairing (intersection data) in asingle segment I/O area, like this:

LL is the length field of the logical parent if this segment is a variable-lengthsegment.

PATIENT

ILLNESS

TREATMNT

ITEM

VENDOR

SHIPMENT

DISBURSE

Figure 32. Patient and item hierarchies

CONCATENATED KEY DATA(LL)INTERSECTION DATA

LOGICAL CHILD LOGICAL PARENT

OFFSET

Figure 33. Concatenated segment

122 Application Programming Guide

Page 147: IMS Application Programming.pdf

How logical relationships affect your programmingThe calls you issue to process segments in logical relationships are the same callsthat you use to process other segments. However, the processing is differentdepending on how the logical segment looks in your I/O area, what the DB PCBmask contains after a retrieve call, and how you can replace, delete, and insertphysical and logical parent segments. Because it is possible to access segments inlogical relationships through the logical path or the physical path, the segmentsmust be protected from being updated by unauthorized programs.

When DBAs define logical relationships, they define a set of rules that determinehow the segments can be deleted, replaced, and inserted. Defining these rules is adatabase design decision. If your program processes segments in logicalrelationships, the DBA (or the person at your installation responsible for databasedesign) should tell you:v What segments look like in your I/O area when you retrieve themv Whether your program is allowed to update and insert segmentsv What to do if you receive a DX, IX, or RX status code

The requirements for inserting a logical child segment are:v In load mode, the logical child can be inserted only under its physical parent.

You do not supply the logical parent in the I/O area.v In update mode, the format of the logical child is different, depending on

whether it is accessed from its physical parent or from its logical parent.– If accessed from its physical parent, the logical child's format is the

concatenated key of the logical parent followed by intersection data.– If accessed from its logical parent, the logical child's format is the

concatenated key of the physical parent, followed by intersection data.v The logical child can be inserted or replaced, depending on the insert rule for

the logical or physical parent. Unless the insert rule of the logical or physicalparent is PHYSICAL, the logical or physical parent must be supplied in the I/Oarea following the logical child, as illustrated in Figure 33 on page 122.

Status codes for logical relationshipsThese status codes apply specifically to segments that are involved in logicalrelationships. These are not all of the status codes that you can receive whenprocessing a logical child segment or a physical or logical parent. If you receiveone of these status codes, it means that you are trying to update the database in away that you are not allowed to. Check with the DBA or person responsible forimplementing logical relationships at your installation to find out what theproblem is.

DX IMS did not delete the segment because the physical delete rule wasviolated. If the segment is a logical parent, it still has active logicalchildren. If the segment is a logical child, it has not been deleted throughits logical path.

IX You tried to insert either a logical child segment or a concatenatedsegment. If it was a logical child segment, the corresponding logical orphysical parent segment does not exist. If it was a concatenated segment,either the insert rule was physical and the logical or physical parent doesnot exist, or the insert rule is virtual and the key of the logical or physicalparent in the I/O area does not match the concatenated key of the logicalor physical parent.

RX The physical replace rule has been violated. The physical replace rule was

Chapter 7. Secondary indexing and logical relationships 123

Page 148: IMS Application Programming.pdf

specified for the destination parent, and an attempt was made to change itsdata. When a destination parent has the physical replace rule, it can bereplaced only through the physical path.

124 Application Programming Guide

Page 149: IMS Application Programming.pdf

Chapter 8. HALDB selective partition processing

You can restrict the processing of DL/I calls to a single HALDB partition or arange of HALDB partitions by using a DD statement with the ddname DFSHALDBto pass control statements. DFS HALDB must be provided in the JCL of the batchjob, the BMP (Batch Message Processing dependent online region), or the JBP (JavaBatch Processing dependent online region).

The following topics provide more about information about HALDB selectivepartition processing:v “Control Statements for HALDB selective partition processing”v “Parameter descriptions for HALDB selective partition processing”v “Examples of HALDB selective partition processing statements” on page 126v “Report generated for HALDB selective partition processing” on page 126

Control Statements for HALDB selective partition processing

�� HALDB PCB= ( nnnn ,ppppppp )dddddddd NUM=yyy

��

Each HALDB control statement must have a PCB keyword that contains therequired parameters. The required parameters for an individual control statementmust be on one line; no continuation is allowed. The input can consist of multipleHALDB control statements. There should be no duplication of DB PCB numbers.In the event of a duplication, the control statement that has been read the mostrecently overrides the previous statement.

Any HALDB control statement that is syntactically correct results in an entrywithin a table. The maximum number of entries in the table is 20. All subsequentstatements that are read, even though syntactically correct, are ignored and resultin a U0201 abend, unless a statement is a duplicate of an entry that is already inthe table.

Parameter descriptions for HALDB selective partition processingnnnn

The DB PCB number as the relative number of the DB PCB defined in the PSB.

ddddddddThe DB PCB label or name.

pppppppThe partition name. This parameter is required.

NUM=yyyThe range of consecutive partitions that this PCB is restricted to using, startingwith the named partition. The range of consecutive partitions is defined as thepartition selection order, which is the next partition selected starting from thetarget partition named in the DFSHALDB statement. The next partition is

© Copyright IBM Corp. 1974, 2010 125

||

|

|||||

Page 150: IMS Application Programming.pdf

determined using either the high keys defined for the HALDB or theprocessing order defined by the partition selection exit. This parameter isoptional.

Examples of HALDB selective partition processing statementsFigure 34 and Figure 35 show different examples of using HALDB selectivepartition processing statements.

Report generated for HALDB selective partition processingWhen you use HALDB selective partition processing, a report called “HALDBSelective Partition Processing” is generated in the the SYSHALDB data set. Thisreport shows the control statements that have been issued and the reason foraccepting or rejecting each statement. Control statements that have been validatedand accepted are shown as “Syntactically correct.” Other messages that mightappear for syntactically correct statements, and their accompanying messages, areshown in Table 15:

Table 15. Messages provided in the report generated for HALDB selective partitionprocessing

Message Explanation

Duplicate, overrides previous statement A HALDB statement for the same PCB wasalready found. The current statementoverrides the previous HALDB statement.

HALDB PCB=(4,POHIDKA)HALDB PCB=(PCBNUM2,POHIDJA)

Figure 34. DFSHALDB for single partition restriction

HALDB PCB=(3,PVHDJ5A,NUM=4)HALDB PCB=(PCBNUM7,PVHDJ5B,NUM=3)

Figure 35. DFSHALDB for range partition restriction

PRINT NOGENPCB TYPE=DB,DBDNAME=G1CSTP,PROCOPT=A,KEYLEN=100,PCBNAME=XXCSTPSENSEG NAME=CUSTOMERSENSEG NAME=DISTRICT,PARENT=CUSTOMERSENSEG NAME=CUSTLOCN,PARENT=CUSTOMERSENSEG NAME=ADDRLINE,PARENT=CUSTLOCNSENSEG NAME=CUSTORDN,PARENT=CUSTLOCNSENSEG NAME=CUSTINVN,PARENT=CUSTOMERSENSEG NAME=PAYMENTS,PARENT=CUSTOMERSENSEG NAME=ADJUSTMT,PARENT=CUSTOMER

PCB TYPE=DB,DBDNAME=G1CSTP,PROCOPT=A,KEYLEN=100,PCBNAME=IICSTP,PROCSEQ=CSTCY02

SENSEG NAME=CUSTOMER

PSBGEN LANG=ASSEM,PSBNAME=G1ACSTP,CMPAT=YESEND

Figure 36. DFSHALDB for independent processing of partitions

126 Application Programming Guide

|||||

||||||||||||||||||||||||||

|||

|

|||

||

|

Page 151: IMS Application Programming.pdf

Table 15. Messages provided in the report generated for HALDB selective partitionprocessing (continued)

Message Explanation

Ignored, number of valid statements exceeds20

More than 20 HALDB statements wereprovided, but only 20 statements areallowed. Reduce the number of HALDBstatements to 20 or fewer, and run the jobagain. This message results in an abendU0201.

NUM parameter must be non-zero numeric The partition range specified in the NUMkeyword must be a non-zero value from 1 to999.

NUM value exceeds three digits The partition range specified in the NUMkeyword must be a non-zero value from 1 to999.

An equal sign must follow NUM keyword An equal sign must follow the NUMkeyword in the HALDB statement. Add anequal sign to the HALDB statement.

The NUM keyword is missing A comma was found after the partitionname, but the NUM keyword was notpresent. Either verify the syntax of thepositional parameters in the HALDBstatement, or add the NUM keyword and therange of partitions for the restriction.

NUM parameter is missing The NUM keyword was found, but the NUMparameter value was not present. Eitherverify the syntax of the positional parametersin the HALDB statement, or add the NUMkeyword and the range of partitions for therestriction.

For HALDB control statements that are not syntactically correct (statements thatare processed and rejected), the messages and explanations that are issued areshown in Table 16:

Table 16. Messages provided in the report generated for syntactically incorrect HALDBstatements

Message Explanation

No HALDB statement type The DFSHALDB data set did not contain aHALDB statement. Add a HALDB statementto prevent this error.

A space must follow HALDB statement type The HALDB statement requires a space afterHALDB and before the PCB keyword.

PCB keyword missing The required keyword PCB was not found.The PCB keyword must be present to processthe HALDB statement successfully.

Equal sign must follow PCB keyword An equal sign did not follow the PCBkeyword. The equal sign must follow thePCB keyword to process the HALDBstatement successfully.

Open parenthesis must follow equal sign An open parenthesis did not follow PCB=.The open parenthesis must follow the PCB=to process the HALDB statement successfully.

Chapter 8. HALDB selective partition processing 127

Page 152: IMS Application Programming.pdf

Table 16. Messages provided in the report generated for syntactically incorrect HALDBstatements (continued)

Message Explanation

Second parameter may be missing The HALDB partition must be provided.Either add the partition name, or verify thatthe syntax of the positional parameters iscorrect.

First parameter exceeds four digits The DB PCB number cannot exceed afour-digit value. Change the DB PCB numberto the correct DB PCB number.

Delimiter is not a comma A comma is missing between parametervalues. The comma is used as a delimiter forthe positional parameters. Either add thecomma, or verify that the syntax of thepositional parameters is correct.

Partition name must start with an alpha The HALDB partition name must begin witha alphabetic character. Add the partitionname or verify the syntax of the positionalparameters is correct.

Delimiter is not a close parenthesis A closing parenthesis is missing from theHALDB statement. Add a closing parenthesisaround the PCB parameters.

Partition name exceeds seven characters The HALDB partition name must be seven orfewer characters. Either add the partitionname, or verify that the syntax of thepositional parameters is correct.

Invalid character in partition name The HALDB partition name contains aninvalid character. Either add the partitionname, or verify that the syntax of thepositional parameters is correct.

Statement contains all spaces The HALDB statement is missing. Add avalid HALDB statement.

Invalid statement input A HALDB statement was found, but it doesnot appear to be complete. Verify the syntaxof the HALDB statement and the positionalparameters specified.

Space must follow close parenthesis A space must follow the closing parenthesis.Add a space after the closing parenthesis.

First parameter missing The PCB number or label is missing. Eitheradd the PCB name or label, or verify that thesyntax of the positional parameters is correct.

Comma and part name missing Only the PCB number or label was providedin the HALDB statement. Either add thepartition name, or verify that the syntax ofthe positional parameters is correct.

Partition name is missing The HALDB partition name must beprovided in the HALDB statement. Eitheradd the partition name, or verify that thesyntax of the positional parameters is correct.

Partition name starts with numeric The HALDB partition name must begin withan alphabetic character. Either add thepartition name, or verify that the syntax ofthe positional parameters is correct.

128 Application Programming Guide

Page 153: IMS Application Programming.pdf

Table 16. Messages provided in the report generated for syntactically incorrect HALDBstatements (continued)

Message Explanation

First parameter must not be zero The PCB number must be a non-zeronumber. Add a non-zero number for the DBPCB number.

Comment statement An asterisk was found in column one of theHALDB statement. This statement wasskipped and considered a comment.

After all of the statements are validated, the job abnormally terminates with anabend code of U0201.

Chapter 8. HALDB selective partition processing 129

Page 154: IMS Application Programming.pdf

130 Application Programming Guide

Page 155: IMS Application Programming.pdf

Chapter 9. Processing GSAM databases

GSAM databases are available to application programs that can run as batchprograms, batch-oriented BMPs, transaction-oriented BMPs or JBPs. If yourapplication program accesses GSAM databases, as you design your programconsider that:v An IMS program can retrieve records and add records to the end of the GSAM

database, but the program cannot delete or replace records in the database.v You use separate calls to access GSAM databases. (Additional checkpoint and

restart considerations are involved in using GSAM.)v Your program must use symbolic CHKP and XRST calls if it uses GSAM. Basic CHKP

calls cannot checkpoint GSAM databases.v When an IMS program uses a GSAM data set, the program treats a GSAM data

set like a sequential nonhierarchic database. The z/OS access methods thatGSAM can use are BSAM on direct access, unit record, and tape devices; andVSAM on direct-access storage. VSAM data sets must be nonkeyed, nonindexed, entry-sequenced data sets (ESDS) and must reside on DASD. VSAMdoes not support temporary, SYSIN, SYSOUT, and unit-record files.

v Because GSAM is a sequential nonhierarchic database, it has no segments, keys,or parentage.

The following topics provide additional information:v “Accessing GSAM databases”v “GSAM record formats” on page 136v “GSAM I/O areas” on page 136v “GSAM status codes” on page 137v “Symbolic CHKP and XRST with GSAM” on page 137v “GSAM coding considerations” on page 138v “Origin of GSAM data set characteristics” on page 139

Related reading: For information about how you can use your applicationprogram to accessing JBPs using GSAM support for the Java class libraries, see“GSAM database access” on page 364.

Accessing GSAM databasesThe calls you use to access Generalized Sequential Access Method (GSAM)databases are different from those you use to access other IMS databases, and youcan use GSAM databases for input and output. For example, your program canread input from a GSAM database sequentially and then load another GSAMdatabase with the output data. Programs that retrieve input from a GSAMdatabase usually retrieve GSAM records sequentially and then process them.Applications that send output to a GSAM database must add output records to theend of the database as the program processes the records. You cannot delete orreplace records in a GSAM database, and any records that you add must go at theend of the database.

© Copyright IBM Corp. 1974, 2010 131

Page 156: IMS Application Programming.pdf

PCB masks for GSAM databasesFor the most part, you process GSAM databases in the same way that you processother IMS databases. You use calls that are very similar to DL/I calls tocommunicate your requests. GSAM describes the results of those calls in a GSAMDB PCB.

Calls to GSAM databases can use either the AIBTDLI or the PCB interface. Forinformation on the AIBTDLI interface, see “The AIBTDLI interface” on page 72.

The DB PCB mask for a GSAM database serves the same purpose as it does forother IMS databases. The program references the fields of the DB PCB through theGSAM DB PCB mask. The GSAM DB PCB mask must contain the same fields asthe GSAM DB PCB and must be of the same length.

Some differences exist between a DB PCB for a GSAM database and one for otherIMS databases. Some of the fields are different, and the GSAM DB PCB has onefield that the other PCBs do not. Table 17 on page 132 shows the order and lengthsof these fields. Because GSAM is not a hierarchical database, some fields in a PCBmask for other IMS databases do not have meanings in a GSAM PCB mask. Thefields that are not used when you access GSAM databases are:v The second field: segment level numberv The sixth field: segment namev The eighth field: number of sensitive segments

Even though GSAM does not use these fields, you must define them in the orderand length shown in Table 17 in the GSAM DB PCB mask.

When you code the fields in a DB PCB mask, name the area that contains all thefields as you do for a DB PCB. The entry statement associates each DB PCB maskin your program with a DB PCB in your program's PSB based on the order of thePCBs in the PSB. The entry statement refers to the DB PCB mask in your programby the name of the mask or by a pointer.

When you code the entry statement in:v COBOL, Java, Pascal, C, and assembler language programs, the entry statement

must list the names of the DB PCB masks in your program.v PL/I programs, the entry statement must list the pointers to the DB PCB masks

in your program.

The first PCB name or pointer in the entry statement corresponds to the first PCB.The second name or pointer in the entry statement corresponds to the second PCB,and so on.

Table 17. GSAM DB PCB mask

Descriptor Byte length DB/DC DBCTL DCCTL DBbatch

TMbatch

Database name1 8 X X X X X

Segment level number2 2 N/A N/A N/A N/A N/A

Status code3 2 X X X X X

Processing options4 4 X X X X X

Reserved for IMS5 4 X X X X X

Segment name6 8 N/A N/A N/A N/A N/A

132 Application Programming Guide

||

||

|||||||||

|||||||

|||||||

|||||||

|||||||

|||||||

|||||||

Page 157: IMS Application Programming.pdf

Table 17. GSAM DB PCB mask (continued)

Descriptor Byte length DB/DC DBCTL DCCTL DBbatch

TMbatch

Length of key feedbackarea andundefined-lengthrecords area7

4 X X X X X

Number of sensitivesegments8

4 N/A N/A N/A N/A N/A

Key feedback area9 8 or 12 forlargedatasets

X X X X X

Length ofundefined-lengthrecords10

4 X X X X X

Notes:

1. Database Name. The name of the GSAM DBD. This field is 8 bytes andcontains character data.

2. Segment Level Number. Not used by GSAM, but you must code it. It is 2bytes.

3. Status Code. IMS places a two-character status code in this field after eachcall to a GSAM database. This code describes the results of the call. IMSupdates this field after each call and does not clear it between calls. Theapplication program should test this field after each call to find out whetherthe call was successful. If the call was completed successfully, this fieldcontains blanks.

4. Processing Options. This is a 4-byte field containing a code that tells IMS thetypes of calls this program can issue. It is a security mechanism in that it canprevent a particular program from updating the database, even though theprogram can read the database. This value is coded in the PROCOPTparameter of the PCB statement when generating the PSB for the applicationprogram. The value does not change. For GSAM, the values are G, GS, L, orLS.

5. Reserved for IMS. This 4-byte field is used by IMS for internal linkage. It isnot used by the application program.

6. Segment Name. This field is not used by GSAM, but it must be coded as partof the GSAM DB PCB mask. It is 8 bytes.

7. Length of Key Feedback Area and Undefined-Length Records Area. This is a4-byte field that contains the decimal value of 12 (or 16 for large format datasets). This is the sum of the lengths of the 9 and 10.

8. Number of Sensitive Segments. This field is not used by GSAM, but itshould be coded as part of the GSAM DB PCB mask. This field is 4 bytes.

9. Key Feedback Area. After a successful retrieval call, GSAM places the addressof the record that is returned to your program in this field. This is called arecord search argument (RSA). You can use it later if you want to retrieve thatrecord directly by including it as one of the parameters on a GU call. This fieldis 8 bytes for basic format data sets or 12 bytes for large format data sets.

10. Undefined-Length Records Area. If you use undefined-length records(RECFM=U), the length in binary of the record you are processing is passedbetween your program and GSAM in this field. This field is 4 bytes long.When you issue a GU or GN call, GSAM places the binary length of the

Chapter 9. Processing GSAM databases 133

|

|||||||||

||||

||||||

||||||||

||||

|||||

|||

||||||

|

|||

|||||

Page 158: IMS Application Programming.pdf

retrieved record in this field. When you issue an ISRT call, put the binarylength of the record you are inserting in this field before issuing the ISRT call.

Retrieving and Inserting GSAM RecordsTo retrieve GSAM records sequentially, use the GN call. The only requiredparameters are the GSAM PCB and the I/O area for the segment. To process thewhole database, issue the GN call until you get a GB status code in the GSAMPCB. This means that you have reached the end of the database. GSAMautomatically closes the database when you reach the end of it. To add records to anew data set or to add new records to the end of an existing data set in thedatabase, use the ISRT call. GSAM adds the records sequentially in the order inwhich you supply them.

You can retrieve records directly from a GSAM database by supplying a recordsearch argument (RSA) to the GSAM database. An RSA is similar to a segmentsearch argument (SSA), but it contains the exact address of the record that youwant to retrieve. The specific contents and format of the RSA depend on the accessmethod that GSAM is using. For BSAM tape data sets and VSAM data sets, theRSA contains the relative byte address (RBA). For BSAM disk data sets, the RSAcontains the disk address and uses the relative track and record format.

The following table provides more details about the format of the RSA for basicformat data sets:

Table 18. Format of the RSA for basic format data sets

Position Address

Positions 1-4 v BSAM (DASD) relative track and record(TTRZ) for the block in the buffer.

v BSAM RBA.

v VSAM RBA.

Position 5 Relative data set of the concatenated data set.The first data set number is 1.

Position 6 Relative volume of the data set. The firstvolume of data set is 1.

Positions 7 and 8 Current displacement.

The following table provides more details about the format of the RSA for largeformat data sets:

Table 19. Format of the RSA for large format data sets

Position Address

Positions 1-4 v BSAM (DASD) relative track and record(TTTR) for the block in the buffer.

v BSAM RBA.

Position 5 Zone byte

Position 6 Relative data set of the concatenated data set.The first data set number is 1.

Position 7 Relative volume of the data set. The firstvolume of data set is 1.

Positions 8-10 Null bytes. Not used.

Positions 11-12 Current displacement.

134 Application Programming Guide

|

||||||||

|||||||

||

||

||

|||

|

|

|||

|||

|||

||

||

||

|||

|

||

|||

|||

||

||

Page 159: IMS Application Programming.pdf

Before you can supply an RSA in a GU call to a GSAM database, that RSA musthave previously been returned to you as a result of a GN or ISRT call. For GSAMto return an RSA, the GN or ISRT call must be issued with a fourth parameter thatpoints to an eight-byte RSA save area in your program, as shown in Table 20 onpage 138. Save this RSA until you want to retrieve that particular record.

To retrieve that particular record, issue a GU call for the record and specify theaddress of its RSA as a fourth parameter of the GU call. GSAM returns the recordto the I/O area that you named as one of the call parameters.

“GSAM coding considerations” on page 138 provides a list of parameters you canuse with GSAM database calls.

Restriction: Retrieve records directly from a GSAM database on DASD only. Whenusing buffered I/O, buffer definitions for the output PCB may affect performance.

Resetting the Position in a GSAM DatabaseYou can use the GU call to reset the position in the GSAM database.

You can reset the position to the start of the GSAM database or to a specificsegment in the GSAM database by completing one of the following tasks:v To reset the position to the start of the GSAM database using basic format data

sets, issue a GU call with an RSA that consists of a fullword with a binary valueof 1, followed by a fullword with a binary value of 0.

v To reset the position to the start of the GSAM database using large format datasets, issue a GU call with an RSA that consists of a fullword with a binary valueof 1, followed by two fullwords with a binary value of 0.

v To reset the position to a specific segment in the GSAM database, issue a GUcall with an RSA that contains the saved RSA value from a prior ISRT or GN callfor that segment.

For more information about issuing a GU call with an RSA, see “Retrieving andInserting GSAM Records” on page 134.

Explicit open and close calls to GSAMIMS opens the GSAM data set when the first call is made and closes the data setwhen the application program terminates. Therefore, the application program doesnot usually need to make explicit open or close calls to GSAM. However, explicitOPEN and CLSE calls are useful if:v the application program loads a GSAM data set, and then in the same step reads

the data set using GSAM (for example, to sort the data set). The applicationprogram should issue the GSAM CLSE call after the load is complete.

v the GSAM data set is an output data set, and it is possible that when theprogram executes it does not make GSAM ISRT calls. A data set is not created.Subsequent attempts to read the nonexistent data set (using GSAM or not) willlikely result in an error. To avoid this situation, explicitly open the data set. DL/Icloses the data set when the step terminates. Closing the data set prevents thepossibility of attempting to read an empty data set.

The explicit OPEN or CLSE call need not include an I/O area parameter. Dependingon the processing option of the PCB, the data set is opened for input or output.You can specify that an output data set contain either ASA or machine control

Chapter 9. Processing GSAM databases 135

|

|||||

|||

||

||

|

|

||

|||

|||

|||

||

Page 160: IMS Application Programming.pdf

characters. Including an I/O area parameter in the call and specifying OUTA in theI/O area indicates ASA control characters. Specifying OUTM specifies machinecontrol characters.

To add new records to an existing non-empty output data set after an explicit CLSEcall when performing a normal start or performing a restart after a failure, specifyDISP=MOD.

GSAM record formatsGSAM records are nonkeyed. For variable-length records you must include therecord length as the first 2 bytes of the record. Undefined-length records, likefixed-length records, contain only data (and control characters, if needed). If youuse undefined-length records, record length is passed between your program andGSAM in the 4-byte field that follows the key feedback area of the GSAM DB PCB.This is the tenth field in Table 17 on page 132. It is called the undefined-lengthrecords area. When you issue an ISRT call, supply the length. When you issue a GNor GU call, GSAM places the length of the returned record in this field. Theadvantage of using undefined-length records is that you do not need to include therecord length at the beginning of the record, and records do not need to be of fixedlength. The length of any record must be less than or equal to the block size(BLKSIZE) and greater than 11 bytes (an z/OS convention).

If you are using VSAM, you can use blocked or unblocked fixed-length orvariable-length records. If you are using BSAM, you can use blocked or unblockedfixed-length, variable-length, or undefined-length records. Whichever you use, besure to specify this on the RECFM keyword in the DATASET statement of theGSAM DBD. You can override this in the RECFM statement of the DCB parameterin the JCL. You can also include carriage control characters in the JCL for allformats. “Origin of GSAM data set characteristics” on page 139 explains what youcan use to override each type of record format.

GSAM I/O areasIf you provide an optional I/O area, it must contain one of these values:v INP for an input data setv OUT for an output data setv OUTA for an output data set with ASA control charactersv OUTM for an output data set with machine control characters

For GN, ISRT, and GU calls, the format of the I/O area depends on whether therecord is fixed-length, undefined-length (valid only for BSAM), or variable-length.For each kind of record, you have the option of using control characters.

The formats of an I/O area for fixed-length or undefined-length records are:v With no control characters, the I/O area contains only data. The data begins in

byte 0.v With control characters, the control characters are in byte 0 and the data begins

in byte 1.

If you are using undefined-length records, the record length is passed betweenyour program and GSAM in the PCB field that follows the key feedback area.

136 Application Programming Guide

|||

Page 161: IMS Application Programming.pdf

When you are issuing an ISRT call, supply the length. When you are issuing a GNor GU call, GSAM places the length of the returned record in this field. This lengthfield is 4 bytes long.

The formats for variable-length records differ because variable-length recordsinclude a length field, which other records do not have. The length field is 2 bytes.Variable-length I/O areas, like fixed-length and undefined-length I/O areas, canhave control characters.v Without control characters, bytes 0 and 1 contain the 2-byte length field, and the

data begins in byte 2.v With control characters, bytes 0 and 1 still contain the length field, but byte 2

contains the control characters, and the data starts in byte 3.

GSAM status codesYour program should test for status codes after each GSAM call, just as it doesafter each DL/I or system service call.

If, you find that you have an error and terminate your program after checking thestatus codes, be sure to note the PCB in error before you terminate. The GSAMPCB address is helpful in determining problems. When a program that uses GSAMterminates abnormally, GSAM issues PURGE and CLSE calls internally, which changesthe PCB information.

Status codes that have specific meanings for GSAM are:

AF GSAM detected a BSAM variable-length record with an invalid format.Terminate your program.

AH You have not supplied an RSA for a GU call.

AI There has been a data management OPEN error.

AJ One of the parameters on the RSA that you supplied is invalid.

AM You have issued an invalid request against a GSAM database.

AO An I/O error occurred when the data set was accessed or closed.

GB You reached the end of the database, and GSAM has closed the database.The next position is the beginning of the database.

IX You issued an ISRT call after receiving an AI or AO status code. Terminateyour program.

Symbolic CHKP and XRST with GSAMTo checkpoint GSAM databases, use symbolic CHKP and XRST calls. By using GSAMto read or write the data set, symbolic CHKP and XRST calls can be used toreposition the data set at the time of restart, enabling you to make your programrestartable. When you use an XRST call, IMS repositions GSAM databases forprocessing. CHKP and XRST calls are available to application programs that can runas batch programs, batch-oriented BMPs, or transaction-oriented BMPs.

Restriction: When restarting GSAM databases:v You cannot use temporary data sets with a symbolic CHKP or XRST call.v A SYSOUT data set at restart time may give duplicate output data.v You cannot restart a program that is loading a GSAM or VSAM database.

Chapter 9. Processing GSAM databases 137

Page 162: IMS Application Programming.pdf

v The GSAM database data set must have the same data set format (basic or large)as when the symbolic CHKP call was issued.

When IMS restores the data areas specified in the XRST call, it also repositions anyGSAM databases that your program was using when it issued the symbolic CHKPcall. If your program was loading GSAM databases when the symbolic CHKP callwas issued, IMS repositions them (if they are accessed by BSAM). If you make acopy of the GSAM data set for use as input to the restart process, ensure that theshort blocks are written to the new data set as short blocks, for example, usingIEBGENER with RECFM=U for SYSUT1. You can also do the restart using theoriginal GSAM data set.

GSAM coding considerationsThe calls your program uses to access GSAM databases are not the same as theDL/I calls. This section tells you how to code GSAM calls and GSAM databases.The system service calls that you use with GSAM are symbolic CHKP and XRST.

Table 20 summarizes GSAM database calls. The five calls you can use to processGSAM databases are:v CLSE

v GN

v GU

v ISRT

v OPEN

The COBOL, PL/I, Pascal, C, and assembler language call formats and parametersfor these calls are the same and are described in Table 20. GSAM calls do not differsignificantly from DL/I calls, but GSAM calls must reference the GSAM PCB, andthey do not use SSAs.

Table 20. Summary of GSAM calls

Call Formats Meaning Use Options Parameters

CLSE Close Explicitly closes GSAMdatabase

None function, gsam pcb

GN�� Get Next Retrieves next sequentialrecord

Can supplyaddress for RSA tobe returned

function, gsam pcb, i/oarea [,rsa name]

GU�� Get Unique Establishes position indatabase or retrieves aunique record

None function, gsam pcb, i/oarea, rsa name

ISRT Insert Adds new record at end ofdatabase

Can supplyaddress for RSA tobe returned

function, gsam pcb, i/oarea [,rsa name]

OPEN Open Explicitly opens GSAMdatabase

Can specifyprinter or punchcontrol characters

function, gsam pcb [, openoption]

138 Application Programming Guide

||

Page 163: IMS Application Programming.pdf

Origin of GSAM data set characteristicsFor an input data set, the record format (RECFM), logical record length (LRECL),and block size (BLKSIZE) are based on the input data set label. If this informationis not provided by a data set label, the DD statement or the DBD specifications areused. The DD statement has priority.

An output data set can have the following characteristics:v Record formatv Logical record lengthv Block sizev Other JCL DCB parametersv DNS type

Specify the record format on the DATASET statement of the GSAM DBD. Theoptions are:v V for variablev VB for variable blockedv F for fixedv FB for fixed blockedv U for undefined

The V, F, or U definition applies and is not overridden by the DCB=RECFM=specification on the DD statement. However, if the DD RECFM indicates blockedand the DBD does not, RECFM is set to blocked. If the DD RECFM of A or Mcontrol character is specified, it applies as well.

Unless an undefined record format is used, specify the logical record using theRECORD= parameter of the DATASET statement of DBDGEN, or useDCB=LRECL=xxx on the DD statement. If the logical record is specified on both,the DD statement has priority. Refer to Table 21 for more details regarding themaximum record length

Table 21. BSAM and VSAM logical record lengths for GSAM data sets by record format

Record Format BSAM logical record length VSAM logical record length

Fixed/Fixed Block 32760 bytes 32760 bytes

Variable/Variable Blocked 32756 bytes 32756 bytes

Undefined 32760 bytes not supported

Specify block size using the BLOCK= or SIZE= parameter of the DATASETstatement of DBDGEN, or use DCB=BLKSIZE=xxx on the DD statement. If blocksize is specified on both, the DD statement has priority. If the block size is notspecified by the DBD or the DD statement, the system determines the size basedon the device type, unless the undefined record format is used.

The other JCL DCB parameters that can be used, include:v CODEv DENv DNSTYPEv TRTCH

Chapter 9. Processing GSAM databases 139

|

|||||

||

|||

|||

|||

||||

Page 164: IMS Application Programming.pdf

v MODEv STACKv PRTSP, which can be used if RECFM does not include A or Mv DCB=BUFNO=X, which, when used, causes GSAM to use X number of buffers

Restriction: Do not use BFALN, BUFL, BUFOFF, FUNC, NCP, and KEYLEN.

DD statement DISP parameter for GSAM data setsThe DD statement DISP parameter varies, depending on whether you are creatinginput or output data sets, and how you plan to use the data sets:v For input data sets, use the DISP=OLD parameter.v For output data sets, consider the following options:

– To create an output data set allocated by the DD statement, set DISP=NEW.– To add new records to an empty data set when performing normal start or a

restart after failure, set DISP=MOD, DISP=SHR, or DISP=OLD.– When restarting the step, set DISP=OLD for existing data sets and

DISP=MOD for empty data sets.– To add new records to an existing non-empty data set when performing a

restart after failure, set DISP=MOD, DISP=SHR, or DISP=OLD. Theseparameters add new records from the restart point on the existing data set.

– To add new records to the end of an existing non-empty data set whenperforming normal start, set DISP=MOD.

Warning: Specifying the DISP=OLD or DISP=SHR parameter for a normal startwith non-empty data sets will overwrite the existing records from the beginning ofthe data set. To add new records to an existing non-empty output data set after anexplicit CLSE call when performing a normal start or performing a restart after afailure, specify DISP=MOD.

Using extended checkpoint restart for GSAM data setsRecommendation: If you are using extended checkpoint restart for GSAM datasets:v Do not use passed data sets.v Do not use backward references to data sets in previous steps.v Do not use DISP=MOD to add records to an existing tape data set.v Do not use DISP=DELETE or DISP=UNCATLG.v Use DFSMS striped data sets under the following conditions:

– When the data sets will be managed by SMS.– When the data sets are likely to exceed the system extent limit for volumes.

v Additionally, keep in mind that:– No attempt is made to reposition a SYSIN, SYSOUT, or temporary data set.– No attempt is made to reposition any of the concatenated data sets for a

concatenated DD statement if any of the data sets are a SYSIN or SYSOUT.– If you are using concatenated data sets, specify the same number and

sequence of data sets at restart and checkpoint time.– GSAM/VSAM load mode restrictions apply to both non-striped and striped

data sets.– If the PSB contains an open GSAM/VSAM output data set when the symbolic

checkpoint call is issued, the system returns an AM status code in the

140 Application Programming Guide

||

||

|||||

|

|

|

|

||

||

||

||

Page 165: IMS Application Programming.pdf

database PCB as a warning. This code means that the data set is notrepositioned at restart, and the checkpoint has completed normally.

Copying GSAM Data Sets Between Checkpoint and RestartTo position GSAM data sets when restarting non-striped GSAM DASD data sets,use the relative track and record format (TTRZ or TTTRZ for large format datasets). GSAM uses the TTRZ or TTTRZ on the volume to position non-stripedGSAM DASD data sets when restarting. For a tape data set, the relative record onthe volume is used. The relative record on the tape volume cannot be changed.

To copy non-striped DASD data sets between checkpoint and restart:v Copy the data set to the same device type.v Avoid any re-blocking by using the undefined record format (RECFM=U) for

both the input and the output data set.

Each copied volume contains the same number of records as the original volumes.

Note: GSAM uses the relative block number (RBN) to reposition striped DASDdata sets. When data sets that are managed by SMS are used with GSAMdatabases, you cannot control how each volume is copied. After the data setis copied, unlike with non-striped DASD data sets, you do not need toensure that the TTRZ or the TTTRZ of the restart record is unchanged.

Converting Data Sets From Non-Striped Data Sets to StripedData Sets

Convert GSAM/BSAM non-striped data sets to striped data sets before you needto perform an extended restart when a system allocation limit is exceeded or asystem X'37' error condition occurs. Non-striped data sets that are not managed bySMS extend beyond their initial primary or secondary allocation only by volume,but with non-striped GSAM/BSAM multiple volume data sets that are managedby SMS, the resulting new space allocation takes effect for all of the volumes in thedata set.

If you copy non-striped data sets that are managed by SMS after you change thespace allocation values, the number of records in the new volumes will be differentfrom the number of records in the old volume. The new primary and secondaryallocation values are used with non-striped data sets. As the data is copied, all ofthe space that is allocated on the new volume is used before the data is copied tothe next volume.

If an error condition (System x37 or system allocation limit exceeded) occursduring the processing of a GSAM/BSAM non-striped data set, and the data set isconverted to a striped data set after the error occurs, a restart after failure will notcomplete successfully. Because the issued checkpoint saved a TTRZ or a TTTRZvalue in the log record for repositioning, the log record for striped data sets will beused by GSAM restart after failure, which requires a relative block number (RBN)to perform the repositioning.

Concatenated data sets used by GSAMGSAM can use concatenated data sets, which may be on unlike device types, suchas DASD and tape, or on different DASD devices. Logical record lengths and blocksizes can differ, and it is not required that the data set with the largest block sizebe concatenated first. The maximum number of concatenated data sets for a single

Chapter 9. Processing GSAM databases 141

||

|

|||||

|

|

||

|

|||||

|

|

|||||||

||||||

|||||||

Page 166: IMS Application Programming.pdf

DD statement is 255. The number of buffers determined for the first of theconcatenated data sets is used for all succeeding data sets. Generation data groupscan result in concatenated data sets.

Suggested method for specifying GSAM data set attributesRecommendation: When specifying GSAM data set attributes:v On the DBD, specify RECFM. (It is required.)v On the DATASET statement, specify the logical record length using RECORD=.

If the data set can become larger than 65535 tracks on a DASD volume and youwant the data set to not span multiple volumes, specify the DSNTYPE=LARGEparameter.

v On the DD statement, do not specify LRECL, RECFM, or BLKSIZE. The systemdetermines block size, with the exception of RECFM=U. The system determineslogical record length from the DBD.

v For the PSB, specify PROCOPT=LS for output and GS for input. If you includeS, GSAM uses multiple buffers instead of a single buffer for improvedperformance.

IMS will add 2 bytes to the record length value specified in the DBD in order toaccommodate the ZZ field that is needed to make up the BSAM RDW. Wheneverthe database is GSAM or BSAM and the records are variable (V or VB), IMS willadd 2 bytes to the record length value in the GSAM records passed by theapplication. Such addition allows IMS to accommodate the ZZ field that makes upthe BSAM RDW (Record Descriptor Word). See Figure 37 for more details.

DLI, DBB, and BMP region types and GSAMTo access GSAM databases, IMS builds its DLI control blocks using PSB and DBDinformation from PSBLIB, DBDLIB and ACBLIB. The source of the PSB and DBDinformation depends on the region type. For DLI offline batch regions, IMS obtainsPSB and DBD information from PSBLIB and DBDLIB. For DBB offline batchregions, IMS database management obtains PSB and DBD information fromACBLIB. For online batch regions (BMPs), IMS builds its DLI control blocks withinformation from ACBLIB. If an application is scheduled in a BMP region and thePSB associated with the application contains one or more GSAM PCBs, IMSscheduling obtains PSB information from ACBLIB and PSBLIB. In this case, thePSB in ACBLIB and PSBLIB must be the same. GSAM database management doesnot obtain PSB and DBD information from ACBLIB. Instead, GSAM databasemanagement obtains PSB and DBD information from PSBLIB and DBDLIB.

//IDASD DD DUMMY//ODASD DD UNIT=SYSDA,VOL=SER=000000,DISP=(,KEEP),// SPACE=(TRK,(5,1)),DSN=GSAM.VARIABLE1,// DCB=(RECFM=VB,BLKSIZE=32760,LRECL=32756)//SYSIN DD *,DCB=BLKSIZE=80S 1 1 1 1 1 DBDNAMEL ISRTL V8187 DATA 1ST RECORD LOADED TO GSAM <---RDWL ISRTL V8187 DATA 2ND RECORD LOADED TO GSAML ISRTL V8187 DATA 3RD RECORD LOADED TO GSAML ISRTL V8187 DATA 4TH RECORD LOADED TO GSAM

Note: In the above example, four GSAM records (IMS segment) can be contained in one 32756 byte (MVS) record.

Figure 37. Example of GSAM or BSAM where the records are variable

142 Application Programming Guide

||||

||||||

Page 167: IMS Application Programming.pdf

When you initialize a DLI, DBB or BMP region using GSAM, you must include an//IMS DD and GSAM DD statements. When DBB or BMP regions are not usingGSAM, //IMS DD statements do not need to be included. To load PSBs and DBDsand build GSAM control blocks, you must include an //IMS DD statement. InFigure 38, an example of the //IMS DD statement with data sets that are largerthan 65535 tracks is shown.

//STEP EXEC PGM=DFSRRC00,PARM=[BMP|DBB|DLI],...’//STEPLIB DD DSN=executionlibrary-name,DISP=SHR// DD DSN=pgmlib-name,DISP=SHR//IMS DD DSN=psblib-name,DISP=SHR// DD DSN=dbdlib-name,DISP=SHR//IMSACB DD DSN=acblib-name,disp=shr (required for DBB)//SYSPRINT DD SYSOUT=A//SYSUDUMP DD SYSOUT=A//ddnamex DD (add DD statements for required GSAM databases)//ddnamex DD (add DD statements for non-GSAM IMS databases

for DLI/DBB)//ddnamex DD DSNTYPE=LARGE,...

.

.

./*

Figure 38. //IMS DD statement example

Chapter 9. Processing GSAM databases 143

||||||||||||||||

||||||

Page 168: IMS Application Programming.pdf

144 Application Programming Guide

Page 169: IMS Application Programming.pdf

Chapter 10. Processing Fast Path databases

This chapter contains information on Fast Path database calls and MSDB andDEBD information that is required by Fast Path calls.

Restriction: This DEDB information applies to CICS users with DBCTL. MSDBsand cannot be accessed through CICS and DBCTL.

The two kinds of Fast Path databases are:v Main storage databases (MSDBs) are available in a DB/DC environment, and

contain only root segments in which you store data that you access mostfrequently.

v Data entry databases (DEDBs) are hierarchic databases that can have as many as15 hierarchic levels and as many as 127 segment types. DEDBs are available toboth IMS users and CICS users with DBCTL.

The following topics provide additional information:v “Fast Path database calls”v “Main storage databases (MSDBs)” on page 146v “Data entry databases (DEDBs)” on page 147v “Processing MSDBs and DEDBs” on page 147v “Restrictions on using calls for MSDBs” on page 154v “Processing DEDBs (IMS and CICS with DBCTL)” on page 154v “Calls with dependent segments for DEDBs” on page 163v “DEDB DL/I calls to extract DEDB information” on page 164v “Fast Path coding considerations” on page 171

Related reading: For more information on the types of processing requirements thetwo types of Fast Path databases satisfy, see IMS Version 10: Database AdministrationGuide. This section contains information on how to write programs to access datain MSDBs and DEDBs.

Fast Path database callsTable 22 summarizes the database calls you can use with Fast Path databases.

Table 22. Summary of Fast Path database calls

Function Code

Types of MSDBs:

DEDBsNonterminal-

RelatedTerminal-

Related Fixed

Terminal-Related

Dynamic

DEQ X

FLD X X X X

GU, GHU X X X X

GN, GHN X X X X

GNP, GHNPDLET

X X

ISRT X X

© Copyright IBM Corp. 1974, 2010 145

|

Page 170: IMS Application Programming.pdf

Table 22. Summary of Fast Path database calls (continued)

Function Code

Types of MSDBs:

DEDBsNonterminal-

RelatedTerminal-

Related Fixed

Terminal-Related

Dynamic

POS X

REPL X X X X

RLSE X

DL/I calls to DEDBs can include the same number of SSAs as existing levels in thehierarchy (a maximum of 15). They can also include command codes and multiplequalification statements.

Restriction:

v Fast Path ignores command codes that are used with sequential dependentsegments.

v If you use a command code that does not apply to the call you are using, FastPath ignores the command code.

v If you use F or L in an SSA for a level greater than the established parent, FastPath ignores the F or L command code.

v DL/I calls to DEDBs cannot include the independent AND, which is used onlywith secondary indexing.

Calls to DEDBs can use all command codes. Only calls to DEDBs that use subsetpointers can use the R, S, Z, W, and M command codes. Table 23 shows which callsyou can use with these command codes.

Table 23. Subset pointer command codes and calls

CommandCode DLET GU GHU GN GHN

GNPGHNP ISRT REPL

M X X X X X

R X X X X

S X X X X X

W X X X X X

X X X X X X X

Main storage databases (MSDBs)MSDBs contain only root segments. Each segment is like a database record,because the segment contains all of the information about a particular subject. In aDL/I hierarchy, a database record is made up of a root segment and all itsdependents. For example, in the medical hierarchy, a particular PATIENT segmentand all the segments underneath that PATIENT segment comprise the databaserecord for that patient. In an MSDB, the segment is the whole database record. Thedatabase record contains only the fields that the segment contains. MSDB segmentsare fixed length.

The two kinds of MSDBs are terminal related and non-terminal related. Interminal-related MSDBs, each segment is owned by one logical terminal. Thesegment that is owned can be updated only by that terminal. Related MSDBs can

146 Application Programming Guide

Page 171: IMS Application Programming.pdf

be fixed or dynamic. You can add segments to and delete segments from dynamicrelated MSDBs. You cannot add segments to or delete segments from fixed relatedMSDBs.

In the second kind of MSDB, called non-terminal related (or nonrelated) MSDBs,the segments are not owned by logical terminals. One way to understand thedifferences between these types of databases and why you would use each one, isto look at the examples of each in the topic "Bank Account Example" in IMSVersion 10: Application Programming Planning Guide.

Data entry databases (DEDBs)A DEDB contains a root segment and as many as 127 dependent segment types.One of these can be a sequential dependent; the other 126 are direct dependents.Sequential dependent segments are stored in chronological order. Direct dependentsegments are stored hierarchically.

DEDBs can provide high data availability. Each DEDB can be partitioned, ordivided into multiple areas. Each area contains a different collection of databaserecords. In addition, you can make as many as seven copies of each area data set.If an error exists in one copy of an area, application programs continue to accessthe data by using another copy of that area. Use of the copy of an area istransparent to the application program. When an error occurs to data in a DEDB,IMS does not stop the database. IMS makes the data in error unavailable butcontinues to schedule and process application programs. Programs that do notneed the data in error are unaffected.

DEDBs can be shared among application programs in separate IMS systems.Sharing DEDBs is virtually the same as sharing full-function databases, and mostof the same rules apply. IMS systems can share DEDBs at the area level (instead ofat the database level as with full-function databases), or at the block level.

Related reading: For more information on DEDB data sharing, see the explanationof administering IMS systems that share data in IMS Version 10: SystemAdministration Guide.

Processing MSDBs and DEDBs

Updating segments: REPL, DLET, ISRT, and FLDThree of the calls that you can use to update an MSDB or DEDB are the same onesthat you use to update other IMS databases: REPL, DLET, and ISRT. You can issue aREPL call to a related MSDB or nonrelated MSDB, and you can issue any of thethree calls for non-terminal-related MSDBs (without terminal-related keys) orDEDBs. When you issue REPL or DLET calls against an MSDB or DEDB, you mustfirst issue a Get Hold call for the segment you want to update, just as you dowhen you replace or delete segments in other IMS databases.

One call that you can use against MSDBs and DEDBs that you cannot use againstother types of IMS databases is the Field (FLD) call, which enables you to accessand change the contents of a field within a segment. The FLD call has two types:v FLD/VERIFY

This type of call compares the value of the field in the target segment to thevalue you supply in the FSA.

v FLD/CHANGE

Chapter 10. Processing Fast Path databases 147

Page 172: IMS Application Programming.pdf

This type of call changes the value of the field in the target segment in the waythat you specify in the FSA. A FLD/CHANGE call is only successful if the previousFLD/VERIFY call is successful.

The FLD call does in one call what a Get Hold call and a REPL call do in two calls.For example, using the ACCOUNT segment shown in the topic "Account Segmentin a Nonrelated MSDB" in IMS Version 10: Application Programming Planning Guide abank would need to perform the following processing to find out whether acustomer could withdraw a certain amount of money from a bank account:1. Retrieve the segment for the customer's account.2. Verify that the balance in the account is more than the amount that the

customer wants to withdraw.3. Update the balance to reflect the withdrawal if the amount of the balance is

more than the amount of the withdrawal.

Without using the FLD call, a program would issue a GU call to retrieve thesegment, then verify its contents with program logic, and finally issue a REPL callto update the balance to reflect the withdrawal. If you use the FLD call with a rootSSA, you can retrieve the desired segment. The FLD call has the same format asSSAs for other calls. If no SSA exists, the first segment in the MSDB or DEDB isretrieved. You use the FLD/VERIFY to compare the BALANCE field to the amount ofthe withdrawal. A FLD/CHANGE call can update the BALANCE field if thecomparison is satisfactory.

The segment retrieved by a FLD call is the same as can be retrieved by a GHU call.After the FLD call, the position is lost. An unqualified GN call after a FLD call returnsthe next segment in the current area.

Checking the contents of a field: FLD/VERIFYA FLD/VERIFY call compares the contents of a specified field in a segment to thevalue that you supply. The way that a FLD/VERIFY call compares the two dependson the operator you supply. When you supply the name of a field and a value forcomparison, you can determine if the value in the field is:v Equal to the value you have suppliedv Greater than the value you have suppliedv Greater than or equal to the value you have suppliedv Less than the value you have suppliedv Less than or equal to the value you have suppliedv Not equal to the value you have supplied

After IMS performs the comparison that you have asked for, it returns a statuscode (in addition to the status code in the PCB) to tell you the results of thecomparison.

You specify the name of the field and the value that you want its value comparedto in a field search argument, or FSA. The FSA is also where IMS returns the statuscode. You place the FSA in an I/O area before you issue a FLD call, and then youreference that I/O area in the call—just as you do for an SSA in a DL/I call. AnFSA is similar to an SSA in that you use it to give information to IMS about theinformation you want to retrieve from the database. An FSA, however, containsmore information than an SSA. Table 24 on page 149 shows the structure andformat of an FSA.

148 Application Programming Guide

Page 173: IMS Application Programming.pdf

Table 24. FSA structure

FSA Component Field Length

FLD NAME 8

SC 1

OP 1

FLD VALUE Variable

CON 1

The five fields in an FSA are:

Field Name (FLD Name)This is the name of the field that you want to update. The field must bedefined in the DBD.

Status Code (SC)This is where IMS returns the status code for this FSA. If IMS successfullyprocesses the FSA, it returns a blank status code. If IMS fails to process theFSA, it returns a FE status code to the PCB to indicate a nonblank status codein the FSA and returns a nonblank FSA status code. The FSA status codes thatIMS might return to you on a FLD/VERIFY call are:

B The length of the data supplied in the field value is invalid, or thesegment length of the data in the database is too small to contain thefield length specified in the DBD.

D The verify check is unsuccessful. In other words, the answer to yourquery is no.

E The field value contains invalid data. The data you supplied in thisfield is not the same type of data that is defined for this field in theDBD.

H The requested field is not found in the segment.

Operator (OP)This tells IMS how you want the two values compared. For a FLD/VERIFY call,you can specify:

E Verify that the value in the field is equal to the value you havesupplied in the FSA.

G Verify that the value in the field is greater than the value you havesupplied in the FSA.

H Verify that the value in the field is greater than or equal to the valueyou have supplied in the FSA.

L Verify that the value in the field is less than the value you havesupplied in the FSA.

M Verify that the value in the field is less than or equal to the value youhave supplied in the FSA.

N Verify that the value in the field is not equal to the value you havesupplied in the FSA.

Field Value (FLD Value)This area contains the value that you want IMS to compare to the value in thesegment field. The data that you supply in this area must be the same type ofdata in the field you have named in the first field of the FSA. The five types of

Chapter 10. Processing Fast Path databases 149

|||

Page 174: IMS Application Programming.pdf

data are: hexadecimal, packed decimal, alphanumeric (or a combination of datatypes), binary fullword, and binary halfword. The length of the data in thisarea must be the same as the length that is defined for this field in the DBD.

Exceptions:

v If you are processing hexadecimal data, the data in the FSA must be inhexadecimal. This means that the length of the data in the FSA is twice thelength of the data in the field in the database. IMS checks the characters inhexadecimal fields for validity before that data is translated to databaseformat. (Only 0 to 9 and A to F are valid characters.)

v For packed-decimal data, you do not need to supply the leading zeros in thefield value. This means that the number of digits in the FSA might be lessthan the number of digits in the corresponding database field. The data thatyou supply in this field must be in a valid packed-decimal format and mustend in a sign digit.

When IMS processes the FSA, it does logical comparisons for alphanumericand hexadecimal fields; it does arithmetic comparisons for packed decimal andbinary fields.

Connector (CON)If this is the only or last FSA in this call, this area contains a blank. If anotherFSA follows this one, this area contains an asterisk (*). You can include severalFSAs in one FLD call, if all the fields that the FSAs reference are in the samesegment. If you get an error status code for a FLD call, check the status codesfor each of the FSAs in the FLD call to determine where the error is.

When you have verified the contents of a field in the database, you can change thecontents of that field in the same call. To do this, supply an FSA that specifies achange operation for that field.

Changing the contents of a field: FLD/CHANGETo indicate to IMS that you want to change the contents of a particular field, usean FSA, just as you do in a FLD/VERIFY call. The difference is in the operators thatyou can specify and the FSA status codes that IMS can return to you after the call.Using Table 24 on page 149 FLD/CHANGE works like this:v You specify the name of the field that you want to change in the first field of the

FSA (Field Name).v You specify an operator in the third field of the FSA (Operator), which indicates

to IMS how you want to change that field.v You specify the value that IMS must use to change the field in the last area of

the FSA (Field Value).

By specifying different operators in a FLD/CHANGE call, you change the field in thedatabase in these ways:v Add the value supplied in the FSA to the value in the field.v Subtract the value supplied in the FSA from the value in the field.v Set the value in the database field to the value supplied in the FSA.

You code these operators in the FSA with these symbols:v To add: +v To subtract: −v To set the field equal to the new value: =

150 Application Programming Guide

Page 175: IMS Application Programming.pdf

You can add and subtract values only when the field in the database containsarithmetic (packed-decimal, binary-fullword, or binary-halfword) data.

The status codes you can receive in a FLD/CHANGE FSA are:

A Invalid operation; for example, you specified the + operator for a field thatcontains character data.

B Invalid data length. The data you supplied in the FSA is not the lengththat is defined for that field in the DBD.

C You attempted to change the key field in the segment. Changing the keyfield is not allowed.

E Invalid data in the FSA. The data that you supplied in the FSA is not thetype of data that is defined for this field in the DBD.

F You tried to change an unowned segment. This status code applies only torelated MSDBs.

G An arithmetic overflow occurred when you changed the data field.

H The requested field was not found in the segment.

Example of using FLD/VERIFY and FLD/CHANGEThe example in this section uses the bank account segment shown in the topic"Bank Account Example" in IMS Version 10: Application Programming Planning Guide.Assume that a customer wants to withdraw $100 from a checking account. Thechecking account number is 24056772. To find out whether the customer canwithdraw this amount, you must check the current balance. If the current balanceis greater than $100, you want to subtract $100 from the balance, and add 1 to thetransaction count in the segment.

You can do all of this processing by using one FLD call and three FSAs. The threeFSAs are described:1. Verify that the value in the BALANCE field is greater than or equal to $100. For

this verification, you specify the BALANCE field, the H operator for greaterthan or equal to, and the amount. The amount is specified without a decimalpoint. Field names less than eight characters long must be padded with trailingblanks to equal eight characters. You also have to leave a blank between thefield name and the operator for the FSA status code. This FSA looks like this:BALANCE��H10000*

The last character in the FSA is an asterisk, because this FSA will be followedby other FSAs.

2. Subtract $100 from the value in the BALANCE field if the first FSA issuccessful. If the first FSA is unsuccessful, IMS does not continue processing. Tosubtract the amount of the withdrawal from the amount of the balance, you usethis FSA:BALANCE��-10000*

Again, the last character in the FSA is an asterisk, because this FSA is followedby a third FSA.

3. Add 1 to the transaction count for the account. To do this, use this FSA:TRANCNT��+001�

In this FSA, the last character is a blank (�), because this is the last FSA for thiscall.

Chapter 10. Processing Fast Path databases 151

Page 176: IMS Application Programming.pdf

When you issue the FLD call, you do not reference each FSA individually; youreference the I/O area that contains all of them.

Commit-point processing in MSDBs and DEDBsThis section describes the MSDB commit view and DEDBs with an MSDB commitview. (The following information assumes that you are already familiar with theconcepts of commit point processing, as described in IMS Version 10: ApplicationProgramming Planning Guide.)

MSDB commit viewWhen you update a segment in an MSDB, IMS does not apply your updatesimmediately. Updates do not go into effect until your program reaches a commitpoint.

As a result of the way updates are handled, you can receive different results if youissue the same call sequence against a full-function database or a DEDB and anMSDB. For example, if you issue GHU and REPL calls for a segment in an MSDB,and then issue another Get call for the same segment in the same commit interval,the segment that IMS returns to you is the “old” value, not the updated one. If, onthe other hand, you issue the same call sequence for a segment in a full-functiondatabase or DEDB, the second Get call returns the updated segment.

When the program reaches a commit point, IMS also reprocesses the FLDVERIFY/CHANGE call. If the VERIFY test passes, the change is applied to thedatabase. If the VERIFY test fails, the changes made since the previous commitpoint are undone, and the transaction is reprocessed.

DEDBs with MSDB commit viewYour existing application programs can use either the MSDB commit view or thedefault DEDB commit view. To use the MSDB commit view for DEDBs, specifyVIEW=MSDB on the PCB statement; if you do not specify VIEW=MSDB, the DEDB usesthe default DEDB commit view. So no changes to any existing applicationprograms are required in order to migrate your MSDBs to DEDBs.

Assume that you specify VIEW=MSDB in the PCB and an application program issuesGHU and REPL calls to a DEDB followed by another GHU call for the segment in thesame commit interval. Then the application program receives the old value of thedata and not the new value from the REPL call. If you do not specify VIEW=MSDB,your application program receives the new updated values of the data, just as youexpect for a DEDB or other DL/I database.

You can specify VIEW=MSDB for any DEDB PCB. If it is specified for a non-DEDBdatabase, you receive message DFS0904 during ACBGEN.

If you issue a REPL call with a PCB that specifies VIEW=MSDB, the segment musthave a key. This requirement applies to any segment in a path if command code'D' is specified. Otherwise, the AM status code is returned. See IMS: Messages andCodes Reference, Volume 4: IMS Component Codes for information about that statuscode.

Figure 39 on page 153 shows an example of a PCB that specifies the VIEW option.

152 Application Programming Guide

Page 177: IMS Application Programming.pdf

VSO considerationsVSO is transparent to the processing of an application. Where the data resides isimmaterial to the application.

Data locking for MSDBs and DEDBsAll MSDB calls, including the FLD call, can lock the data at the segment level. Thelock is acquired at the time the call is processed and is released at the end of thecall. All DEDB calls, with the exception of HSSP calls, are locked at the VSAM CIlevel. For single-segment, root-only, fixed-length VSO areas, if you specifyPROCOPT R or G, the application program can obtain segment-level locks for allcalls. If you specify any other PROCOPT, the application program obtains VSAMCI locks.

Related reading: For more information on HSSP, see IMS Version 10: DatabaseAdministration Guide.

Segment-level locking (SLL) provides a two-tier locking scheme. First, a share(SHR) lock is obtained for the entire CI. Then, an exclusive (EXCL) segment lock isobtained for the requested segment. This scheme allows for contention detectionbetween SLL users of the CI and EXCL requestors of the CI. When contentionoccurs between an existing EXCL CI lock user and a SHR CI lock requestor, theSHR CI lock is upgraded to an EXCL CI lock. During the time that this EXCL CIlock is held, subsequent SHR CI lock requests must wait until the EXCL CI isreleased at the next commit point.

DEDB FLD calls are not locked at call time. Instead, the lock is acquired at acommit point.

During sync-point processing, the lock is re-acquired (if not already held), and thechanges are verified. Verification failure results in the message being reprocessed(for message-driven applications) or an FE status code (for non-message-drivenapplications). Verification can fail if the segment used by the FLD call has beendeleted or replaced before a sync-point.

Segment retrieval for a FLD call is the same as for a GU call. An unqualified FLD callreturns the first segment in the current area, just as an unqualified GU call does.After the FLD call is processed, all locks for the current CI are released if thecurrent CI is unmodified by any previous call.

When a compression routine is defined on the root segment of a DEDB with aroot-only structure, and when that root segment is a fixed-length segment, itslength becomes variable after being compressed. To replace a compressed segment,you must perform a delete and an insert. In this case, segment level control andlocking will not be available.

PCB , *00000100TYPE=DB, *00000200NAME=DEDBJN21, *00000300PROCOPT=A, *00000400KEYLEN=30, *00000500VIEW=MSDB, *00000600POS=M 00000700

Figure 39. Sample PCB specifying View=MSDB

Chapter 10. Processing Fast Path databases 153

Page 178: IMS Application Programming.pdf

Restrictions on using calls for MSDBs

To retrieve segments from an MSDB 1, you can issue Get calls just as you do toretrieve segments from other IMS databases. Because MSDBs contain only rootsegments, you only use GU and GN calls (and GHU and GHN calls when you plan toupdate a segment). If the segment name field in the SSA contains *MYLTERM, theGU, GHU, and FLD calls return the LTERM-owned segment, and the remainder of theSSA is ignored.

When you are processing MSDBs, you should consider the following differencesbetween calls to MSDBs and to other IMS databases:v You can use only one SSA in a call to an MSDB.v MSDB calls cannot use command codes.v MSDB calls cannot use multiple qualification statements (Boolean operators).v The maximum length for an MSDB segment key is 240 bytes (not 255 bytes, as

in other IMS databases).v If the SSA names an arithmetic field (types P, H, or F) as specified in the

database description (DBD), the database search is performed using arithmeticcomparisons (rather than the logical comparisons that are used for DL/I calls).

v If a hexadecimal field is specified, each byte in the database field is representedin the SSA by its two-character hexadecimal representation. This representationmakes the search argument twice as long as the database field.Characters in hexadecimal-type SSA qualification statements are tested forvalidity before translation to the database format. Only numerals 0 through 9and letters A through F are accepted.

v Terminal-related and non-terminal-related LTERM-keyed MSDBs are notsupported for ETO or LU 6.2 terminals. Attempted access results in no databeing retrieved and an AM status code. See IMS Version 10: Communications andConnections Guide for more information on ETO and LU 6.2.

v MSDBs cannot be shared among IMS subsystems in a sysplex group. Whenusing the Fast Path Expedited Message Handler (EMH), terminal related andnon-terminal related with terminal key MSDBs can only be accessed by staticterminals. These static terminals run transactions with Sysplex Processing Code(SPC) of Locals Only as specified in DBFHAGU0 (Input Edit Router exitroutine).

Processing DEDBs (IMS and CICS with DBCTL)This section explains subset pointers, the POS call, data locking, and the P and Hprocessing options.

Processing DEDBs with subset pointersSubset pointers and the command codes you use with them are optimization toolsthat significantly improve the efficiency of your program when you need toprocess long segment chains. Subset pointers are a means of dividing a chain ofsegment occurrences under the same parent into two or more groups or subsets.You can define as many as eight subset pointers for any segment type. You thendefine the subset pointers from within an application program. (This is furtherdescribed in “Using subset pointers” on page 157.) Each subset pointer points tothe start of a new subset. For example, in Figure 40 on page 155, suppose you

1. This section does not apply to CICS users.

154 Application Programming Guide

Page 179: IMS Application Programming.pdf

define one subset pointer that divides the last three segment occurrences from thefirst four. Your program can then refer to that subset pointer through commandcodes and directly retrieve the last three segment occurrences.

You can use subset pointers at any level of the database hierarchy, except at theroot level. If you try to use subset pointers at the root level, they are ignored.

Figure 41 and Figure 42 on page 156show some of the ways you can set subsetpointers. Subset pointers are independent of one another, which means that youcan set one or more pointers to any segment in the chain. For example, you can setmore than one subset pointer to a segment, as shown in Figure 41.

You can also define a one-to-one relationship between the pointers and thesegments, as shown inFigure 42 on page 156.

Figure 40. Processing a long chain of segment occurrences with subset pointers

Figure 41. Examples of setting subset pointers

Chapter 10. Processing Fast Path databases 155

Page 180: IMS Application Programming.pdf

Figure 43 shows how the use of subset pointers divides a chain of segmentoccurrences under the same parent into subsets. Each subset ends with the lastsegment in the entire chain. For example, the last segment in the subset that isdefined by subset pointer 1 is B7.

Before you use subset pointersFor your program to use subset pointers, the pointers must be defined in the DBDfor the DEDB and in your program's PSB:v In the DBD, you specify the number of pointers for a segment chain. You can

specify as many as eight pointers for any segment chain.v In the PSB, you specify which pointers your program is to use. Define this on

the SENSEG statement. (Each pointer is defined as an integer from 1 to 8.) Also,indicate on the SENSEG statement whether your program can set the pointers ituses. If your program has read sensitivity, it cannot set pointers but can only

Figure 42. Additional examples of setting subset pointers

Figure 43. How subset pointers divide a chain into subsets

156 Application Programming Guide

Page 181: IMS Application Programming.pdf

retrieve segments using subset pointers that are already set. If your program hasupdate sensitivity, it can also update subset pointers by using the S, W, M, andZ command codes.

After the pointers are defined in the DBD and the PSB, an application program canset the pointers to segments in a chain. When an application program finishesexecuting, the subset pointers used by that program remain as they were set by theprogram; they are not reset.

Designating subset pointersTo use subset pointers in your program, you must know the numbers for thepointers as they were defined in the PSB. When you use the subset pointercommand codes, specify the number of each subset pointer you want to usefollowed by the command code. For example, you use R3 to indicate that youwant to retrieve the first segment occurrence in the subset defined by subsetpointer 3. No default exists, so if you do not include a number between 1 and 8,IMS considers your SSA invalid and returns an AJ status code.

Using subset pointersTo take advantage of subsets, application programs use five command codes. TheR command code retrieves the first segment in a subset. The following 4 commandcodes, which are explained in the topic "General Command Codes for DL/I Calls"in IMS Version 10: Application Programming API Reference, redefine subsets bymodifying the subset pointers:

Z Sets a subset pointer to 0.

M Sets a subset pointer to the segment following the current segment.

S Unconditionally sets a subset pointer to the current segment.

W Conditionally sets a subset pointer to the current segment.

Before your program can set a subset pointer, it must establish a position in thedatabase. A call must be fully satisfied before a subset pointer is set. The segment apointer is set to depends on your current position at the completion of the call. If acall to retrieve a segment is not completely satisfied and a position is notestablished, the subset pointers remain as they were before the call was made. Youcan use subset pointer command codes in either an unqualified SSA or a qualifiedSSA. To use a command code in a call with an unqualified SSA, use the commandcode along with the number of the subset pointer you want, after the segmentname. This is shown in Table 25.

Table 25. Unqualified SSA with subset pointer command code

Seg Name * Cmd Code Ssptr. �

8 1 Variable Variable 1

To use a subset pointer command code with a qualified SSA, use the commandcode and subset pointer number immediately before the left parenthesis of thequalification statement, as shown in Table 26.

Table 26. Qualified SSA with subset pointer command code

Seg Name * Cmd Code Ssptr. ( Fld Name R.O. Fld Value )

8 1 Variable Variable 1 8 2 Variable 1

Chapter 10. Processing Fast Path databases 157

Page 182: IMS Application Programming.pdf

The examples in this section use calls with unqualified SSA. The examples arebased on the topic "Sample Application Program" in IMS Version 10: ApplicationProgramming API Reference, which is described in “Fast Path coding considerations”on page 171.

Inserting segments in a subset: When you use the R command code to insert anunkeyed segment in a subset, the new segment is inserted before the first segmentoccurrence in the subset. However, the subset pointer is not automatically set tothe new segment occurrence.

Example: The following call inserts a new B segment occurrence in front ofsegment B5, but does not set subset pointer 1 to point to the new B segmentoccurrence:ISRT A�������(Akey����=�A1)

B�������*R1

To set subset pointer 1 to the new segment, you use the S command code alongwith the R command code, as shown in the following example:ISRT A�������(Akey����=�A1)

B�������*R1S1

If the subset does not exist (subset pointer 1 is set to 0), the segment is added tothe end of the segment chain.

Deleting the segment pointed to by a subset pointer: If you delete the segmentpointed to by a subset pointer, the subset pointer points to the next segmentoccurrence in the chain. If the segment you delete is the last segment in the chain,the subset pointer is set to 0.

Combining command codes: You can use the S, M, and W command codes withother command codes, and you can combine subset pointer command codes witheach other, as long as they do not conflict. For example, you can use R and Stogether, but you cannot use S and Z together because their functions conflict. Ifyou combine command codes that conflict, IMS returns an AJ status code to yourprogram.

You can use one R command code for each SSA and one update command code(Z, M, S, or W) for each subset pointer.

Subset pointer status codesIf you make an error in an SSA that contains subset pointer command codes, IMScan return either of these status codes to your program:

AJ The SSA used an R, S, Z, W, or M command code for a segment that doesnot have subset pointers defined in the DBD.

The subset command codes included in the SSA are in conflict. Forexample, if one SSA contains an S command code and a Z command codefor the same subset pointer, IMS returns an AJ status code. S indicates thatyou want to set the pointer to current position; Z indicates that you wantto set the pointer to 0. You cannot use these command codes in one SSA.

The SSA includes more than one R command code.

The pointer number following a subset pointer command code is invalid.You either did not include a number, or you included an invalid character.The number following the command code must be between 1 and 8.

AM The subset pointer referenced in the SSA is not specified in the program's

158 Application Programming Guide

Page 183: IMS Application Programming.pdf

PSB. For example, if your program's PSB specifies that your program canuse subset pointers 1 and 4, and your SSA references subset pointer 5, IMSreturns an AM status code.

Your program tried to use a command code that updates the pointer (S, W,or M), but the program's PSB did not specify pointer-update sensitivity.

Your program attempted to open a GSAM database without specifying anIOAREA.

Retrieving location with the POS call (for DEDB only)With the POS (Position) call, you can:v Retrieve the location of a specific sequential dependent segment.v Retrieve the location of the last-inserted sequential dependent segment, its time

stamp, and the IMS ID.v Retrieve the time stamp of a sequential dependent or Logical Begin.v Tell the amount of unused space within each DEDB area. For example, you can

use the information that IMS returns for a POS call to scan or delete thesequential dependent segments for a particular time period.

The topic "POS Call" in IMS Version 10: Application Programming API Referenceexplains how you code the POS call and what the I/O area for the POS call lookslike. If the area that the POS call specifies is unavailable, the I/O area is unchanged,and the FH status code is returned.

Locating a specific sequential dependentWhen you have position on a particular root segment, you can retrieve the positioninformation and the area name of a specific sequential dependent of that root. Ifyou have a position established on a sequential dependent segment, the searchstarts from that position. IMS returns the position information for the firstsequential dependent segment that satisfies the call. To retrieve this information,issue a POS call with a qualified or unqualified SSA containing the segment nameof the sequential dependent. Current position after this kind of POS call is the sameplace that it would be after a GNP call.

After a successful POS call, the I/O area contains:

LL A 2-byte field giving the total length of the data in the I/O area, inbinary.

Area Name An 8-byte field giving the ddname from the AREA statement.

Position An 8-byte field containing the position information for therequested segment.

Exception: If the sequential dependent segment that is the target ofthe POS call is inserted in the same synchronization interval, noposition information is returned. Bytes 11-18 contain X'FF'. Otherfields contain normal data.

Unused CIs A 4-byte field containing the number of unused CIs in thesequential dependent part.

Unused CIs A 4-byte field containing the number of unused CIs in theindependent overflow part.

Locating the last inserted sequential dependent segmentYou can also retrieve the position information for the most recently insertedsequential dependent segment of a given root segment. To do this, you issue a POS

Chapter 10. Processing Fast Path databases 159

Page 184: IMS Application Programming.pdf

call with an unqualified or qualified SSA containing the root segment as thesegment name. Current position after this type of call follows the same rules asposition after a GU call.

You can also retrieve the position of the SDEP, its time stamp, and the ID of theIMS that owns the segment. To do this, you issue a POS call with a qualified SSAand provide the keyword PCSEGTSP in position one of the I/O area as input to thePOS call. The keyword requests the POS call to return the position of the SDEP, itstime stamp, and the ID of the IMS that owns the segment.

Requirement: The I/O area must be increased in size to 42 bytes to allow for theadded data being returned. The I/O area includes a 2-byte LL field that is notshown in Table 27. This LL field is described after Table 27.

Table 27. Qualified POS call: keywords and map of I/O area returned

Keyword word 0 word 1 word 2 word 3 word 4 word 5 word 6 word 7 word 8 word 9

<null> Field 1 Field 2 Field 3 Field 4 N/A N/A

PCSEGTSP Field 1 Field 2 Field 5 Field 6 Field 7

Field 1 Area name

Field 2 Sequential dependent location from qualified SSA

Field 3 Unused CIs in sequential dependent part

Field 4 Unused CIs in independent overflow part

Field 5 Committed sequential dependent segment time stamp

Field 6 IMS ID

Field 7 Pad

After a successful POS call, the I/O area contains:

LL (Not shown in table) A 2-byte field, in binary, containing the totallength of the data in the I/O area.

(Field 1)

Area NameAn 8-byte field giving the ddname from the AREAstatement.

(Field 2)

PositionAn 8-byte field containing the position information for themost recently inserted sequential dependent segment. Thisfield contains zeros if no sequential dependent exists forthis root.

Sequential dependent location from qualified SSAIMS places two pieces of data in this 8-byte field after asuccessful POS call. The first 4 bytes contain the cyclecount, and the second 4 bytes contain the VSAM RBA.

If the sequential dependent segment that is the target ofthe POS call is inserted in the same synchronizationinterval, no position information is returned. Bytes 11-18contain X'FF'. Other fields contain normal data.

160 Application Programming Guide

Page 185: IMS Application Programming.pdf

(Field 3)

Unused CIs in sequential dependent partA 4-byte field containing the number of unused controlintervals in the sequential dependent part.

(Field 4)

Unused CIs in independent overflow partA 4-byte field containing the number of unused controlintervals in the independent overflow part.

(Field 5)

Committed Sequential Dependent Segment Time StampAn 8-byte field containing the time stamp that correspondsto the SDEP segment located by the qualified POS call.

(Field 6)

IMS IDIdentifies the IMS that owns the CI where the SDEPsegment was located.

(Field 7)

Pad An 8-byte pad area to align the I/O area on a double wordboundary. No data is returned to this field.

Identifying free spaceTo retrieve the area name and the next available position within the sequentialdependent part from all online areas, you can issue an unqualified POS call. Thistype of call also retrieves the unused space in the independent overflow andsequential dependent parts.

After a unsuccessful unqualified POS call, the I/O area contains the length (LL),followed by the same number of entries as existing areas within the database. Eachentry contains the fields shown below:

Area Name An 8-byte field giving the ddname from the AREA.

Position An 8-byte field with binary zeros.

Unused SDEP CIs A 4-byte field with binary zeros.

Unused IOV CIs A 4-byte field with two binary zeros followed by abad status code.

Commit-point processing in a DEDBIMS retains database updates in processor storage until the program reaches acommit point. IMS saves updates to a DEDB in Fast Path buffers. The databaseupdates are not applied to the DEDB until after the program has successfullycompleted commit-point processing. Unlike Get calls to an MSDB, however, a Getcall to an updated segment in a DEDB returns the updated value, even if a commitpoint has not occurred.

When a BMP is processing DEDBs, it must issue a CHKP or SYNC call to docommit-point processing before it terminates. Otherwise, the BMP abnormallyterminates with abend U1008.

If you want a DEDB to have an MSDB commit view, refer to “Commit-pointprocessing in MSDBs and DEDBs” on page 152.

Chapter 10. Processing Fast Path databases 161

Page 186: IMS Application Programming.pdf

P processing optionIf the P processing option is specified in the PCB for your program, a GC statuscode is returned to your program whenever a call to retrieve or insert a segmentcauses a unit of work (UOW) boundary to be crossed.

Related reading: For more information on the UOW for DEDBs, see IMS Version10: Database Administration Guide.

Although crossing the UOW boundary probably has no particular significance foryour program, the GC status code indicates that this is a good time to issue eithera SYNC or CHKP call. The advantages of issuing a SYNC or CHKP call after yourprogram receives a GC status code are:v Your position in the database is retained. Issuing a SYNC or CHKP call normally

causes position in the database to be lost, and the application program mustreestablish position before it can resume processing.

v Commit points occur at regular intervals.

When a GC status code is returned, no data is retrieved or inserted. In yourprogram, you can either:v Issue a SYNC or CHKP call, and resume database processing by reissuing the call

that caused the GC status code.v Ignore the GC status code, and resume database processing by reissuing the call

that caused the status code.

H processing optionIf the H processing option has been specified in the PCB for your call program, aGC status code is returned whenever a call to retrieve or insert a segment causes aunit of work (UOW) or an area boundary to be crossed. The program must cause acommit process before any other calls can be issued to that PCB.

If a commit process is not caused, an FR status code results (total buffer allocationexceeded), and all database changes for this synchronization interval are “washed”(sync-point failure).

A GC status code is returned when crossing the area boundary so that theapplication program can issue a SYNC or CHKP call to force cleanup of resources(such as buffers) that were obtained in processing the previous area. This cleanupmight cause successive returns of a GC status code for a GN or GHN call, even if aSYNC or CHKP call is issued appropriately for the previous GC status code.

When an application is running HSSP and proceeding through the DEDB AREAsequentially, a buffer shortage condition may occur due to large IOV chains. In thiscase, a FW status code is returned to the application. Usually, the application issuesa commit request and position is set to the next UOW. However, this does notallow the previous UOW to finish processing. In order to finish processing theprevious UOW, you can issue a commit request after the FW status code isreceived and set the position to remain in the same UOW. You must also repositionthe application to the position that gave the FW status code. The following showsan example of the command sequence and corresponding application responses.

GN root1GN root2GN root3

162 Application Programming Guide

Page 187: IMS Application Programming.pdf

GN root4 /*FW status code received*/CHKPGN SSA=(root4) root4 /*User reposition prior to CHKP*/GN root5

Data lockingFor information on how data locking is handled for DEDBs, see “Data locking forMSDBs and DEDBs” on page 153.

Calls with dependent segments for DEDBsThis section provides information on which calls you can use with direct andsequential dependent segments for DEDBs. The DL/I calls that you can issueagainst a root segment are: GU, GN (GNP has no meaning for a root segment), DLET,ISRT, and REPL. You can issue all DL/I calls against a direct dependent segment,and you can issue Get and ISRT calls against sequential dependents segments.

Direct dependent segmentsDL/I calls to direct dependents include the same number of SSAs as existing levelsin the hierarchy (a maximum of 15). They can also include command codes andmultiple qualification statements. The same rules apply to using command codeson DL/I calls to DEDBs as to full-function databases.

Exception:

v If you use the D command code in a call to a DEDB, the P processing optionneed not be specified in the PCB for the program. The P processing option has adifferent meaning for DEDBs than for full-function databases. (See “P processingoption” on page 162.)

Some special command codes can be used only with DEDBs that use subsetpointers. Your program uses these command codes to read and update the subsetpointers. Subset pointers are explained in “Processing DEDBs with subset pointers”on page 154.

Sequential dependent segmentsBecause sequential dependents are stored in chronological order, they are useful injournaling, data collection, and auditing application programs. You can accesssequential dependents directly. However, sequential dependents are normallyretrieved sequentially using the Database Scan utility.

Restriction: When processing sequential dependent segments:v You can only use the F command code with sequential dependents; IMS ignores

all other command codes.v You cannot use Boolean operators in calls to sequential dependents.

Related reading: For more information about the utility, see IMS Version 10:Database Utilities Reference.

Chapter 10. Processing Fast Path databases 163

Page 188: IMS Application Programming.pdf

DEDB DL/I calls to extract DEDB informationDL/I calls can be issued to obtain structural information about Data EntryDatabases (DEDBs). Any application that can issue DL/I calls can take advantageof these DL/I calls.

There are two basic call types:v The first type returns the minimum I/O area length required for a specific type

'2' DL/I call.v The second type returns specific information about the specified DEDB.

Each of these DL/I calls uses a call interface block called the Input Output InputArea (IOAI), a Telecommunication-Program Program Specification Block (TP PCB),and specific calls that require an I/O area. Some required initialization of the IOAIis common for all calls and some initialization is specific to an individual call. TheIOAI and the I/O area must be obtained in key 8 storage.

The following table describes the DL/I calls to extract DEDB information.

Table 28. DEDB DL/I Calls

DL/I Call Description

AL_LEN Returns the minimum length of the I/O areathat is required for an AREALIST call.

DI_LEN Returns the minimum length of the I/O areathat is required for an DEDBINFO call.

DS_LEN Returns the minimum length of the I/O arearequired for a DEDBSTR call.

AREALIST Returns a list of areas that are part of thespecified DEDB, with each area mapped byDBFCDAL1.

DEDBINFO Returns DEDB information from the DMCB,mapped by DBFCDDI1.

DEDBSTR Returns a list of segments and a segmentdata for DEDB with each segment mappedby DBFCDDS1.

The DL/I call that use the standard interface with register 1 must point toIOAI_CA.

The following figure shows the IOAI structure.startingoffset note

IOAI_START DS 0FIOAI_NAME DC CL4’IOAI’ 0 *1IOAI_#FPU DC CL4’#FPU’ 4 *1IOAI_#FPI DC CL8’#FPUCDPI’ 8 *1IOAI_SUBC DC CL8’ ’ 10 *1*IOAI_BLEN DC A(0) 18 *1IOAI_ILEN DC A(0) 1C *1IOAI_IOAREA DC A(0) 20 *1*IOAI_CALL DC A(0) 24 *1IOAI_PCBI DC A(0) 28 *1IOAI_IOAI DC A(0) 2C *1*

164 Application Programming Guide

|

|||

|

||

|

|||||

|

||

||

|||

|||

|||

||||

|||

|||||

||

|

||||||||||||||||

Page 189: IMS Application Programming.pdf

IOAI_DLEN DC A(0) 30 *2IOAI_STATUS DC CL2’ ’ 34 *2IOAI_B_LEVEL DC XL2’0’ 36 *2IOAI_STATUS_RC DC A(0) 38 *2IOAI_USERVER DC A(0) 3C *1IOAI_IMSVER DC A(0) 40 *2*IOAI_IMSLEVEL DC A(0) 44 *2*IOAI_APPL_NAME DC CL8’ ’ 48 *1IOAI_USERDATA DC CL8’ ’ 50 *1IOAI_TIMESTAMP DC CL8’ ’ 58 *2* input words.IOAI_IN0 DC A(0) 60 *3IOAI_IN1 DC A(0) 64 *3IOAI_IN2 DC A(0) 68 *3IOAI_IN3 DC A(0) 6C *3IOAI_IN4 DC A(0) 70 *3* feedback wordsIOAI_FDBK0 DC A(0) 74 *2IOAI_FDBK1 DC A(0) 78 *2IOAI_FDBK2 DC A(0) 7C *2IOAI_FDBK3 DC A(0) 80 *2IOAI_FDBK4 DC A(0) 84 *2* workareas.IOAI_WA0 DC A(0) 88 *4IOAI_WA1 DC A(0) 8C *4IOAI_WA2 DC A(0) 90 *4IOAI_WA3 DC A(0) 94 *4IOAI_WA4 DC A(0) 98 *4*

DS 20F’0’ 9C for future expansionIOAI_END_CHAR DC CL4’IEND’ EC *1IOAI_LEN len(DBFIOAI) = x’F0’ bytes

Notes:

1. The user is responsible for initializing these fields.2. IMS uses these fields to return data to the caller. Which fields contain returned

data depends on the DL/I call and are documented in the section on thespecific call types.

3. May be used to pass additional data on the DL/I call, as documented undereach DL/I call.

4. These fields are unchanged, and can be used as work areas by the application.

The fields in the following table must be initialized for all of the following DL/Icalls.

Table 29. Field initialization for DEDB DL/I calls

Field Description

IOAI_NAME The characters 'IOAI' identifying this block.

IOAI_#FPU The characters '#FPU' Indicating this is a#FPU call.

IOAI_#FPI The characters '#FPUCDPI' indicating this isa subset call.

IOAI_SUBC The DL/I call: AL_LEN, AREALIST,DS_LEN, DEDBSTR, DI_LEN or DEDBINFO.

IOAI_BLEN The total length of the IOAI (x'F0').

IOAI_CALL Address of IOAI_#FPU.

IOAI_PCBI Address of the TPCB.

Chapter 10. Processing Fast Path databases 165

||||||||||||||||||||||||||||||||||

|

|

|||

||

|

||

||

||

||

|||

|||

|||

||

||

||

Page 190: IMS Application Programming.pdf

Table 29. Field initialization for DEDB DL/I calls (continued)

Field Description

IOAI_IOAI Address of this block. The user must set thehigh order bit on to indicate the end of theDL/I list.

IOAI_USERVER Call version number. Defaults to one. This isthe version number of a specific call. Thisfield will be updated in the future if aspecific call is altered such that theapplication must be sensitive to the changes.

IOAI_END_CHAR The chars 'IEND' identifying the end ofblock.

The following fields are initialized for specific DL/I calls. If a specific call does notneed an I/O area, these fields are ignored.

Table 30. Fields initialized for specific DEDB DL/I calls

Field Description

IOAI_ILEN The total length of the I/O area, includingprefix and suffix.

IOAI_IOAREA Address of the I/O area.

I/O Area 1st word: The I/O area length (same asIOAI_ILEN). Last word: X'FFFFFFFF', whichis an 'end of I/O area' marker.

IOAI_IN0 -> IOAI_IN4 Five input words that might be required.

The following fields are updated by IMS for all the DEDB DL/I call types.

Table 31. Fields updated by IMS for all DL/I call types

Field Description

IOAI_DLEN The length of the output data that is returnedby IMS. This field is informational only.

IOAI_STATUS A 2-byte status code.

IOAI_STATUS_RC A return code if needed.

IOAI_IMSVER The maximum version of this call.

IOAI_IMSLEVEL The IMS level.

The following fields might be updated by specific DL/I calls.

Table 32. Fields updated by specific DL/I calls

Field Description

I/O Area 1st word: unchanged. Data: see specific calltypes. Last word: potentially changed.

IOAI_FDBK0 -> IOAI_FDBK4 Five output words which may return data asdocumented by specific calls.

166 Application Programming Guide

|

||

||||

||||||

||||

||

||

||

|||

||

||||

|||

|

||

||

|||

||

||

||

|||

|

||

||

|||

||||

Page 191: IMS Application Programming.pdf

AL_LEN CallThe AL_LEN call returns the minimum length of the I/O area required for anAREALIST call.

InputIOAI

Formatted and filled out as documented above.

IOAI_IN0Points to storage containing the DEB name.

OutputIOAI_STATUS

Call status, ' ' means successful.

IOAI_FDBK0The minimum length of the I/O area.

IOAI_FDBK1The number of AREAS in this DEDB.

DI_LEN CallReturn the minimum length of the I/O area required for an DEDBINFO call.

InputIOAI

Formatted and filled out as documented above.

IOAI_IN0Points to storage containing the DEB name.

OutputIOAI_STATUS

Call status, ' ' means successful.

IOAI_FDBK0The minimum length of the I/O area.

DS_LEN CallReturn the minimum length of the I/O area required for a DEDBSTR call.

InputIOAI

Formatted and filled out as documented above.

IOAI_IN0Points to storage containing the DEB name.

OutputIOAI_STATUS

Call status, ' ' means successful.

IOAI_FDBK0The minimum length of the I/O area.

IOAI_FDBK1The number of SEGMENTS in this DEDB.

Chapter 10. Processing Fast Path databases 167

|

||

|

||

||

|

||

||

||

|

|

|

||

||

|

||

||

|

|

|

||

||

|

||

||

||

Page 192: IMS Application Programming.pdf

AREALIST CallReturn a list of areas which are part of the specified DEDB, with each area mappedby DBFCDAL1.

InputIOAI

Formatted and filled out as documented above.

IOAI_IN0Points to storage containing the DEB name.

I/O AreaFormatted as documented above.

OutputIOAI_STATUS

Call status, ' ' means successful.

IOAI_FDBK0The minimum length of the I/O area.

IOAI_FDBK1The number of AREAS in this DEDB.

The I/O Area0 4 8 C 14 len-4______________________________________//_____________________| I/O | offset| data | DEDB | area list | end of data || area | to |length | name | using DBFCDAL1 | marker || len | data | | | control blocks | x’EEEEEEEE’ |______________________________________//_____________________

len:4 4 4 8 variable 4

DEDBINFO CallReturn DEDB information from the DMCB, mapped by DBFCDDI1.

InputIOAI

Formatted and filled out as documented above.

IOAI_IN0Points to storage containing the DEB name.

I/O AreaFormatted with length in the first word, and 'FFFFFFFF' as an end of I/O areamarker.

OutputIOAI_FDBK0

The minimum length of the I/O area.

IOAI_FDBK1The minimum I/O area for the DEDBSTR call.

IOAI_FDBK2The minimum I/O area for the AREALIST call.

The I/O Area

168 Application Programming Guide

|

||

|

||

||

||

|

||

||

||

|

||||||||

|

|

|

||

||

|||

|

||

||

||

||

Page 193: IMS Application Programming.pdf

0 4 8 C 14 len-4_____________________________________________________________| I/O | offset| data | DEDB | the DEDB info | end of data || area | to |length | name | using DBFCDDI1 | marker || len | data | | | control block | x’EEEEEEEE’ |_____________________________________________________________

len:4 4 4 8 len(DBFCDDI1) 4

DEDSTR CallReturn a list of segments and segment data for a DEDB with each segmentmapped by DBFCDDS1.

InputIOAI

Formatted and filled out as documented above.

IOAI_IN0Points to storage containing the DEB name.

I/O AreaFormatted with length in the first word, and 'FFFFFFFF' as an end of I/O areamarker.

OutputIOAI_STATUS

The minimum length of the I/O area.

IOAI_FDBK0The minimum I/O area for the DEDBSTR call.

IOAI_FDBK1The minimum I/O area for the SEGMENTS call.

The I/O Area0 4 8 C 14 len-4______________________________________//_____________________| I/O | offset| data | DEDB | segments | end of data || area | to |length | name | in DBFCDDS1 | marker || len | data | | | control blocks | x’EEEEEEEE’ |______________________________________//_____________________

len:4 4 4 8 variable 4

DBFCDAL1 mapping: offsetCDAL_START DS 0FCDAL_ARNM DS CL8 00 Area nameCDAL_FLGS DS 0XL4 08 Flag BytesCDAL_FLG1 DS XL1 08 Flags for area status:CDAL_F1OP EQU X’01’ - Area is openedCDAL_F1BK EQU X’02’ - Temporary bit for backoutCDAL_F1UT EQU X’04’ - Utility active on this areaCDAL_F1ER EQU X’08’ - Error recovery neededCDAL_F1AF EQU X’80’ - Sequential dep. part fullCDAL_F1EP EQU X’40’ - I/O errorCDAL_F1ST EQU X’20’ - Area stop requestCDAL_F1RE EQU X’10’ - Area restart requestCDAL_FLG2 DS XL1 09 Reserved for Flag Byte #2CDAL_FLG3 DS XL1 0A Reserved for Flag Byte #3CDAL_FLG4 DS XL1 0B Reserved for Flag Byte #4

DS 1F 0C for growthCDAL_LEND DS 0F End of area list entryCDAL_LEN EQU *-&AA._START; Len of area list entry

Chapter 10. Processing Fast Path databases 169

||||||||

|

||

|

||

||

|||

|

||

||

||

|

||||||||

|||||||||||||||||||

Page 194: IMS Application Programming.pdf

DBFCDDI0 mapping: offsetCDDI_START DS 0DCDDI_DBNM DS CL8 00 Database nameCDDI_ANR DS H 08 Number of areas definedCDDI_HSLV DS H 0A Max SEGM level in the DBCDDI_SGNR DS H 0C Highest valid SEGM codeCDDI_SEGL DS H 0E Maximum IOA lengthCDDI_HBLK DS F 10 Number of anchor blocksCDDI_RMNM DS CL8 14 Randomizing module nameCDDI_RMEP DS F 1C Randomizing module entry point

DS 8F 20 ReservedDS 0D Align on double word boundary

CDDI_LEN EQU *-&AA._START; Length of this area (x’40’)

DBFCDDS1 mapping: offsetCDDS_START DS 0FCDDS_GNAM DS CL8 00 SEGMENT NAMECDDS_GDOF DS H 08 OFFSET FROM START SEQ TO DATACDDS_MAX DS H 0A MAX SEG LENCDDS_MIN DS H 0C MIN SEG LENCDDS_DBOF DS H 0E OFFSET TO SEG ENTRIESCDDS_NRFLD DS FL1 10 NUMBER OF FIELDS IN SEGCDDS_SC DS FL1 11 SEGMENT CODECDDS_PREF DS H 12 POINTER OFFSET IN PARENT PREFCDDS_FLG1 DS X 14 FLAG BYTECDDS_FL1K EQU X’80’ KEY SEGMENTCDDS_FL1S EQU X’40’ SEQUENTIAL DEP SEGMENTCDDS_FL1P EQU X’20’ PCL POINTER TO PARENTCDDS_FISRT DS X 15 INSERT RULESCDDS_PARA DS H 16 OFFSET TO PARENT SEGMENTCDDS_SBLP DS F 18 SIBLING POINTERCDDS_LEVL DS XL1 1C SEGMENT LEVELCDDS_KEYL DS XL1 1D KEY LENGTH - 1CDDS_KDOF DS H 1E OFFSET TO KEY FIELD IN SEGMENTCDDS_RSRVE DS XL4 20 FOR USE IN UMDR0 | RESERVEDCDDS_CMPC DS A 24 A(CMPC)CDDS_FLG2 DS XL1 28 FLAG BYTE 2 (fixed length)

DS XL3 29 FOR GROWTHDS 5F 2C for growth

CDDS_END DS 0F ENDCDDS_LEN EQU *-&AA._START; len of SDB entry

The following status codes are specific to these new DL/I calls.

Table 33. Status codes for specific DEDB DL/I calls

Status Code Description

AA Invalid #FPU/#FPUCDPI call.

AB Getmain error.

AC DEDB name not found.

AD The I/O area was not long enough to containthe data.

AE IOAI_LEN was zeros. It must be filled by thecaller.

AF The I/O area address was not passed in byIOAI_IOAREA.

AG The IOAI does not point to itself, IOAI_IOAI.

AH The IOAI did not contain 'IOAI'.

AI The I/O area length in the I/O area does notmatch IOAI.

170 Application Programming Guide

|||||||||||||

|||||||||||||||||||||||||||

|

||

||

||

||

||

|||

|||

|||

||

||

|||

Page 195: IMS Application Programming.pdf

Table 33. Status codes for specific DEDB DL/I calls (continued)

Status Code Description

AJ The I/O area did not contain the end-of-listmarker.

AK The IOAI did not have end-of-block marker'IEND'.

AL IOAI_BLEN is not correct.

AM DEDB not passed in via the IOAI on the#FPUCDPI call.

Fast Path coding considerationsYou can use DL/I calls to access Fast Path databases. You can also use twoadditional calls: FLD and POS. The type of Fast Path database that you areprocessing determines when you can use each of these calls.

To process MSDBs, you can use these calls:v For nonterminal-related MSDBs:

FLD

GU and GHU

GN and GHN

REPL

v For terminal-related, fixed MSDBs:FLD

GU and GHU

GN and GHN

REPL

v For terminal-related, dynamic MSDBs:DLET

FLD

GU and GHU

GN and GHN

ISRT

REPL

You can use these calls to process a DEDB:v DEQ

v DLET

v FLD

v GU and GHU

v GN and GHN

v GNP and GHNP

v ISRT

v POS

v REPL

v RLSE

Chapter 10. Processing Fast Path databases 171

|

||

|||

|||

||

||||

|

|

Page 196: IMS Application Programming.pdf

172 Application Programming Guide

Page 197: IMS Application Programming.pdf

Chapter 11. Writing ODBA application programs

This chapter describes the Open Database Access (ODBA) callable interface to IMSDB and presents information about how you write z/OS application programs thatuse the interface. By using the ODBA interface, IMS DB databases can be accessedfrom environments that are outside the scope of IMS's control, such as DB2 forz/OS stored procedures.

The following topics provide additional information:v “General application program flow” on page 174v “Server program structure” on page 177v “DB2 for z/OS Stored Procedures use of ODBA” on page 178

The ODBA interface is not needed within IMS-controlled regions, such as MPRs,BMPs, or IFPs, for calls to locally-controlled databases.

The z/OS application programs (hereafter called the ODBA application programs)run in a separate z/OS address space that IMS regards as a separate region fromthe control region. The separate z/OS address space hereafter is called the z/OSapplication region.

The ODBA interface gains access to IMS DB through the Database ResourceAdapter (DRA). The ODBA application programs (which can access any addressspace within the z/OS they are running in) gain access to IMS DB databasesthrough the ODBA interface. Figure 44 illustrates this concept and shows therelationship between the components of this environment.

One z/OS application region can connect to multiple IMS DBs and multiple z/OSapplication regions can connect to a single IMS DB. The connection is similar tothat of CICS to DBCTL.

Related Reading: For a description of RRS and its uses, see IMS Version 10:Application Programming Planning Guide for information on the Distributed SyncPoint.

Figure 44. z/OS application region's connection to IMS DB

© Copyright IBM Corp. 1974, 2010 173

Page 198: IMS Application Programming.pdf

General application program flowz/OS application programs issue DL/I calls using an application interface block(AIB). No other interface is supported.

Restriction: The ODBA interface does not support calls into batch DL/I regions.

Several conditions must be met for the AIB call to succeed:1. If an AIB is not passed in the call, a U261 abend is issued.2. If the AIB that is passed is not valid, a U476 abend is issued.3. If the AIB that is passed is not large enough (264 bytes), the AIB return and

reason codes are set to X'104' and X'228'.4. If the AIB that is passed is not on a fullword boundary, the z/OS system will

return an abend S201.5. If there are other internal problems with the call, other return and reason codes

are passed back to the z/OS application program. See IMS: Messages and CodesReference, Volume 4: IMS Component Codes for a complete list of these return andreason codes.

The z/OS must link edit with a language module (DFSCDLI0) or this module canbe loaded into the z/OS application region. The entry point for DFSCDLI0 isAERTDLI.

A simple example of the program flow of a z/OS application program is:1. Establish the application execution environment.2. Allocate a PSB.3. Perform DB calls.4. Commit the changes.5. Deallocate the PSB.6. Terminate the connection.

The following topics provide additional information:v “Establishing the application execution environment”v “Allocating a PSB” on page 175v “Performing DB calls” on page 176v “Commit changes” on page 176v “Deallocating the PSB” on page 176v “Terminating the connection” on page 176

Establishing the application execution environmentThe application execution environment must be initialized in the z/OS applicationregion. Use the CIMS INIT call to initialize the environment. If the optionalDFSRSNM2 field of the AIB contains a startup table ID, a connection to the IMSDB in the startup table is made. If the field is blank, connect to the IMS DB whenyou allocate a PSB.

The form of the connection call is:CALL AERTDLI parmcount, CIMS, AIB

Where:

174 Application Programming Guide

Page 199: IMS Application Programming.pdf

CIMS Is the required call function.

AIB Has the following fields:

AIBSFUNCThe subfunction is INIT. This field is mandatory.

AIBRSNM1An optional field that provides an eye catcher identifier of theapplication server that is associated with the AIB. This field is 8bytes.

AIBRSNM2Provides the optional 4-byte startup table ID. The ID is optional ifthe call is issued as preconditioning only. If the ID is given, thez/OS application region connects to the IMS DB specified in theDBCTLID parameter of the selected startup table.

The characteristics of the connection are determined from the DRA startup table.The startup table name is DFSxxxx0, where xxxx is the startup table ID that is usedin the CIMS and APSB calls. Each startup table defines a combination ofconnection attributes, one of which is a subsystem ID of the IMS DB.

Related Reading: For more information about building a DRA startup table, seeIMS Version 10: System Definition Reference.

Allocating a PSBThe APSB call, introduced for CPIC-driven programs, is used with the ODBAinterface to allocate a PSB for the z/OS application region. Security is checkedbefore the call can succeed. See IMS Version 10: Database Administration Guide fordetails. The APSB call is in the following form:CALL AERTDLI parmcount, APSB, AIB

Where:

APSB Is the required call function.

AIB Is the name of the application interface block. The fields in the AIB mustbe filled in:

AIBRSNM1Is the 8-character PSB name.

AIBRSNM2Is the 4-byte startup table ID.

Several conditions must be met for the allocation request to succeed.1. The PSB must exist and security checking through RACF must succeed.2. A CIMS INIT call must have been successful.3. RRS/MVS must be active when the APSB call is made.

Multiple PSBs can be active at the same time, which is typical for serverenvironments. No token is specifically provided to identify which PSB is to beused for a given call to a given IMS DB, so the same AIB must be used for all callsto the same PSB instance (APSB, DB calls, DPSB). This enables multiple instancesof the same PSB to be in use for the same IMS DB at the same time. Theparallelism is controlled by the thread count specified in the startup table. Themaximum number of threads and dependent regions supported by an IMS DBinstance is 999.

Chapter 11. Writing ODBA application programs 175

Page 200: IMS Application Programming.pdf

Performing DB callsAll DL/I calls, with a few exceptions, are supported through the AIB. Theunsupported calls entail message handling (the IOPCB is available only for systemcalls), CKPT, ROLL, ROLB, and INQY PROGRAM. Alternate destination PCBscannot be used. Both full-function databases and DEDBs are available.

Commit changesSynchronization is performed by issuing the distributed commit calls, SRRCMIT orATRCMIT, or possibly their rollback forms of SRRBACK or ATRBACK. IMSsync-point calls are not allowed. Commit is effective for all RRS/MVS controlledresources in the z/OS task.

Deallocating the PSBThe DPSB call is used when the work unit is complete. In the default case, acommit call must be issued before a DPSB call can be issued. No DL/I call,including system service calls, can be made between the commit and the DPSBcall.

The DPSB call is in the following form:CALL AERTDLI parmcount, DPSB, AIB

Where:

DPSB Is the required call function.

AIB Is the name of the application interface block. The following fields in theAIB must be filled in:

AIBRSNM1Is the 8-character PSB name.

AIBSFUNCIs an optional field. Set it to 'PREPbbbb' when you want todeallocate the PSB before initialization of commit processing andwhen the commit processing is provided from outside theapplication.

IMS performs phase 1 commit processing and returns control tothe requestor, but holds the in-doubt work until RRS/MVS (thecommit manager) requests full commit processing. An example isin DB2 UDB for z/OS Stored Procedures, where DB2 for z/OSinitializes commit processing on behalf of the procedure.

See “DB2 for z/OS Stored Procedures use of ODBA” on page 178for a discussion of this scenario.

Terminating the connectionThe termination call is in the following form:CALL AERTDLI parmcount, CIMS, AIB

Where:

CIMS Is the required call function.

AIB Is the name of the application interface block. The following fields in theAIB must be filled in:

176 Application Programming Guide

Page 201: IMS Application Programming.pdf

AIBSFUNCIs a mandatory field whose value is TERM or TALL. Use TERM tosever a single IMS DB connection. Use TALL to sever allconnections for this z/OS application region and remove the DRAfrom the address space.

AIBRSNM1Is an optional field that provides an eye catcher identifier of theapplication server associated with the AIB. This field is 8 bytes inlength.

AIBRSNM2When subfunction equals TERM, provides the 4-byte startup tableID used in a previous APSB call. Is not needed when thesubfunction equals TALL.

Server program structureThe commit scope within the z/OS application environment is all the work underthe TCB from which the commit request is made to RRS/MVS. Serverenvironments, therefore, need a separate TCB under which the individual clientrequests will be managed. Each TCB will map to a PST for thread handling.

Figure 45 shows an example TCB structure for a server environment.

Each connection to an IMS DB uses a thread under the TCB. When the APSB call isprocessed, a context is established and tied to the TCB. At commit time, allcontexts for this TCB are committed or aborted by RRS/MVS.

Loading DFSCDLI0 rather than link editing is attractive when the z/OS applicationregion is a server supporting many clients with many instances of threadsconnected with the IMS DBs.

IMSDatabaseManager(DL/I SAS)

z/OSApplication

Region

z/OS

TCB DFSCDLI0

TCB

DRA

PST

PST

PSTTCB

TCB

Figure 45. DRA uses one TCB per thread

Chapter 11. Writing ODBA application programs 177

Page 202: IMS Application Programming.pdf

DB2 for z/OS Stored Procedures use of ODBADB2 for z/OS Stored Procedures are a special case of the general server structuredescribed in “Server program structure” on page 177. Stored Proceduresconnecting to ODBA require DB2 for z/OS Version 5 or later and must run in awork load manager (WLM)-managed stored procedures address space.

DB2 for z/OS establishes the ODBA environment by issuing the INIT subcall forthe stored procedure address space. Connection to a specific IMS DB occurs whenthe APSB call is issued.

Each stored procedure running in the stored procedure address space runs underits own TCB that was established by DB2 for z/OS when the stored procedure isinitialized. DB2 for z/OS issues the commit call on behalf of the stored procedurewhen control is returned to DB2 for z/OS. Only the PREP subfunction of the DPSBcall should be issued by the stored procedures themselves.

Figure 46 illustrates the connection from a DB2 for z/OS Stored Procedures addressspace to an IMS DB subsystem. This connection allows DL/I data to be presentedthrough an SQL interface, either locally to this DB2 for z/OS or to DRDA®

connected DB2 for z/OS databases.

Figure 47 on page 179 illustrates the general relationships involved with using DB2for z/OS Stored Procedures and IMS DB together.

z/OS

z/OStables

IMSdatabases

z/OSapplication

region

ODBA

DRA

IMSDatabaseManager(DL/SAS)

Figure 46. DB2 for z/OS Stored Procedures connection to IMS DB

178 Application Programming Guide

|

|||

|

Page 203: IMS Application Programming.pdf

z/OS

EXEC SQL

Call PGMX

EXEC SQL

Commit

DRDAClient

DB2

SchedPGMX

ReturnValuestoUser

PGMX

Call APSB

Call GU DB

Call DPSB PREP

IMSDB

RRS/MVS

Figure 47. DB2 for z/OS Stored Procedures relationships

Chapter 11. Writing ODBA application programs 179

Page 204: IMS Application Programming.pdf

180 Application Programming Guide

Page 205: IMS Application Programming.pdf

Part 2. Application programming for IMS TM

Chapter 12. Defining application programelements for IMS TM . . . . . . . . . . 183Formatting DL/I calls for language interfaces . . 183Application programming for assembler language 184

Format . . . . . . . . . . . . . . 184Parameters . . . . . . . . . . . . . 185Example DL/I call formats . . . . . . . . 186

Application programming for C language . . . . 186Format . . . . . . . . . . . . . . 187Parameters . . . . . . . . . . . . . 188I/O area . . . . . . . . . . . . . . 189Example DL/I call formats . . . . . . . . 189

Application programming for COBOL . . . . . 189Format . . . . . . . . . . . . . . 190Parameters . . . . . . . . . . . . . 191Example DL/I call formats . . . . . . . . 192

Application programming for Java . . . . . . 192Application programming for Pascal . . . . . 192

Format . . . . . . . . . . . . . . 192Parameters . . . . . . . . . . . . . 193Example DL/I call formats . . . . . . . . 195

Application programming for PL/I . . . . . . 195Format . . . . . . . . . . . . . . 195Parameters . . . . . . . . . . . . . 196Example DL/I call formats . . . . . . . . 197

Relationship of calls to PCB types . . . . . . 197Specifying the I/O PCB mask . . . . . . . . 198Specifying the alternate PCB mask . . . . . . 202Specifying the AIB mask . . . . . . . . . 203Specifying the I/O areas. . . . . . . . . . 205AIBTDLI interface . . . . . . . . . . . . 205Specifying language-specific entry points . . . . 206

Assembler language . . . . . . . . . . 206C language . . . . . . . . . . . . . 206COBOL . . . . . . . . . . . . . . 207Pascal . . . . . . . . . . . . . . . 207PL/I . . . . . . . . . . . . . . . 208CCETDLI and AIBTDLI interface considerations 208

Program communication block (PCB) lists . . . . 208PCB list format . . . . . . . . . . . . 208Format of a GPSB PCB list . . . . . . . . 209PCB summary . . . . . . . . . . . . 209

Language environments . . . . . . . . . . 209The CEETDLI interface to IMS . . . . . . 209LANG= option on PSBGEN for PL/Icompatibility . . . . . . . . . . . . 210

Special DL/I situations . . . . . . . . . . 210Mixed-language programming. . . . . . . 210Using Language Environment routine retention 211Using the extended addressing capabilities ofMVS/ESA . . . . . . . . . . . . . 211Preloaded programs . . . . . . . . . . 211DCCTL . . . . . . . . . . . . . . 211

Chapter 13. Message processing . . . . . . 213How your program processes messages . . . . 213

Message types . . . . . . . . . . . . 213When a message is processed . . . . . . . 217Results of a message: I/O PCB . . . . . . 218

How IMS TM edits messages . . . . . . . . 219Printing output messages . . . . . . . . 219Using Basic Edit . . . . . . . . . . . 219Using Intersystem Communication edit. . . . 220Message Format Service . . . . . . . . . 220Using LU 6.2 User Edit exit routine (optional) 227

Message processing considerations for DB2 . . . 227Sending messages to other terminals and programs 228

Sending messages to other terminals . . . . 229Sending messages to other application programs 231How the VTAM I/O facility affects your VTAMterminal . . . . . . . . . . . . . . 233

Communicating with other IMS TM systems usingMSC . . . . . . . . . . . . . . . . 233

Implications of MSC for program coding . . . 233Receiving messages from other IMS TM systems 234Sending messages to alternate destinations inother IMS TM systems . . . . . . . . . 235

IMS conversations . . . . . . . . . . . . 236A conversational example . . . . . . . . 237Conversational structure. . . . . . . . . 238Replying to the terminal. . . . . . . . . 242Using ROLB, ROLL, and ROLS in conversations 242Passing the conversation to anotherconversational program . . . . . . . . . 242Message switching in APPC conversations . . 245

Processing conversations with APPC . . . . . 246Ending the APPC conversation . . . . . . 247Coding a conversational program . . . . . 247Standard IMS application programs . . . . . 248Modified IMS application programs . . . . . 248CPI-C driven application programs . . . . . 249

Processing conversations with OTMA . . . . . 250Backing out to a prior commit point: ROLL, ROLB,and ROLS calls . . . . . . . . . . . . . 250

Comparison of ROLB, ROLL, and ROLS . . . 251ROLL . . . . . . . . . . . . . . . 251ROLB . . . . . . . . . . . . . . . 252ROLS . . . . . . . . . . . . . . . 253

Backing out to an intermediate backout point:SETS/SETU and ROLS . . . . . . . . . . 254

SETS/SETU . . . . . . . . . . . . . 255ROLS . . . . . . . . . . . . . . . 256

Writing message-driven programs . . . . . . 257Coding DC calls and data areas . . . . . . . 257

Before coding your program . . . . . . . 258Skeleton MPP . . . . . . . . . . . . 258Coding your program in assembler language 259Coding your program in C language . . . . 259Coding your program in COBOL . . . . . . 261Coding your program in Pascal . . . . . . 263Coding your program in PL/I . . . . . . . 265Message processing considerations for DB2 . . 267

© Copyright IBM Corp. 1974, 2010 181

||

Page 206: IMS Application Programming.pdf

Chapter 14. Spool API . . . . . . . . . . 269Understanding parsing errors . . . . . . . . 269

Keywords . . . . . . . . . . . . . 269Status codes . . . . . . . . . . . . . 269Error codes . . . . . . . . . . . . . 269Diagnosis examples . . . . . . . . . . 271

Understanding allocation errors . . . . . . . 273Understanding dynamic output for print data sets 273

CHNG call with PRTO option . . . . . . . 273CHNG call with TXTU option . . . . . . . 274CHNG call with OUTN option . . . . . . 274

Sample program using the Spool API . . . . . 274Application PCB structure . . . . . . . . 274GU call to I/O PCB . . . . . . . . . . 275CHNG call to alternate PCB . . . . . . . 275ISRT call to alternate PCB . . . . . . . . 276Program termination . . . . . . . . . . 277

Chapter 15. Introduction to Message FormatService (MFS) . . . . . . . . . . . . . 279Advantages of using MFS . . . . . . . . . 279

Simplify development and maintenance . . . 279Improve online performance of a terminal . . . 280

MFS control blocks . . . . . . . . . . . 281MFS examples . . . . . . . . . . . . 281Relationship between MFS control blocks andscreen format . . . . . . . . . . . . 286

Overview of MFS components and operation. . . 287MFS Language utility (DFSUPAA0) . . . . . 288MFS Service utility (DFSUTSA0) . . . . . . 289MFS Device Characteristics Table utility(DFSUTB00) . . . . . . . . . . . . . 289MFS message editor . . . . . . . . . . 289MFS pool manager . . . . . . . . . . 289MFSTEST pool manager . . . . . . . . . 290

Devices and logical units that operate with MFS 290Using distributed presentation management (DPM) 292

Chapter 16. Callout requests for externalservices or data . . . . . . . . . . . . 293Callout request approaches . . . . . . . . . 294

Using IMS SOAP Gateway Version 10 . . . . 294Using IMS TM Resource Adapter Version 10 . . 294Using a user-written IMS Connect TCP/IPapplication . . . . . . . . . . . . . 294

OTMA destination descriptors . . . . . . . . 294Resume tpipe protocol . . . . . . . . . . 295

Resume tpipe security . . . . . . . . . 296Implementing the synchronous callout function 296

Example COBOL program implementation ofthe synchronous callout function . . . . . . 297Concurrent processing . . . . . . . . . 298

Implementing the asynchronous callout function 299

182 Application Programming Guide

|||||||||||||||||||||||||||

Page 207: IMS Application Programming.pdf

Chapter 12. Defining application program elements for IMS TM

This section describes the elements of your application program that are used tocommunicate with IMS. Your application program must define these elements. Thesection also describes formatting DL/I calls for language interfaces and provideslanguage calls information for assembler language, C language, COBOL, Java,Pascal, and PL/I.

The following topics provide additional information:v “Formatting DL/I calls for language interfaces”v “Application programming for assembler language” on page 184v “Application programming for C language” on page 186v “Application programming for COBOL” on page 189v “Application programming for Java” on page 192v “Application programming for Pascal” on page 192v “Application programming for PL/I” on page 195v “Relationship of calls to PCB types” on page 197v “Specifying the I/O PCB mask” on page 198v “Specifying the alternate PCB mask” on page 202v “Specifying the AIB mask” on page 203v “Specifying the I/O areas” on page 205v “AIBTDLI interface” on page 205v “Specifying language-specific entry points” on page 206v “Program communication block (PCB) lists” on page 208v “Language environments” on page 209v “Special DL/I situations” on page 210

Related reading: For detailed information on specific parameters for the DL/I callssee the topic "DL/I Calls for Transaction Management" in IMS Version 10:Application Programming API Reference and the topic "DL/I Calls for SystemServices" in IMS Version 10: Application Programming API Reference.

Formatting DL/I calls for language interfacesWhen you use DL/I calls in a programming language supported by IMS(assembler language, C language, COBOL, Pascal, or PL/I), you must call the DL/Ilanguage interface to initiate the functions specified with the DL/I calls. IMS offersseveral interfaces for DL/I calls:v A language-independent interface for any programs that are Language

Environment conforming (CEETDLI)v Language-specific interfaces for all supported languages (xxxTDLI)v A non-language-specific interface for all supported languages (AIBTDLI)

Note: Java makes use of the all three DL/I language interfaces, but the use ismasked and no calls are necessary to initiate the functions specified with theDL/I calls.

© Copyright IBM Corp. 1974, 2010 183

|||||

|||

Page 208: IMS Application Programming.pdf

Related reading: Not every DL/I call uses all the parameters shown. Fordescriptions of the call functions and the parameters they use, see the IMS Version10: Application Programming API Reference. For more information about mappingJava to IMS DL/I calls, see the base package of the Java API specification for IMS.

Because the exact syntax for calling the language interfaces varies among theprogramming languages, the following sections describe the language-specificformat. Not every DL/I call uses all the parameters shown.

Application programming for assembler languageThis section contains the format, parameters, and sample DL/I call formats for IMSapplication programs in assembler language. In assembler language programs, allDL/I call parameters that are passed as addresses can be passed in a register,which, if used, must be enclosed in parentheses.

Format

�� CALL(2)

ASMTDLI,( function )(1) ,i/o_pcb A

parmcount, B,alternate_pcb

AC

(2)AIBTDLI,( function, aib )

(1) Aparmcount, B

C

� ,(1)

VL

��

A:

,i/o_area,mod_name,token,options_list

,feedback area

B:

,i/o_area_ length,i/o_area

� ,area_length,area

184 Application Programming Guide

||||

Page 209: IMS Application Programming.pdf

C:

,destination_name,options_list

,feedback_area

Notes:

1 Assembler language must use either parmcount or VL.

2 See the topic "DL/I Calls for Transaction Management" in IMS Version 10: Application ProgrammingAPI Reference and the topic "DL/I Calls for System Services" in IMS Version 10: ApplicationProgramming API Reference for descriptions of call functions and parameters.

Parametersparmcount

Specifies the address of a 4-byte field in user-defined storage that contains thenumber of parameters in the parameter list that follows parmcount. Assemblerlanguage application programs must use either parmcount or VL.

functionSpecifies the address of a 4-byte field in user-defined storage that contains thecall function to be used. The call function must be left-justified and paddedwith blanks. For example, (GU��) is a call function.

i/o pcbSpecifies the address of the I/O program communication block (PCB). The I/OPCB address is the first address passed on entry to the application program inthe PCB list, given the following circumstances:v A program executing in DLI or database management batch (DBB) regions

where CMPAT=YES is coded on the PSB.v Any program executing in batch message processing program (BMP),

message processing program (MPP), or IMS Fast Path (IFP) regionsregardless of the CMPAT= value.

alternate pcbSpecifies the address of the alternate PCB to be used for the call. The PCBaddress must be one of the PCB addresses passed on entry to the applicationprogram in the PCB list.

aib Specifies the address of the application interface block (AIB) in user-definedstorage. For more information on the contents of the AIB, see “AIBTDLIinterface” on page 205.

i/o areaSpecifies the address of the I/O area in user-defined storage used for the call.The I/O area must be large enough to contain the returned data.

i/o area lengthSpecifies the address of a 4-byte field in user-defined storage that contains theI/O area length (specified in binary).

area lengthSpecifies the address of a 4-byte field in user-defined storage that contains thelength (specified in binary) of the area immediately following it in theparameter list. Up to seven area length/area pairs can be specified.

Chapter 12. Defining application program elements for IMS TM 185

Page 210: IMS Application Programming.pdf

areaSpecifies the address of the area in user-defined storage to be checkpointed. Upto seven area length/area pairs can be specified.

tokenSpecifies the address of a 4-byte field in user-defined storage that contains auser token.

options listSpecifies the address of the options list in user-defined storage that containsprocessing options used with the call.

feedback areaSpecifies the address of the feedback area in user-defined storage that receivesinformation about options list processing errors.

mod nameSpecifies the address of an 8-byte area in user-defined storage that contains theuser-defined MOD name used with the call. The mod name parameter is usedonly with MFS.

destination nameSpecifies the address of an 8-byte field in user-defined storage that contains thename of the logical terminal or transaction code to which messages resultingfrom the call are sent.

VLSignifies the end of the parameter list. Assembler language programs must useeither parmcount or VL.

Example DL/I call formatsDL/I AIBTDLI interface:

CALL AIBTDLI,(function,aib,i/o area),VL

DL/I language-specific interface:CALL ASMTDLI,(function,i/o pcb,i/o area),VL

Application programming for C languageThis section contains the format, parameters, and sample DL/I call formats for IMSapplication programs in C language.

186 Application Programming Guide

Page 211: IMS Application Programming.pdf

Format

��(1)

rc=CTDLI( function );parmcount, ,i/o_pcb

AB

,alt_pcbAC

(2) (1)rc=AIBTDLI(parmcount ,function, aib );

ABC

D

��

A:

,i/o_area,mod_name,token,options_list

, feedback_area

B:

�,i/o_area_length,i/o_area,area_length,area

C:

,destination_name,options_list

,feedback_area

D:

(1)CEETDLI( function );

parmcount, ,i/o_pcbAB

,alt_pcbAC

,aibABC

Chapter 12. Defining application program elements for IMS TM 187

Page 212: IMS Application Programming.pdf

Notes:

1 See the topic "DL/I Calls for Transaction Management" in IMS Version 10: Application ProgrammingAPI Reference and the topic "DL/I Calls for System Services" in IMS Version 10: ApplicationProgramming API Reference for descriptions of call functions and parameters.

2 For AIBTDLI, parmcount is required for applications.

Parametersrr Receives the DL/I status or return code. It is a 2-character field shifted into the

2 lower bytes of an integer variable (int). If the status or return code is twoblanks, 0 is placed in the field. You can test the rc parameter with an ifstatement; for example, if (rc == 'IX'). You can also use rc in a switchstatement. You can choose to ignore the value placed in rc and use the statuscode returned in the program communication block (PCB) instead.

parmcountSpecifies the name of a fixed-binary (31) variable in user-defined storage that isa pointer to the number of parameters in the parameter list that followsparmcount. The parmcount field is a pointer to long.

functionSpecifies the name of a character (4) variable, left-justified, in user-definedstorage, which contains the call function to be used. The call function must bepadded with blanks. For example, (GU��) is a call function.

i/o pcbSpecifies the address of the I/O PCB. The I/O PCB address is the first addresspassed on entry to the application program in the PCB list, given the followingcircumstances:v A program executing in DLI or database management batch (DBB) regions

where CMPAT=YES is coded on the PSB.v Any program executing in batch message processing program (BMP),

message processing program (MPP), or IMS Fast Path (IFP) regionsregardless of the CMPAT= value.

alternate pcbSpecifies the name of a pointer variable that contains the address of the I/OPCB or alternate PCB to be used for the call. The PCB address must be one ofthe PCB addresses passed on entry to the application program in the PCB list.

aib Specifies the name of the pointer variable that contains the address of thestructure that defines the application interface block (AIB) in user-definedstorage. For more information on the contents of the AIB, see “AIBTDLIinterface” on page 205.

i/o areaSpecifies the name of a pointer variable to a major structure, array, or characterstring that defines the I/O area in user-defined storage to be used for the call.The I/O area must be large enough to contain the returned data.

i/o area lengthSpecifies the name of a fixed-binary (31) variable in user-defined storage thatcontains the I/O area length.

area lengthSpecifies the name of a fixed-binary (31) variable in user-defined storage thatcontains the length of the area immediately following it in the parameter list.Up to seven area length/area pairs can be specified.

188 Application Programming Guide

Page 213: IMS Application Programming.pdf

areaSpecifies the name of the pointer variable that contains the address of thestructure that defines the user-defined storage to be checkpointed. Up to sevenarea length/area pairs can be specified.

tokenSpecifies the name of a character (4) variable in user-defined storage thatcontains a user token.

options listSpecifies the name of the pointer variable that contains the address of thestructure that defines the user-defined storage that contains processing optionsused with the call.

feedback areaSpecifies the name of the pointer variable that contains the address of thestructure that defines the user-defined storage that receives information aboutoptions list processing errors.

mod nameSpecifies the name of a character (8) variable in user-defined storage thatcontains the user-defined MOD name used with the call. The mod nameparameter is used only with MFS.

destination nameSpecifies the name of a character (8) variable in user-defined storage thatcontains the name of the logical or terminal transaction code to whichmessages resulting from the call are sent.

I/O areaIn C language, the I/O area can be of any type, including structure or array. Theceetdli declarations in leawi.h and the ctdli declarations in ims.h do not have anyprototype information, so no type checking of the parameters is done. The I/Oarea can be auto, static, or allocated (with malloc or calloc). Give specialconsideration to C-strings because DL/I does not recognize the C convention ofterminating strings with nulls ('\0'). Instead of using the strcpy and strcmpfunctions, you might want to use the memcpy and memcmp functions.

Example DL/I call formatsDL/I CEEDTLI interface:#include <leawi.h>ceetdli(function,aib,i/o_area)

DL/I AIBTDLI interface:int rc;...rc = aibtdli(parmcount,function,aib,i/o_area)

DL/I language-specific interface:#include <ims.h>int rc;...rc = ctdli(function,i/o_pcb,i/o_area)

Application programming for COBOLThis section contains the format, parameters, and DL/I call sample formats for IMSapplication programs in COBOL.

Chapter 12. Defining application program elements for IMS TM 189

Page 214: IMS Application Programming.pdf

Format

�� CALL(1)

'CBLTDLI'USING functionparmcount, ,i/o_pcb

AB

,alt_pcbAC

(1)'AIBTDLI'USING function , aib

parmcount, ABC

(1)'CEETDLI'USING function

parmcount, ,i/o_pcbAB

,alt_pcbAC

,aibABC

. ��

A:

,i/o area,mod_name,token,options_list

,feedback_area

B:

�,i/o_area_length,i/o_area,area_length,area

C:

,destination_name,options_list

,feedback_area

Notes:

1 See the topic "DL/I Calls for Transaction Management" in IMS Version 10: Application ProgrammingAPI Reference and the topic "DL/I Calls for System Services" in IMS Version 10: ApplicationProgramming API Reference for descriptions of call functions and parameters.

190 Application Programming Guide

Page 215: IMS Application Programming.pdf

Parametersparmcount

Specifies the identifier of a usage binary (4) byte data item in user-definedstorage that contains the number of parameters in the parameter list thatfollows parmcount.

functionSpecifies the identifier of a usage display (4) byte data item, left-justified, inuser-defined storage, which contains the call function to be used. The callfunction must be padded with blanks. For example, (GU��) is a call function.

i/o pcbSpecifies the address of the I/O program communication block (PCB). The I/OPCB address is the first address passed on entry to the application program inthe PCB list, given the following circumstances:v A program executing in DLI or database management batch (DBB) regions

where CMPAT=YES is coded on the PSB.v Any program executing in batch message processing program (BMP),

message processing program (MPP), or IMS Fast Path (IFP) regionsregardless of the CMPAT= value.

alternate pcbSpecifies the identifier of the I/O PCB or alternate PCB group item from thePCB list that is passed to the application program on entry. This identifier isused for the call.

aib Specifies the identifier of the group item that defines the application interfaceblock (AIB) in user-defined storage. For more information on the contents ofthe AIB, see “AIBTDLI interface” on page 205.

i/o areaSpecifies the identifier of a group item, table, or usage display data item thatdefines the I/O area to be used for the call. The I/O area must be largeenough to contain the returned data.

i/o area lengthSpecifies the identifier of a usage binary (4) byte data item in user-definedstorage that contains the I/O area length.

area lengthSpecifies the identifier of a usage binary (4) byte data item in user-definedstorage that contains the length of the area immediately following it in theparameter list. Up to seven area length/area pairs can be specified.

areaSpecifies the identifier of the group item that defines the area to becheckpointed. Up to seven area length/area pairs can be specified.

tokenSpecifies the identifier of a usage display (4) byte data item that contains auser token.

options listSpecifies the identifier of the group item that defines the user-defined storagethat contains processing options used with the call.

feedback areaSpecifies the identifier of the group item that defines the user-defined storagethat receives information about options list processing errors.

Chapter 12. Defining application program elements for IMS TM 191

Page 216: IMS Application Programming.pdf

mod nameSpecifies the identifier of a usage display (8) byte data item in user-definedstorage that contains the user-defined MOD name used with the call.

destination nameSpecifies the identifier of a usage display (8) byte data item that contains thename of the logical terminal or transaction code to which messages resultingfrom the call are sent.

Example DL/I call formatsDL/I CEETDLI interface:CALL 'CEETDLI' USING function, aib,i/o area.

DL/I AIBTDLI interface:CALL 'AIBTDLI' USING function, aib,i/o area.

DL/I language-specific interface:CALL 'CBLTDLI' USING function, i/o pcb, i/o area.

Application programming for JavaThis topic contains classes for that allow you to process transactions in adependent region using the Java class libraries for IMS:

IMSFieldMessageAn abstract base class for objects representing a message sent or receivedfrom an IMS message queue

IMSMessageQueueProvides services to send and receive messages to an IMS message queueor to the application's Scratch Pad Area (SPA)

IMSTransactionProvides Java Dependent Region programs access to IMS transactionservices such as commit and rollback

SaveAreaUsed during CHKP/XRST calls to checkpoint the application data objects

Related reading: For more information regarding these classes and their role inJava application programs that access IMS databases, see thecom.ibm.ims.application package in the Java API specification for IMS.

Application programming for PascalThis section contains the format, parameters, and DL/I call sample formats for IMSapplication programs in Pascal.

Format

192 Application Programming Guide

|

||

|||

|||

|||

||

|||

Page 217: IMS Application Programming.pdf

�� PASTDLI ( A, VAR i/o_pcb

BC

, VAR alt_pcbBD

AIBTDLI ( A , VAR aib ,BCD

) ; ��

A:

(1)CONST function

CONST parmcount ,

B:

, VAR i/o_area, VAR mod_name, CONST token, VAR options_list

, VAR feedback_area

C:

, VAR i/o_area_length , VAR i/o_area

� , VAR area_length , area

D:

, VAR destination_name, VAR options_list

, VAR feedback_area

Notes:

1 See the topic "DL/I Calls for Transaction Management" in IMS Version 10: Application ProgrammingAPI Reference and the topic "DL/I Calls for System Services" in IMS Version 10: ApplicationProgramming API Reference for descriptions of call functions and parameters.

Parametersparmcount

specifies the address of a fixed-binary (31) variable in user-defined storage thatcontains the number of parameters in the parameter list that follows parmcount.

functionSpecifies the name of a character (4) variable, left-justified, in user-definedstorage, which contains the call function to be used. The call function must bepadded with blanks. For example, (GU��) is a call function.

Chapter 12. Defining application program elements for IMS TM 193

Page 218: IMS Application Programming.pdf

i/o pcbSpecifies the address of the program communication block (I/O PCB). The I/OPCB address is the first address passed on entry to the application program inthe PCB list, given the following circumstances:v A program executing in DLI or database management batch (DBB) regions

where CMPAT=YES is coded on the PSB.v Any program executing in batch message processing program (BMP),

message processing program (MPP), or IMS Fast Path (IFP) regionsregardless of the CMPAT= value.

alternate pcbSpecifies the name of a pointer variable that contains the address of the I/OPCB defined in the call procedure statement.

aib Specifies the name of a pointer variable that contains the address of thestructure that defines the application interface block (AIB) in user-definedstorage. For more information on the contents of the AIB, see “AIBTDLIinterface” on page 205.

i/o areaSpecifies the name of a pointer variable to a major structure, array, or characterstring that defines the I/O area in user-defined storage to be used for the call.The I/O area must be large enough to contain the returned data.

i/o area lengthSpecifies the name of a fixed-binary (31) variable in user-defined storage thatcontains the I/O area length.

area lengthSpecifies the name of a fixed binary (31) variable in user-defined storage thatcontains the length (specified in binary) of the area immediately following it inthe parameter list. Up to seven area length/area pairs can be specified.

areaSpecifies the name of a pointer variable that contains the address of thestructure that defines the area in user-defined storage to be checkpointed. Upto seven area length/area pairs can be specified.

tokenSpecifies the name of a character (4) variable in user-defined storage thatcontains a user token.

options listSpecifies the name of a pointer variable that contains the address of thestructure that defines the user-defined storage that contains processing optionsused with the call.

feedback areaSpecifies the name of the pointer variable that contains the address of thestructure that defines the user-defined storage that receives information aboutoptions list processing errors.

mod nameSpecifies the name of a character (8) variable in user-defined storage thatcontains the user-defined MOD name used with the call.

destination nameSpecifies the name of a character (8) variable in user-defined storage thatcontains the name of the logical terminal or transaction code to whichmessages resulting from the call are sent.

194 Application Programming Guide

Page 219: IMS Application Programming.pdf

Example DL/I call formatsDL/I AIBTDLI interface:AIBTDLI(CONST function,

VAR aib,VAR I/O area);

DL/I language-specific interface:PASTDLI(CONST function,area VAR I/O PCB

VAR I/O area);

Application programming for PL/IThis section contains the format, parameters, and DL/I call sample formats for IMSapplication programs in PL/I.

For the PLITDLI interface all parameters except parmcount are indirect pointers; forthe AIBTDLI interface, all parameters are direct pointers.

The following topics provide additional information:v “Format”v “Parameters” on page 196v “Example DL/I call formats” on page 197

Format

�� CALL(1)

PLITDLI ( parmcount , function, i/o_pcb

AB

, alt pcbAC

(1)AIBTDLI ( parmcount , function , aib

ABC

(1)CEETDLI ( parmcount , function

, i/o_pcbAB

, alt_pcbAC

, aibABC

) ; ��

A:

Chapter 12. Defining application program elements for IMS TM 195

Page 220: IMS Application Programming.pdf

, i/o_area, mod_name, token, options_list

, feedback_area

B:

, i/o_area_length , i/o_area

� , area_length , area

C:

, destination_name, options_list

, feedback_area

Notes:

1 See the topic "DL/I Calls for Transaction Management" in IMS Version 10: Application ProgrammingAPI Reference and the topic "DL/I Calls for System Services" in IMS Version 10: ApplicationProgramming API Reference for descriptions of call functions and parameters.

Parametersparmcount

Specifies the name of a fixed-binary (31-byte) variable that contains the numberof arguments that follow parmcount.

functionSpecifies the name of a character (4-byte) variable, left justified, blank paddedcharacter string that contains the call function to be used. For example, (GU��)is a call function.

i/o pcbSpecifies the address of the program communication block (I/O PCB). The I/OPCB address is the first address passed on entry to the application program inthe PCB list, given the following circumstances:v A program executing in DLI or DBB regions where CMPAT=YES is coded on

the PSB.v Any program executing in batch message processing program (BMP),

message processing program (MPP), or IMS Fast Path (IFP) regionsregardless of the CMPAT= value.

alternate pcbSpecifies the structure associated with the I/O PCB or alternate PCB to be usedfor the call. This structure is based on a PCB address that must be one of thePCB addresses passed on entry to the application program.

aib Specifies the name of the structure that defines the application interface block(AIB). For more information on the contents of the AIB, see “AIBTDLIinterface” on page 205.

196 Application Programming Guide

Page 221: IMS Application Programming.pdf

i/o areaSpecifies the name of the I/O area used for the call. The I/O area must belarge enough to contain the returned data.

i/o area lengthSpecifies the name of a fixed binary (31) variable in user-defined storage thatcontains the I/O area length (specified in binary).

area lengthSpecifies the name of a fixed binary (31) variable that contains the length(specified in binary) of the area immediately following it in the parameter list.Up to seven area length/area pairs can be specified.

areaSpecifies the name of the area to be checkpointed. Up to seven arealength/area pairs can be specified.

tokenSpecifies the name of a character (4) variable that contains a user token.

options listSpecifies the name of a structure that contains processing options used withthe call.

feedback areaSpecifies the name of a structure that receives information about options listprocessing errors.

mod nameSpecifies the name of a character (8) variable character string containing theuser-defined MOD name used with the call.

destination nameSpecifies the name of a character (8) variable character string containing thelogical terminal or transaction code to which messages resulting from the callare sent.

Example DL/I call formatsDL/I CEETDLI interface:%INCLUDE CEEIBMAW;CALL CEETDLI (function, i/o pcb, i/o area);

DL/I AIBTDLI interface:CALL AIBTDLI (parmcount, function, aib, i/o area);

DL/I language-specific interface:CALL PLITDLI (parmcount, function, i/o pcb, i/o area);

Relationship of calls to PCB typesTable 34 on page 198 shows the relationship of DL/I calls to I/O and alternateprogram communication blocks (PCBs). The PCB can be specified in one of twoways, depending on which xxxTDLI interface is used:v As a parameter in the call listv In the AIB

Chapter 12. Defining application program elements for IMS TM 197

Page 222: IMS Application Programming.pdf

Table 34. Call relationship to PCBs and AIBs

Call I/O PCBs ALT PCBs

APSB 1

AUTH X

CHKP (basic) X

CHKP (symbolic) X

CHNG 2 X

CMD X

DPSB 1

GCMD X

GN X

GSCD X

GU X

INIT X

INQY X X

ISRT X X

LOG X

PURG X X

ROLB X

ROLS X

ROLL 1

SETO X X

SETS X

SETU X

SYNC X

XRST X

Notes:

1. This call is not associated with a PCB.

2. The alternate PCB used by this call must be modifiable.

Specifying the I/O PCB maskAfter your program issues a call with the I/O program communications block(PCB), IMS returns information about the results of the call to the I/O PCB. Todetermine the results of the call, your program must check the information thatIMS returns.

Issuing a system service call requires an I/O PCB. Because the I/O PCB residesoutside your program, you must define a mask of the PCB in your program tocheck the results of IMS calls. The mask must contain the same fields, in the sameorder, as the I/O PCB. Your program can then refer to the fields in the PCBthrough the PCB mask.

An I/O PCB contains the fields listed in Table 35. Table 35 also describes thesefields, their lengths, and which environments are applicable for each field.

198 Application Programming Guide

Page 223: IMS Application Programming.pdf

Table 35. I/O PCB mask

Descriptor ByteLength

DB/DC DBCTL DCCTL DB Batch TM Batch

Logical terminalname 1

8 X X

Reserved for IMS 2 2 X X

Status code 3 2 X X X X X

4-byte Local date andtime 4

Date 2 X X

Time 2 X X

Input messagesequence number 5

4 X X

Message outputdescriptor name 6

8 X X

Userid 7 8 X X

Group name 8 8 X X

12-Byte TimeStamp 9

Date 4 X X

Time 6 X X

UTC Offset 2 X X

Userid Indicator10 1 X X

Reserved for IMS2 3

Notes:

1. Logical Terminal Name

This field contains the name of the terminal that sent the message. When yourprogram retrieves an input message, IMS places the name of the logicalterminal that sent the message in this field. When you want to send a messageback to this terminal, you refer to the I/O PCB when you issue the ISRT call,and IMS takes the name of the logical terminal from the I/O PCB as thedestination.

2. Reserved for IMS

These fields are reserved.3. Status Code

IMS places the status code describing the result of the DL/I call in this field.IMS updates the status code after each DL/I call that the program issues. Yourprogram should always test the status code after issuing a DL/I call.The three status code categories are:v Successful status codes or status codes with exceptional but valid

conditions. This category does not contain errors. If the call was completelysuccessful, this field contains blanks. Many of the codes in this category arefor information only. For example, a QC status code means that no moremessages exist in the message queue for the program. When your programreceives this status code, it should terminate.

Chapter 12. Defining application program elements for IMS TM 199

Page 224: IMS Application Programming.pdf

v Programming errors. The errors in this category are usually ones that youcan correct. For example, an AD status code indicates an invalid functioncode.

v I/O or system errors.For the second and third categories, your program should have an errorroutine that prints information about the last call that was issued programtermination. Most installations have a standard error routine that allapplication programs at the installation use.

4. Local Date and Time

The current local date and time are in the prefix of all input messages exceptthose originating from non-message-driven BMPs. The local date is apacked-decimal, right-aligned date, in the format yyddd. The local time is apacked-decimal time in the format hhmmsst. The current local date and timeindicate when IMS received the entire message and enqueued it as input forthe program, rather than the time that the application program received themessage. To obtain the application processing time, you must use the timefacility of the programming language you are using.For a conversation, for an input message originating from a program or for amessage received using Multiple System Coupling (MSC), the time and dateindicate when the original message was received from the terminal.

Note: Be careful when comparing the local date and time in the I/O PCBwith the current time returned by the operating system. The I/O PCBdate and time may not be consistent with the current time. It may evenbe greater than the current time for the following reasons:v The time stamp in the I/O PCB is the local time that the message

was received by IMS. If the local time was changed after the messagearrived, it is possible for the current time to appear to be earlier thanthe I/O PCB time. This effect would be likely to occur in the hourimmediately after the fall time change, when the clock is set back byone hour.

v The time stamp in the I/O PCB is derived from an internal IMS timestamp stored with the message. This internal time stamp is inCoordinated Universal Time (UTC), and contains the time zone offsetthat was in effect at the time the message was enqueued. This timezone offset is added to the UTC time to obtain the local time that isplaced in the I/O PCB. However, the time zone offset that is stored isonly fifteen minutes. If the real time zone offset was not an integermultiple of fifteen minutes, the local time passed back in the I/OPCB will differ from the actual time by plus or minus 7.5 minutes.This could cause the I/O PCB time to be later than the current time.See IMS Version 10: Operations and Automation Guide for furtherexplanation.

Concerns about the value in the local time stamp in the I/O PCB can bereduced by using the extended time stamp introduced in IMS V6. Thesystem administrator can choose the format of the extended time stampto be either local time or UTC. In some situations, it may beadvantageous for the application to request the time in UTC from theoperating system and compare it to the UTC form of the extended timestamp. This is an option available in installations where there is no ETRto keep the IMS UTC offset in sync with the z/OS UTC offset overchanges in local time.

5. Input Message Sequence Number

200 Application Programming Guide

Page 225: IMS Application Programming.pdf

The input message sequence number is in the prefix of all input messagesexcept those originating from non-message-driven BMPs. This field containsthe sequence number IMS assigned to the input message. The number isbinary. IMS assigns sequence numbers by physical terminal, which arecontinuous since the time of the most recent IMS startup.

6. Message Output Descriptor Name

You only use this field when you use MFS. When you issue a GU call with amessage output descriptor (MOD), IMS places its name in this area. If yourprogram encounters an error, it can change the format of the screen and sendan error message to the terminal by using this field. To do this, the programmust change the MOD name by including the MOD name parameter on anISRT or PURG call.Although MFS does not support APPC, LU 6.2 programs can use an interfaceto emulate MFS. For example, the application program can use the MODname to communicate with IMS to specify how an error message is to beformatted.Related reading: For more information on the MOD name and the LTERMinterface, see IMS Version 10: Communications and Connections Guide.

7. Userid

The use of this field is connected with RACF signon security. If signon is notactive in the system, this field contains blanks.If signon is active in the system, the field contains one of the following:v The user's identification from the source terminal.v The LTERM name of the source terminal if signon is not active for that

terminal.v The authorization ID. For batch-oriented BMPs, the authorization ID is

dependent on the value specified for the BMPUSID= keyword in theDFSDCxxx PROCLIB member:– If BMPUSID=USERID is specified, the value from the USER= keyword

on the JOB statement is used.– If USER= is not specified on the JOB statement, the program's PSB name

is used.– If BMPUSID=PSBNAME is specified, or if BMPUSID= is not specified at

all, the program's PSB name is used.Related Reading: For more information about authorizing resource usein a dependent region, see IMS Version 10: System Administration Guide.

8. Group Name

The group name, which is used by DB2 to provide security for SQL calls, iscreated through IMS transactions.Three instances that apply to the group name are:v If you use RACF and signon on your IMS system, the RACROUTE SAF

(extract) call returns an eight-character group name.v If you use your own security package on your IMS system, the RACROUTE

SAF call returns any eight-character name from the package and treats it asa group name. If the RACROUTE SAF call returns a return code of 4 or 8, agroup name was not returned, and IMS blanks out the group name field.

v If you use LU 6.2, the transaction header can contain a group name.Related reading: See IMS Version 10: Communications and Connections Guidefor more information on LU 6.2.

9. 12-Byte Time Stamp

Chapter 12. Defining application program elements for IMS TM 201

Page 226: IMS Application Programming.pdf

This field contains the current date and time fields, but in the IMS internalpacked-decimal format. The time stamp has the following parts:

Date yyyydddf

This packed-decimal date contains the year (yyyy), day of theyear (ddd), and a valid packed-decimal + sign such as (f).

Time hhmmssthmiju

This packed-decimal time consists of hours, minutes, andseconds (hhmmss) and fractions of the second to themicrosecond (thmiju). No packed-decimal sign is affixed tothis part of the time stamp.

UTC Offset aqq$

The packed-decimal UTC offset is prefixed by 4 bits ofattributes (a). If the 4th bit of (a) is 0, the time stamp is UTC;otherwise, the time stamp is local time. The control regionparameter, TSR=(U/L), specified in the DFSPBxxx PROCLIBmember, controls the representation of the time stamp withrespect to local time versus UTC time.

The offset value (qq$) is the number of quarter hours of offsetto be added to UTC or local time to convert to local or UTCtime respectively.

The offset sign ($) follows the convention for apacked-decimal plus or minus sign.

Field 4 on the I/O PCB Mask always contains the local dateand time. For a description of field 4, see the notes forTable 35 on page 199.

Related reading: For a more detailed description of the internalpacked-decimal time-format, see IMS Version 10: System Utilities Reference.

10. Userid Indicator

The Userid Indicator is provided in the I/O PCB and in the response to theINQY call. The Userid Indicator contains one of the following:v U - The user's identification from the source terminal during signonv L - The LTERM name of the source terminal if signon is not activev P - The PSBNAME of the source BMP or transactionv O - Other nameThe value contained in the Userid Indicator field indicates the contents of theuserid field.

Specifying the alternate PCB maskAn alternate program communication block (PCB) mask contains three fields.Table 36 describes these fields, the field length, and in which environment the fieldapplies.

Table 36. Alternate PCB mask

Descriptor Byte Length DB/DC DBCTL DCCTL DBBatch

TMBatch

Logical terminal name 1 8 bytes X X

Reserved for IMS 2 2 bytes X X

202 Application Programming Guide

Page 227: IMS Application Programming.pdf

Table 36. Alternate PCB mask (continued)

Descriptor Byte Length DB/DC DBCTL DCCTL DBBatch

TMBatch

Status code 3 2 bytes X X

Notes:

1. Logical Terminal Name

This field contains the name of the logical terminal, LU 6.2 descriptor or thetransaction code to which you want to send the message.Related reading: For more information on LU 6.2, see IMS Version 10:Communications and Connections Guide.

2. Reserved for IMS

This 2-byte field is reserved.3. Status Code

This field contains the 2-byte status code that describes the results of the callthat used this PCB most recently.

For information on when to use an alternate PCB, see “Sending messages to otherterminals and programs” on page 228.

Specifying the AIB maskThe AIB is used by your program to communicate with IMS, when yourapplication does not have a program communication block (PCB) address or thecall function does not use a PCB. The AIB mask enables your program to interpretthe control block defined. The AIB structure must be defined in working storage,on a fullword boundary, and initialized according to the order and byte length ofthe fields as shown in Table 37. The table’s notes describe the contents of eachfield.

Table 37. AIB fields

Descriptor Byte Length DB/DC DBCTL DCCTL DBBatch

TMBatch

AIB identifier 1 8 X X X X X

DFSAIB allocatedlength 2

4 X X X X X

Subfunction code 3 8 X X X X X

Resource name 4 8 X X X X X

Reserved 5 16

Maximum output arealength 6

4 X X X X X

Output area lengthused 7

4 X X X X X

Reserved 8 12

Return code 9 4 X X X X X

Reason code 10 4 X X X X X

Error code extension 11 4 X X

Resource address 12 4 X X X X X

Reserved 13 48

Chapter 12. Defining application program elements for IMS TM 203

Page 228: IMS Application Programming.pdf

Notes:

1. AIB Identifier (AIBID)

This 8-byte field contains the AIB identifier. You must initialize AIBID in yourapplication program to the value DFSAIB��. before you issue DL/I calls. Thisfield is required. When the call is completed, the information returned in thisfield is unchanged.

2. DFSAIB Allocated Length (AIBLEN)

This field contains the actual 4-byte length of the AIB as defined by yourprogram. You must initialize AIBLEN in your application program before youissue DL/I calls. The minimum length required is 128 bytes. When the call iscompleted, the information returned in this field is unchanged. This field isrequired.

3. Subfunction Code (AIBSFUNC)

This 8-byte field contains the subfunction code for those calls that use asubfunction. You must initialize AIBSFUNC in your application programbefore you issue DL/I calls. When the call is completed, the informationreturned in this field is unchanged.

4. Resource Name (AIBRSNM1)

This 8-byte field contains the name of a resource. The resource variesdepending on the call. You must initialize AIBRSNM1 in your applicationprogram before you issue DL/I calls. When the call is complete, theinformation returned in this field is unchanged. This field is required.For PCB related calls where the AIB is used to pass the PCB name instead ofpassing the PCB address in the call list, this field contains the PCB name. ThePCB name for the I/O PCB is IOPCB��. The PCB name for other types ofPCBs is defined in the PCBNAME= parameter in PSBGEN.

5. Reserved

This 16-byte field is reserved.6. Maximum Output Area Length (AIBOALEN)

This 4-byte field contains the length of the output area in bytes that wasspecified in the call list. You must initialize AIBOALEN in your applicationprogram for all calls that return data to the output area. When the call iscompleted, the information returned in this area is unchanged.

7. Used Output Area Length (AIBOAUSE)

This 4-byte field contains the length of the data returned by IMS for all callsthat return data to the output area. When the call is completed this fieldcontains the length of the I/O area used for this call.

8. Reserved

This 12-byte field is reserved.The first four bytes are used by the ICAL call to specify the time to wait forthe synchronous call process to complete (AIBRSFLD).

9. Return code (AIBRETRN)

When the call is completed, this 4-byte field contains the return code.10. Reason Code (AIBREASN)

When the call is completed, this 4-byte field contains the reason code.11. Error Code Extension (AIBERRXT)

This 4-byte field contains additional error information depending on thereturn code in AIBRETRN and the reason code in AIBREASN.

204 Application Programming Guide

||

Page 229: IMS Application Programming.pdf

12. Resource Address (AIBRSA1)

When the call is completed, this 4-byte field contains call-specific information.For PCB related calls where the AIB is used to pass the PCB name instead ofpassing the PCB address in the call list, this field returns the PCB address.

13. Reserved

This 48-byte field is reserved.

The application program can use the returned PCB address, when available, toinspect the status code in the PCB and to obtain any other information needed bythe application program.

Specifying the I/O areasUse an I/O area to pass segments between the application program and IMS TM.What the I/O area contains depends on the type of call you are issuing:v When your program retrieves a segment, IMS TM places the segment your

program requested in the I/O area.v When your program adds a new segment, your program first builds the new

segment in the I/O area.v Before modifying a segment, your program must first retrieve the segment.

When your program retrieves the segment, IMS TM places the segment in anI/O area.

The format of the record segments you pass between your program and IMS canbe fixed length or variable length. Only one difference is important to theapplication program: a message segment contains a 2-byte length field (or 4 bytesfor the PLITDLI interface) at the beginning of the data area of the segment.

The I/O area for IMS TM calls must be large enough to hold the largest messagesegment your program retrieves from or sends to IMS TM.

AIBTDLI interfaceThis section explains how to use the application interface block (AIB), an interfacebetween your application program and IMS.

Restriction: No fields in the AIB can be used by the application program except asdefined by IMS.

When you use the AIBTDLI interface, you specify the program communicationblock (PCB) requested for the call by placing the PCB name (as defined byPSBGEN) in the resource name field of the AIB. You do not specify the PCBaddress. Because the AIB contains the PCB name, your application program canrefer to the PCB name rather than the PCB address. Your application program doesnot need to know the relative PCB position in the PCB list. At completion of thecall, the AIB returns the PCB address that corresponds to the PCB name passed bythe application program.

The names of DB PCBs and alternate PCBs are defined by the user duringPSBGEN. All I/O PCBs are generated with the PCB name ���. For a generatedprogram specification block (GPSB), the I/O PCB is generated with the PCB nameIOPCB���, and the modifiable alternate PCB is generated with the PCB nameTPPCB1��.

Chapter 12. Defining application program elements for IMS TM 205

Page 230: IMS Application Programming.pdf

The ability to pass the PCB name means that you do not need to know the relativePCB number in the PCB list. In addition, the AIBTDLI interface enables yourapplication program to make calls on PCBs that do not reside in the PCB list. TheLIST= keyword controls whether the PCB is included in the PCB list. The LIST=keyword is defined in the PCB macro during PSBGEN.

Related reading: See IMS Version 10: System Utilities Reference for more information.

The AIB resides in user-defined storage that is passed to IMS for DL/I calls thatuse the AIBTDLI interface. Upon call completion, IMS updates the AIB. Allocate atleast 128 bytes of storage for the AIB.

Specifying language-specific entry pointsIMS gives control to an application program through an entry point. The formatsfor coding entry statements in assembler language, C language, COBOL, Java,Pascal, and PL/I are shown in this section. Your entry point must refer to theprogram communication blocks (PCBs) in the order in which they are defined inthe PSB.

IMS passes the PCB pointers to a PL/I program differently than it passes them toan assembler language, C language, COBOL, Java, or Pascal program. In addition,Pascal requires that IMS pass an integer before passing the PCB pointers. IMS usesthe LANG keyword or the PSBGEN statement of PSBGEN to determine the type ofprogram to which it is passing control. Therefore, you must be sure that thelanguage specified during PSBGEN is consistent with the language of the program.

Application interfaces that use the AIB structure (AIBTDLI or CEETDLI) use thePCB name rather than the PCB structure and do not require the PCB list to bepassed at entry to the application program.

When you code each DL/I call, you must provide the PCB you want to use forthat call. For all IMS TM application programs, the list of PCBs the program canaccess is passed to the program at its entry point.

Assembler languageYou can use any name for the entry statement to an assembler language DL/Iprogram. When IMS passes control to the application program, register 1 containsthe address of a variable-length fullword parameter list. Each word in the listcontains the address of a PCB. Save the parameter list address before youoverwrite the contents of register 1. IMS sets the high-order byte of the lastfullword in the list to X'80' to indicate the end of the list. Use standard z/OSlinkage conventions with forward and backward chaining.

C languageWhen IMS passes control to your program, it passes the addresses, in the form ofpointers, for each of the PCBs your program uses. The usual argc and argvarguments are not available to a program invoked by IMS. The IMS parameter listis made accessible by using the __pcblist macro. You can directly reference thePCBs by __pcblist[0], __pcblist[1], or you can define macros to give these moremeaningful names. I/O PCBs must be cast to get the proper type:(IO_PCB_TYPE *)(__pcblist[0])

The entry statement for a C language program is the main statement.

206 Application Programming Guide

Page 231: IMS Application Programming.pdf

#pragma runopts(env(IMS),plist(IMS))#include <ims.h>

main(){...}

The env option specifies the operating environment in which your C languageprogram is to run. For example, if your C language program is invoked under IMSand uses IMS facilities, specify env(IMS). The plist option specifies the format ofthe invocation parameters received by your C language program when it isinvoked. When your program is invoked by a system support services programsuch as IMS, the format of the parameters passed to your main program must beconverted into the C language format: argv, argc, and envp. To do this conversion,you must specify the format of the parameter list received by your C languageprogram. The ims.h include file contains declarations for PCB masks.

You can finish in three ways:v End the main procedure without an explicit return statement.v Execute a return statement from main.v Execute an exit or an abort call from anywhere, or alternately issue a longjmp

back to main, and then do a normal return.

One C language program can pass control to another by using the system function.The normal rules for passing parameters apply. For example, when using thesystem function, the argc and argv arguments can be used to pass information. Theinitial __pcblist is made available to the invoked program.

COBOLThe procedure statement must refer to the I/O PCB first, then to any alternate PCBit uses, and finally to the DB PCBs it uses. The alternate PCBs and DB PCBs mustbe listed in the order in which they are defined in the PSB.Procedure division using the PCB-NAME-1 [,...,PCB-NAME-N]

On previous versions of IMS, using might be coded on the entry statement toreference PCBs. However, IMS continues to accept such coding on the entrystatement.

Recommendation: Use the procedure statement rather than the entry statement toreference the PCBs.

PascalThe entry point must be declared as a REENTRANT procedure. When IMS passescontrol to a Pascal procedure, the first address in the parameter list is reserved forPascal’s use and the other addresses are the PCBs the program uses. The PCBtypes must be defined before this entry statement. The IMS interface routinePASTDLI must be declared with the GENERIC directive.procedure ANYNAME(var SAVE: INTEGER;

var pcb1-name: pcb1-name-type[;...var pcbn-name: pcbn-name-type]); REENTRANT;

procedure ANYNAME;(* Any local declarations *)

Chapter 12. Defining application program elements for IMS TM 207

Page 232: IMS Application Programming.pdf

procedure PASTDLI; GENERIC;begin

(* Code for ANYNAME *)end;

PL/I

The entry statement can be any valid PL/I name and must appear as the firstexecutable statement in the program. When IMS passes control to your program, itpasses the addresses of each of the PCBs your program uses in the form ofpointers. When you code the entry statement, make sure you code the parametersof this statement as pointers to the PCBs, and not the PCB names.anyname: PROCEDURE (pcb1_ptr [,..., pcbn_ptr]) OPTIONS (MAIN);...RETURN;

CCETDLI and AIBTDLI interface considerationsThis section explains the interfaces: CEETDLI and AIBTDLI

The considerations are:v For PL/I programs, the CEETDLI entry point is defined in the CEEIBMAW

include file. Alternatively, you can declare it yourself. But it must be declared asan assembler language entry (DCL CEETDLI OPTIONS(ASM);).

v For C language applications, you must specify env(IMS) and plist(IMS); thesespecifications enable the application to accept the PCB list of arguments. TheCEETDLI function is defined in <leawi.h>; the CTDLI function is defined in<ims.h>.

The considerations are:v When using the AIBTDLI interface for C/MVS, COBOL, or PL/I language

applications, the language run-time options for suppressing abend interception(that is, NOSPIE and NOSTAE) must be specified. However, for LanguageEnvironment-conforming applications, the NOSPIE and NOSTAE restriction isremoved.

v The AIBTDLI entry point for PL/I programs must be declared as an assemblerlanguage entry (DCL AIBTDLI OPTIONS(ASM);).

v For C language applications, you must specify env(IMS) and plist(IMS); thesespecifications enable the application to accept the PCB list of arguments.

Program communication block (PCB) listsThis section describes the formats of program communication block (PCB) lists andGPSB PCB lists and provides a description of PCBs in various types of applicationprograms.

PCB list formatThis is the format of a PCB:[IOPCB][Alternate PCB ... Alternate PCB][DB PCB ... DB PCB][GSAM PCB ... GSAM PCB]

Each PSB must contain at least one PCB. An I/O PCB or alternate PCB is requiredfor transaction management calls, and an I/O PCB is required for most system

208 Application Programming Guide

Page 233: IMS Application Programming.pdf

service calls. DB PCBs for DL/I databases are used only with the IMS DatabaseManager, but can be present even though your program is running under DCCTLor TM Batch. (A DB PCB can be a full-function PCB, a DEDB PCB, or an MSDBPCB.) GSAM PCBs can be used with DCCTL or TM batch.

Format of a GPSB PCB listA generated program specification block (GPSB) has the following format:[IOPCB][Alternate PCB]

A GPSB contains only an I/O PCB and one modifiable alternate PCB. It can beused by all transaction management application programs, and permits access tothe PCBs specified without the need for PSBGEN.

The PCBs in a GPSB have predefined PCB names. The name of the I/O PCB isIOPCB��. The name of the alternate PCB is TPPCB1��.

PCB summaryThis section summarizes the information concerning I/O PCBs and alternate PCBsin various types of application programs.

TM Batch ProgramsAlternate PCBs are always included in the list of PCBs supplied to theprogram by IMS TM. The I/O PCB is always present in the PCB listregardless of the CMPAT options specified in PSBGEN.

BMPs, MPPs, and IFPsThe I/O PCB is always present in the PCB list and is always the firstaddress in the list, regardless of the CMPAT options specified in the PSB.The PCB list always contains the address of the I/O PCB followed by theaddresses of any alternate PCBs, followed by the addresses of the DBPCBs.

Language environmentsIBM Language Environment provides the strategic execution environment forrunning your application programs written in one or more high level languages. Itprovides not only language-specific run-time support, but also cross-languagerun-time services for your applications, such as support for initialization,termination, message handling, condition handling, storage management, andNational Language Support. Many of Language Environment's services areaccessible explicitly through a set of Language Environment interfaces that arecommon across programming languages; these services are accessible from anyLanguage Environment-conforming program.

Language Environment-conforming programs can be compiled with the followingcompilers:v IBM C++/MVS™

v IBM COBOLv IBM PL/I

The CEETDLI interface to IMSThe language-independent CEETDLI interface to IMS is provided by LanguageEnvironment. It is the only IMS interface that supports the advanced error

Chapter 12. Defining application program elements for IMS TM 209

Page 234: IMS Application Programming.pdf

handling capabilities provided by Language Environment. The CEETDLI interfacesupports the same functionality as the other IMS application interfaces, and it hasthe following characteristics:v The parmcount variable is optional.v Length fields are 2 bytes long.v Direct pointers are used.

Related reading: For more information about Language Environment, see z/OSLanguage Environment Programming Guidez/OS Language Environment ProgrammingGuideand Language Environment Installation and Programming.

LANG= option on PSBGEN for PL/I compatibilityFor IMS PL/I applications running in a compatibility mode that uses thePLICALLA entry point, you must specify LANG=PLI on the PSBGEN. Your otheroption is to change the entry point and add SYSTEM(IMS) to the EXEC PARM ofthe compile step so that you can specify LANG=blank or LANG=PLI on thePSBGEN. Table 38 summarizes when you can use LANG=blank and LANG=PLI.

Table 38. Using LANG= option in a Language Environment for PL/I compatibility

Compile exec statement isPARM=(...,SYSTEM(IMS)...

Entry point name is PLICALLAValid LANG= value

Yes Yes LANG=PLI

Yes No LANG=blank or LANG=PLI

No No Note: Not valid for IMS PL/Iapplications

No Yes LANG=PLI

PLICALLA is only valid for PL/I compatibility with Language Environment. If aPL/I application using PLICALLA entry at bind time is bound using LanguageEnvironment with the PLICALLA entry, the bind will work; however, you mustspecify LANG=PLI in the PSB. If the application is re-compiled using PL/I forz/OS & VM Version 1 Release 1 or later, and then bound using LanguageEnvironment Version 1 Release 2 or later, the bind will fail. You must remove thePLICALLA entry statement from the bind.

Special DL/I situationsThis section contains information on mixed-language programming, using theextended addressing capabilities of MVS/ESA, COBOL compiler options forpreloaded programs, and considerations for the DCCTL environment.

Mixed-language programmingWhen an application program uses the Language Environmentlanguage-independent interface, CEETDLI, IMS does not need to know thelanguage of the calling program.

When the application program calls IMS in a language-dependent interface, IMSdetermines the language of the calling program according to the entry namespecified in the CALL statement:v CALL CBLTDLI indicates the program is in COBOL.v CALL PLITDLI indicates the program is in PL/I.

210 Application Programming Guide

Page 235: IMS Application Programming.pdf

v CALL PASTDLI indicates the program is in Pascal.v ctdli(...) indicates the program is in C language.v CALL ASMTDLI indicates the program is in assembler language.

If a PL/I program calls an assembler language subroutine and the assemblerlanguage subroutine makes DL/I calls by using CALL ASMTDLI, the assemblerlanguage subroutine should use the assembler language calling convention, not thePL/I convention.

In this situation, where the I/O area uses the LLZZ format, the LL is a halfword,not the fullword that is used for PLITDLI.

For more information on Language Environment, see “Language environments” onpage 209.

Using Language Environment routine retentionIf you run programs in an IMS TM dependent region that requires LanguageEnvironment (such as an IMS message processing region), you can improveperformance if you use Language Environment library routine retention along withthe existing PREINIT feature of IMS TM.

Using the extended addressing capabilities of MVS/ESAThe two modes in MVS/ESA with extended addressing capabilities are: theaddressing mode (AMODE) and the residency mode (RMODE).

IMS places no constraints on the RMODE and AMODE of an application program.The program can reside in the extended virtual storage area. The parametersreferenced in the call can also be in the extended virtual storage area.

Preloaded programsIf you compile your COBOL program with the COBOL for z/OS & VM compilerand preload it, you must use the COBOL compiler option RENT. Alternatively, ifyou compile your COBOL program with the VS COBOL II compiler and preload it,you must use the COBOL compiler options RES and RENT.

DCCTLIn a DCCTL environment, the application can only reference the address of an I/OPCB, alternate PCB, or GSAM PCB. An application program can use a PSB thatcontains PCBs referencing databases; however, these PCBs cannot be used duringprocessing. Entry statements for COBOL, PL/I, C, and Pascal must refer to allPCBs included in the PSB, including PCBs which you might not be able to process,as PCBs must be included in the order in which they are listed in the PSB. Thisincludes all PCBs prior to the last referenced PCB and can include DB PCBs. If youused a GSAM PCB, all PCBs ahead of it must be referenced.

Chapter 12. Defining application program elements for IMS TM 211

Page 236: IMS Application Programming.pdf

212 Application Programming Guide

Page 237: IMS Application Programming.pdf

Chapter 13. Message processing

This chapter explains message processing concepts and techniques that extendwhat IMS TM application programs can do. It also provides examples ofmessage-driven program structure in Assembler language, C language, COBOL,Pascal, and PL/I.

The following topics provide additional information:v “How your program processes messages”v “How IMS TM edits messages” on page 219v “Message processing considerations for DB2” on page 227v “Sending messages to other terminals and programs” on page 228v “Communicating with other IMS TM systems using MSC” on page 233v “IMS conversations” on page 236v “Processing conversations with APPC” on page 246v “Processing conversations with OTMA” on page 250v “Backing out to a prior commit point: ROLL, ROLB, and ROLS calls” on page

250v “Backing out to an intermediate backout point: SETS/SETU and ROLS” on page

254v “Writing message-driven programs” on page 257v “Coding DC calls and data areas” on page 257

How your program processes messagesTo retrieve and send messages, an IMS TM application program issues calls to IMSTM. When your program issues a call to retrieve a message, IMS TM places theinput message in the I/O area you name in the call. Before you issue a call to senda message, you must build the output message in an I/O area in your program.

Message typesAn operator at a terminal can send four kinds of messages to IMS TM. Thedestination of an IMS TM message identifies which kind of message is being sent:v Another terminal. A logical terminal name in the first 8 bytes means that this is

a message switch destined for another terminal. For a user at a logical terminalto send a message to another logical terminal, the user enters the name of thereceiving logical terminal followed by the message. The IMS TM control regionroutes the message to the specified logical terminal. This kind of message doesnot result in the scheduling of any activity in a message processing program(MPP).

v An application program. A transaction code in the first 8 bytes means that themessage is destined for an application program. IMS TM uses a transaction codeto identify MPPs and transaction-oriented batch message processing programs(BMPs). To use a particular application program to process requests, the userenters the transaction code for that application program.

v IMS TM. A “/” (slash) in the first byte means that the message is a commanddestined for IMS TM.

© Copyright IBM Corp. 1974, 2010 213

Page 238: IMS Application Programming.pdf

v Message switch service. A system service DFSAPPC request is destined for themessage switch service.

An application program can send three kinds of messages:v Commands. A “/” in the first byte of the message text means that the message is

a command for IMS TM. Programmers design applications to issue commandswhen they want a program to perform tasks that an operator at a terminalusually performs. This is called automated operator interface (AOI) and isdescribed in IMS Version 10: Communications and Connections Guide and the IMSVersion 10: Operations and Automation Guide.Use the CMD call to issue commands. Do not use the ISRT call for issuingcommands, because a message created with ISRT can contain a slash in the firstbyte without being a command.

v Messages to logical terminals by specifying a logical terminal name.v Program-to-program switches using a transaction code.

The messages that your program receives and sends are made up of segments. Usea GU call to retrieve the first segment of a new message, and use GN calls to retrievethe remaining segments of the message. Figure 48 shows three messages. MessageA contains one segment, message B contains two segments, and message Ccontains three segments.

To retrieve message A, you only have to issue a GU call. To retrieve messages B andC, issue one GU call to retrieve the first segment, then a GN call for each remainingsegment. This assumes that you know how many segments each message contains.If you do not know this, issue GN calls until IMS TM returns a QD status code,indicating that all of the segments for that message have been retrieved.

If you inadvertently issues a GU call after retrieving the first segment of themulti-segment messages, IMS TM returns a QC status code. This status indicatesthat no more messages are present, without your program retrieving the additionalsegments associated with the message. Data would have been lost without anyindication that it happened.

Input message format and contentsThe input message that an application program receives from a terminal or anotherprogram always has these fields: the length field, the ZZ field, the transaction codefield, and the text field. The tables that follow show the message input layouts.The input message field names are in the first row of each table. The numberbelow each field name is the length in bytes that has been defined for that field.Table 39 on page 215 shows the format of an input message for the AIBTDLI,ASMTDLI, CBLTDLI, CEETDLI, CTDLI, and PASTDLI interfaces. The message isslightly different for the PLITDLI interface as shown in Table 40 on page 215.

Message A Message B

Segment B1

Segment B2

Segment A1

Message C

Segment C1

Segment C2

Segment C3

Figure 48. Message segments

214 Application Programming Guide

Page 239: IMS Application Programming.pdf

Table 39. Input message format

Field Name Field Length

LL 2

ZZ 2

TRANCODE 8

Text Variable

Table 40. Input message format for the PLITDLI interface

Field Name Field Length

LLLL 4

ZZ 2

TRANCODE 8

Text Variable

The contents of the input message fields are:

LL or LLLLThe length field contains the length of the input message segment in binary,including LL (or LLLL) and ZZ. IMS TM supplies this number in the lengthfield when you retrieve the input message.

For the AIBTDLI, ASMTDLI, CBLTDLI, CEETDLI, CTDLI, and PASTDLIinterfaces, define the LL field as 2 bytes long.

For the PLITDLI interface, define the LLLL field as 4 bytes long. The value inthe LLLL field is the input message length minus 2 bytes. For example, if thetext is 12 bytes, then the fullword LLLL contains a value of 24 bytes. Thisvalue is the total of LLLL (4 bytes) + ZZ (2 bytes) + TRANCODE (8 bytes) +text (12 bytes) − 2 bytes.

ZZThe ZZ field is a 2-byte field that is reserved for IMS TM. Your program doesnot modify this field.

TRANCODEThe TRANCODE is the transaction code for the incoming message.

TextThis field contains the message text sent from the terminal to the applicationprogram. The first segment of a message can also contain the transaction codeassociated with the program in the beginning of the text portion of themessage. Input messages do not have to include the transaction code, but youcan provide it for consistency.

The text field’s contents in the input message and the formatting of the contentswhen your program receives the message depends on the editing routine yourprogram uses.

Output message format and contentsThe format of the output message that you build to send back to a terminal or toanother program is similar to the format of the input message, but the fieldscontain different information.

Chapter 13. Message processing 215

Page 240: IMS Application Programming.pdf

Output messages contain four fields: the length field, the Z1 field, the Z2 field, andthe text field. Table 41 and Table 42 show the message output layouts. The outputmessage field names are in the first row of each table. The number below eachfield name is the length in bytes that has been defined for that field. Table 41shows the format of an output message for AIBTDLI, ASMTDLI, CBLTDLI,CEETDLI, CTDLI, and PASTDLI interfaces. The format for PLITDLI is slightlydifferent as shown in Table 42.

Table 41. Output message format

Field Name Field Length

LL 2

Z1 1

Z2 1

Text Variable

Table 42. Output message format for PLITDLI

Field Name Field Length

LLLL 4

Z1 1

Z2 1

Text Variable

The contents of the output message fields are:

LL or LLLLThe field length contains the length of the message in binary, including the LL(or LLLL), Z1, and Z2 fields. For output message segments, supply this lengthwhen you are ready to send the message segment.

For the AIBTDLI, ASMTDLI, CBLTDLI, CEETDLI, CTDLI, and PASTDLIinterfaces, the LL field must be 2 bytes long. For the PLITDLI interface, theLLLL field must be 4 bytes long and contain the length of the messagesegment, minus 2 bytes.

Z1 The Z1 field is a 1-byte field that must contain binary zeros. It is reserved forIMS TM.

Z2 The Z2 field is a 1-byte field that can contain special device-dependentinstructions (such as instructions to ring the alarm bell, instructions todisconnect a switched line, or paging instructions) or device-dependentinformation (such as information about structured field data or bypassingMFS).

If you do not use any of these instructions, the Z2 field must contain binaryzeros. For MFS, this field contains the number of the option that is being usedfor this message.

TextThe text portion of the message segment contains the data that you want tosend to the logical terminal or to an application program. (Text messages aretypically EBCDIC characters.) The length of the text depends on the data thatyou want to send.

216 Application Programming Guide

Page 241: IMS Application Programming.pdf

When a message is processedA program’s response to a message will depend on the type of message theprogram receives. A transaction code associates a request for information from aterminal with the application program that can process and respond to thatrequest. IMS TM schedules an MPP when there are messages to be processed thatcontain the transaction code associated with that MPP.

Example: Suppose you have an MPP that processes the transaction code“INVINQ” for inventory inquiry. The MPP receives a request from a user at aterminal for information on the inventory of parts. When the user enters thetransaction code for that application program, IMS TM schedules the applicationprogram that can process the request.

When you enter INVINQ and one or more part numbers, the MPP sends yourprogram the quantity of each part on hand and the quantity on order.

When you enter INVINQ at the terminal, IMS TM puts the message on themessage queue for the MPP that processes INVINQ. Then, after IMS TM hasscheduled the MPP, the MPP issues GU and GN calls to retrieve the message. Toretrieve the messages from LTERM1, the application program issues a GU for thefirst segment of a message, then issues GN calls until IMS TM returns a QD statuscode. This means that the program has retrieved all of the segments of thatmessage. The program then processes the request, and sends the output message tothe queue for your logical terminal. (The logical terminal name is in the I/O PCB.)When the MPP sends the output message, IMS TM sends it to the queue for thatlogical terminal, and the message goes to the physical terminal. Figure 49 showsthe flow of a message between the terminal and the MPP.

Figure 50 on page 218 shows the calls you use, the status codes, and what theinput and output for the inventory inquiry would look like. To show you how touse GU and GN to retrieve messages, and how you insert multiple-segmentmessages, this example shows messages containing three segments. If input andoutput messages in this example were single segment messages, the programwould issue only a GU to retrieve the entire message, and only one ISRT to send themessage.

The message formats shown in Figure 50 on page 218 are examples; not allmessages are in this format. When the program receives the input message in theI/O area, the first field of each segment contains the length of that segment. This isthe LL field in the figure. For clarity, Figure 50 on page 218 shows this length indecimal; in the input message, however, it is in binary. The second field (ZZ) isreserved for IMS TM; it is 2 bytes long. The text of the message follows the

Logical Terminal queuePhysical terminal

Transaction queue

Application program

Physical terminal

Figure 49. Transaction message flow

Chapter 13. Message processing 217

Page 242: IMS Application Programming.pdf

reserved 2 bytes. The first message segment contains the transaction code in the 8bytes following the ZZ field. These are the first 8 bytes of the text portion of themessage.

The format of the output messages is the same. You do not need to include thename of the logical terminal, because it is in the first 8 bytes of the I/O PCB.

PART, QTY, and ON ORDER in Figure 50 are headings. These are values that youcan define as constants that you want to appear on the terminal screen. To includeheadings in MFS output messages, define them as literals.

Results of a message: I/O PCBAfter your program issues a call, IMS TM returns information about the results ofthe call in the I/O PCB. To find out about the results of the call, your applicationprogram must check the information that IMS TM returns to the I/O PCB.

When your application program retrieves a message, IMS TM returns thisinformation about the message to the I/O PCB:v The name of the terminal that sent the message.v A 2-character status code describing the results of the call. If the program

receives a status code of QC after issuing a call to retrieve a message, no moremessages are available for the program to process.

v The current date, time, and sequence number for the message.v The user ID of the person at the terminal or the transaction code for the

program that sent the message.

Because the I/O PCB resides in storage outside of your program, you define amask of the PCB in your program based at this address to check the results of IMSTM calls. The mask contains the same fields in the same order as the I/O PCB.

Related reading: For more information on I/O PCB masks, see “Specifying the I/OPCB mask” on page 198.

DC calls I/O area Statuscode

bbbbbbQD

bbbbbb

PART QTY ON ORDER12X 90 072B 41 1537Y 3 25

LTERM 1

INVINQ PART 12XPART 72BPART 37Y

LTERM 1

LLZZ TEXT1900INVINQ PART 12X1200PART 72B1200PART 37Y

LLZZ TEXT130012X090000130072B041015130037Y003025

GUGNGNGN...ISRTISRTISRT

Figure 50. Inventory inquiry MPP example

218 Application Programming Guide

Page 243: IMS Application Programming.pdf

How IMS TM edits messagesWhen an application program passes messages to and from a terminal, IMS TMedits the messages before the program receives the message from the terminal andbefore the terminal receives the message from the application program. IMS TMgives you many choices about how you want your messages to appear both on theterminal screen and in the program's I/O area. You need to know which editingroutines have been specified for your program and how they affect yourprogramming.

The three editing routines available to non-LU 6.2 terminals in IMS TM are:

Basic EditPerforms basic edit functions if you do not use MFS and if the messagedoes not originate at an LU 6.1 device. You must provide control charactersfor some formatting functions.

Intersystem Communication (ISC) EditProvides the default edit for messages that originate from an LU 6.1device. You can enter binary data in addition to text.

Message Format Service (MFS)Formats messages through control blocks. You define the way the messageslook with the control blocks.

For LU 6.2 devices, use the LU 6.2 Edit exit routine to edit input and outputmessages.

Related reading: For more information on LU 6.2, see IMS Version 10:Communications and Connections Guide. For more information on LU 6.2 Edit exitroutine, see IMS Version 10: Exit Routine Reference.

Printing output messagesYou must provide the horizontal and vertical control characters that are necessaryto format your output messages.

To print your output at a printer terminal, include these control characters wherenecessary within the text of the message:

X'05' Skip to the tab stop, but stay on the same line.

X'15' Start a new line at the left margin.

X'25' Skip to a new line, but stay at the same place horizontally.

If you want to skip multiple lines, you can start a new line (X'15'), then skip asmany lines as necessary (X'25').

Using Basic EditIf you do not use MFS or an LU 6.1 device, IMS TM does some editingautomatically. The editing IMS TM does to the first message segment is differentfrom the editing IMS TM does for subsequent message segments. See IMS Version10: Communications and Connections Guide for a complete description of Basic Edit.

Editing input messagesWhen IMS TM receives the first segment of an input message for your applicationprogram, IMS TM:v Removes leading and trailing control characters.

Chapter 13. Message processing 219

Page 244: IMS Application Programming.pdf

v Removes leading blanks.v Removes backspaces (from a printer terminal).v Translates to uppercase, if this is specified with the EDIT=UC specification on

the system definition TRANSACT macro.

If the message segment contains a password, IMS TM edits the segment by:v Removing the password and inserting a blank in place of the password.v Removing the password if the first character of the text is a blank. IMS TM does

not insert the blank.v Left-justifying the text of the segment.

For subsequent input message segments, IMS TM does not remove leading blanksfrom the text of the message. The other formatting features are the same.

Editing output messagesFor output messages, Basic Edit:v Changes nongraphic characters in the output message before the data goes to

the output device.v Inserts any necessary idle characters after new line, line feed, and tab characters.v Adds line control characters for the operation of the communication line.

Using Intersystem Communication editIntersystem Communication (ISC) edit is the default edit for messages from LU 6.1devices. It is not valid for any other device types. One advantage of using ISC editis that IMS TM does not edit the text of a message, allowing you to enter binarydata.

Editing input messagesThe editing IMS TM does to input messages depends on whether the FunctionManagement (FM) header contains the SNA-defined primary resource name (PRN)parameter. In either case, IMS TM removes the FM header before the inputmessage is received by the application program.

If the FM header does not contain the PRN parameter:v IMS TM removes leading control characters and blanks when it receives the first

segment of an input message for your application program.v If the message segment contains a password, IMS TM removes the password

and inserts a blank where the password was.v IMS TM does not edit the text of the message (the data following the password).

If the FM header contains the PRN parameter:v The PRN is treated as the transaction code and is received by your application

program as the first field in the message segment.v The message segment is not edited by IMS TM.

Editing output messagesISC edit does not edit output messages.

Message Format ServiceMFS is a part of IMS TM that uses control blocks that you define to formatmessages between a terminal and an MPP. The MFS control blocks indicate to IMSTM how you want your input and output messages arranged:

220 Application Programming Guide

|

Page 245: IMS Application Programming.pdf

v For input messages, MFS control blocks define how the message that theterminal sends to your MPP is arranged in the I/O area.

v For output messages, MFS control blocks define how the message that your MPPsends to the terminal is arranged on the screen or at the printer. You can alsodefine words or other data that appear on the screen (headings, for example) butdo not appear in the program's I/O area. This data, called a literal, can be a fieldin the output message from the application program or a field in the inputmessage from the terminal.

For detailed information on MFS, see Chapter 15, “Introduction to Message FormatService (MFS),” on page 279.

Terminals and MFSWhether your program uses MFS depends on the types of terminals and secondarylogical units (SLUs) your network uses. You can bypass MFS formatting of anoutput message for a 3270 device or for SLU Type 2 devices. When MFS isbypassed, you construct the entire 3270 data stream from within your program.

Restriction: MFS cannot be used with LU 6.2 devices (APPC).

Related reading: For more information on LU 6.2 and APPC, see IMS Version 10:Communications and Connections Guide.

The decisions about using MFS are high-level design decisions that are separatefrom the tasks of application design and application programming; manyinstallations that use MFS have a specialist who designs MFS screens and messageformats for all applications that use MFS.

MFS makes it possible for an MPP to communicate with different types ofterminals without having to change the way it reads and builds messages. Whenthe MPP receives a message from a terminal, the message's format in the MPP I/Oarea depends on the MFS options specified and not on what kind of terminal sentit. MFS shields the MPP from the physical device that is sending the message inthe same way that a DB PCB shields the program from what the data in thedatabase actually looks like and how it is stored.

MFS input message formatsYou define a message to MFS in fields just as you would define fields within adatabase segment. When you define the fields that make up a message segment,you give MFS information such as:v The field lengthv The fill character used when the length of the input data is less than the length

defined for the fieldv Whether the data in the field is left-justified or right-justifiedv If the field is truncated, whether it is truncated on the left or right

The order and length of these fields within the message segment depends on theMFS option that your program is using. You specify the MFS option in the MID.The decision of which option to use for an application program is based on:v How complex the input data isv How much the input data variesv The language the application program is written inv The complexity of the application programv Performance factors

Chapter 13. Message processing 221

Page 246: IMS Application Programming.pdf

The Z2 field in MFS messages contains the MFS formatting option being used toformat the messages to and from your program. If something is wrong in the waythat IMS TM returns the messages to your I/O area, and you suspect that theproblem might be with the MFS option used, you can check this field to see if IMSTM is using the correct option. A X'00' in this field means that MFS did not formatthe message at all.

One way to understand how each of the MFS options formats your input andoutput messages is to look at examples of each option.

Example: Suppose that you have defined the four message segments shown inTable 43. Each of the segments contains a 2-byte length field and a 2-byte ZZ field.The first segment contains the transaction code that the person at the terminalentered to invoke the application program. The number of bytes defined for eachfield appears below the name of the field in the figure.

When you use the PLITDLI interface, you must define the length field as a binaryfullword, LLLL. When you use the AIBTDLI, ASMTDLI, CBLTDLI, CEETDLI,CTDLI, or PASTDLI interfaces, you must define the length field as a halfword, LL.The value provided by the PL/I application program must represent the actualsegment length minus 2 bytes. For example, if the output text is 10 bytes, then thevalue of the fullword LLLL is 14 and is the sum of the length of LLLL (4 bytes − 2bytes) + Z1 (1 byte) + Z2 (1 byte) + TEXT (10 bytes).

Table 43. Four-segment message

Segment Number Field Name Field Length Field Value

1

LL 2 0027

ZZ 2 XXXX

TRANCODE 8 YYYY

Text 5 PATIENT#

Text 10 NAME

2

LL 2 0054

ZZ 2 XXXX

Text 50 ADDRESAF

3

LL 2 0016

ZZ 2 XXXX

Text 6 CHARGES

Text 6 PAYMENTS

4

LL 2 0024

ZZ 2 XXXX

Text 10 TREATMENT

Text 10 DOCTOR

For these examples, assume that:v The transaction code is defined in the MID as a literal.v All of the fields are left-justified.v The fill character is defined as a blank. When the length of the data in a field is

less than the length that has been defined for that field, MFS pads the field withfill characters. Fill characters can be:

222 Application Programming Guide

Page 247: IMS Application Programming.pdf

– Blanks– An EBCDIC character– An EBCDIC graphic character– A null, specified as X'3F'When you specify that the fill character is to be a null, MFS compresses the fieldto the length of the data if that length is less than the field length.The fields for segment 4 of the message in Table 43 on page 222 are arranged onthe terminal screen in the format shown in Figure 51.Example: Assume the person enters the name of a patient, and the charges andpayments associated with that patient.

MFS provides three options for message formatting:v “MFS option 1”v “MFS option 2” on page 224v “MFS option 3” on page 225

MFS option 1: Use this option when the program receives and transmits most ofthe fields in the message segments. The way that option 1 formats messagesdepends on whether you have defined a null as the fill character for any of thefields in the segment.

If none of the fields in the message were defined as having a fill character of null:v The program receives all the segments in the message.v Each segment is the length that was specified for it in the MID.v Each segment contains all its fields.v Each field contains data, data and fill characters, or all fill characters.

Table 44 shows the Option 1 Format of segments received by the applicationprogram.

Table 44. MFS option 1 message format

Segment Number Field Name Field Length Field Value

1

LL 2 0027

Z1 1 XX

Z2 1 01

TRANCODE 8 YYYY

Text 5 blanks

Text 10 MCROSS����

PATIENT#: NAME: MC ROSS

ADDRESAF:

CHARGES: 106.50 PAYMENTS: 90.00

TREATMENT:

DOCTOR:

Figure 51. Terminal screen for MFS example

Chapter 13. Message processing 223

Page 248: IMS Application Programming.pdf

Table 44. MFS option 1 message format (continued)

Segment Number Field Name Field Length Field Value

2

LL 2 0054

Z1 1 XX

Z2 1 01

Text 50 blanks

3

LL 2 0016

Z1 1 XX

Z2 1 01

Text 6 010650

Text 6 009000

4

LL 2 0024

Z1 1 XX

Z2 1 01

Text 10 blanks

Text 10 blanks

The message format for option 1 output messages is the same as the input messageformat. The program builds output messages in an I/O area in the format shownfor segment 4 in Table 44 on page 223. The program can truncate or omit fields inone of two ways:v Inserting a short segmentv Placing a null character in the field

If one or more of the fields are defined as having a null fill character, the messageis different. In this case, the message has these characteristics:v If a field has been defined as having a fill character of null and the terminal

offers not data, the field is eliminated from the message segment.v If all of the fields in a segment have a null fill character and none of the fields

contains any literals, the segment is eliminated from the message.v If only some of the fields in a segment have a null fill character, any field

containing nulls is eliminated from the segment. The relative positions of thefields remaining within the segments are changed.

v When the length of the data that is received from the originating terminal is lessthan the length that is been defined for the field, the field is truncated to thelength of the data.

MFS option 2: Use this option when the program processes multisegmentmessages where most of the fields are transmitted but some of the segments areomitted. Option 2 formats messages in the same way that option 1 does, unless thesegment contains no input data from the terminal after IMS TM has removed theliterals. If this is true, and if no additional segments in the message contain inputdata from the terminal, IMS TM ends the message. The last segment that theprogram receives is the last segment that contains input data from the terminal.

Sometimes a segment that does not have any input data from the terminal isfollowed by segments that do contain input data from the terminal. When this

224 Application Programming Guide

Page 249: IMS Application Programming.pdf

happens, MFS gives the program the length field and the Z fields for the segment,followed by a 1-byte field containing X'3F'. This indicates to the program that thisis a null segment.

If the message segments shown in Table 43 on page 222 are formatted by option 2,they appear in the format shown in Table 45.

Table 45. MFS option 2 message format

Segment Number Field Name Field Length Field Value

1

LL 2 0027

Z1 1 XX

Z2 1 02

TRANCODE 8 YYYY

Text 5 blanks

Text 10 MCROSS����

2

LL 2 0005

Z1 1 XX

Z2 1 02

Text 1 X'3F'

3

LL 2 0016

Z1 1 XX

Z2 1 02

Text 6 010650

Text 6 009000

Segment 2 in Table 45 contains only a X'3F' because that segment is null, butSegment 3 contains data. This message does not contain a segment 4 because it isnull.

MFS option 3: Use this option when the program receives and transmits only afew of the fields within a segment. When you use option 3, the program receivesonly those fields that have been received from the terminal. The program receivesonly segments that contain fields received from the originating terminal. Segmentsand fields can be of variable length if you have defined option 3 as having a nullfill character.

A segment in an option 3 message is identified by its relative segment number—inother words, what position in the message it occupies. The fields within a segmentare identified by their offset count within the segment.

Example: The NAME field in segment 1 (MCROSS����) has an offset value of 17.The value 17 is the sum of the lengths of the fields preceding the NAME field andincludes an 8-byte transaction code and a 5-byte field of blanks. It does not includethe 2-byte relative segment number field (field A in Table 46 on page 226), the2-byte length field (field B), or the 2-byte relative offset field (field C).

Option 3 messages do not contain literals defined in the MID. This means that thetransaction code is removed from the message, except during a conversation. If the

Chapter 13. Message processing 225

Page 250: IMS Application Programming.pdf

transaction that the program is processing is a conversational transaction, thetransaction code is not removed from the message. The transaction code stillappears in the Scratchpad Area (SPA).

Each segment the program receives contains the relative number of this segment inthe message (field A in Table 46). In addition, each data field within the segment ispreceded by two fields:v A 2-byte length field (B). Including the length field itself, the 2-byte relative field

offset, and the data in the field.v A 2-byte relative field offset (C), giving the field's position in the segment as

defined in the MID.

These two fields are followed by the data field. MFS includes these fields for eachfield that is returned to the application program.

If the message segments shown in Table 43 on page 222 are formatted by option 3,they appear in the format shown in Table 46. The notes for the tables explain theletters A, B, C, and D, which are in the first row of segment 1 and segment 3.

Table 46. MFS option 3 message format

Segment Number Field Name Field Length Field Value

1

LL 2 0020

Z1 1 XX

Z2 1 03

A 2 0001

B 2 0014

C 2 0017

D 10 MCROSS����

2

LL 2 0000

Z1 1 XX

Z2 1 03

A 2 0003

B 2 0010

C 2 0004

D 6 010650

B 2 0010

C 2 0010

D 6 009000

Notes to Table 46:

v The fields marked A contain the relative segment number. This number gives thesegment's position within the message.

v The fields marked B contain the field length. This length is the sum of thelengths of B field (2 bytes) + C field (2 bytes) + D field (the length of the data).

v The fields marked C contain the relative field offset. This gives each field'sposition within the segment.

v The fields marked D contain the data from the terminal. In this example, the fillcharacter was defined as blank, so the data field is always its defined length.

226 Application Programming Guide

Page 251: IMS Application Programming.pdf

IMS TM does not truncate it. If you define the fill character as null, the lengthsof the data fields can differ from the lengths defined for them in the segment.With a null fill character, if the length of the data from the terminal is less thanthe length defined for the field, IMS TM truncates the field to the length of thedata. Using a null fill with option 3 reduces the space required for the messageeven further.

MFS output message formatsFor output messages, define to MFS what it is to receive from the applicationprogram. If using option 1 or option 2, the output message format is the same as itis for input messages. Present all fields and segments to MFS. You can present nullsegments. All fields in output messages are fixed length and fixed position. Outputmessages do not contain option numbers.

Option 3 output messages are similar to input messages, except that they do notcontain option numbers. The program submits the fields as required in theirsegments with the position information.

Using LU 6.2 User Edit exit routine (optional)This exit routine edits input and output messages from LU 6.2 devices when theimplicit application program interface support is used. If it is not provided, thenmessages are presented without modification. IMS does not invoke the exit forCPI-C driven transactions because IMS does not participate in the data flows whenthe application program uses the CPI directly.

The LU 6.2 User Edit exit routine is called once for each message segment orinbound control flow. You can call the exit routine for data messages and use it to:v Examine the contents of a message segment.v Change the contents of a message segment.v Expand or compact the contents of a message segment.v Discard a message segment and process subsequent segments, if any.v Use the Deallocate_Abend command to end the conversation.

For more information on LU 6.2 User Edit exit routine, see IMS Version 10:Communications and Connections Guide and IMS Version 10: Operations andAutomation Guide.

Message processing considerations for DB2For the most part, the message processing function of a dependent region thataccesses DB2 databases is similar to that of a dependent region that accesses onlyDL/I databases. The method each program uses to retrieve and send messages andback out database changes is the same. The differences are:v DL/I statements are coded differently from SQL (structured query language)

statements.v When an IMS TM application program receives control from IMS TM, IMS has

already acquired the resources the program is able to access. IMS TM schedulesthe program, although some of the databases are not available. DB2 does notallocate resources for the program until the program issues its first SQLstatement. If DB2 cannot allocate the resources your program needs, yourprogram can optionally receive an initialization error when it issues its first SQLcall.

Chapter 13. Message processing 227

Page 252: IMS Application Programming.pdf

v When an application issues a successful checkpoint call or a successful messageGU call, DB2 closes any cursors that the program is using. This means that yourprogram should issue its OPEN CURSOR statement after a checkpoint call or amessage GU.

IMS TM and DB2 work together to keep data integrity in these ways:v When your program reaches a commit point, IMS TM makes any changes that

the program has made to DL/I databases permanent, releases output messagesfor their destinations, and notifies DB2 that the program has reached a commitpoint. DB2 then makes permanent any changes that the program has made toDB2 databases.

v When your program terminates abnormally or issues one of the IMS TMrollback calls (ROLB, ROLS without a token, or ROLL), IMS TM cancels any outputmessages your program has produced, backs out changes your program hasmade to DL/I databases since the last commit point, and notifies DB2. DB2backs out the changes that the program has made to DB2 databases since thelast commit point.

Through the Automated Operator Interface (AOI), IMS TM application programscan issue DB2 commands and IMS TM commands. To issue DB2 commands, theprogram issues the IMS TM /SSR command followed by the DB2 command. Theoutput of the /SSR command is routed to the master terminal operator (MTO).

Sending messages to other terminals and programsWhen an application program processes a message from a terminal, it usuallysends the response to the terminal that sent the input message. But sometimes youmight want to send output messages to a terminal other than the originatingterminal, or to other terminals in addition to the originating terminal. You mightalso want to send messages to other application programs.

To send a message to a different terminal or to an application program, issue theISRT call, but reference an alternate program communication block (PCB) instead ofthe TP PCB. Alternate PCBs can be defined for a particular terminal or program, orthey can be defined as modifiable. If the alternate PCB is not modifiable, only issuean ISRT call referencing the alternate PCB to send a message to the terminal orprogram that it represents. If the alternate PCB is modifiable, set the destination forthe alternate PCB before issuing the ISRT call. To do this, use a CHNG call.

When you use an alternate PCB:v If you want to send output messages to one alternate destination, define the

alternate PCB for that destination.v If you want to send output messages to more than one alternate destination, and

you want to be able to change the destination of the alternate PCB, define thealternate PCB as modifiable during program specification block (PSB)generation. Then, before you issue the ISRT call, you issue a CHNG call to set thedestination of the alternate modifiable PCB for the destination program orterminal.The express alternate PCB is a special kind of alternate PCB that is defined duringPSB generation, by specifying EXPRESS=YES.When you use an express alternate PCB, messages you send using that PCB aresent to their final destinations immediately. Messages sent with other PCBs aresent to temporary destinations until the program reaches a commit point.Messages sent with express PCBs are sent if the program subsequently

228 Application Programming Guide

Page 253: IMS Application Programming.pdf

terminates abnormally, or issues one of the rollback calls: ROLL, ROLB, or ROLS.Using an express alternate PCB in this kind of situation is a way to ensure thatthe program can notify the person at the terminal, even if abnormal terminationoccurs. For all PCBs, when a program abnormally terminates or issues a ROLL,ROLB, or ROLS call, messages inserted but not made available for transmission arecancelled, while messages made available for transmission are never cancelled.For a nonexpress PCB, the message is not made available for transmission to itsdestination until the program reaches a commit point. The commit point occurswhen the program terminates, issues a CHKP call, or requests the next inputmessage and the transaction has been defined with MODE=SNGL.For an express PCB, when IMS TM knows that it has the complete message, itmakes the message available for transmission to the destination. In addition tooccurring at a commit point, this also occurs when the application programissues a PURG call using that PCB or requests the next input message.A PSBGEN can also specify an alternate PCB as an alternate response PCBdefined during PSB generation.

v If you want to send a message to an LU 6.2 device, you can specify the LU 6.2descriptor name that is associated with that device. IMS internally performs theuppercase translation of the destination name (CNT or SMB).

Related Reading: For more information on sending messages to alternate PCBs,see “Sending messages to other terminals and programs” on page 228. .

Sending messages to other terminalsTo reply to a different terminal, also use the ISRT call, but use an alternate(program communication block) PCB instead of the TP PCB.

Just as the TP PCB represents the terminal that sent the message, an alternate PCBrepresents the terminal to which you want to send the message.

Single alternate terminalIf you are going to send messages to only one alternate terminal, you can definethe alternate PCB for that terminal during PSB generation. When you define analternate PCB for a particular destination, you cannot change that destinationduring program execution. Each time you issue an ISRT call that references thatPCB, the message goes to the logical terminal whose name was specified for thealternate PCB. To send a message to that terminal, place one message segment at atime in the I/O area, and issue an ISRT call referring to the alternate PCB, insteadof the TP PCB.

Several alternate terminalsTo send messages to several terminals, you can define the alternate PCB asmodifiable during PSB generation. Therefore, the alternate PCB represents morethan one alternate terminal. You can change the destination while your program isrunning.

Before you can set or change the destination of an alternate PCB, you mustindicate to IMS TM that the message you have been building so far with that PCBis finished. To do this, issue a PURG call.

PURG allows you to send multiple output messages while processing one inputmessage. When you do not use PURG, IMS TM groups message segments into amessage and sends them when the program issues a GU for a new message,terminates, or reaches a commit point. A PURG call tells IMS TM that the messagebuilt against this TP PCB or alternate PCB (by issuing one ISRT call per message

Chapter 13. Message processing 229

|||

Page 254: IMS Application Programming.pdf

segment) is complete. IMS TM collects the message segments that you haveinserted into one PCB as one message and sends it to the destination representedby the alternate PCB you have referenced.

A PURG call that does not contain the address of an I/O area indicates to IMS TMthat this message is complete. If you include an I/O area in the call, PURG acts asan ISRT call as well. IMS TM treats the data in the I/O area as the first segment ofa new message. When you include an I/O area on a PURG call, you can also includea MOD name to change the format of the screen for this message. Althoughspecifying the MOD name is optional, when you use it, you can specify it onlyonce per message or in only the first ISRT or PURG that begins the message.

To set the destination of a modifiable alternate PCB during program execution, youuse a CHNG call. When you issue the CHNG call you supply the name of the logicalterminal to which you want to send the message. The alternate PCB you use thenremains set with that destination until you do one of the following:v Issue another CHNG call to reset the destination.v Issue another GU to the message queue to start processing a new message. In this

case, the name still appears in the alternate PCB, even though it is no longervalid.

v Terminate your program. When you do this, IMS TM resets the destination toblanks.

The first 8 bytes of the alternate PCB contain the name of the logical terminal towhich you want to send the message.

When you issue a CHNG call, give IMS TM the address of the alternate PCB you areusing and the destination name you want set for that alternate PCB.

When you use the PURG call, you give IMS TM only the address of the alternatePCB. IMS TM sends the message you have built using that PCB.

To indicate an error situation, you can send a message by issuing an ISRT callfollowed by a PURG call against an express PCB. These calls send the message to itsfinal destination immediately.

Example: The program could go through these steps:1. The program issues a GU call (and GN calls, if necessary) to retrieve an input

message.2. While processing the message, the program encounters an abnormal situation.3. The program issues a PURG call to indicate to IMS TM the start of a new

message.4. The program issues a CHNG call to set the destination of an express PCB to the

name of the originating logical terminal. The program can get this name fromthe first 8 bytes of the I/O PCB.

5. The program issues ISRT calls as necessary to send message segments. The ISRTcalls reference the express PCB.

6. The program issues a PURG call referencing the express PCB. IMS TM thensends the message to its final destination.

7. The program can then terminate abnormally, or it can issue a ROLL, ROLB, orROLS call to back out its database updates and cancel the output messages it hascreated since the last commit point.

230 Application Programming Guide

Page 255: IMS Application Programming.pdf

If your output messages contained three segments, and you used the PURG call toindicate the end of a message (and not to send the next message segment), youcould use this call sequence:CHNG ALTPCB1, LTERMAISRT ALTPCB1, SEG1ISRT ALTPCB1, SEG2ISRT ALTPCB1, SEG3PURG ALTPCB1CHNG ALTPCB1, LTERMBISRT ALTPCB1, SEG4ISRT ALTPCB1, SEG5ISRT ALTPCB1, SEG6

Sending messages to other application programsA program-to-program switch occurs when an IMS application running in an IMSdependent region sends a message to another IMS application running in an IMSdependent region.

You can issue a program-to-program switch to send and receive messages with anyof the following types of IMS applications:v message processing program (MPP)v batch message processing (BMP) programv Java message processing (JMP) programv Java batch processing (JBP) program

To send a message to another online program, use an alternate (programcommunication block) PCB and use some of the same options in an alternate PCBto send messages to alternate terminals. If you send messages to only oneapplication program, then you can define the alternate PCB with the transactioncode for that application program during PSB generation. If you send messages tomore than one application program, you can define the alternate PCB asmodifiable.

If you use an alternate modifiable PCB, IMS TM does some security checkingwhen you issue the CHNG call to set the destination of the alternate modifiable PCB.The terminal that enters the transaction code that causes the message switch mustbe authorized to enter the transaction code that the CHNG call places in the alternatemodifiable PCB. IMS TM does not do any security checking when you issue theISRT call.

When an IMS TM application program issues a CHNG call, that call invokes RACF,and a check is made to determine whether the originating terminal is authorizedfor the transaction code just issued. If, instead of using the CHNG call, the programissues an ISRT call against a preset alternate PCB, no security check is made,regardless of the environment.

When you do a program-to-program message switch, you have the sameconsiderations as when you communicate with a logical terminal. You have toremember these points:v Create an I/O area large enough to hold the largest segment that you are

sending.v Use an alternate PCB, not the TP PCB, to send the message.v Issue a CHNG call before the ISRT call to place the program's transaction code in

the first field of the alternate PCB. If the alternate PCB was set to thistransaction code in the PSBGEN, then you just issue the ISRT call.

Chapter 13. Message processing 231

|||

||

|

|

|

|

|||||

Page 256: IMS Application Programming.pdf

v IMS TM must know the transaction code. Define it at system definition.v A nonconversational program can do a program-to-program message switch to

another nonconversational program, but not to a conversational program.v A conversational program can do a program-to-program message switch to

either another conversational program or a nonconversational program.

Open Transaction Manager Access (OTMA) program-to-program switching has thefollowing restrictions:v In a shared queues environment that has both synchronous APPC/OTMA

support (AOS=Y on the DFSDCxxx PROCLIB member) and RRS support(RRS=Y on the startup procedure) enabled, an application program running on aback-end IMS system that initiates an outbound APPC protected conversationwith another IMS system is restricted to a single program-to-program switch.

v If an application program performs multiple program-to-program switches afterallocating an APPC outbound protected conversation on another IMS system, theresults are unpredictable and can include a WAIT-RRS/PC condition in the MPPdependent region.

A message switch to another conversational program transfers the SPA and theresponsibility to respond to the originating terminal to the new applicationprogram. (See “Passing the conversation to another conversational program” onpage 242.) A message switch to a nonconversational program does not change theresponsibilities of the conversational program. The conversational program muststill return the SPA to IMS TM (if the SPA has been modified) and must respond tothe originating terminal. Table 47 and Table 48 show the format for an outputmessage to an application program.

Table 47. Message Format for program-to-program message switch for AIBTDLI, ASMTDLI,CBLTDLI, CEETDLI, CTDLI, and PASTDLI interfaces

Field Name Field Length

LL 2

Z1 1

Z2 1

Text Variable

Table 48. Message format for program-to-program message switch for the PLITDLI interface

Field Name Field Length

LLLL 4

Z1 1

Z2 1

Text Variable

As you can see, the format is the same as for output messages to terminals. Z1 andZ2 are fields that must contain binary zeros. These fields are reserved for IMS. Thetext field contains the message segment that you want to send to the applicationprogram.

If the program that is processing the message expects the transaction code, includeProgram B's transaction code as part of the message text of the message's firstsegment, because IMS TM does not automatically include the transaction code inthe first segment of a switched message. Including the transaction code in the first

232 Application Programming Guide

Page 257: IMS Application Programming.pdf

segment's message text keeps the first segments of all messages in the sameformat, regardless of whether they are sent from terminals or other programs.

Related reading: For more information on program switching in a JMP or JBPapplication, see “Program switching in JMP and JBP applications” on page 394

How the VTAM I/O facility affects your VTAM terminalVTAM terminals can fail to respond to requests sent by IMS. The master terminaloperator or an automated operator interface application program can optionallyactivate a “timeout” facility. This allows a message stating a specific amount oftime has passed to be sent to the master terminal operator.

IMS TM can be set up to do one of the following:v Do nothing, which means that your terminal remains inactive. This is the

default.v Send a message to the master terminal operator stating that the specified period

of time has passed. The operator can then determine what action, if any, shouldbe taken.

v Send a message to the master terminal operator stating that the specified periodof time has passed. IMS TM then issues the VTAM VARY NET, INACT commandfollowed by a VTAM VARY NET, ACT command. If the terminal is defined to IMSTM as non-shared and operable, and if IMS TM is not shutting down, IMS TMissues an OPNDST for the terminal.Restriction: This option does not apply to ISC terminals. If your installationchooses this option and an ISC terminal times out, a message is sent to themaster terminal stating that the specified period of time has passed. Theoperator can determine what action, if any, should be taken.

Communicating with other IMS TM systems using MSCIn addition to communicating with programs and terminals in your IMS TMsystem, your program can communicate with terminals and programs in other IMSTM systems through Multiple Systems Coupling (MSC). MSC makes this possibleby establishing links between two or more separate IMS TM systems. Theterminals and transaction codes within each IMS TM system are defined asbelonging to that system. Terminals and transaction codes within your system arecalled “local,” and terminals and transaction codes defined in other IMS TMsystems connected by MSC links are called “remote.”

Related reading: For an overview of MSC, see IMS Version 10: Communications andConnections Guide.

The following topics provide additional information:v “Implications of MSC for program coding”v “Receiving messages from other IMS TM systems” on page 234v “Sending messages to alternate destinations in other IMS TM systems” on page

235

Implications of MSC for program codingFor the most part, communicating with a remote terminal or program does notaffect how you code your program. MSC handles the message routing betweensystems.

Chapter 13. Message processing 233

Page 258: IMS Application Programming.pdf

Example: If you receive an input message from a remote terminal, and you wantto reply to that terminal, you issue an ISRT call against the I/O PCB—just as youwould reply to a terminal in your system.

In the following two situations, MSC might affect your programming:v When your program needs to know whether an input message is from a remote

terminal or a local terminal. For example, if two terminals in separate IMS TMsystems had the same logical terminal name, your program's processing mightbe affected by knowing which system sent the message.

v When you want to send a message to an alternate destination in another IMSTM system.

Restriction: If a transaction allocated by an LU 6.2 device is destined to a remotesystem through MSC links, IMS rejects the transaction with the messageTP_NOT_Avail_No_Retry.

Related Reading: For more information on LU 6.2, see IMS Version 10:Communications and Connections Guide.

Directed routing makes it possible for your program to find out whether an inputmessage is from your system or from a remote system, and to set the destinationof an output message for an alternate destination in another IMS TM system. Withdirected routing, you can send a message to an alternate destination in anotherIMS TM system, even if that destination is not defined in your system as remote.

Restriction: MSC directed routing does not support a program-to-program switchbetween conversational transactions.

Related Reading: For more information about MSC directed routing, see IMSVersion 10: Communications and Connections Guide.

Receiving messages from other IMS TM systemsWhen an application program retrieves an input message, the program candetermine whether the input message is from a terminal or program in its IMS TMsystem, or from a terminal or program in another IMS TM system. There might besituations in which the application program's processing is changed if the inputmessage is from a remote terminal, rather than from a local terminal.

Example: Suppose that your IMS TM system is system A, and that it is linked toanother IMS TM system called system B. MSC links are one-way links. The linkfrom system A to system B is called LINK1, and the link from system B to systemA is called LINK2. The application program named MPP1 runs in system A. Thelogical terminal name of the master terminals in both systems is MASTER.Figure 52 on page 235 shows systems A and B.

234 Application Programming Guide

Page 259: IMS Application Programming.pdf

If the MASTER terminal in system B sends a message indicating that the system isshutting down to MPP1 in system A, MPP1 needs to know that the message isfrom MASTER in system B and not MASTER in system A.

If you have specified ROUTING=YES on the TRANSACT macro during IMS TMsystem definition, IMS TM does two things to indicate to the program that themessage is from a terminal in another IMS TM system.

First, instead of placing the logical terminal name in the first field of the I/O PCB,IMS TM places the name of the MSC logical link in this field. In the example, thisis LINK1. This is the logical link name that was specified on the MSNAME macroat system definition. However, if the message is subsequently sent back to theoriginating system, the originating LTERM name is reinstated in the first field ofthe I/O PCB.

Second, IMS TM turns on a bit in the field of the I/O PCB that is reserved for IMS.This is the second bit in the first byte of the 2-byte field. Figure 53 shows thelocation of this bit within the reserved field.

MPP1 tests this bit to determine if the message is from MASTER in system A. If itis, MPP1 should terminate immediately. However, if the message is from MASTERin system B, MPP1 could perform some local processing and send transactions forsystem B to a message queue so that those transactions could be processed lateron, when system B is up.

Sending messages to alternate destinations in other IMS TMsystems

To send an output message to an alternate terminal in another IMS TM system,your system must have an MSC link with the system to which you want to send

LINK1

LINK2

MASTER MPP1

SYSTEM B

MASTER

SYSTEM A

Figure 52. MSC example

0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15

1st byte 2nd byte

Reserved for IMS2 bytes

Figure 53. Directed routing bit in I/O PCB

Chapter 13. Message processing 235

Page 260: IMS Application Programming.pdf

the message. To do this, issue a CHNG call against an alternate PCB and supply thename of the MSC link (in the example this is LINK1) that connects the two IMSTM systems.

Example: If you were sending a message to TERMINAL 1 in system B after youreceived a message from some other terminal, you would first issue this CHNG call:CHNG altpcb, LINK1

Then issue an ISRT call (or calls) to send the message just as you would send amessage to a local terminal. Table 49 and Table 50 show the format of the DirectRouting Output Message.

Table 49. Directed routing output message format for AIBTDLI, ASMTDLI, CBLTDLI,CEETDLI, CTDLI, and PASTDLI interfaces

Field Name Field Length

LL 2

ZZ 2

DESTNAME 1 - 8

b 1

Text Variable

Table 50. Directed routing output message format for the PLITDLI interface

Field Name Field Length

LLLL 4

ZZ 2

DESTNAME 1 - 8

b 1

Text Variable

The field formats in a directed routing output message are listed below:v The LL and ZZ fields are 2 bytes each (For the PLITDLI interface, use the 4-byte

field LLLL). LL (or LLLL) contains the total length of the message. This is thesum of all of the fields in the message, including the LL field (and in PL/I,LLLL contains the total length minus 2). ZZ is reserved for IMS.

v The destination name, DESTNAME, is the name of the logical terminal to whichyou are sending the message. This field is from 1 to 8 bytes long and it must befollowed by a blank.If the destination in the other system is a terminal, IMS TM removes theDESTNAME from the message. If the destination in the other system is aprogram, IMS TM does not remove the DESTNAME.

v The TEXT field contains the text of the message. Its length depends on themessage you are sending.

If your message contains a security violation, MSC detects it in the receivingsystem (in this case, system B), and reports it to the person at the originatingterminal (system A).

IMS conversationsDefinitions:

236 Application Programming Guide

Page 261: IMS Application Programming.pdf

v A conversational program is a message processing program (MPP) that processestransactions made up of several steps. It does not process the entire transactionat the same time. A conversational program divides processing into a connectedseries of terminal-to-program-to-terminal interactions. You use conversationalprocessing when one transaction contains several parts.

v A nonconversational program receives a message from a terminal, processes therequest, and sends a message back to the terminal. A conversational programreceives a message from a terminal, and replies to the terminal, but saves thedata from the transaction in a scratchpad area (SPA). Then, when the person atthe terminal enters more data, the program has the data it saved from the lastmessage in the SPA, so it can continue processing the request without the personat the terminal having to enter the data again.

A conversational exampleFor this example, suppose that you want to find out if someone can qualify for acar loan. This inquiry contains two parts. First, you give the name and address ofthe person requesting the loan and the number of years for which the personwants the loan. After you give this information, IMS TM asks you for theinformation on the car: model, year, and cost. You enter this information, IMS TMinvokes the program that processes this information, and the program tells youwhether the loan can be granted.

If you use MFS, the process involves these steps:1. Enter the format command (/FORMAT) and the MOD name. This tells IMS to

format the screen in the way defined by this message output descriptor (MOD).If the MOD name is CL, the command is:/FORMAT CL

IMS TM then takes that MOD from the MFS library and formats your screen inthe way defined by the MOD. When the MOD for the car loan applicationformats your screen, it looks like this:CARLOANNAME:ADDRESS:YEARS:

The word “CARLOAN” is the transaction code for this application. Eachtransaction code is associated with an application program, so when IMS TMreceives the transaction code “CARLOAN,”IMS TM knows what applicationprogram to schedule for this request.

2. Enter the customer's name and address, and the length of the loan. When youenter this information, your screen looks like this:CARLOANNAME: JOHN EDWARDSADDRESS: 463 PINEWOODYEARS: 5

3. IMS TM reads the transaction code, CARLOAN, and invokes the program thathandles that transaction code. MFS formats the information from the screen forthe MPP's I/O area by using the DIF and the MID.When the MPP issues its first call, which is usually a GU for the SPA, IMS TMclears the SPA to binary zeros and passes it to the application program.

4. Next, the MPP processes the input data from the terminal and does two things.It moves the data that it will need to save to the SPA, and it builds the outputmessage for the terminal in the I/O area. The information that the MPP savesin the SPA is the information the MPP will need when the second part of therequest comes in from the terminal. You do not save information in the SPA

Chapter 13. Message processing 237

Page 262: IMS Application Programming.pdf

that you can get from the database. In this example, you save the name of thecustomer applying for the loan, because if the customer is granted the loan, theprogram uses the customer name to locate the information to be updated in thedatabase.The program then issues an ISRT call to return the SPA to IMS, and anotherISRT call to send the output message to the terminal.The response that the MPP sends to the terminal gives IMS TM the name of theMOD to format the screen for the next cycle of the conversation. In that cycle,you need to supply the model, year, and cost of the car that John Edwardswants to buy. Your screen looks like this:MODEL:YEAR:COST:

5. IMS TM again uses the device input format (DIF) and message input descriptor(MID) associated with the transaction code, and sends the information back tothe MPP. The MPP has not been running all this time. when IMS TM receivesthe terminal input with the transaction code CARLOAN, IMS TM invokes theMPP that processes that transaction again for this cycle of the conversation.

6. IMS TM returns the updated SPA to the MPP when the MPP issues a GU, thenreturns the message to the MPP when the MPP issues a GN. The MPP does therequired processing (in this case, determining whether the loan can be grantedand updating the database if necessary), and is then ready to end theconversation. To do this, the MPP blanks out the transaction code in the SPA,inserts it back to IMS, then sends a message to the terminal saying whether theloan can be granted.

Conversational structureStructuring your conversational program depends on the interactions between yourprogram and the person at the terminal. To understand what conversationalprocessing involves, see “IMS conversations” on page 236.

Before structuring your program, you need to know:v What should the program do in an error situation?

When a program in a conversation terminates abnormally, IMS TM backs outonly the last cycle of the conversation. A cycle in a conversation is oneterminal/program interaction. Because the conversation can terminateabnormally during any cycle, you should be aware of some things you can do tosimplify recovery of the conversation:– The ROLB or ROLS call can be used in conversational programs to back out

database updates that the program has made since the last commit point.ROLL can also be used in conversational programs, but terminates theconversation. “Using ROLB, ROLL, and ROLS in conversations” on page 242explains how these calls work with conversational processing.

– If possible, updating the database should be part of the last cycle of theconversation so that you do not have different levels of database updatesresulting from the conversation.

– If your program encounters an error situation and it has to terminate, it canuse an express alternate (program communication block) PCB to send amessage to the originating terminal, and, if desired, to the master terminaloperator.To do this, the program issues a CHNG call against the express alternate PCBand supplies the name of the logical terminal from the TP PCB, then an ISRTcall that references that PCB and the I/O area that contains the message. The

238 Application Programming Guide

Page 263: IMS Application Programming.pdf

program can then issue another CHNG call to set the destination of the expressalternate PCB for the master terminal, and another ISRT call that referencesthat PCB, and the I/O area that contains the output message.

v Does your application program process each cycle of the conversation?A conversation can be processed by one or several application programs. If yourprogram processes each stage of the conversation (in other words, your programprocesses each input message from the terminal), the program has to know whatstage of the conversation it is processing when it receives each input message.When the person at the terminal enters the transaction code that starts theconversation, IMS TM clears the SPA to binary zeros and passes the SPA to theprogram when the program issues a GU call. On subsequent passes, however, theprogram has to be able to tell which stage of the conversation it is on so that itcan branch to the section of the program that handles that processing.One technique that the program can use to determine which cycle of theconversation it is processing is to keep a counter in the SPA. The programincrements this counter at each stage of the conversation. Then, each time theprogram begins a new cycle of the conversation (by issuing a GU call to retrievethe SPA), the program can check the counter in the SPA to determine whichcycle it is processing, then branch to the appropriate section.

v How can your program pass control of the conversation to another conversationprogram?Sometimes it is more efficient to use several application programs to process aconversation. This does not affect the person at the terminal. It depends on theprocessing that is required.In the car loan example, one MPP could process the first part of the conversation(processing the name, address, and number of years), and another MPP couldprocess the second part of the conversation (processing the data about the carand responding with the status of the loan).A program can:– Reply to the originating terminal using a deferred program switch.– Pass the SPA (and, optionally, a message) to another conversational program

without responding to the terminal using an immediate program switch. In thiscase, it is the next program's responsibility to respond to the originatingterminal.Definitions:

- A deferred program switch responds to the terminal but causes the next inputfrom the terminal to go to another conversational program.

- An immediate program switch passes the conversation directly to anotherconversational program.

A conversational program must:1. Retrieve the SPA and the message using GU and GN calls.

If your MPP is starting this conversation, test the variable area of the SPA forzeros to determine if this is the beginning of the conversation. If the SPAdoes not contain zeros, it means that you started the conversation earlier andthat you are now at a later stage in the conversation. If this is true, youwould branch to the part of your program that processes this stage of theconversation to continue the conversation.If another MPP has passed control to your MPP to continue the conversation,the SPA contains the data you need to process the message, so you do nothave to test it for zeros. Start processing the message immediately.

2. Process the message, including handling any necessary database access.

Chapter 13. Message processing 239

Page 264: IMS Application Programming.pdf

3. Send the output message to the terminal by using an ISRT call against theI/O PCB. This step can follow step 4.

4. Store the data (that your program, or the program that you pass control to,needs to continue processing) in the SPA using an ISRT call to the I/O PCB.(This step can precede step 3.) IMS TM determines which segment is the SPAby examining the ZZZZ field of the segment shown in Table 51and Table 52.

To end the conversation, move blanks to the area of the SPA that contains thetransaction code, and then insert the SPA back to IMS TM by issuing an ISRTcall and referencing the I/O PCB.If your MPP passes the conversation to another conversational program, thesteps after the program processes the message are somewhat different. “Passingthe conversation to another conversational program” on page 242 explains this.Also, your program should be designed to handle the situation that occurs whenthe first GU call to the I/O PCB does not return a message to the applicationprogram. This can happen if the person at the terminal cancels the conversationby entering the /EXIT command before the program issues a GU call. (Thishappens if the message from this terminal was the only message in the messagequeue for the program.)

The contents of SPAThe SPA that IMS TM gives your program when you issue a GU contains the fourparts shown in Table 51 and Table 52.

Table 51. SPA format for AIBTDLI, ASMTDLI, CBLTDLI, CEETDLI, CTDLI, and PASTDLIinterfaces

Field Name Field Length

LL 2

ZZZZ 4

TRANCODE 8

User Work Area Variable

Table 52. SPA format for the PLITDLI interface

Field Name Field Length

LLLL 4

ZZZZ 4

TRANCODE 8

User Work Area Variable

The SPA format fields are:

LL or LLLLA length field that gives the total length of the SPA. This length includes 2bytes for the LL field. (For the PLITDLI interface, use a 4-byte field. Itscontents include 4 bytes for LLLL, minus 2.)

ZZZZA 4-byte field reserved for IMS TM that your program must not modify.

TRANCODEThe 8-byte transaction code for this conversation.

User Work AreaA work area that you use to save the information that you need to continue

240 Application Programming Guide

Page 265: IMS Application Programming.pdf

the conversation. The length of this area depends on the length of the data youwant to save. This length is defined at system definition.

When your program retrieves the SPA with a GU to start the conversation, IMS TMremoves the transaction code from the message. In your first message segment,you receive only the data from the message that the person at the terminal entered.

The following list indicates the ways that an application program processes theSPA. The program must:v Not modify the first 6 bytes of the SPA (LL and ZZZZ). IMS TM uses these

fields to identify the SPA.If the program modifies the SPA, the program must return the SPA to IMS TM(or, for a program switch, to the other program).

v Not return the SPA to IMS TM more than once during one cycle of theconversation.

v Not insert the SPA to an alternate PCB that represents a nonconversationaltransaction code or a logical terminal. The program can use an alternateresponse PCB if it represents that same physical terminal as the originatinglogical terminal.

Restriction: If you are using MFS, the IMS TM does not always remove thetransaction code.

The appearance of messages in a conversationBecause the first segment contains the SPA, conversational input messages aremade up of at least two segments. The input message starts in the second messagesegment.

The input message segment in a conversation contains only the data from theterminal. During the first step in the conversation, IMS TM removes the transactioncode from the input message and places it in the SPA. When the program issuesthe first GU, IMS TM returns the SPA. To retrieve the first message segment, theprogram must issue a GN.

The format for the output messages that you send to the terminal is no differentthan the format for output messages in nonconversational programs.

Saving information in the SPAAfter you have processed the message and are ready to reply to the terminal, youcan save the necessary data in the SPA. The part of the SPA in which you savedata is the work area portion. Use the ISRT call to save data to the work area. Thisis a special use of the ISRT call, because you are not sending the SPA to a terminal,but rather saving it for future use.

If your program processes each stage of the conversation, you just issue an ISRTcall to the I/O PCB and give the name of the I/O area that contains the SPA. Forexample:ISRT I/O PCB, I/O AREA

This returns the updated SPA to IMS TM so that IMS TM can pass it to yourprogram at the next cycle of the conversation.

If you do not modify the SPA, you do not need to return it to IMS. However, theSPA will be passed by IMS TM to your program at the next cycle of theconversation.

Chapter 13. Message processing 241

Page 266: IMS Application Programming.pdf

Replying to the terminalFor a conversation to continue, the originating terminal must receive a response toeach of its input messages. The person at the terminal cannot enter any more datato be processed (except IMS TM commands) until the response has been receivedat the terminal.

To continue the conversation, the program must respond to the originatingterminal by issuing the required ISRT calls to send the output message to theterminal. To send a message to the originating terminal, the ISRT calls mustreference either the TP PCB or an alternate response PCB. Use an alternateresponse PCB in a conversation when the terminal you are responding to has twocomponents—for example, a printer and a punch—and you want to send theoutput message to a component that is separate from the component that sent theinput message. If the program references an alternate response PCB, the PCB mustbe defined for the same physical terminal as the logical terminal that sent the inputmessage.

The program can send only one output message to the terminal for each inputmessage. Output messages can contain multiple segments, but the program cannotuse the PURG call to send multiple output messages. If a conversational programissues a PURG call, IMS TM returns an AZ status code to the application programand does not process the call.

Using ROLB, ROLL, and ROLS in conversationsIssuing a ROLB or ROLS in a conversational program causes IMS TM to back out themessages that the application program has sent. This means that, if the programissues a ROLB or ROLS and then reaches a commit point without sending therequired response to the originating terminal, IMS TM terminates the conversationand sends the message DFS2171I NO RESPONSE CONVERSATION TERMINATED. to theoriginating terminal.

If you issue ROLL during a conversation, IMS TM backs out the updates andcancels output messages, but it also terminates the conversation.

If the application program has processed input as a result of a protectedconversation with RRS/MVS, the ROLB will result in IMS abnormally terminatingthe application program with an ABENDU0711, Reason Code X’20’. IMS willdiscard the input message.

Passing the conversation to another conversational programA conversational program can pass the conversation to another conversationalprogram in two ways:v A deferred switch.

The program can respond to the terminal but cause the next input from theterminal to go to another conversational program by:– Issuing an ISRT call against the I/O PCB to respond to the terminal– Placing the transaction code for the new conversational program in the SPA– Issuing an ISRT call referencing the I/O PCB and the SPA to return the SPA to

IMS TMIMS TM then routes the next input message from the terminal to the programassociated with the transaction code that was specified in the SPA. Otherconversational programs can continue to make program switches by changingthe transaction code in the SPA.

242 Application Programming Guide

Page 267: IMS Application Programming.pdf

v An immediate switch.The program can pass the conversation directly to another conversationalprogram by issuing an ISRT call against the alternate PCB that has its destinationset to the other conversational program.The first ISRT call must send the SPA to the other program, but the programpassing control can issue subsequent ISRT calls to send a message to the newprogram. If the program does this, in addition to routing the SPA to the otherconversational program, IMS TM updates the SPA as if the program hadreturned the SPA to IMS. If the program does an immediate switch, the programcannot also return the SPA to IMS TM or respond to the original terminal.

Restrictions on passing the conversationThese are restrictions that apply to passing the conversation to anotherconversational program:v When an immediate program switch occurs and the MPP receives an XE status

code, the program attempts to insert the SPA to an alternate express PCB.Remove the EXPRESS=YES option from the PCB or define and use another PCBthat is not express. This restriction prevents the second transaction fromcontinuing the conversation if the first transaction abends after inserting theSPA.The person at the terminal can issue the /SET CONV XX command, where XX isthe program that is to be scheduled in order to process the next step of theconversation.

v The SPA size for a conversational program-to-program switch on a remote MSCsystem also has restrictions when the source system (where the inputtingterminal resides) or an intermediate MSC system is IMS Version 5 or earlier:– If the SPA ISRT is on a remote MSC system, and is going back to the

inputting terminal on the source IMS system, the SPA must be smaller than orequal to the SPA size of the current transaction.

– If the SPA ISRT is on a remote MSC system, and the destination is atransaction, the SPA must be equal in size to the SPA of the currenttransaction.

v APPC or OTMA protected transactions do not allow immediate program ordeferred program switches. If either of these switches occur, the MPP receives anX6 status code.

Defining the SPA sizeDefine the SPA size with the TRANSACT macro. An option to capture truncateddata is also defined with the TRANSACT macro. The format is:TRANSACT SPA=(size,STRUNC|RTRUNC)

The default is to support truncated data (STRUNC). When a conversation isinitially started, and on each program switch, the truncated data option is checkedand set or reset as specified. When the truncated data option is set, it remains setfor the life of the conversation, or until a program switch occurs to a transactionthat specifies that the option be reset.

Example: Assume you have three transactions defined as follows:TRANA SPA=100TRANB SPA=050TRANC SPA=150

Chapter 13. Message processing 243

|||

||||||

|||

|||

|||

|||

|||

Page 268: IMS Application Programming.pdf

For TRANC to receive the truncated data (which is the second 50 bytes fromTRANA that TRANB does not receive) from TRANA, one of the following sets ofspecifications can be used:v TRANA - STRUNC or none, TRANB - STRUNC or none, TRANC - STRUNC or

nonev TRANA - RTRUNC, TRANB - STRUNC, TRANC - STRUNC or none

Conversational processing and MSCIf your installation has two or more IMS TM systems, and they are linked to eachother through MSC, a program in one system can process a conversation thatoriginated in another system.v If a conversational program in system A issues an ISRT call that references a

response alternate PCB in system B, system B does the necessary verification.This is because the destination is implicit in the input system. The verificationthat system B does includes determining whether the logical terminal that isrepresented by the response alternate PCB is assigned to the same physicalterminal as the logical terminal that sent the input message. If it is not, system B(the originating system) terminates the conversation abnormally without issuinga status code to the application program.

v Suppose program A processes a conversation that originates from a terminal insystem B. Program A passes the conversation to another conversational programby changing the transaction code in the SPA. If the transaction code thatprogram A supplies is invalid, system B (the originating system) terminates theconversation abnormally without returning a status code to the applicationprogram.

v When the source system (where the inputting terminal resides) is IMS Version 5or earlier, the SPA size for a conversational program-to-program switch hasrestrictions. For more information, see “Restrictions on passing the conversation”on page 243.

Ending the conversationTo end the conversation, a program blanks out the transaction code in the SPA andreturns it to IMS TM by issuing an ISRT call and referencing the I/O PCB and theSPA. This terminates the conversation as soon as the terminal has received theresponse.

The program can also end the conversation by placing a nonconversationaltransaction code in the transaction field of the SPA and returning the SPA to IMS.This causes the conversation to remain active until the person at the terminal hasentered the next message. The transaction code will be inserted from the SPA intothe first segment of the input message. IMS TM then routes this message from theterminal to the MPP or BMP that processes the transaction code that was specifiedin the SPA.

In addition to being ended by the program, a conversation can be ended by theperson at the originating terminal, the master terminal operator, and IMS.v The person at the originating terminal can end the conversation by issuing one

of several commands:

/EXIT The person at the terminal can enter the /EXIT command byitself, or the /EXIT command followed by the conversationalidentification number assigned by the IMS TM system.

/HOLD The /HOLD command stops the conversation temporarily to allowthe person at the terminal to enter other transactions while IMSTM holds the conversation. When IMS TM responds to the /HOLD

244 Application Programming Guide

Page 269: IMS Application Programming.pdf

command, it supplies an identifier that the person at theterminal can later use to reactivate the conversation. The/RELEASE command followed by this identifier reactivates theconversation.

v /START LINE. The master terminal operator can end the conversation byentering a /START LINE command (without specifying a PTERM) or /START NODEcommand for the terminal in the conversation or a /START USER command for asigned-off dynamic user in conversation.

v IMS TM ends a conversation if, after the program successfully issues a GU call oran ISRT call to return the SPA, the program does not send a response to theterminal. In this situation, IMS TM sends the message DFS2171I NO RESPONSE,CONVERSATION TERMINATED to the terminal. IMS TM then terminates theconversation and performs commit point processing for the application program.

Message switching in APPC conversationsWith the system service DFSAPPC, you can transfer messages between separateLU 6.2 devices and between an LU 6.2 device and another terminal supported byIMS TM. Message delivery with DFSAPPC is asynchronous, so messages are heldon the IMS TM message queue until they can be delivered.

To send a message with DFSAPPC, specify the logical terminal name of an IMSTM terminal or the Transaction Program (TP) name of an LU 6.2 device.

DFSAPPC formatThe message format for DFSAPPC is as follows:DFSAPPC (options)user_data

DFSAPPC can be coded as follows:

�� DFSAPPCb

( LTERM=value ),

LU=valueMODE=valueTYPE= B

NSIDE=valueSYNC= N

CTPN= valueb

��

A blank (�) is required between DFSAPPC and the specified options.

Blanks are valid within the specified options except within keywords or values.Either commas or blanks can be used as delimiters between options, but becausethe use of commas is valid, the TP name must be followed by at least one blank.

If an LU 6.2 conversation has not been established from other sources (for example,during a CPI-C driven application program), DFSAPPC is used to establish theconversation with a partner LU 6.2 device. If no options are specified withDFSAPPC, IMS TM default options are used.

Chapter 13. Message processing 245

Page 270: IMS Application Programming.pdf

Option keywordsLTERM=

Specifies the LTERM name of an IMS TM logical terminal. An LTERM namecan contain up to eight alphanumeric or national (@, $, #) characters. If youspecify LTERM, you cannot specify the other option keywords.

LU=Specifies the LU name of the partner in an LU 6.2 conversation. The LU namecan contain up to eight alphanumeric or national characters, but the firstcharacter must be a letter or a national character. If both LU and SIDE optionsare specified, LU overrides the LU name contained in the side informationentry but does not change that LU name.

If the LU name is a network-qualified name, it can be up to 17 characters longand consist of the network ID of the originating system, followed by a '.', andthe LU name (for example, netwrkid.luname). The LU name and the networkID can be up to eight characters long.

MODE=Specifies the MODE name of the partner in an LU 6.2 conversation. The MODEname can contain up to eight alphanumeric or national characters, but the firstcharacter must be a letter or a national character. If both MODE and SIDEoption keywords are specified, MODE overrides the MODE name contained inthe side information entry but does not change that MODE name.

TPN=Specifies the transaction program (TP) name of the partner in an LU 6.2conversation. The TP name can contain up to 64 characters from the 00640character set. Because the character set allows commas, at least one blank mustfollow the TP name. If both TPN and SIDE option keywords are specified, TPNoverrides the TP name contained in the side information entry but does notchange that name.

Related Reading: The CPI Communications Reference describes the 00640character set, which contains all alphanumeric and national characters and 20special characters.

SIDE=Specifies the name of the side information entry for the partner in an LU 6.2conversation. The side information entry name can contain up to eightcharacters from the 01134 character set. If the SIDE option keyword isspecified, it can be overridden with LU, MODE, and TPN option keywords.

Related Reading: The CPI Communications Reference describes the 01134character set, which contains the uppercase alphabet and the digits, 0-9.

SYNC=N|CSpecifies the synchronization level of the LU 6.2 conversation. N selects noneas the synchronization level, and C selects confirm as the synchronization level.

TYPE=B|MSpecifies the conversation type for the LU 6.2 conversation. B selects a basicconversation type, and M selects a mapped conversation type.

Processing conversations with APPCAPPC/IMS supports three different types of application programs:v Standard: No explicit use of CPI Communications facilities.

246 Application Programming Guide

Page 271: IMS Application Programming.pdf

v Modified: Uses the I/O PCB to communicate with the original input terminal.Uses CPI Communications calls to allocate new conversations and to send andreceive data.

v CPI Communications driven: Uses CPI Communications calls to receive theincoming message and to send a reply on the same conversation. Uses the DL/IAPSB call to allocate a PSB to access IMS databases and alternate PCBs.

In the modified or CPI Communications driven application programs, if an APPCconversation is allocated with SYNCLVL=SYNCPT, z/OS manages the sync-pointprocess for the APPC conversation participants: the application program and IMS.Transaction rollback and rescheduling is possible, because IMS issues the SRRCMITor SRRBACK calls on behalf of the modified IMS APPC application program. If theCPI-C driven program is linked with the IMS stub code (DFSCPIR0) as required inprevious releases, IMS also issues the SRRCMIT or SRRBACK calls. If the programis not linked with the stub code, then IMS is driven by the z/OS sync pointmanager when the application issues these calls. With z/OS as the sync pointmanager, failures can also be backed out.

You can schedule your standard and modified application programs locally andremotely using MSC or APPC/MVS. The logic flow for local scheduling differsfrom the logic flow for remote scheduling.

Scheduling programs remotely through MSC is not supported if an APPC/MVSconversation with SYNCLVL=SYNCPT is specified.

Ending the APPC conversationThe two ways to end a conversation using LU 6.2 devices are to:v Issue the CPI-C verb, DEALLOCATEv Insert a blank transaction code into the SPA for IMS conversational transactions

Restriction: You cannot use the /EXIT command for LU 6.2 conversations.

Several error conditions can exist at the end of an LU 6.2 conversation:v If your application program sends data to the LU 6.2 device just before

deallocating conversation, IMS TM issues a SENDERROR and SENDDATA ofthe DFS1966 error message. This indicates that the transaction ended, but thatthe last message could not be delivered. For SENDERROR to be activated,specify a synchronization level of CONFIRM.

v If IMS TM encounters an error sending output from an IMS TM conversationaltransaction to the LU 6.2 device, the output is discarded, and the conversation isterminated for both IMS TM and LU 6.2.

v If an IMS TM conversational application program abends during an LU 6.2conversation, a DFS555 error message is sent to the originating LU 6.2 device,and the conversation is terminated for both IMS TM and LU 6.2.

Coding a conversational programBefore coding a conversational program, obtain this information:v The transaction code to use for a program to which you pass controlv The data that you should save in the SPAv The maximum length of that data

A SPA contains four fields:

Chapter 13. Message processing 247

Page 272: IMS Application Programming.pdf

v The 2-byte length field.v The 4-byte field that is reserved for IMS TM.v The 8-byte transaction code.v The work area where you store the conversation data. The length of this field is

defined at system definition.

Standard IMS application programsStandard IMS application programs use the existing IMS call interface. Applicationprograms that use the IMS standard API can take advantage of the LU 6.2protocols. Standard IMS application programs use a DL/I GU call to get theincoming transaction. These standard IMS application programs also use DL/IISRT calls to generate output messages to the same or different terminals,regardless of whether LU 6.2 is used.2 The identical program can work correctly forboth LU 6.2 and non-LU 6.2 terminal types. IMS generates the appropriate calls toAPPC/MVS services.

When an advanced program-to-program communication (APPC) applicationprogram enters an IMS transaction that executes on a remote IMS, an LU 6.2conversation is established between the APPC application program and the localIMS system. The local IMS is considered the partner LU of the LU 6.2conversation. The transaction is then queued on the remote transaction queue ofthe local IMS system. From this point on, the transaction goes through normalMSC processing. After the remote IMS system executes the transaction, the outputis returned to the local IMS system and is then delivered to the originating LU 6.2application program.

Modified IMS application programsModified IMS application programs use a DL/I GU call to get the incomingtransaction. These modified IMS application programs also use DL/I ISRT calls togenerate output messages to the same or different terminals, regardless of whetherLU 6.2 is used.3 Unlike standard IMS application programs, modified IMSapplication programs use CPI Communications calls to allocate new conversations,and to send and receive data. IMS has no direct control of these CPICommunications conversations.

Modified IMS transactions are indistinguishable from standard IMS transactionsuntil program execution. In fact, the same application program can be a standardIMS application on one execution, and a modified IMS application on a differentexecution. The distinction is simply whether the application program uses CPICommunications resources.

Modified IMS programs are scheduled by IMS TM, and the DL/I calls areprocessed by the DL/I language interface. The conversation, however, ismaintained by APPC/MVS, and any failures that involve APPC/MVS are notbacked out by IMS TM. The general format of a modified IMS application programis shown in Figure 54 on page 249.

Related Reading: For more information on failure recovery and modified DL/Iapplication program design, see IMS Version 10: Application Programming PlanningGuide.

2. A non-message-driven BMP is considered a standard IMS application program when it does not use the explicit API.

3. A non-message-driven BMP is considered a modified standard IMS application program when it uses the explicit API.

248 Application Programming Guide

Page 273: IMS Application Programming.pdf

Restriction: The APPC conversation cannot span sync points. If the conversation isnot deallocated before a sync point is reached, IMS causes the conversation to beterminated by issuing a clean TP call (ATBCMTP). A new APPC conversation canbe allocated after each sync point.

When an APPC program enters an IMS transaction that executes on a remote IMSsystem, an LU 6.2 conversation is established between the APPC program and thelocal IMS system. The local IMS system is considered the partner LU of the LU 6.2conversation. The transaction is then queued on the local IMS system's remotetransaction queue. From this point on, the transaction goes through normal MSCprocessing. After the remote IMS system executes the transaction, the output isreturned to the local IMS and is then delivered to the originating LU 6.2 program.

CPI-C driven application programsCPI Communications driven application programs are defined only in theAPPC/MVS TP_Profile data set; they are not defined to IMS. Their definition isdynamically built by IMS when a transaction is presented for scheduling byAPPC/MVS, based on the APPC/MVS TP_Profile definition after IMS restart. Thedefinition is keyed by TP name. APPC/MVS manages the TP_Profile information.

When a CPI Communications driven transaction program requests a PSB, the PSBmust already be defined to IMS through the APPLCTN macro for system definitionand through PSBGEN or ACBGEN when APPLCTN PSB= is specified. WhenAPPLCTN GPSB= is specified, a PSBGEN or ACBGEN is not required.

CPI-C driven application programs must begin with the CPI-C verbs, ACCEPT andRECEIVE, to initiate the LU 6.2 conversation. You can then issue the APSB call toallocate a PSB for use by the application program. After the APSB call is issued, youcan issue additional DL/I calls using the PCBs that were allocated. You then issuethe SRRCMIT verb to commit changes or the SRRBACK verb to back out changes.To use SRRCMIT and SRRBACK, your application program must be linked withDFSCPIR0.

Restriction: The I/O PCB cannot be used for message processing calls by CPI-Cdriven application programs. See the description of each call for specific CPIrestrictions.

To deallocate the PSB in use, issue the DPSB call. You can then issue another APSBcall, or use the CPI-C verb, DEALLOCATE, to end the conversation.

CPI-C driven application programs are considered discardable (unless they areallocated with a SYNCLVL=SYNCPT) by IMS TM and are therefore not recoveredautomatically at system failure. If they are allocated with a SYNCLVL=SYNCPT, atwo-phase commit process is used to recover from any failures. The general formatof a CPI-C driven application program is shown in Figure 55 on page 250.

GU IOPCBALLOCATESENDRECEIVEDEALLOCATE

ISRT IOPCB

Figure 54. General format of a modified DL/I application program

Chapter 13. Message processing 249

Page 274: IMS Application Programming.pdf

Related Reading: For more information on recovery procedures and CPI-C drivenapplication program design, see IMS Version 10: Communications and ConnectionsGuide.

Restriction: The APPC conversation cannot span sync points. If the conversation isnot deallocated before a sync point is reached, IMS causes the conversation to beterminated by issuing a clean TP call (ATBCMTP). A new APPC conversation canbe allocated after each sync point.

Processing conversations with OTMAYou can run IMS conversational transactions through OTMA. Refer to IMS Version10: Communications and Connections Guide.

Backing out to a prior commit point: ROLL, ROLB, and ROLS callsWhen a program determines that some of its processing is invalid, you can usethese calls to remove the effects of its incorrect processing: Roll Back calls ROLL,ROLS using a database PCB, ROLS with no I/O area or token, and ROLB. When youissue one of these calls, IMS does the following:v Backs out the database updates that the program has made since the program’s

most recent commit point.v Cancels the non-express output messages that the program has created since the

program’s most recent commit point.

The main difference among these calls is that ROLB returns control to theapplication program after backing out updates and canceling output messages,ROLS does not return control to the application program, and ROLL terminates theprogram with a user abend code of 0778. ROLB can return to the program the firstmessage segment since the most recent commit point, but ROLL and ROLS cannot.

The ROLL and ROLB calls, and the ROLS call without a token specified, are validwhen the PSB contains PCBs for Generalized Sequential Access Method (GSAM)data sets. However, segments inserted in the GSAM data sets since the last commitpoint are not backed out by these calls. An extended checkpoint-restart can be usedto reposition the GSAM data sets when restarting.

You can use a ROLS call either to back out to the prior commit point or to back outto an intermediate backout point established by a prior SETS call. This sectionrefers only to the form of ROLS that backs out to the prior commit point. Forinformation about the other form of ROLS, see “Backing out to an intermediatebackout point: SETS/SETU and ROLS” on page 254.

Table 53 on page 251 summarizes the similarities and differences among the ROLL,ROLS and ROLB calls when specific actions are taken.

ACCEPTRECEIVE

APSBGU DBPCBREPL DBPCBSRRCMIT

DPSBDEALLOCATE

Figure 55. General format of a CPI-C driven application program

250 Application Programming Guide

Page 275: IMS Application Programming.pdf

The following topics provide additional information:v “Comparison of ROLB, ROLL, and ROLS”v “ROLL”v “ROLB” on page 252v “ROLS” on page 253

Comparison of ROLB, ROLL, and ROLSTable 53. Comparison of ROLB, ROLL, and ROLS

Actions Taken ROLB ROLL ROLS

Back out database updates since the last commit point. X X X

Cancel output messages created since the last commitpoint.

X1 X1 X1

Delete the message in process from the queue.Previous messages (if any) processed since the lastcommit point are returned to the queue to bereprocessed.

X

Return the first segment of the first input messagesince the most recent commit point.

X2

3303 abnormal termination and returns the processedinput messages to the message queue.

X3

778 abnormal termination, no dump. X

No abend; program continues processing. X

Notes:

1. ROLB, ROLL, or ROLS cancel output messages sent with an express PCB unless theprogram issued a PURG.

Example: If the program issues the call sequence below, MSG1 would be sent to itsdestination because the PURG tells IMS that MSG1 is complete and the I/O area nowcontains the first segment of the next message (which in this example is MSG2). MSG2,however, would be canceled:

ISRT EXPRESS PCB, MSG1PURG EXPRESS PCB, MSG2ROLB I/O PCB

Because IMS has the complete message (MSG1) and because an express PCB is beingused, the message can be sent before a commit point.

2. Returned only if you supply the address of an I/O area as one of the call parameters.

3. The transaction is suspended and requeued for subsequent processing.

ROLLA ROLL call backs out the database updates and cancels any non-express outputmessages the program has created since the last commit point. It also deletes thecurrent input message. Any other input messages processed since the last commitpoint are returned to the queue to be reprocessed. IMS then terminates theprogram with a user abend code 0778. This type of abnormal terminationterminates the program without a storage dump.

When you issue a ROLL call, the only parameter you supply is the call function,ROLL.

You can use the ROLL call in a batch program. If your system log is on direct accessstorage, and if dynamic backout has been specified through the use of the BKO

Chapter 13. Message processing 251

Page 276: IMS Application Programming.pdf

execution parameter, database changes since the last commit point will be backedout. Otherwise they will not be backed out. One reason for issuing ROLL in a batchprogram is for compatibility.

After backout is complete, the original transaction is discarded if it is discardable,and it is not re-executed. IMS issues the APPC/MVS verb ATBCMTPTYPE(ABEND) specifying the TPI to notify remote transaction programs. Issuingthe APPC/MVS verb causes all active conversations (including any spawned bythe application program) to be DEALLOCATED TYP(ABEND_SVC).

ROLBThe advantage of using ROLB is that IMS returns control to the program afterexecuting ROLB, so the program can continue processing. The parameters for ROLare:v The call function ROLB

v The name of the I/O PCB or AIB

The total effect of the ROLB call depends on the type of IMS application that issuedit.v For current IMS application programs:

After IMS backout is complete, the original transaction is represented to the IMSapplication program. Any resources that cannot be rolled back by IMS areignored. For example, output sent to an express alternate PCB and a PURG call isissued before the ROLB.

v For modified IMS application programs:The same consideration for the current IMS application programs applies. It isthe responsibility of the application program to notify any spawnedconversations that a ROLB was issued.

v For CPI-C driven IMS application programs:Only IMS resources are affected. All database changes are backed out. Anymessages inserted to nonexpress alternate PCBs are discarded. Also, anymessages inserted to express PCBs that have not had a PURGE call are discarded.It is the responsibility of the application program to notify the originatingremote program and any spawned conversations that a ROLB call was issued.

In MPPs and transaction-oriented BMPsIf the program supplies the address of an I/O area as one of the ROLB parameters,the ROLB call acts as a message retrieval call and returns the first segment of thefirst input message since the most recent commit point. This is true only if theprogram has issued a GU call to the message queue since the last commit point; it ifhas not, it was not processing a message when it issued the ROLB call.

If the program issues a GN to the message queue after issuing the ROLB, IMS returnsthe next segment of the message that was being processed when ROLB was issued.If there are no more segments for that message, IMS returns a QD status code.

If the program issues a GU to the message queue after the ROLB call, IMS returns thefirst segment of the next message to the application program. If there are no moremessages on the message queue for the program to process, IMS returns a QCstatus code to the program.

If you include the I/O area parameter, but you have not issued a successful GU callto the message queue since the last commit point, IMS returns a QE status code toyour program.

252 Application Programming Guide

Page 277: IMS Application Programming.pdf

If you do not include the address of an I/O area in the ROLB call, IMS does thesame things for you. If the program has issued a successful GU in the committravel, and then issues a GN, IMS returns a QD status code. If the program issues aGU after the ROLB, IMS returns the first segment of the next message, or a QC statuscode if there are no more messages for the program.

If you have not issued a successful GU since the last commit point, and you do notinclude an I/O area parameter on the ROLB call, IMS backs out the databaseupdates and cancels the output messages created since the last commit point.

In batch programsIf your system log is on direct access storage, and if dynamic backout has beenspecified through the use of the BKO execution parameter, you can use the ROLBcall in a batch program. The ROLB call does not process messages as it does formessage processing programs (MPPs); it backs out the database updates since thelast commit point and returns control to your program. You cannot specify theaddress of an I/O area as one of the parameters on the call; if you do, an ADstatus code is returned to your program. You must, however, have an I/O PCB foryour program. Specify CMPAT=YES on the CMPAT keyword in the PSBGENstatement for your program’s PSB.

Related Reading: For more information on using the CMPAT keyword, see IMSVersion 10: System Utilities Reference. For information on coding the ROLB call, seethe topic "ROLB Call" in IMS Version 10: Application Programming API Reference.

ROLSThe two ways that you can use the ROLS call to back out to the prior commit pointand return the processed input messages to IMS for later reprocessing are:v Have your program issue the ROLS call using the I/O PCB but without an I/O

area or token in the call. The parameters for this form of the ROLS call are:– The call function ROLS

– The name of the I/O PCB or AIBv Have your program issue the ROLS call using a database PCB that has received

one of the data-unavailable status codes. This has the same result as ifunavailable data were encountered, and the INIT call was not issued. ROLS mustbe the next call for that PCB. Intervening calls using other PCBs are permitted.

On a ROLS with a token, message queue repositioning can occur for all non-expressmessages including all messages processed by IMS. This processing usingAPPC/MVS calls and includes the initial message segments. The original inputtransaction can be represented to the IMS application program. Input and outputpositioning is determined by the SETS call. This positioning applies to current andmodified IMS application programs but does not apply to CPI-C driven IMSprograms. The IMS application program must notify all remote transactionprograms of the ROLS.

On a ROLS without a token, IMS issues the APPC/MVS verb, ATBCMTPTYPE(ABEND), specifying the TPI. Issuing this verb causes all conversationsassociated with the application program to be DEALLOCATEDTYPE(ABEND_SVC). If the original transaction was entered from an LU 6.2 deviceand IMS received the message from APPC/MVS, a discardable transaction isdiscarded rather than being placed on the suspend queue like a non-discardabletransaction.

Chapter 13. Message processing 253

Page 278: IMS Application Programming.pdf

Related Reading: For more information on LU 6.2, see IMS Version 10:Communications and Connections Guide.

The parameters for this form of the ROLS call are:v The call function, ROLSv The name of the DB PCB that received the BA or BB status code

In both of the ways to use ROLS calls, the ROLS call causes a 3303 abnormaltermination and does not return control to the application program. IMS keeps theinput message for future processing.

Backing out to an intermediate backout point: SETS/SETU and ROLSYou can use a ROLS call either to back out to an intermediate backout pointestablished by a prior SETS or SETU call or to back out to the prior commit point.This section refers only to the form of ROLS that backs out to the intermediatebackout point. For information about the other form of ROLS, see “Backing out to aprior commit point: ROLL, ROLB, and ROLS calls” on page 250.

The ROLS call that backs out to an intermediate point backs out only DL/I changes.This version of the ROLS call does not affect CICS changes using CICS file controlor CICS transient data.

The SETS and ROLS calls set intermediate backout points within the call processingof the application program and then backout database changes to any of thesepoints. Up to nine intermediate backout points can be set. The SETS call specifies atoken for each point. IMS then associates this token with the current processingpoint. A subsequent ROLS call, using the same token, backs out all database changesand discards all non-express messages that were performed following the SETS callwith the same token. Figure 56 on page 255 shows how the SETS and ROLS callswork together.

In addition, to assist the application program in reestablishing other variablesfollowing a ROLS call, user data can be included in the I/O area of the SETS call.This data is then returned when the ROLS call with the same token is issued.

254 Application Programming Guide

Page 279: IMS Application Programming.pdf

SETS/SETUThe SETS call sets up to nine intermediate backout points or cancels all existingbackout points. By using the SETS call, you can back out pieces of work. If thenecessary data to complete one piece of work is unavailable, you can complete adifferent piece of work and then return to the former piece.

To set an intermediate backout point, issue the call using the I/O PCB and includean I/O area and a token. The I/O area has the format LLZZ user-data, where LL isthe length of the data in the I/O area including the length of the LLZZ portion.The ZZ field must contain binary zeros. The data in the I/O area is returned to theapplication program on the related ROLS call. If you do not want to save some datato be returned on the ROLS call, you must set the LL that defines the length of theI/O area to 4.

For PLITDLI, you must define the LL field as a fullword rather than a halfword asit is for the other languages. The content of the LL field for PLITDLI is consistentwith the I/O area for other calls using the LLZZ format; that is, the content is thetotal length of the area including the length of the 4-byte LL field minus 2.

A 4-byte token associated with the current processing point is also required. Thistoken can be a new token for this program execution or match a token issued by a

Backs outprogram toSETS Token=B

Program starts

SETS Token=n

GHUREPL

ISTR MSG1-Segment 1 to I/O PCB

GHUDLET

ISTR MSG1-Segment 2 to I/O PCB

SETS Token=B

ROLS Token=B

Figure 56. SETS and ROLS calls working together

Chapter 13. Message processing 255

Page 280: IMS Application Programming.pdf

preceding SETS call. If the token is new, no preceding SETS calls are canceled. If thetoken matches the token of a preceding SETS call, the current SETS call assumesthat position. In this case, all SETS calls that were issued subsequent to the SETScall with the matching token are canceled.

The parameters for this form of the SETS call are:v The call function SETSv The name of the I/O PCB or AIBv The name of the I/O area containing the user datav The name of an area containing the token

For the SETS call format, see the topic "SETS/SETU Call" in IMS Version 10:Application Programming API Reference.

To cancel all previous backout points, the call is issued using the I/O PCB butdoes not include an I/O area or a token. When no I/O area is included in the call,all intermediate backout points set by prior SETS calls are canceled.

The parameters for this form of the SETS call are:v The call function SETSv The name of the I/O PCB or AIB

Because it is not possible to back out committed data, commit point processingcauses all outstanding SETS to be canceled.

If PCBs for DEDB, MSDB, and GSAM organizations are in the PSB, or if theprogram accesses an attached subsystem, a partial backout is not possible. In thatcase, the SETS call is rejected with an SC status code. If the SETU call is usedinstead, it is not rejected because of unsupported PCBs, but returns an SC statuscode as a warning that the PSB contains unsupported PCBs and the function is notapplicable to these unsupported PCBs.

Related Reading: For the status codes that are returned after the SETS call and theexplanation of those status codes and the response required, see IMS Version 10:Application Programming API Reference.

ROLSThe ROLS call backs out database changes to a processing point set by a previousSETS or SETU call, or to the prior commit point and returns the processed inputmessages to the message queue.

To back out database changes and message activity that have occurred since aprior SETS call, you issue the ROLS call using the I/O PCB and specifying an I/Oarea and token in the call. If the token does not match a token set by a precedingSETS call, an error status is returned. If the token does match the token of apreceding SETS call, the database updates made since this corresponding SETS callare backed out, and all non-express messages inserted since the corresponding SETSare discarded. The ROLS call returns blanks if the call is processed, and returns astatus code if an error or warning occurs. If you are using SETU with ROLS and havean external subsystem, the ROLS call will not be rejected, but an RC status code willbe returned as a warning. All SETS points that were issued as part of theprocessing that was backed out are then canceled, and the existing databaseposition for all supported PCBs is reset. For the ROLS call format, see the topic"ROLB Call" in IMS Version 10: Application Programming API Reference.

256 Application Programming Guide

Page 281: IMS Application Programming.pdf

The parameters for this form of the ROLS call are:v The call function ROLSv The name of the I/O PCB or AIBv The name of the I/O area to receive the user datav The name of an area containing the 4-byte token

Related reading: For the status codes that are returned after the ROLS call and theexplanations of those status codes and the response required, see IMS: Messages andCodes Reference, Volume 4: IMS Component Codes.

Writing message-driven programsA message-driven program is similar to an MPP: it retrieves messages andprocesses them, and it can read and update MSDBs, DEDBs, and full-functiondatabases.

Message-driven programs can send messages to these destinations:v The logical terminal that sent the input message, by issuing an ISRT call

referencing the I/O PCBv A different component of the physical terminal that sent the input message, by

issuing an ISRT call referencing an alternate response PCBv A different physical terminal from the one that sent the input message, by

issuing an ISRT call referencing an alternate PCB

The message processing functions available to a message-driven program havesome restrictions. These restrictions apply only to messages received or sent by theI/O PCB. The input message for a message-driven program must be a singlesegment message. Therefore, GU is the only call you can use to obtain the inputmessage. The response message sent by the I/O PCB also must be a singlesegment message.

The transactions are in the response mode. This means that you must respondbefore the next message can be sent. You cannot use SPAs because amessage-driven program cannot be a conversational program.

Not all of the system service calls are available. These system service calls are validin a message-driven region:

CHKP (basic)DEQ

INIT

LOG

SETS

ROLB

ROLS

However, other conditions might restrict their function in this environment. Theoptions or calls issued using alternate terminal PCBs have no constraints.

Coding DC calls and data areasThe way you code DC calls and data areas depends on the applicationprogramming language you use.

Chapter 13. Message processing 257

Page 282: IMS Application Programming.pdf

Before coding your programIn addition to the information you need about the database processing that yourprogram does, you need to know about message processing. Before you start tocode, be sure you are not missing any of this information. Also, be aware of thestandards at your installation that affect your program.

Information you need about your program's design:v The names of the logical terminals that your program will communicate withv The transaction codes, if any, for the application program's MPP skeleton to

which your program will send messagesv The DC call structure for your programv The destination for each output message that you sendv The names of any alternate destinations to which your program sends messages

Information you need about input messages:v The size and layout of the input messages your program will receive (if

possible)v The format in which your program will receive the input messagesv The editing routine your program usesv The range of valid data in input messagesv The type of data that input messages will containv The maximum and minimum length of input message segmentsv The number of segments in a message

Information you need about output messages:v The format in which IMS expects to receive output from your application

program MPP skeletonv The destination for the output messagesv The maximum and minimum length of output message segments

Skeleton MPPFor examples of skeleton MPPs, refer to:

Language See

C Figure 57 on page 260

COBOL Figure 58 on page 262

Pascal Figure 59 on page 264

PL/I Figure 60 on page 266

These programs do not have all the processing logic that a typical MPP has. Thepurpose of providing these programs is to show you the basic MPP structure inCOBOL, C language, Pascal, and PL/I. All the programs follow these steps:1. The program retrieves an input message segment from a terminal by issuing a

GU call to the I/O PCB. This retrieves the first segment of the message. Unlessthis message contains only one segment, your program issues GN calls to theI/O PCB to retrieve the remaining segments of the message. IMS places theinput message segment in the I/O area that you specify in the call. In each ofskeleton MPP examples, this is the MSG-SEG-IO-AREA.

258 Application Programming Guide

Page 283: IMS Application Programming.pdf

2. The program retrieves a segment from the database by issuing a GU call to theDB PCB. This call specifies an SSA, SSA-NAME, to qualify the request. IMSplaces the database segment in the I/O area specified in the call. In this case,the I/O area is called DB-SEG-IO-AREA.

3. The program sends an output message to an alternate destination by issuing anISRT call to the alternate PCB. Before issuing the ISRT call, the program mustbuild the output message segment in an I/O area, and then the programspecifies the I/O area in the ISRT call. The I/O area for this call isALT-MSG-SEG-OUT.

The sample program is simplified for demonstration purposes; for example, thecall to initiate sync point is not shown in the sample program. Include other IMScalls in a complete application program.

Coding your program in assembler languageThe coding conventions of an assembler language MPP are the same as those for aDL/I assembler program. An assembler language MPP receives a PCB parameterlist address in register 1 when it executes its entry statement. The first address inthis list is a pointer to the TP PCB; the addresses of any alternate PCBs that theprogram uses come after the I/O PCB address, and the addresses of the databasePCBs that the program uses follow. Bit 0 of the last address parameter is set to 1.

Coding your program in C languageThe program shown in Figure 57 on page 260 is a skeleton MPP written in Clanguage. The numbers to the right of the program refer to the notes that followthe program.

All storage areas that are referenced in the parameter list of your C languageapplication program call to IMS can reside in the extended virtual storage area.

Chapter 13. Message processing 259

Page 284: IMS Application Programming.pdf

Notes for C Language Program:

1. The env(IMS) establishes the correct operating environment and the plist(IMS)establishes the correct parameter list, when invoked under IMS. The ims.hheader file contains declarations for PCB layouts, __pcblist, and the ctdliroutine. The PCB layouts define masks for the DB PCBs that the program usesas structures. These definitions make it possible for the program to checkfields in the DB PCBs.The stdio.h header file contains declarations for sprintf, which is useful forbuilding SSAs.

2. After IMS has loaded the application program's PSB, IMS passes control to theapplication program through this entry point.

3. These are convenient definitions for the function codes and could be in one ofyour include files.

4. These could be structures, with no loss of efficiency.5. The return code (status value) from DL/I calls can be returned and used

separately.6. The C language run-time sets up the __pcblist values. The order in which you

refer to the PCBs must be the same order in which they have been defined inthe PSB: first the TP PCB, then any alternate PCBs that your program uses,and finally the database PCBs that your program uses.

NOTES#pragma runopts(env(IMS),plist(IMS)) 1

#include <ims.h>#include <stdio.h>/* *//* ENTRY POINT *//* */main() { 2

static const char func_GU[4] = "GU "; 3static const char func_ISRT[4] = "ISRT";.#define io_pcb ((IO_PCB_TYPE *)(_pcblist[0])

4#define alt_pcb (_pcblist[1])#define db_pcb (_pcblist[2]).int rc;

5.#define io_pcb ((IO_PCB_TYPE *)(_pcblist[0])

6#define alt_pcb (_pcblist[1])#define db_pcb (_pcblist[2]).rc = ctdli(func_GU, io_pcb, msg_seg_io_area);

7.

rc = ctdli(func_GU, db_pcb, db_seg_io_area, ssa_name);8

.rc = ctdli(func_ISRT, alt_pcb, alt_msg_seg_out);

9.}10C language interface11

Figure 57. Skeleton MPP written in C

260 Application Programming Guide

Page 285: IMS Application Programming.pdf

7. The program issues a GU call to the I/O PCB to retrieve the first messagesegment. You can leave out the rc =, and check the status in some other way.

8. The program issues a GU call to the DB PCB to retrieve a database segment.The function codes for these two calls are identical; the way that IMSidentifies them is by the PCB to which each call refers.

9. The program then sends an output message to an alternate destination byissuing an ISRT call to an alternate PCB.

10. When there are no more messages for the program to process, the programreturns control to IMS by returning from main or by calling exit().

11. IMS provides a language interface module (DFSLI000) that gives a commoninterface to IMS. This module must be made available to the applicationprogram at bind time.

Coding your program in COBOLThe program shown in Figure 58 on page 262is a skeleton MPP in COBOL thatshows the main elements of an MPP. The numbers to the right of each part of theprogram refer to the notes that follow the program.

If you plan to preload your IBM COBOL for z/OS & VM program, you must usethe compiler option RENT. Alternatively, if you plan to preload your VS COBOL IIprogram, you must use the compiler options RES and RENT.

If you want to use the IBM COBOL for z/OS & VM compiler to compile aprogram that is to execute in AMODE(31) on z/OS, you must use the compileroption RENT. Alternatively, if you want to use the VS COBOL II compiler tocompile a program that is to execute in AMODE(31) on z/OS, you must use thecompiler options RES and RENT. All storage areas that are referenced in theparameter lists of your calls to IMS can optionally reside in the extended virtualstorage area.

IBM COBOL for z/OS & VM and VS COBOL II programs can coexist in the sameapplication.

Chapter 13. Message processing 261

Page 286: IMS Application Programming.pdf

Notes to COBOL Program:

1. To define each of the call functions that your program uses, use a 77 or 01 levelworking-storage statement. Assign the value to the call function in a pictureclause defined as four alphanumeric characters.

2. Use a 01 level working-storage statement for each I/O area that you will usefor message segments.

3. In the linkage section of the program, use a 01 level entry for each PCB thatyour program uses. You can list the PCBs in the order that you list them in theentry statement, but this is not a requirement.

4. On the procedure statement, list the PCBs that your program uses in the orderthey are defined in the program's PSB: first the TP PCB, then any alternatePCBs, and finally the database PCBs that your program uses.

5. The program issues a GU call to the I/O PCB to retrieve the first segment of aninput message.

6. The program issues a GU call to the DB PCB to retrieve the segment that wouldbe described in the SSA-NAME area.

7. The program sends an output message segment to an alternate destination byusing an alternate PCB.

NOTES:ENVIRONMENT DIVISION.

.

.

.DATA DIVISION.WORKING-STORAGE SECTION. 1

77 GU-CALL PICTURE XXXX VALUE ’GU ’.77 ISRT-CALL PICTURE XXXX VALUE ’ISRT’.77 CT PICTURE S9(5) COMPUTATIONAL VALUE +4.01 SSA-NAME..01 MSG-SEG-IO-AREA. 2.01 DB-SEG-IO-AREA..01 ALT-MSG-SEG-OUT..

LINKAGE SECTION.01 IO-PCB. 3.01 ALT-PCB..01 DB-PCB..

PROCEDURE DIVISION USING IO-PCB, ALT-PCB, DB-PCB 4.CALL ’CBLTDLI’ USING GU-CALL, IO-PCB, 5

MSG-SEG-IO-AREA..CALL ’CBLTDLI’ USING GU-CALL, DB-PCB, 6

DB-SEG-IO-AREA, SSA-NAME..CALL ’CBLTDLI’ USING ISRT-CALL, ALT-PCB, 7

ALT-MSG-SEG-OUT..GOBACK. 8

COBOL LANGUAGE INTERFACE 9

Figure 58. Skeleton MPP written in COBOL

262 Application Programming Guide

|

|

Page 287: IMS Application Programming.pdf

8. When no more messages are available for your MPP to process, you returncontrol to IMS by issuing the GOBACK statement.If you compile all of your COBOL programs in the task with VS COBOL II, youcan use the GOBACK statement with its normal COBOL-defined semantics.

Note: The STOP RUN and EXIT PROGRAM statements are not supported. Usingthese statements might cause unpredictable results or abends.

9. If the COBOL compiler option NODYNAM is specified, you must link edit thelanguage interface module, DFSLI000, with your compiled COBOL applicationprogram. If the COBOL compiler option DYNAM is specified, do not link editDFSLI000 with your compiled COBOL program.

Coding your program in PascalThe program shown in Figure 59 on page 264 is a skeleton MPP written in Pascal.The numbers to the right of the program refer to the notes that follow theprogram.

All storage areas that are referenced in the parameter list of your Pascal applicationprogram's call to IMS can reside in the extended virtual storage area.

Chapter 13. Message processing 263

||

||

||

Page 288: IMS Application Programming.pdf

Notes to Pascal Program:

1. Define the name of the Pascal compile unit.2. Define the data types needed for the PCBs used in your program.3. Define the PCB data types used in your program.

NOTES:segment PASCIMS; 1type

CHAR4 = packed array [1..4] of CHAR;2CHARn = packed array [1..n] of CHAR;IOPCBTYPE = record 3

(* Field declarations *)end;

ALTPCBTYPE = record(* Field declarations *)

end;DBPCBTYPE = record

(* Field declarations *)end;

procedure PASCIMS (var SAVE: INTEGER; 4var IOPCB: IOPCBTYPE;var ALTPCB: ALTPCBTYPE;var DBPCB: DBPCBTYPE); REENTRANT;

procedure PASCIMS;type 5

SSATYPE = record(* Field declarations *)

end;

MSG_SEG_IO_AREA_TYPE = record(* Field declarations *)

end;

DB_SEG_IO_AREA_TYPE = record(* Field declarations *)

end;

ALT_MSG_SEG_OUT_TYPE = record(* Field declarations *)

end;var 6

MSG_SEG_IO_AREA : MSG_SEG_IO_AREA_TYPE;DB_SEG_IO_AREA : DB_SEG_IO_AREA_TYPE;ALT_MSG_SEG_OUT : ALT_MSG_SEG_OUT_TYPE;

const 7GU = ’GU ’;ISRT = ’ISRT’;SSANAME = SSATYPE(...);

procedure PASTDLI; GENERIC; 8begin

PASTDLI(const GU, 9var IOPCB,var MSG_SEG_IO_AREA);

PASTDLI(const GU, 10var DBPCB,var DB_SEG_IO_AREA,const SSANAME);

PASTDLI(const ISRT, 11var ALTPCB,var ALT_MSG_SEG_OUT);

end; 12Pascal language interface 13

Figure 59. Skeleton MPP written in Pascal

264 Application Programming Guide

Page 289: IMS Application Programming.pdf

4. Declare the procedure heading for the REENTRANT procedure called by IMS.The first word in the parameter list should be an INTEGER, which is reservedfor VS Pascal's use, and the rest of the parameters will be the addresses of thePCBs received from IMS.

5. Define the data types needed for the SSAs and I/O areas.6. Declare the variables used for the SSAs and I/O areas.7. Define the constants (function codes, SSAs, and so forth) used in the PASTDLI

DL/I calls.8. Declare the IMS interface routine with the GENERIC Directive. GENERIC

identifies external routines that allow multiple parameter list formats. AGENERIC routine's parameters are “declared” only when the routine is called.

9. The program issues a GU call to the I/O PCB to retrieve the first segment of aninput message. The declaration of the parameters in your program mightdiffer from this example.

10. The program can issue a GU call to a DB PCB to retrieve a database segment.The function codes for these two calls are identical; the way that IMSdistinguishes between them is by the PCB to which each call refers. Thedeclaration of the parameters in your program might differ from this example.

11. The program sends an output message segment to an alternate destination byissuing an ISRT call to an alternate PCB. The declaration of the parameters inyour program might differ from this example.

12. When there are no more messages for your MPP to process, you return controlto IMS by exiting the PASCIMS procedure. You can also code a RETURNstatement to leave at another point.

13. You must bind your program to the IMS language interface module,DFSLI000, after you have compiled your program.

Coding your program in PL/IThe program shown in Figure 60 on page 266 is a skeleton MPP written in PL/I.The numbers to the right of the program refer to the notes for the program.

All storage areas that are referenced in the parameter list of your PL/I applicationprogram call to IMS can optionally reside in the extended virtual storage area.

If you plan to execute PL/I programs in 31-bit addressing mode, see OS PL/IVersion 2 Programming Guide.

Chapter 13. Message processing 265

Page 290: IMS Application Programming.pdf

Notes to PL/I Program:

1. This is the standard entry point to a PL/I Optimizing Compiler MPP. Thisstatement includes a pointer for each PCB that the MPP uses. You must referto the PCBs in the same order as they are listed in the PSB: first the TP PCB,then any alternate PCBs that your program uses, and finally the databasePCBs that your program uses.

2. The program defines each call function that it uses in its data area. In PL/I,you define the function codes as character strings and assign the appropriatevalues to them.

3. Define PCB Masks as major structures based on the addresses passed in thePROCEDURE statement. Although not shown in the example, you will codethe appropriate additional fields in the structure, depending on the type ofPCB to which the mask is associated.

4. To define your PCBs, use major structure declarations.5. PL/I calls have a parameter that is not required in COBOL programs or

assembler language programs. This is the parmcount, and it is always the firstparameter. You define the values that your program will need for theparmcount in each of its calls. The parmcount gives the number of parametersthat follow parmcount itself.

6. The program issues a GU call to the I/O PCB to retrieve the first messagesegment.

7. The program can issue a GU call to a DB PCB to retrieve a database segment.The function codes for these two calls are identical; the way that IMSdistinguishes between them is by the PCB to which each call refers.

NOTES/* *//* ENTRY POINT *//* */

UPDMAST: PROCEDURE (IO_PTR, ALT_PTR, DB_PTR) 1OPTIONS (MAIN);

DCL FUNC_GU CHAR(4) INIT(’GU ’); 2DCL FUNC_ISRT CHAR(4) INIT(’ISRT’);.DCL SSA_NAME...;.DCL MSG_SEG_IO_AREA CHAR(n); 3DCL DB_SEG_IO_AREA CHAR(n);DCL ALT_MSG_SEG_OUT CHAR(n);.DCL 1 IO_PCB BASED (IO_PTR),...; 4DCL 1 ALT_PCB BASED (ALT_PTR),...;DCL 1 DB_PCB BASED (DB_PTR),...;.DCL THREE FIXED BINARY(31) INIT(3); 5DCL FOUR FIXED BINARY(31) INIT(4);DCL PLITDLI ENTRY EXTERNAL;.CALL PLITDLI (THREE, FUNC_GU, IO_PTR, MSG_SEG_IO_AREA); 6.CALL PLITDLI (FOUR, FUNC_GU, DB_PTR, DB_SEG_IO_AREA, 7

SSA_NAME);.CALL PLITDLI (THREE, FUNC_ISRT, ALT_PTR, ALT_MSG_SEG_OUT); 8.END UPDMAST; 9PL/I LANGUAGE INTERFACE 10

Figure 60. Skeleton MPP written in PL/I

266 Application Programming Guide

Page 291: IMS Application Programming.pdf

8. The program then sends an output message to an alternate destination byissuing an ISRT call to an alternate PCB.

9. When there are no more messages for the program to process, the programreturns control to IMS by issuing the END statement or the RETURNstatement.

10. You must bind your program to the IMS language interface module,DFSLI000, after you have compiled your program.

Message processing considerations for DB2For the most part, the message processing function of a dependent region thataccesses DB2 databases is similar to that of a dependent region that accesses onlyDL/I databases. The method each program uses to retrieve and send messages andback out database changes is the same. The differences are:v DL/I statements are coded differently from SQL (structured query language)

statements.v When an IMS TM application program receives control from IMS TM, IMS has

already acquired the resources the program is able to access. IMS TM schedulesthe program, although some of the databases are not available. DB2 does notallocate resources for the program until the program issues its first SQLstatement. If DB2 cannot allocate the resources your program needs, yourprogram can optionally receive an initialization error when it issues its first SQLcall.

v When an application issues a successful checkpoint call or a successful messageGU call, DB2 closes any cursors that the program is using. This means that yourprogram should issue its OPEN CURSOR statement after a checkpoint call or amessage GU.

IMS TM and DB2 work together to keep data integrity in these ways:v When your program reaches a commit point, IMS TM makes any changes that

the program has made to DL/I databases permanent, releases output messagesfor their destinations, and notifies DB2 that the program has reached a commitpoint. DB2 then makes permanent any changes that the program has made toDB2 databases.

v When your program terminates abnormally or issues one of the IMS TMrollback calls (ROLB, ROLS without a token, or ROLL), IMS TM cancels any outputmessages your program has produced, backs out changes your program hasmade to DL/I databases since the last commit point, and notifies DB2. DB2backs out the changes that the program has made to DB2 databases since thelast commit point.

Through the Automated Operator Interface (AOI), IMS TM application programscan issue DB2 commands and IMS TM commands. To issue DB2 commands, theprogram issues the IMS TM /SSR command followed by the DB2 command. Theoutput of the /SSR command is routed to the master terminal operator (MTO).

Chapter 13. Message processing 267

Page 292: IMS Application Programming.pdf

268 Application Programming Guide

Page 293: IMS Application Programming.pdf

Chapter 14. Spool API

The IMS Spool API support provides feedback to the application program whenIMS detects errors in the print data set options of the CHNG and SETO calls. Forconvenience, your application program can display these errors by sending amessage to an IMS printer or by performing another action that lets you examinethe parameter lists and feedback area without looking at a dump listing.

This information applies only to the calls as they are used with Spool API support.

The following topics provide additional information:v “Understanding parsing errors”v “Understanding allocation errors” on page 273v “Understanding dynamic output for print data sets” on page 273v “Sample program using the Spool API” on page 274

Understanding parsing errorsWhen you are diagnosing multiple parsing error return codes, the first codereturned is usually the most informative.

KeywordsThe CHNG and SETO calls have two types of keywords. The type of keyworddetermines what type of keyword validation IMS should perform. The keywordtypes are:v Keywords valid for the calls (for example, IAFP, PRTO, TXTU, and OUTN)v Keywords valid as operands of the PRTO keyword (for example CLASS and

FORMS).

Incorrectly specified length fields can cause errors when IMS checks for validkeywords. When IMS is checking the validity of keywords on the CHNG and SETOcalls, one set of keywords is valid. When IMS is checking the validity of keywordson the PRTO keyword, another set of keywords is valid. For this reason, incorrectlyspecified length fields can cause a scan to terminate prematurely, and keywordsthat appear to be valid are actually invalid because of where they occur in the calllist. IMS might report that a valid keyword is invalid if it detects a keyword withan incorrect length field or a keyword that occurs in the wrong place in the calllist.

Status codesThe status code returned for the call can also suggest the location of the error.Although exceptions exist, generally, an AR status code is returned when thekeyword is invalid for the call. An AS status code is returned when the keyword isinvalid as a PRTO option.

Error codesThis topic contains information on Spool API error codes that your applicationprogram can receive. “Diagnosis examples” on page 271 contain examples of errorsand the resulting error codes provided to the application program.

© Copyright IBM Corp. 1974, 2010 269

Page 294: IMS Application Programming.pdf

Error Code Reason

(0002) Unrecognized option keyword.

Possible reasons for this error are:v The keyword is misspelled.v The keyword is spelled correctly but is followed by an invalid

delimiter.v The length specified field representing the PRTO is shorter than

the actual length of the options.v A keyword is not valid for the indicated call.

(0004) Either too few or too many characters were specified in the optionvariable. An option variable following a keyword in the options listfor the call is not within the length limits for the option.

(0006) The length field (LL) in the option variable is too large to becontained in the options list. The options list length field (LL)indicates that the options list ends before the end of the specifiedoption variable.

(0008) The option variable contains an invalid character or does not beginwith an alphabetic character.

(000A) A required option keyword was not specified.

Possible reasons for this error are:v One or more additional keywords are required because one or

more keywords were specified in the options list.v The specified length of the options list is more than zero but the

list does not contain any options.

(000C) The specified combination of option keywords is invalid. Possiblecauses for this error are:v The keyword is not allowed because of other keywords specified

in the options list.v The option keyword is specified more than once.

(000E) IMS found an error in one or more operands while it was parsingthe print data set descriptors. IMS usually uses z/OS services (SJF)to validate the print descriptors (PRTO= option variable). WhenIMS calls SJF, it requests the same validation as for the TSOOUTDES command. Therefore, IMS is insensitive to changes inoutput descriptors. Valid descriptors for your system are a functionof the MVS release level. For a list of valid descriptors and propersyntax, use the TSO HELP OUTDES command.

IMS must first establish that the format of the PRTO options is in aformat that allows the use of SJF services. If it is not, IMS returnsthe status code AS, the error code (000E), and a descriptive errormessage. If the error is detected during the SJF process, the errormessage from SJF will include information of the form(R.C.=xxxx,REAS.=yyyyyyyy), and an error message indicating theerror.

Related reading: For more information on SJF return and reasoncodes, see z/OS V1R9 MVS Programming: Authorized AssemblerServices Guide.

270 Application Programming Guide

Page 295: IMS Application Programming.pdf

The range of some variables is controlled by the initializationparameters. Values for the maximum number of copies, allowableremote destination, classes, and form names are examples ofvariables influenced by the initialization parameters.

Diagnosis examplesThis topic contains examples of mistakes that can generate the various spool APIerror codes, and diagnosis of the problems. Some length fields are omitted whenthey are not necessary to illustrate the example. The feedback and options lists thatare shown on multiple lines are contiguous.

Error code (0002)Two examples of the error code 0002 are shown in this section.

For the first example the options list contains both the keywords PRTO and TXTU.The keyword, TXTU, is invalid for the SETO call.CALL = SETO

OPTIONS LIST = PRTO=04DEST(018),CLASS(A),TXTU=SET1FEEDBACK = TXTU(0002)STATUS CODE = AR

For the second example, the length field of the PRTO options is too short tocontain all of the options. This means that IMS finds the COPIES and FORMSkeywords outside the PRTO options list area and indicates that they are invalid onthe CHNG call.CALL = CHNG

OPTIONS LIST = IAFP=N0M,PRTO=0FDEST(018),LINECT(200),CLASS(A),COPIES(80),FORMS(ANS)

FEEDBACK = COPIES(0002),FORMS(0002)STATUS CODE = AR

Error code (0004)For this example, the operand for the OUTN keyword is 9 bytes long and exceedsthe maximum value for the OUTPUT JCL statement.CALL = CHNG

OPTIONS LIST = IAFP=N0M,OUTN=OUTPUTDD1FEEDBACK = OUTN(0004)STATUS CODE = AR

Error code (0006)The length of the options list for this call is too short to contain all of the operandsof the PRTO keyword.

This example shows an options list that is X'48' bytes long and is the correctlength. The length field of the PRTO keyword incorrectly indicates a length ofX'5A'. The length of the PRTO options exceeds the length of the entire options listso IMS ignores the PRTO keyword and scans the rest of the options list for validkeywords. The feedback area contains the PRTO(0006) code (indicating a lengtherror) and the (0002) code (indicating that the PRTO keywords are in error). This isbecause the keywords beyond the first PRTO keyword, up to the length specifiedin the options list length field, have been scanned in search of valid keywords forthe call. The status code of AR indicates that the keywords are considered invalidfor the call and not the PRTO keyword.CALL = CHNG

0400 05OPTIONS LIST = 0800IAFP=N0M,PRTO=0ADEST(018),LINECT(200),CLASS(A),

Chapter 14. Spool API 271

Page 296: IMS Application Programming.pdf

COPIES(3),FORMS(ANS)FEEDBACK = PRTO(0006),LINECT(0002),CLASS(0002),COPIES(0002),

FORMS(0002)STATUS CODE = AR

Error code (0008)In this example, the message option of the IAFP keyword is incorrectly specified as“Z”.CALL = CHNG

00OPTIONS LIST = IAFP=N0Z,PRTO=0BDEST(018)FEEDBACK = IAFP(0008) INVALID VARIABLESTATUS CODE = AR

Error code (000A)In this example, the valid keyword TXTU is specified, but the call also requiresthat the IAFP keyword be specified if the TXTU keyword is used.CALL = CHNG

OPTIONS LIST = TXTU=SET1FEEDBACK = TXTU(000A)STATUS CODE = AR

Error code (000C)The AR status code is returned with the (0002) error code. This implies that theproblem is with the call options and not with the PRTO options.

The call options list contains the PRTO and TXTU keywords. These options cannotbe used in the same options call list.CALL = CHNG

00OPTIONS LIST = IAFP=A00,PRTO=0BCOPIES(3),TXTU=SET1FEEDBACK = TXTU(000C)STATUS CODE = AR

Error code (000E)In this example, the COPIES parameter has the incorrect value “RG” specified asone of its operands. The error message indicates that the values for these operandsmust be numeric.CALL = CHNG

01OPTIONS LIST = IAFP=A00,PRTO=0BCOPIES((3),(8,RG,18,80))FEEDBACK = PRTO(000E) (R.C.=0004,REAS.=00000204) COPIES/RG VALUE

MUST BE NUMERIC CHARACTERSSTATUS CODE = AS

This example includes an invalid PRTO operand. The resulting reason code ofX'000000D0' indicates that the XYZ operand is invalid.CALL = CHNG

00OPTIONS LIST = IAFP=A00,PRTO=0AXYZ(018)FEEDBACK = PRTO(000E) (R.C.=0004,REAS.=000000D0) XYZSTATUS CODE = AS

272 Application Programming Guide

Page 297: IMS Application Programming.pdf

Understanding allocation errorsThe IMS Spool API interface defers dynamic allocation of the print data set untildata is actually inserted into the data set. Incorrect data set print options on theCHNG or SETO call can cause errors during dynamic allocation. The print data setoptions can be parsed during the processing of the CHNG and SETO calls but somethings, for example the destination name parameter, can be validated only duringdynamic allocation.

If one of the print options is incorrect and dynamic allocation fails when the IMSperforms the first insert for the data set, IMS returns a AX status code to the ISRTcall. IMA also issues message DFS0013E and writes a diagnostic log record (67D0)that you can use to evaluate the problem. The format of the error messageindicates the type of service that was invoked and the return and reason codes thatwere responsible for the error. The error message can indicate these services:

DYN MVS dynamic allocation (SVC99)

OPN MVS data set open

OUT MVS dynamic output descriptors build (SVC109)

UNA MVS dynamic unallocation (SVC99)

WRT MVS BSAM write

If the DFS0013E message indicates an error return code from any of these services,you should consult the corresponding MVS documentation for more informationon the error code. If the service is for dynamic allocation, dynamic unallocation, ordynamic output descriptor build, see z/OS V1R9 MVS Programming: AuthorizedAssembler Services Guide for the appropriate return and reason codes.

One common mistake is the use of an invalid destination or selection of integrityoption 2 (non-selectable destination) when the destination of IMSTEMP has notbeen defined to JES. If you specify an invalid destination in the destination nameparameter, the call will result in a dynamic unallocation error when IMSunallocates the print data set.

Understanding dynamic output for print data setsIMS can use the z/OS services for Dynamic Output (SVC109) for print data sets.IMS uses this service to specify the attributes provided by the application for theprint data sets being created. The service can be used on the CHNG call with thePRTO, TXTU, and OUTN options.

Related reading: For more information, see z/OS V1R9 MVS Programming:Authorized Assembler Services Guide.

CHNG call with PRTO optionWhen you use the CHNG call and PRTO option, IMS activates SJF to verify the printoptions to call z/OS services for Dynamic Output. This creates the outputdescriptors that are used when the print data set is allocated. This is the simplestway for the application to provide print data set characteristics. However, it alsouses the most overhead because parsing must occur for each CHNG call. If yourapplication is WFI or creates multiple data sets with the same print options, useanother option to reduce the parsing impact. You must specify the IAFP optionkeyword with this option.

Chapter 14. Spool API 273

||||||||

Page 298: IMS Application Programming.pdf

CHNG call with TXTU optionIf your application can manage the text units necessary for Dynamic Output, thenyou can avoid parsing for many of the print data sets. You can do this in one oftwo ways:v The application can build the text unit in the necessary format within the

application area and pass these text units to IMS with the CHNG call and TXTUoption.

v The application can provide the print options to IMS with a SETO call andprovide a work area for the construction of the text units. After z/OS hasfinished parsing and text construction, the work area passed will contain the textunits necessary for Dynamic Output after a successful SETO call. The applicationmust not relocate this work area because the work area contains addresssensitive information.

Regardless of the method the application uses to manage the text units,applications that can reuse the text units can often achieve better performance byusing the TXTU option on the CHNG call.

You must specify the IAFP option keyword with this option.

CHNG call with OUTN optionThe dependent region JCL can contain OUTPUT JCL statements. If yourapplication can use this method, you can use the CHNG call and OUTN option toreference OUTPUT JCL statements. When you use the OUTN option, IMS willreference the OUTPUT JCL statements at dynamic allocation. JES will obtain theprint data set characteristics from the OUTPUT JCL statement. You must specifythe IAFP option keyword with this option.

Sample program using the Spool APIThe Spool API provides functions that allow an application program to write datato the IMS Spool using the same techniques for sending data to native IMSprinters.

The Spool API provides functions such as error checking for invalid OUTDESparameters. Error checking makes application programs more complex. To simplifythese application programs, develop a common routine to manage errorinformation, then make the diagnostic information from the Spool API available forproblem determination.

The sample programs in this sectionshow how DL/I calls can be coded to senddata to the IMS Spool. Only the parts of the application program necessary tounderstand the DL/I call formats are included. The examples are in assemblerlanguage.

Application PCB structureThe application PCBs are as follows:

I/O PCBALTPCB1ALTPCB2ALTPCB3ALTPCB4

274 Application Programming Guide

|

||||||

Page 299: IMS Application Programming.pdf

GU call to I/O PCBIMS application programs begin with initialization and a call to the I/O PCB toobtain the input message. The example in Figure 61 shows how to issue a GU call tothe I/O PCB.

After completing the GU call to the I/O PCB, the application program preparesoutput data for the IMS Spool.

CHNG call to alternate PCBIn the same way that other programs specify the destination of the output usingthe CHNG call, this program specifies the IMS Spool as the output destination. For anative IMS printer, the DEST NAME parameter identifies the output LTERM name.When a CHNG call is issued that contains the IAFP= keyword, the DEST NAMEparameter is used only if integrity option '2' is specified. If option '2' is notspecified, the DEST NAME parameter can be used by the application program toidentify something else, such as the routine producing the change call. Thedestination for the print data set is established using a combination of initializationparameters or OUTDES parameters.

The example in Figure 62 shows how to issue a CHNG call to the alternatemodifiable PCB.

************************************************************************ ISSUE GU ON IOPCB ************************************************************************

L 9,IOPCB I/O PCB ADDRESSLA 9,0(9)MVC FUNC,=CL4’GU’ GU FUNCTIONCALL ASMTDLI,(FUNC,(9),IOA1),VLBAL 10,STATUS CHECK STATUS

* ADDITIONAL PROGRAM LOGIC HEREFUNC DC CL4’ ’IOA1 DC AL2(IOA1LEN),AL2(0)TRAN DS CL8 TRANSACTION CODE AREADATA DS CL5 DATA STARTS HERE

DC 20F’0’IOA1LEN EQU *-IOA1

Figure 61. Issuing a GU call to the I/O PCB

Chapter 14. Spool API 275

Page 300: IMS Application Programming.pdf

After the CHNG call is issued, the application program creates the print data set byissuing ISRT calls.

ISRT call to alternate PCBOnce the IMS Spool is specified as the destination of the PCB, ISRT calls can beissued against the alternate PCB.

The example in Figure 63 shows how to issue the ISRT call to the alternatemodifiable PCB.

************************************************************************ ISSUE CHNG ON ALTPCB4 ************************************************************************

L 9,ALTPCB4 ALT MODIFIABLE PCBLA 9,0(9) CLEAR HIGH BYTE/BITMVC FUNC,=CL4’CHNG’ CHNG FUNCTIONCALL ASMTDLI,(FUNC,(9),DEST2,OPT1,FBA1),VLBAL 10,STATUS CHECK STATUS OF CALL

* ADDITIONAL PROGRAM LOGIC HEREFUNC DC CL4’ ’DEST2 DC CL8’IAFP1’ LTERM NAME*

DC C’OPT1’ OPTIONS LIST AREAOPT1 DC AL2(OPT1LEN),AL2(0)

DC C’IAFP=’OCC DC C’M’ DEFAULT TO MACHINE CHAROOPT DC C’1’ DEFAULT TO HOLDOMSG DC C’M’ DEFAULT TO ISSUE MSG

DC C’,’DC C’PRTO=’

PRTO1 EQU *DC AL2(PRTO1LEN)DC C’COPIES(2),CLASS(T),DEST(RMT003)’

PRTO1LEN EQU *-PRTO1DC C’ ’

OPT1LEN EQU *-OPT1*FBA1 DC AL2(FBA1LEN),AL2(0)

DC CL40’ ’FBA1LEN EQU *-FBA1

Figure 62. Issuing a CHNG call to the alternate modifiable PCB

************************************************************************ ISSUE ISRT TO ALTPCB4 ************************************************************************

L 9,ALTPCB4 ALT MODIFIABLE PCBLA 9,0(9) CLEAR HIGH BYTE/BITMVC FUNC,=CL4’ISRT’ ISRT FUNCTIONCALL ASMTDLI,(FUNC,(9),IOA2),VLBAL 10,STATUS CHECK STATUS OF CALL

* ADDITIONAL PROGRAM LOGIC HEREFUNC DC CL4’ ’IOA2 DC AL2(IOA2LEN),AL2(0)IOA21 DC AL2(MSG2LEN),AL2(0)

DC C’ ’ CONTROL CHARACTERDC C’MESSAGE TO SEND TO IMS SPOOL’

MSG2LEN EQU *-IOA21IOA2LEN EQU *-IOA2

Figure 63. Issuing an ISRT call to the alternate modifiable PCB

276 Application Programming Guide

Page 301: IMS Application Programming.pdf

The print data streams can be stored in databases or generated by the application,depending on the requirements of the application program and the type of data setbeing created.

Program terminationAfter the calls are issued, the program sends a message back to originatingterminal, issues a GU call to the I/O PCB, or terminates normally.

Chapter 14. Spool API 277

Page 302: IMS Application Programming.pdf

278 Application Programming Guide

Page 303: IMS Application Programming.pdf

Chapter 15. Introduction to Message Format Service (MFS)

The IMS message format service (MFS) is a facility of the IMS Transaction Managerenvironment that formats messages to and from terminal devices, so that IMSapplication programs do not deal with device-specific characteristics in input oroutput messages. In addition, MFS formats messages to and from user-writtenprograms in remote controllers and subsystems, so that application programs donot deal with transmission-specific characteristics of the remote controller.

MFS uses control blocks you specify to indicate to IMS how input and outputmessages are arranged.v For input messages, MFS control blocks define how the message sent by the

device to the application program is arranged in the program's I/O area.v For output messages, MFS control blocks define how the message sent by the

application program to the device is arranged on the screen or at the printer.Data that appears on the screen but not in the program's I/O area, such as aliteral, can also be defined.

In IMS Transaction Manager systems, data passing between the applicationprogram and terminals or remote programs can be edited by MFS or basic edit.Whether an application program uses MFS depends on the type of terminals orsecondary logical units (SLUs) your network uses.

Restriction: MFS does not support message formatting for LU 6.2 devices.

The following topics provide additional information:v “Advantages of using MFS”v “MFS control blocks” on page 281v “Overview of MFS components and operation” on page 287v “Devices and logical units that operate with MFS” on page 290v “Using distributed presentation management (DPM)” on page 292

See also the "Application Programming using MFS" section in the IMS Version 10:Application Programming API Reference.

Advantages of using MFSThe advantages of using MFS are as follows:v MFS simplifies developing and maintaining terminal-oriented applications by

performing common application functions and providing independence fromspecific devices or remote programs.

v MFS improves online performance by using control blocks for online processing.

Simplify development and maintenanceTo simplify IMS application development and maintenance, MFS performs manycommon application program functions and gives application programs a highdegree of independence from specific devices or remote programs.

With the device independence offered by MFS, one application program canprocess data to and from multiple device types while still using their different

© Copyright IBM Corp. 1974, 2010 279

||

Page 304: IMS Application Programming.pdf

capabilities. Thus, MFS can minimize the number of required changes inapplication programs when new terminal types are added.

MFS makes it possible for an application program to communicate with differenttypes of terminals without having to change the way it reads and builds messages.When the application receives a message from a terminal, how the messageappears in the program's I/O area is independent of what kind of terminal sent it;it depends on the MFS options specified for the program. If the next message theapplication receives is from a different type of terminal, you do not need to doanything to the application. MFS shields the application from the physical devicethat is sending the message in the same way that a DB program communicationblock (PCB) shields a program from what the data in the database actually lookslike and how it is stored.

Other common functions performed by MFS include left or right justification ofdata, padding, exits for validity checking, time and date stamping, page andmessage numbering, and data sequencing and segmenting. When MFS assumesthese functions, the application program handles only the actual processing of themessage data.

Figure 64 shows how MFS can make an application program device-independentby formatting input data from the device or remote program for presentation toIMS, and formatting the application program data for presentation to the outputdevice or remote program.

Improve online performance of a terminalMFS also improves online performance of a terminal-oriented IMS by using controlblocks designed for online processing. The MFS control blocks are compiled offline,when the IMS Transaction Manager system is not being executed, from sourcelanguage definitions. MFS can check their validity and make many decisionsoffline to reduce online processing. In addition, during online processing, MFS useslook-aside buffering of the MFS control blocks to reduce CPU and channel costs ofinput/output activity.

Because MFS control blocks are reentrant and can be used for multipleapplications, online storage requirements are reduced. Optional real storageindexing and anticipatory fetching of the control blocks can also reduce responsetime. Further performance improvements can be gained when IMS is generated forz/OS, since multiple I/O operations can execute concurrently to load the formatblocks from the MFS format library.

In addition, MFS uses z/OS paging services; this helps to reduce page faults by theIMS control region task.

MFS-supporteddevice

IMSapplicationprogram

MFS

Device input Input message

Output messageDevice output

Figure 64. Message formatting using MFS

280 Application Programming Guide

Page 305: IMS Application Programming.pdf

MFS can reduce use of communication lines by compressing data and transmittingonly required data. This reduces line load and improves both response time anddevice performance.

MFS control blocksThere are four types of MFS control blocks that you specify to format input andoutput for the application program and the terminal or remote program:

Message Output Descriptors (MODs)Define the layout of messages MFS receives from the application program.

Device Output Formats (DOFs)Describe how MFS formats messages for each of the devices the programcommunicates with.

Device Input Formats (DIFs)Describe the formats of messages MFS receives from each of the devicesthe program communicates with.

Message Input Descriptors (MIDs)Describe how MFS further formats messages so that the applicationprogram can process them.

Throughout this information, the term “message descriptors” refers to both MIDsand MODs. The term “device formats” refers to both DIFs and DOFs.

Each MOD, DOF, DIF and MID deals with a specific message. There must be aMOD and DOF for each unique message a program sends, and a DIF and MID foreach unique message a program receives.

MFS examplesOne way to understand the relationship between the MFS control blocks is to lookat a message from the time a user enters it at the terminal to the time theapplication program processes the message and sends a reply back to the terminal.Though MFS can be used with both display terminals and printer devices, forclarity in this example, a display terminal is being used.

Figure 65 shows the relationships between the MFS control blocks.

Chapter 15. Introduction to Message Format Service (MFS) 281

Page 306: IMS Application Programming.pdf

Looking at payroll recordsSuppose your installation has a message processing program used to viewemployee payroll records. From a display terminal, issue the IMS format command(/FORMAT), and the MOD name. This formats the screen in the way defined bythe MOD written by the MFS programmer. When you enter the MOD name, thescreen contains only literals and no output data from the application program. Atthis stage, no application program is involved. (For more information about/FORMAT, see IMS Version 10: Command Reference, Volume 1.)

In this example, suppose the name of the MOD that formats the screen for thisapplication is PAYDAY. Enter this command:/FORMAT PAYDAY

IMS locates the MFS MOD control block with the name PAYDAY and arranges thescreen in the format defined by the DOF. Figure 69 on page 287 shows an exampleof the MFS control statements that define a MID, MOD, DIF, and DOF.

Figure 66 shows how this screen looks.

Applicationprogram

MFS

DOF

DIF

DOF MOD

MID

MOD

Messagequeue

Format ControlBlock Library

IMS

Receive formatEnter data

Receiveoutput

Requestformat

Figure 65. MFS control block relationships

282 Application Programming Guide

Page 307: IMS Application Programming.pdf

The DOF defines a terminal format that asks you to give the employee's name andemployee number. PAYUP is the transaction code associated with the applicationthat processes this information. When you enter the MOD name, the transactioncode is included in the first screen format displayed. This means that you do notneed to know the name of the program that processes the data; you only need thename of the MOD that formats the screen.

After the screen format is displayed, you can enter the information. There are fourstages to sending a message to the program and receiving the reply:1. Enter the information at the terminal. For this example, enter the prompted

information.Figure 67 shows how this screen looks after information is entered.

2. When IMS receives this data, MFS uses the DIF and the MID control blocks totranslate the data from the way it was entered on the terminal screen to theway that the application program is expecting to receive it. The DIF controlblock tells MFS the format of the data to come in from the terminal. The MIDcontrol block tells MFS how the application program expects to receive thedata. When the application program issues a message call, IMS places the“translated” message in the program's I/O area.When the application receives the message in its I/O area, the message lookslike this:PAYUP JOE BLUTZEN 60249

“PAYUP” is the transaction code. The name of the logical terminal does notappear in the message itself; IMS places it in the first field of the I/O PCB.

3. The application program processes the message, including any requireddatabase access, and builds the output message in the application program'sI/O area. After retrieving the information from the database, the programbuilds the output message segment for the employee, with social security andrate of pay information. The application program's I/O area contains:LLZZJOE BLUTZEN 60249532596381150.00

*EMPLOYEE PAYROLL*******************

FIRST NAME: LAST NAME:EMPLOYEE NO:

INPUT:

Figure 66. PAYDAY screen, formatted by DOF

*EMPLOYEE PAYROLL*******************

FIRST NAME: Joe LAST NAME: BlutzenEMPLOYEE NO: 60249

INPUT:

Figure 67. PAYDAY screen, with filled input fields

Chapter 15. Introduction to Message Format Service (MFS) 283

Page 308: IMS Application Programming.pdf

The LL is a 2-byte field in MFS messages that indicates the length of the field.How the LL field is defined depends on what programming language used towrite the application program. For the AIBTDLI, ASMTDLI, CEETDLI, orPASTDLI interfaces, the LL field must be defined as a binary half word. For thePLITDLI interface, the LL field must be defined as a binary fullword. The valueprovided in the PLITDLI interface must represent the actual segment lengthminus 2 bytes.The ZZ is a 2-byte length field in MFS messages that contains the MFSformatting option that is being used to format the messages to and from theapplication program. MFS options are discussed in further detail in the topic"Input Message Formatting Options" in IMS Version 10: Application ProgrammingAPI Reference.

4. When the application program sends the message back to the terminal, MFStranslates the message again, this time from the application program format tothe format in which the terminal expects the data.The MOD tells MFS the format that the message will be in when it comes fromthe application program's I/O area. The DOF tells MFS how the message issupposed to look on the terminal screen. MFS translates the message and IMSdisplays the translated message on the terminal screen.Figure 68 shows how the screen looks.

Listing a subset of employeesSuppose you have an MPP that answers this request:

List the employees who have the skill “ENGINEER” with a skill level of “3.”List only those employees who have been with the firm for at least 4 years.

To enter the request from a display terminal, issue the format command(/FORMAT) and the MOD name. This formats the screen in the way defined bythe MOD you supply. When you enter the MOD name, the screen contains onlyliterals and no output data from an application program. At this stage, an MPP isnot involved. Suppose the name of the MOD that formats the screen for thisrequest is LE, for “locate employee.” Enter this:/FORMAT LE

IMS locates the MFS MOD control block with the name LE and arranges yourscreen in the format defined by the DOF. Your screen then looks like this:SKILLLEVELYEARS

LOCEMP

*EMPLOYEE PAYROLL*******************

FIRST NAME: Joe LAST NAME: BlutzenEMPLOYEE NO: 60249SOC SEC NO: 532-59-6381RATE OF PAY: $150.00

INPUT:

Figure 68. PAYDAY screen, output formatted by DOF and displayed

284 Application Programming Guide

Page 309: IMS Application Programming.pdf

The DOF defines a terminal format that asks you to qualify your request for anemployee by giving the skill, level, and number of years of service of the employeeyou want. LOCEMP is the transaction code that is associated with the MPP thatcan process this request. When you enter the MOD name, the transaction code isincluded in the first screen format that is displayed for you. This means that youdo not need the name of the program that processes your request; you only needthe name of the MOD that formats the screen.

After the screen format is displayed, you can enter your request. There are fourstages in sending a message to the program and receiving the reply.1. Enter the information at the terminal. In this example, enter the values of the

qualifications that IMS has given you on the screen: the skill is “eng”(engineer), the skill level is “3,” and the number of years with the firm is “4”.After you enter your request, your screen contains this data:SKILL ENGLEVEL 3YEARS 4

LOCEMP

2. When IMS receives this data, MFS uses the DIF and the MID control blocks totranslate the data from the way you entered it on the terminal screen to theway that the application program is expecting to receive it. The DIF controlblock tells MFS how the data is going to come in from the terminal. The MIDcontrol block tells MFS how the application program is expecting to receive thedata. When the application program issues a GU call to the I/O PCB, IMS placesthe “translated” message in the program's I/O area.When the MPP receives the message in its I/O area, the message looks likethis:

LOCEMP ENG0304“LOCEMP” is the transaction code. The name of the logical terminal does notappear in the message itself; IMS places it in the first field of the I/O PCB.

3. The MPP processes the message, including any required database access, andbuilds the output message in the MPP's I/O area.Suppose more than one employee meets these qualifications. The MPP can useone message segment for each employee. After retrieving the information fromthe database, the program builds the output message segment for the firstemployee. The program's I/O area contains:LLZZJONES,CE 3294

When the program sends the second segment, the I/O area contains:LLZZBAKER,KT 4105

4. When the application program sends the message back to the terminal, MFStranslates the message again, this time from the application program format tothe format in which the terminal expects the data.The MOD tells MFS the format that the message will be in when it comes fromthe application program's I/O area. The DOF tells MFS how the message issupposed to look on the terminal screen. MFS translates the message and IMSdisplays the translated message on the terminal screen. The screen thencontains the following data:SKILL ENGNAME NOJONES,CE 3294BAKER,KT 4105

Chapter 15. Introduction to Message Format Service (MFS) 285

Page 310: IMS Application Programming.pdf

Relationship between MFS control blocks and screen formatThis section discusses the relationship between MFS source language definitionsand formats you see at the device. The sample code is designed for a 3270 display.

The standard way for an end-user or operator to receive an initial format is torequest it with a /FORMAT command, specifying the name of a MOD. In Figure 69on page 287, the label on the MOD is PAYDAY. This MOD contains the parameterSOR=PAYF, which points to a device output format, or DOF, with the same label.

The initial DOF also becomes the format for device input. Therefore, if you specifyDIV TYPE=INOUT in the DOF, a device input format (DIF) is also generated. Inthe sample code, PAYF is both a DOF and a DIF, since it also describes the formatof the next input. The final output message can be displayed with a format that isspecified for output only and no DIF is generated.

Both the MOD and the MID point to the same DOF, thus establishing therelationship between device-related and message-related control blocks.

For output, MFS moves fields defined in a MOD to fields on the screen defined bya DOF. When a field definition is coded (MFLD) in a MOD, it is given a label. Thesame label is used in the coding of the device field (DFLD) in the DOF, definingwhere the field appears on the screen.

MFS moves data fields from output messages to screen fields; this is referred to asmapping. For input, MFS moves modified screen fields to data fields in the inputmessage for the program by mapping identically labeled fields in the DIF andMID. For more detailed information on specifying these control blocks, see IMSVersion 10: Database Utilities Reference.

The MFS control blocks are generated from the source statements like those inFigure 69 during execution of the MFS language utility program. The controlblocks are stored in the various MFS libraries.

286 Application Programming Guide

Page 311: IMS Application Programming.pdf

Overview of MFS components and operationMFS has the following components:v The “MFS Language utility (DFSUPAA0)” on page 288, which generates control

blocks from user-written control statements and places them in a library calledIMS.FORMAT.

v The “MFS Service utility (DFSUTSA0)” on page 289, which is used formaintaining the control blocks in IMS.FORMAT.

v The “MFS Device Characteristics Table utility (DFSUTB00)” on page 289, whichis used to add new screen sizes in the device characteristics table (DCT) andgenerate new MFS default formats for the screen size without system definition.

DOF/DIF

PAYF FMTDEV TYPE=(3270,2),FEAT=IGNORE,DSCA=X’00A0’DIV TYPE=INOUTDPAGE CURSOR=((5,15))DFLD '**********************',POS=(1,21)DFLD '* EMPLOYEE PAYROLL *',POS=(2,21)DFLD '**********************',POS=(3,21)DFLD 'FIRST NAME:',POS=(5,2)

FNAME DFLD POS=(5,15),LTH=16DFLD 'LAST NAME:',POS=(5,36)

LNAME DFLD POS=(5,48),LTH=16DFLD 'EMPLOYEE NO:',POS=(7,2)

EMPNO DFLD POS=(7,16),LTH=6DFLD 'SOC SEC NO:',POS=(9,2)

SSN DFLD POS=(9,15),LTH=11DFLD 'RATE OF PAY: $',POS=(11,2)

RATE DFLD POS=(11,17),LTH=9DFLD 'INPUT:',POS=(16,2)

INPUT DFLD POS=(16,10),LTH=30FMTEND

MID

PAYIN MSG TYPE:INPUT,SOR=(PAYF,IGNORE)SEGMFLD ’PAYUP ’ SUPPLIES TRANCODEMFLD LNAME,LTH=16MFLD FNAME,LTH=16MFLD EMPNO,LTH=6MFLD SSN,LTH=11MFLD RATE,LTH=9MFLD INPUT,LTH=30,JUST=R,FILL=C'0'MSGEND

MOD

PAYDAY MSG TYPE:OUTPUT,SOR=(PAYF,IGNORE)SEGMFLD LNAME,LTH=16MFLD FNAME,LTH=16MFLD EMPNO,LTH=6MFLD SSN,LTH=11MFLD RATE,LTH=9MFLD INPUT,LTH=30,JUST=R,FILL=C'0'MSGEND

Figure 69. Sample MFS control block coding

Chapter 15. Introduction to Message Format Service (MFS) 287

Page 312: IMS Application Programming.pdf

v The “MFS message editor” on page 289, which formats messages according tothe control block specifications generated by the language utility.

v The “MFS pool manager” on page 289keeps the MFS control blocks required bythe message editor in the real storage MFBP (message format buffer pool).

v The “MFSTEST pool manager” on page 290, which replaces the MFS poolmanager when the language utility is being used in test mode.

Note: The IMS online change function also plays an important part in updatingthe MFS libraries, even though it is not an MFS utility. The online changefunction allows the control block libraries to be modified while the IMScontrol region is executing. For a more complete description of onlinechange, see IMS Version 10: System Administration Guide.

MFS Language utility (DFSUPAA0)The MFS language utility processes user-written control statements. The primaryfunction of this utility is to create MFS control blocks used in online execution.Definition control statements define the MFS control blocks.

Additional functions of the MFS language utility include:v SYSPRINT listing controlv SYSIN/SYSLIB record stacking and unstackingv Repetitive generation of message and device fieldsv Equate processingv Alphabetic character generationv Copying SYSLIB members into the utility input streamv Printing statistics of counters maintained by the utility

A number of parameters on the JCL EXEC statement used during compilation canbe varied to control printed output, compress the partitioned data set librariesIMS.FORMAT and IMS.REFERAL, and prevent definitions with a specified level oferror from being written in IMS.REFERAL.

The language utility can operate in three modes: standard, test, and batch. Allproduce the same control blocks. They differ in their ability to operate concurrentlywith the IMS online control region and in their use of the MFS libraries.

In standard mode, the MFSUTL job control procedure can execute concurrentlywith the IMS control region. It stores control blocks in the IMS.FORMAT library.

In test mode, the MFSTEST procedure can execute concurrently with the IMSonline control region. It stores control blocks in the IMS.TFORMAT library.

In batch mode, the MFSBTCH1 procedure places the control blocks in a temporarylibrary, IMS.MFSBATCH. The MFSBTCH2 procedure transfers the control blocks toIMS.FORMAT. The MFSBTCH1 procedure can be executed many times, and controlblocks can be accumulated in IMS.MFSBATCH before they are transferred to thestaging library.

The language utility checks the syntax of the source language definitions andconverts them to a form intermediate between the source language and the finalonline control block, called an intermediate text block (ITB). In standard mode, itwrites these ITBs in the historical reference library, IMS.REFERAL. Although mostITBs are immediately converted to online control blocks and written in the staging

288 Application Programming Guide

Page 313: IMS Application Programming.pdf

library, IMS.FORMAT, the ITBs and the relationships between them are stillretained in IMS.REFERAL. When the language utility begins processing, a table ofall ITBs currently in IMS.REFERAL and their interrelationships is created. Eachnew definition is then checked against the table. Newly entered definitions thathave valid syntax, that belong to a complete format set (complete with DIF or DOFand associated MID or MOD), and have consistent references to other ITBs in theset, are converted to online control blocks and are immediately written in theIMS.FORMAT library (in standard mode) or the IMS.TFORMAT library (in testmode).

Two IMS commands are available to request format sets while using the languageutility. To request use of a format set, a terminal operator enters the /FORMATcommand. To test the format sets in IMS.TFORMAT, the terminal operator entersthe /TEST MFS command. Then the /FORMAT command can be used to call testformat sets from IMS.TFORMAT (and format sets from IMS.FORMAT, if necessary)into the communication line buffer pool for test MFS operation. After successfultesting, the format sets can be written in the staging library, IMS.FORMAT.

The use of the MFS commands /FORMAT and /TEST is explained in the discussion ofthose commands in the IMS Version 10: Command Reference, Volume 1.

MFS Service utility (DFSUTSA0)The MFS service utility performs optional indexing, reporting, and maintenancefunctions. The INDEX function puts index entries for specified IMS.FORMATcontrol blocks in a special real storage directory, to allow faster access to thecontrol blocks. Other functions are used to delete or obtain reports on the contentsof the libraries and directories.

Related Reading: For more information about the MFS service utility, see IMSVersion 10: System Utilities Reference.

MFS Device Characteristics Table utility (DFSUTB00)The MFS device characteristics table (MFS DCT) utility is used to add new screensizes to the DCT and generate new MFS default formats for those screen sizeswithout performing an IMS system definition. The definition of the new screensizes to the utility is made on the new ETO device descriptor. New screen sizedefinitions are added to screen sizes that were previously defined.

Related reading: For an example of an MFS device descriptor used by the DCT, orfor more information on ETO, see IMS Version 10: Communications and ConnectionsGuide. For more information on the MFS DCT utility, see IMS Version 10: SystemUtilities Reference.

MFS message editorThe MFS message editor formats messages according to the control blockspecifications generated by the language utility from control statement definitionsyou enter. The editor can also give control to optional user-written orIMS-provided field and segment editing routines (such as validity checks). TheIMS-provided editing routines are shown in IMS Version 10: Communications andConnections Guide.

MFS pool managerMFS tries to minimize I/O to the format library by keeping referenced blocks instorage. This storage is managed by the MFS pool manager. The INDEX function

Chapter 15. Introduction to Message Format Service (MFS) 289

Page 314: IMS Application Programming.pdf

of the MFS service utility allows you to customize this function, by constructing alist of the directory addresses for specified format blocks, eliminating the need forIMS to read the data set directory before fetching a block.

For more information, refer to the IMS Version 10: System Utilities Reference.

MFSTEST pool managerIf the optional MFSTEST facility is used, MFS control blocks are managed by theMFSTEST pool manager. The communication line buffer pool space allowed forMFS testing is specified at system definition, but the space can be changed whenthe IMS control region is initialized. This space value is the maximum amountused for MFSTEST blocks at any one time—it is not a reserved portion of the pool.

Devices and logical units that operate with MFSIn addition to 3270 devices, MFS operates with the 3600 and 4700 FinanceCommunication System (FIN), the 3770 Data Communication System, the 3790Communication System, and with Secondary Logical Unit (SLU) types 1, 2, 6, andP. Network Terminal Option (NTO) devices are supported as secondary logical unittype 1 consoles.

Table 54 shows which devices or logical units can be defined for MFS operation inthe IMS system by their number (3270, for example), and which can be defined bythe type of logical unit to which they are assigned (SLU 1, for example). Thoughthe 3600 devices are included in the FIN series, you can specify them with their36xx designations; MFS messages use the FIxx designations regardless of whichform of designation you specify. In general, however, application designers andprogrammers using this information only need to know how the devices they aredefining control blocks for have been defined to the IMS system in theirinstallation.

Table 54. Terminal devices that operate with MFS

SNA Devices or Logical Units3

Device

DevicesDefined by

Number1NTO

Devices2 SLU 1 SLU 2 SLU P LU 6.1

3180 X 4 X 4

3270 X 4 X 4

3290 X 4 X 4

5550 X 4 TYPE:3270-An

3270-Ann

3270 printers; 5553, 5557 X 4 COMPTn=MFS-SCS1

3730 X

3767 COMPTn=MFS-SCS1

3770 console, printers,print data set

COMPTn=MFS-SCS1

X

3770 readers, punches,transmit data set

COMPTn=MFS-SCS2

X

290 Application Programming Guide

Page 315: IMS Application Programming.pdf

Table 54. Terminal devices that operate with MFS (continued)

SNA Devices or Logical Units3

Device

DevicesDefined by

Number1NTO

Devices2 SLU 1 SLU 2 SLU P LU 6.1

3790 print data set (bulk) COMPTn=MFS-SCS1

COMPTn=MFS-SCS1DPM-An

3790 transmit data set COMPTn=MFS-SCS2

3790 attached 3270 X 4

6670

8100 X

8100 attached 3270 X X 4

8100 attached Series/1 X

8100 attached S/32 X

8100 attached S/34 X

8100 attached S/38 X

Finance X COMPTn=MFS-SCS1DPM-An

TTY X

3101 X

Other systems (IMS toIMS or IMS to other)

COMPTn=DPM=Bn

Notes:

1. With options= (...,MFS,...) in the TERMINAL or TYPE macro.

2. Defined with UNITYPE= on the TYPE macro and PU= on the TERMINAL macro.

3. Defined by logical unit type or logical unit type with COMPTn= or TYPE= in the TERMINAL macro or ETOlogon descriptor. The LU 6.1 definition refers to ISC subsystems.

4. Defaults to operate with MFS.

The definition for SLU 1 can specify an MFS operation with SNA character strings(SCS) 1 or 2. SCS1 designates that messages are sent to a printer or the print dataset or received from a keyboard in the 3770 Programmable or 3790 controller diskstorage; SCS2 designates that messages are sent to or received from card I/O or atransmit data set.

Terminals defined as SLU 2 have characteristics like the 3270, and like the 3270,can be defined to operate with MFS. In general, a 3290 terminal operates like a3270 terminal, and references to 3270 terminals in this information are applicable to3290 devices. However, 3290 partitioning and scrolling support is only providedfor 3290 devices defined to IMS as SLU 2.

Generally, the 3180 and 5550 terminals operate like a 3270 terminal, and referencesto 3270 terminals also apply to these devices. Likewise, the 5553 and 5557 printerdevices operate like a 3270P.

Chapter 15. Introduction to Message Format Service (MFS) 291

Page 316: IMS Application Programming.pdf

Restriction: 5550 Kanji support is only provided for the 5550 terminal defined asan SLU 2 and for the 5553 and 5557 defined as SCS1 printers.

If IMS is to communicate with the user-written remote program in a 3790 or anFIN controller, the device must be defined as an SLU P. Definitions for SLU P mustspecify MFS operation as either MFS-SCS1 or DPM-An, where DPM meansdistributed presentation management and An is a user-assigned number (A1through A15).

Most of the MFS formatting functions currently available to other devices, exceptspecific device formatting, are available to the user-written program. Under usercontrol, these formatting functions (such as paging) can be divided between MFSand the remote program.

Using distributed presentation management (DPM)With distributed presentation management (DPM), formatting functions usuallyperformed by MFS are distributed between MFS and a user-written program forSLU P devices or ISC nodes. If the 3790 or FIN controller has previously beendefined to IMS by unit number, some changes must be made to convert to DPM.

With DPM, the physical terminal characteristics of the secondary logical unit donot have to be defined to MFS. MFS has to format only the messages fortransmission to the user program in the remote controller or ISC node, which mustassume responsibility for completing the device formatting, if necessary, andpresent the data to the physical device it selects.

For remote programs using DPM, the data stream passing between MFS and theremote programs can be device independent. The messages from the IMSapplication program can include some device control characters. If so, the IMSapplication program and the data stream to the remote program might lose theirdevice independence.

If IMS is to communicate with other subsystems (such as IMS, CICS oruser-written), the other subsystem must be defined as an ISC subsystem.Definitions for ISC must:v Specify MFS operation as DPM-Bn, where DPM is as described in “Using

distributed presentation management (DPM)” and Bn is a user-assigned number(B1 through B15).

v Define TYPE:LUTYPE6 on the TERMINAL macro during system definition.

DPM with ISC provides:v Output paging on demand that allows paging to be distributed between IMS

and another systemv Automatically paged output that allows MFS pages to be transmitted to another

system without intervening paging requestsv Transaction routing that allows application programs to view the routing

information when it is provided in the input message

292 Application Programming Guide

Page 317: IMS Application Programming.pdf

Chapter 16. Callout requests for external services or data

IMS applications can issue callout requests for external services or data, andoptionally receive responses back in the same or a different transaction, throughIMS Connect and OTMA. The request for services or data is a callout request.

When an IMS application program makes a callout request, IMS can be viewed asa client in a client-server relationship, where the server is the external applicationto which IMS is making the callout request. If the IMS application, after issuing therequest, waits for the response in the dependent region, the request is asynchronous callout request. If the IMS application terminates after the request isissued and does not wait for a response in the dependent region, the request is anasynchronous callout request.

For synchronous callout requests, an IMS application program that runs in an IMSdependent region issues a DL/I call ICAL and waits in the dependent region toprocess the response. When the DL/I ICAL call is issued, IMS generates acorrelation token for synchronous callout requests. This correlation token isincluded with the callout request and must be returned to IMS with the responseto route the response back to the requesting IMS application program.

For asynchronous callout requests, an IMS application program that runs in an IMSdependent region inserts the callout request to an ALTPCB queue (the ISRTALTPCB call) and then terminates to free the dependent region. IMS does notgenerate a correlation token for asynchronous callout requests. If a response to thecallout request is required, the correlation of the response to the callout requestmust be managed by the IMS application program. When IMS receives a responseto an asynchronous callout request, IMS processes the response as a newtransaction.

The following table summarizes the differences between the synchronous andasynchronous callout requests.

Table 55. Summary of differences between synchronous and asynchronous callout requests

Callout process Synchronous callout request Asynchronous callout request

Placing the request in the OTMA holdqueue

The requesting IMS application issuesan ICAL call.

The requesting IMS application issuesan ISRT ALTPCB call.

Status of the IMS application after therequest is issued

The application waits in thedependent region for the response.Dependent regions are blocked.

The application terminates.

Message processing handling The message processing is handled byIMS OTMA.

The message processing is handled bythe IMS message queue.

Response handling The response is correlated back to therequesting IMS application, based onthe correlation token, during the sameunit of work.

If there is a response, the requestingor a different IMS application must becoded to handle the response that isreturned in a different transaction.The unit of work for the transactionhas to commit for the asynchronousoutput to flow.

Related reading:

© Copyright IBM Corp. 1974, 2010 293

|

|

|||

|||||||

||||||

||||||||

||

||

|||

||||||

|||||

|

|||||

|||||

||||||||

|

Page 318: IMS Application Programming.pdf

v For more information about the DL/I call ICAL, see the topic “ICAL call” inIMS Version 10: Application Programming API Reference.

v For information about configuring your environment for IMS callout support,see the topic “OTMA support for callout requests from IMS applicationprograms” in IMS Version 10: Communications and Connections Guide.

Callout request approachesYou can issue a synchronous or asynchronous callout request using IMS SOAPGateway, IMS TM Resource Adapter, or by writing your own user-supplied IMSConnect client applications. Callout requests are routed through IMS Connect.

Using IMS SOAP Gateway Version 10Use IMS SOAP Gateway to issue callout requests from IMS applications to anygeneric Web service.

IMS SOAP Gateway enables IMS applications as either Web service providers orconsumers. Tooling support for IMS SOAP Gateway is available in IBM RationalDeveloper for System z for generating the required Web service artifacts based onconnection and interaction information for communicating with IMS Connect, andthe language structure of the IMS applications. IMS SOAP Gateway also provides adeployment utility to support the deployment of IMS applications as eitherproviders or consumers of Web services.

Using IMS TM Resource Adapter Version 10Use IMS TM Resource Adapter to issue callout requests from IMS applications toany message-driven bean (MDB), Enterprise JavaBeans (EJB) component, Java EEapplication (previously known as J2EE application), or Web service.

IMS TM Resource Adapter enables Java EE applications to access IMS transactionsover the Internet, as well as to issue callout requests to external Java EEapplications from IMS applications that run in IMS dependent regions. The IMSTM Resource Adapter includes a runtime component for IBM WebSphereApplication Server. Tooling support for the IMS TM Resource Adapter is availablein IBM Rational Application Developer for WebSphere Software, as well as variousRational and WebSphere integrated development environments (IDEs) that includethe J2EE Connector (J2C) wizard.

Using a user-written IMS Connect TCP/IP applicationYou can write your own IMS Connect TCP/IP applications or use avendor-supplied solution that uses TCP/IP and the IMS Connect protocol toretrieve callout requests. Your custom IMS Connect client application must issue aRESUME TPIPE call to an OTMA routing destination, also known as a transactionpipe (tpipe), that is defined in an OTMA destination descriptor. This tpipe holdsthe callout requests. Your custom IMS Connect TCP/IP application must poll thetpipe to retrieve the callout requests.

OTMA destination descriptorsBoth synchronous and asynchronous callout requests use OTMA destinationdescriptors to specify the tpipe hold queue to route the callout messages.

For IMS Connect destinations, the OTMA destination descriptor provides a layer ofabstraction between the application program and the tpipes. The destination name

294 Application Programming Guide

||

|||

||

|||

|

||

|||||||

|

|||

||||||||

|

|||||||

||

||

||

Page 319: IMS Application Programming.pdf

specified in the descriptor can be explicit or generalized using a mask character.The tpipe name specified in the descriptor can be an individual tpipe name, asuper member name, or left blank, in which case the specified destination name isused as the tpipe name.

These attributes can be specified in the OTMA descriptors:

Destination typeThe OTMA destination descriptor supports only IMS Connect, specified byIMSCON, and non-OTMA destinations, specified by NONOTMA, asdestination types.

IMS Connect destinationsDestinations are specified by an OTMA tmember name or an OTMA supermember name and an optional tpipe name.

IMS Connect XML conversionThis conversion is supported for IMS SOAP Gateway only. You must providean XML adapter name and an XML converter name.

Timeout for request(Optional.) The timeout period is specified in the time in hundredths of asecond to wait for the callout request processing to complete in the dependentregion.

Related reading:

v For details about OTMA destination descriptors, see the topic “OTMAdestination descriptors” in IMS Version 10: Communications and Connections Guide.

v For more information about the syntax and parameters of the OTMA destinationdescriptor, see the information about the DFSYDTx PROCLIB member in theIMS Version 10: System Definition Guide.

Resume tpipe protocolThe resume tpipe protocol retrieves asynchronous and synchronous calloutmessages from IMS.

An IMS Connect client signals how long to wait for output from IMS by specifyingan IRM timeout value with the IRM_TIMER field. The IRM timeout value affectsthe RESUME TPIPE call that is sent to IMS Connect and the ACK or NAKresponse message that is sent to IMS Connect.

When you use IMS TM Resource Adapter or IMS SOAP Gateway to handle thecallout request from your IMS application, the communication with IMS Connect ishandled for you.

Both the IMS TM Resource Adapter and IMS SOAP Gateway listen forsynchronous callout requests by continuously issuing the RESUME TPIPE call toIMS Connect. If a callout request message is on the tpipe queue, OTMA sends thecallout request to IMS Connect, IMS Connect processes the message, converting themessage to XML if necessary (for IMS SOAP Gateway if using the IMS ConnectXML adapter function), and then sends the message to the IMS TM ResourceAdapter or IMS SOAP Gateway.

If you have a custom IMS Connect client, you must code the client to issue aRESUME TPIPE call to retrieve the callout messages

Chapter 16. Callout requests for external services or data 295

||||

|

||||

|||

|||

||||

|

||

|||

||

||

||||

|||

|||||||

||

Page 320: IMS Application Programming.pdf

Resume tpipe securityYou can protect callout messages from unauthorized use of the RESUME TPIPEcall by using either the Resource Access Control Facility (RACF), the OTMAResume TPIPE Security exit routine (DFSYRTUX), or both.

When security is enabled, the user ID that issues the RESUME TPIPE call must beauthorized to access the tpipe name that is contained in the RESUME TPIPE callmessage before any messages are sent to an OTMA client.

The security checking performed by RACF and the security checking performed bythe DFSYRTUX exit routine are optional. If both RACF and the DFSYRTUX areused, RACF is called first before giving control to the DFSYRTUX exit routine, inwhich case, the DFSYRTUX exit routine can override RACF, depending on yourneeds.

Implementing the synchronous callout functionTo issue a synchronous callout request from your IMS application, issue the ICALcall and specify the OTMA descriptor name. The ICAL call can also be issuedthrough a REXXTDLI call, or from a Java application that runs in a JMP or JBPregion.

Optionally, you can also specify a timeout value (the maximum time to wait forthe response to return). Input and output messages from IMS can be 32 K or largerper segment.

As a prerequisite to implementing a synchronous callout application, make surethat IMS Connect is configured and started. You should also ensure that theappropriate exit routines are enabled in IMS Connect for your IMS ConnectTCP/IP client.

The following high-level steps provide an overview of implementing anddeploying your synchronous callout application and function:1. Create or modify an IMS application for the ICAL call.2. Define the OTMA destination descriptor.3. Restart IMS for the newly defined OTMA descriptor.4. Implement a synchronous callout request by using one of the callout request

approaches (using IMS TM Resource Adaptor, IMS SOAP Gateway, or auser-written IMS Connect client application).

5. Run the IMS application that was created or modified in step 1 to issue thesynchronous callout request.

The following diagram shows the message flow of the synchronous calloutfunction. The request starts with an IMS application that issues an ICAL call. Theresponse is returned to the requesting IMS application.

296 Application Programming Guide

|

|||

|||

|||||

||

||||

|||

||||

||

|

|

|

|||

||

||||

Page 321: IMS Application Programming.pdf

Example COBOL program implementation of the synchronouscallout function

To issue the ICAL call in a COBOL program, use the CALL statement.CALL ’AIBTDLI’ USING ICAL, AIB, CA-REQUEST, SCA-RESPONSE.

WebSphereApplication

Server

User-writtenIMS Connect client

application(such as SAP)

IMS TMResourceAdapter

IMS

IMS application

ICAL call withSENDRECVsubfunction

OTMAdescriptor

IMSConnect

Send flowReceive flow

EJB/MDB

Web serviceprovider(such asMicrosoft

.NET)

IMS EnterpriseSuite

SOAP Gateway

Figure 70. Message flow of the synchronous callout function

Chapter 16. Callout requests for external services or data 297

|

||||

|

|

|

|

Page 322: IMS Application Programming.pdf

The following example demonstrates the required AIB field declaration for theICAL call in the COBOL program. A complete COBOL example (with part nameDFSSCBL) is provided with the callout IVP sample in the SDFSSMPL samplelibrary.01 AIB.

02 AIBRID PIC x(8) VALUE ’DFSAIB ’.02 AIBRLEN PIC 9(9) USAGE BINARY.02 AIBSFUNC PIC x(8) VALUE ’SENDRECV’.02 AIBRSNM1 PIC x(8) VALUE ’OTMDEST1’.02 AIBOALEN PIC 9(9) USAGE BINARY VALUE 45.02 AIBOAUSE PIC 9(9) USAGE BINARY VALUE 100.02 AIBRSFLD PIC 9(9) USAGE BINARY VALUE 500.02 AIBRETRN PIC 9(9) USAGE BINARY.02 AIBREASN PIC 9(9) USAGE BINARY.02 AIBERRXT PIC 9(9) USAGE BINARY.

...

The following example shows the CA-REQUEST and SCA-RESPONSE declarationsin the COBOL program.* ICAL Request Area01 CA-REQUEST.

02 CA-MESSAGE PIC X(45) VALUE SPACES.

* ICAL Response Area01 SCA-RESPONSE.

02 SCA-MESSAGE PIC X(100) VALUE SPACES.

Concurrent processingYou can make concurrent ICAL calls from your IMS applications that are routed tothe same or different destinations. By using the RESUME TPIPE call and thesend-only protocol, the synchronous callout function allows the requests to be sentand the responses to be received in different connections and threads. You canhave one connection for retrieving the callout requests and use other connectionsto return the response messages simultaneously.

A correlation token is created by IMS to correlate the response message back to thecorrect IMS transaction instance. The capability of having different threads andconnections for pulling callout requests and for returning response messagesprovides maximum concurrency.

Related reading:

v For more information about the DL/I call ICAL, see the topic “ICAL call” inIMS Version 10: Application Programming API Reference.

v For an example of how the synchronous callout request is made using a DL/Icall ICAL function, see the topic “Examples of DL/I call functions” in IMSVersion 10: Application Programming API Reference.

v For information about how to issue a synchronous callout request using theREXXTDLI interface, see the topic “REXXTDLI calls” in IMS Version 10:Application Programming API Reference.

v For information about issuing a synchronous callout request from a Javaapplication running in a JMP or JBP region, see the topic “Issuing synchronouscallout requests from a Java dependent region” on page 395.

v For details about implementing the synchronous callout function with IMS TMResource Adaptor, see the topic “Callout programming models” in IMS TMResource Adapter User's Guide and Reference.

298 Application Programming Guide

||||

||||||||||||

||

|||||||

|

||||||

||||

|

||

|||

|||

|||

|||

Page 323: IMS Application Programming.pdf

v For details about implementing the synchronous callout function with IMSSOAP Gateway, see the topic “Modifying an IMS application for calloutrequests” in IMS SOAP Gateway User's Guide and Reference.

v For an overview of configuring a synchronous callout environment when IMSConnect is used as the OTMA hold-queue capable client, see the topic“Synchronous callout requests” in IMS Version 10: Communications andConnections Guide.

Implementing the asynchronous callout functionTo issue an asynchronous callout request from your IMS application, issue the ISRTALTPCB call and specify the OTMA destination descriptor name.

Any response to the callout request that is returned to IMS is treated as a newincoming transaction. If there is a response, the requesting application or adifferent IMS application must be coded to handle the response that is returned ina separate transaction.

Unlike synchronous callout requests, asynchronous callout requests do not requirethe IMS application program that issues the request to wait for a response in thedependent region. After it issues an asynchronous callout request, the applicationprogram can terminate and free the dependent region. Any response to the calloutrequest that is returned to IMS is treated as a new incoming transaction and IMSschedules a new application program instance to process it.

If an asynchronous callout request generates a response, however, the benefitgained by freeing dependent regions might be offset by the additional complexityof managing the response. For asynchronous callout responses, your installation isresponsible for developing the method for correlating the response to the originalrequest. For synchronous callout requests, IMS manages that correlation.

The following high-level steps provide an overview of implementing anddeploying your asynchronous callout application and function:1. Plan for the correlation of asynchronous callout responses.2. Create or modify an IMS application to issue an ISRT ALTPCB call for

asynchronous callout requests.3. Define the OTMA destination descriptor.4. Restart IMS for the newly defined OTMA descriptor.5. Run the IMS application that issues the callout request. The IMS application is

usually triggered through an initiating client, such as a terminal, or an IMSConnect or OTMA client.

Related reading:

v For details about implementing the asynchronous callout function, see the topic“Asynchronous callout requests” in IMS Version 10: Communications andConnections Guide.

Chapter 16. Callout requests for external services or data 299

|||

||||

||

||

||||

||||||

|||||

||

|

||

|

|

|||

|

|||

Page 324: IMS Application Programming.pdf

300 Application Programming Guide

Page 325: IMS Application Programming.pdf

Part 3. Application programming for EXEC DLI

Chapter 17. Writing your application programsfor EXEC DLI . . . . . . . . . . . . . 303Programming guidelines . . . . . . . . . 303

Coding a program in assembler language . . . 304Coding a program in COBOL . . . . . . . 308Coding a program in PL/I . . . . . . . . 311Coding a program in C . . . . . . . . . 315

Preparing your EXEC DLI program for execution 321Translator options required for EXEC DLI . . . 321Compiler options required for EXEC DLI . . . 321Binder options required for EXEC DLI . . . . 322

Chapter 18. Defining application programelements . . . . . . . . . . . . . . 323Specifying an application interface block (AIB) . . 323

AIB mask . . . . . . . . . . . . . 323CICS restrictions with AIB support . . . . . 323

Specifying the DL/I interface block (DIB) . . . . 323Defining a key feedback area . . . . . . . . 327Defining I/O areas . . . . . . . . . . . 327

COBOL I/O area . . . . . . . . . . . 327PL/I I/O area . . . . . . . . . . . . 328Assembler language I/O area . . . . . . . 328

Chapter 19. EXEC DLI commands for anapplication program . . . . . . . . . . 329PCBs and PSB . . . . . . . . . . . . . 329

I/O PCB . . . . . . . . . . . . . . 329Alternate PCB . . . . . . . . . . . . 329DB PCB . . . . . . . . . . . . . . 329GSAM PCB . . . . . . . . . . . . . 329PCB summary . . . . . . . . . . . . 330Format of a PSB . . . . . . . . . . . 331

Chapter 20. Recovering databases andmaintaining database integrity . . . . . . . 333Issuing checkpoints in a batch or BMP program 333

Issuing the CHKP command . . . . . . . 334Issuing the SYMCHKP command. . . . . . 334

Restarting your program and checking for position 334Backing out database updates dynamically: theROLL and ROLB commands . . . . . . . . 334Using intermediate backout points: the SETS andROLS commands . . . . . . . . . . . . 335

Chapter 21. Processing Fast Path databases 337Processing DEDBs with subset pointers. . . . . 337

Preparing to use subset pointers . . . . . . 339Designating subset pointers . . . . . . . 340Subset pointer options . . . . . . . . . 340Subset pointer status codes . . . . . . . . 347

The POS command . . . . . . . . . . . 347Locating a specific sequential dependentsegment . . . . . . . . . . . . . . 348

Locating the last inserted sequential dependentsegment . . . . . . . . . . . . . . 348Identifying free space with the POS command 349The P processing option . . . . . . . . . 349

Chapter 22. Comparing command-level andcall-level programs . . . . . . . . . . . 351DL/I calls for IMS and CICS . . . . . . . . 351Comparing EXEC DLI commands and DL/I calls 352Comparing command codes and options . . . . 353

Chapter 23. Data availability enhancements . . 355Accepting database availability status codes . . . 355Obtaining information about database availability 355

© Copyright IBM Corp. 1974, 2010 301

Page 326: IMS Application Programming.pdf

302 Application Programming Guide

Page 327: IMS Application Programming.pdf

Chapter 17. Writing your application programs for EXEC DLI

This chapter provides programming guidelines and information on preparingprograms for execution using EXEC DLI commands. It also contains skeletonprograms in assembler language, COBOL, PL/I, C, and C++.

The following topics provide additional information:v “Programming guidelines”v “Preparing your EXEC DLI program for execution” on page 321

Programming guidelinesThis description provides some guidelines for writing efficient and error-freeprograms

The number, type, and sequence of the DL/I requests your program issues affectthe efficiency of your program. A program that is poorly designed runs if it iscoded correctly. The suggestions that follow can help you develop the mostefficient design possible for your application program. Inefficiently designedprograms can adversely affect performance and are hard to change. Being aware ofhow certain combinations of commands or calls affects performance helps you toavoid these problems and design a more efficient program.

After you have a general sequence of calls mapped out for your program, usethese guidelines to improve the sequence. Usually an efficient sequence of requestscauses efficient internal DL/I processing.v Use the simplest call. Qualify your requests to narrow the search for DL/I, but

do not use more qualification than required.v Use the request or sequence of requests that gives DL/I the shortest path to the

segment you want.v Use the fewest number of requests possible in your program. Each DL/I request

your program issues uses system time and resources. You may be able toeliminate unnecessary calls by:– Using path requests if you are replacing, retrieving, or inserting more than

one segment in the same path. If you are using more than one request to dothis, you are issuing unnecessary requests.

– Changing the sequence so that your program saves the segment in a separateI/O area, and then gets it from that I/O area the second time it needs thesegment. If your program retrieves the same segment more than once duringprogram execution, you are issuing an unnecessary request.

– Anticipating and eliminating needless and nonproductive requests, such asrequests that result in GB, GE, and II status codes. For example, if you areissuing GNs for a particular segment type and you know how manyoccurrences of that segment type exist, do not issue the GN that results in a GEstatus code. You can keep track of the number of occurrences your programretrieves, and then continue with other processing when you know you haveretrieved all the occurrences of that segment type.

– Issuing an insert request with a qualification for each parent instead ofissuing Get requests for the parents to make sure that they exist. When you

© Copyright IBM Corp. 1974, 2010 303

Page 328: IMS Application Programming.pdf

are inserting segments, you cannot insert dependents unless the parents exist.If DL/I returns a GE status code, at least one of the parents does not exist.

v Keep the main section of the program logic together. For example, branch toconditional routines, such as error and print routines, in other parts of theprogram, instead of having to branch around them to continue normalprocessing.

v Use call sequences that make good use of the physical placement of the data.Access segments in hierarchical sequence as much as possible. Avoid movingbackward in the hierarchy.

v Process database records in order of the key field of the root segments. (ForHDAM databases, this order depends on the randomizing routine that is used.Check with your DBA for this information.)

v Try to avoid constructing the logic of the program and the structure ofcommands or calls in a way that depends heavily on the database structure.Depending on the current structure of the hierarchy reduces the program'sflexibility.

Coding a program in assembler languageThe following sample is a CICS online program that is written in assemblerlanguage. It shows how the different parts of a command-level program fittogether and how the EXEC DLI commands are coded.

Except for a few commands, this program applies to batch, BMP, and CICSprograms. Any differences are highlighted in the notes for the sample assemblercode. The numbering on the right of the sample code references these notes.*ASM XOPTS(CICS,DLI)* �1�R2 EQU 2R3 EQU 3R4 EQU 4R11 EQU 11R12 EQU 12R13 EQU 13DFHEISTG DSECTSEGKEYA DS CL4SEGKEYB DS CL4 �2�SEGKEYC DS CL4SEGKEY1 DS CL4SEGKEY2 DS CL4CONKEYB DS CL8SEGNAME DS CL8SEGLEN DS HPCBNUM DS HAREAA DS CL80AREAB DS CL80 �3�AREAC DS CL80AREAG DS CL250AREASTAT DS CL360* COPY MAPSET********************************************************************* INITIALIZATION* HANDLE ERROR CONDITIONS IN ERROR ROUTINE �4�* HANDLE ABENDS (DLI ERROR STATUS CODES) IN ABEND ROUTINE* RECEIVE INPUT MESSAGE********************************************************************SAMPLE DFHEIENT CODEREG=(R2,R3),DATAREG=(R13,R12),EIBREG=R11 �5�*

EXEC CICS HANDLE CONDITION ERROR(ERRORS) �6�

304 Application Programming Guide

Page 329: IMS Application Programming.pdf

*EXEC CICS HANDLE ABEND LABEL(ABENDS) �6�

*EXEC CICS RECEIVE MAP (’SAMPMAP’) MAPSET(’MAPSET’) �6�

* ANALYZE INPUT MESSAGE AND PERFORM NON-DLI PROCESSING********************************************************************* SCHEDULE PSB NAMED ’SAMPLE1’********************************************************************

EXEC DLI SCHD PSB(SAMPLE1) �7�BAL R4,TESTDIB CHECK STATUS

********************************************************************* RETRIEVE ROOT SEGMENT AND ALL ITS DEPENDENTS********************************************************************

MVC SEGKEYA,=C’A300’ �8�EXEC DLI GU USING PCB(1) SEGMENT(SEGA) INTO(AREAA) X

SEGLENGTH(80) WHERE(KEYA=SEGKEYA) FIELDLENGTH(4)BAL R4,TESTDIB CHECK STATUS

GNPLOOP EQU *EXEC DLI GNP USING PCB(1) INTO(AREAG) SEGLENGTH(250)CLC DIBSTAT,=C’GE’ LOOK FOR END �9�BE LOOPDONE DONE AT ’GE’BAL R4,TESTDIB CHECK STATUSB GNPLOOP

LOOPDONE EQU ********************************************************************** INSERT NEW ROOT SEGMENT********************************************************************

MVC AREAA,=CL80’DATA FOR NEW SEGMENT INCLUDING KEY’EXEC DLI ISRT USING PCB(1) SEGMENT(SEGA) FROM(AREAA) X

SEGLENGTH(80)BAL R4,TESTDIB CHECK STATUS

********************************************************************* RETRIEVE 3 SEGMENTS IN PATH AND REPLACE THEM********************************************************************

MVC SEGKEYA,=C’A200’MVC SEGKEYB,=C’B240’MVC SEGKEYC,=C’C241’EXEC DLI GU USING PCB(1) X

SEGMENT(SEGA) WHERE(KEYA=SEGKEYA) X�10�FIELDLENGTH(4) XINTO(AREAA) XSEGLENGTH(80) XSEGMENT(SEGB) WHERE(KEYB=SEGKEYB) FIELDLENGTH(4) XINTO(AREAB) XSEGLENGTH(80) XSEGMENT(SEGC) WHERE(KEYC=SEGKEYC) FIELDLENGTH(4) XINTO(AREAC) XSEGLENGTH(80)

BAL R4,TESTDIB* UPDATE FIELDS IN THE 3 SEGMENTS

EXEC DLI REPL USING PCB(1) XSEGMENT(SEGA) FROM(AREAA) SEGLENGTH(80) XSEGMENT(SEGB) FROM(AREAB) SEGLENGTH(80) XSEGMENT(SEGC) FROM(AREAC) SEGLENGTH(80)

BAL R4,TESTDIB CHECK STATUS********************************************************************* INSERT NEW SEGMENT USING CONCATENATED KEY TO QUALIFY PARENT*******************************************************************

Chapter 17. Writing your application programs for EXEC DLI 305

Page 330: IMS Application Programming.pdf

*MVC AREAC,=CL80’DATA FOR NEW SEGMENT INCLUDING KEY’MVC CONKEYB,=C’A200B240’EXEC DLI ISRT USING PCB(1) X

SEGMENT(SEGB) KEYS(CONKEYB) KEYLENGTH(8) XSEGMENT(SEGC) FROM(AREAC) SEGLENGTH(80)

BAL R4,TESTDIB CHECK STATUS********************************************************************* RETRIEVE SEGMENT DIRECTLY USING CONCATENATED KEY* AND THEN DELETE IT AND ITS DEPENDENTS********************************************************************

MVC CONKEYB,=C’A200B230’EXEC DLI GU USING PCB(1) X

SEGMENT(SEGB) XKEYS(CONKEYB) KEYLENGTH(8) XINTO(AREAB) SEGLENGTH(80)

BAL R4,TESTDIB CHECK STATUSEXEC DLI DLET USING PCB(1) X

SEGMENT(SEGB) SEGLENGTH(80) FROM(AREAB)BAL R4,TESTDIB CHECK STATUS

********************************************************************* RETRIEVE SEGMENT BY QUALIFYING PARENT WITH CONCATENATED KEY,* OBJECT SEGMENT WITH WHERE OPTION USING A LITERAL,* AND THEN SET PARENTAGE** USE VARIABLES FOR PCB INDEX, SEGMENT NAME, AND SEGMENT LENGTH********************************************************************

MVC CONKEYB,=C’A200B230’MVC SEGNAME,=CL8’SEGA’MVC SEGLEN,=H’80’MVC PCBNUM,=H’1’EXEC DLI GU USING PCB(PCBNUM) X

SEGMENT((SEGNAME)) XKEYS(CONKEYB) KEYLENGTH(8) SETPARENT XSEGMENT(SEGC) INTO(AREAC) SEGLENGTH(SEGLEN) XWHERE(KEYC=’C520’)

BAL R4,TESTDIB CHECK STATUS********************************************************************* RETRIEVE DATABASE STATISTICS********************************************************************

EXEC DLI STAT USING PCB(1) INTO(AREASTAT) XVSAM FORMATTED LENGTH(360)

BAL R4,TESTDIB CHECK STATUS********************************************************************* RETRIEVE ROOT SEGMENT USING BOOLEAN OPERATORS********************************************************************

MVC SEGKEY1,=C’A050’MVC SEGKEY2,=C’A150’EXEC DLI GU USING PCB(1) SEGMENT(SEGA) INTO(AREAA) X

SEGLENGTH(80) FIELDLENGTH(4,4,4,4) XWHERE(KEYA > SEGKEY1 AND KEYA < SEGKEY2KEYA > ’A275’ AND KEYA < ’A350’)

BAL R4,TESTDIB CHECK STATUS********************************************************************* TERMINATE PSB WHEN DLI PROCESSING IS COMPLETED********************************************************************

EXEC DLI TERM �11�

306 Application Programming Guide

Page 331: IMS Application Programming.pdf

********************************************************************* SEND OUTPUT MESSAGE********************************************************************

EXEC CICS SEND MAP(’SAMPMAP’) MAPSET(’MAPSET’) �6�EXEC CICS WAIT TERMINAL

********************************************************************* COMPLETE TRANSACTION AND RETURN TO CICS********************************************************************

EXEC CICS RETURN �12�********************************************************************* CHECK STATUS IN DIB********************************************************************TESTDIB EQU *

CLC DIBSTAT,=C’ ’ IS STATUS BLANK �13�BER R4 YES - RETURN

* HANDLE DLI STATUS CODES REPRESENTING EXCEPTIONAL CONDITIONS*

BR R4 RETURNERRORS EQU ** HANDLE ERROR CONDITIONS*ABENDS EQU ** HANDLE ABENDS INCLUDING DLI ERROR STATUS CODES*

END

Notes for the sample assembler code:

�1�For a CICS online program containing EXEC DLI commands, you mustspecify the DLI and CICS options. For a batch or BMP program containingEXEC DLI, you must specify only the DLI option.�2�For reentry, define each of the areas the program uses—I/O areas, keyfeedback areas, and segment name areas in DFHEISTG.�3�Define an I/O area for each segment you retrieve, add, or replace (in asingle command).�4�For a batch or BMP program containing EXEC DLI, you must save registerson entry and restore registers on exit according to z/OS register-savingconventions.�5�In a batch or BMP program, a DFHEIENT saves the registers on entry. Donot specify the EIBREG parameter in a batch program.�6�Do not code EXEC CICS commands in a batch or BMP program.�7�In a CICS online program, use the SCHD PSB command to obtain a PSB forthe use of your program. Do not schedule a PSB in a batch or BMP program.�8�This GU command retrieves the first occurrence of SEGA with a key of A300.You do not have to provide the KEYLENGTH or SEGLENGTH options in anassembler language program.�9�This GNP command retrieves all dependents under segment SEGA. The GEstatus code indicates that no more dependents exist.�10�This GU command is an example of a path command. Use a separate I/Oarea for each segment you retrieve.�11�In a CICS online program, the TERM command terminates the PSBscheduled earlier. You do not terminate the PSB in a batch or BMP program.

Chapter 17. Writing your application programs for EXEC DLI 307

Page 332: IMS Application Programming.pdf

�12�For a batch or BMP program, code DFHEIRET with an optional RCREGparameter instead of EXEC CICS RETURN. The RCREG parameter identifies aregister containing the return code.�13�After issuing each command, you should check the status code in the DIB.

Coding a program in COBOLThe following sample program is written in COBOL. It shows how the differentparts of a command-level program fit together, and how the EXEC DLI commandsare coded. The sample program applies to the COBOL V4 compiler (5734-CB2), theOS/VS COBOL compiler (5740-CB1), IBM COBOL for z/OS & VM (5688-197), andthe VS COBOL II compiler (5668-958 and 5668-940).

Except for a few commands, this program applies to batch, BMP, and CICSprograms. Any differences are highlighted in the notes for the sample COBOLcode. The numbering on the right of the sample code references the notes.CBL LIB,APOST,XOPTS(CICS,DLI) IDENTIFICATION DIVISION.

PROGRAM-ID. SAMPLE. �1�ENVIRONMENT DIVISION.CONFIGURATION SECTION.

.* SOURCE-COMPUTER. IBM-370.

.* OBJECT-COMPUTER. IBM-370.DATA DIVISION.WORKING-STORAGE SECTION.77 SEGKEYA PIC X(4).77 SEGKEYB PIC X(4). �2�77 SEGKEYC PIC X(4).77 SEGKEY1 PIC X(4).77 SEGKEY2 PIC X(4).77 SEGKEY3 PIC X(4).77 SEGKEY4 PIC X(4).77 CONKEYB PIC X(8).77 SEGNAME PIC X(8).77 SEGLEN COMP PIC S9(4).77 PCBNUM COMP PIC S9(4).01 AREAA PIC X(80).* DEFINE SEGMENT I/O AREA01 AREAB PIC X(80).01 AREAC PIC X(80). �3�01 AREAG PIC X(250).01 AREASTAT PIC X(360).* COPY MAPSET.PROCEDURE DIVISION.** **************************************************************** INITIALIZATION* HANDLE ERROR CONDITIONS IN ERROR ROUTINE* HANDLE ABENDS (DLI ERROR STATUS CODES) IN ABEND ROUTINE* RECEIVE INPUT MESSAGE* ****************************************************************

EXEC CICS HANDLE CONDITION ERROR(ERRORS) END-EXEC. �4�*

EXEC CICS HANDLE ABEND LABEL(ABENDS) END-EXEC. �4�*

EXEC CICS RECEIVE MAP (’SAMPMAP’) MAPSET(’MAPSET’) END-EXEC. �4�* ANALYZE INPUT MESSAGE AND PERFORM NON-DLI PROCESSING** **************************************************************** SCHEDULE PSB NAMED ’SAMPLE1’* ****************************************************************

EXEC DLI SCHD PSB(SAMPLE1) END-EXEC.PERFORM TEST-DIB THRU OK. �5�

308 Application Programming Guide

Page 333: IMS Application Programming.pdf

** **************************************************************** RETRIEVE ROOT SEGMENT AND ALL ITS DEPENDENTS* ****************************************************************

MOVE ’A300’ TO SEGKEYA.EXEC DLI GU USING PCB(1) SEGMENT(SEGA) INTO(AREAA)

SEGLENGTH(80) WHERE(KEYA=SEGKEYA) �6�FIELDLENGTH(4)

END-EXEC.PERFORM TEST-DIB THRU OK.

GNPLOOP.EXEC DLI GNP USING PCB(1) INTO(AREAG) SEGLENGTH(250)END-EXEC.IF DIBSTAT EQUAL TO ’GE’ THEN GO TO LOOPDONE.PERFORM TEST-DIB THRU OK.GO TO GNPLOOP.

LOOPDONE.*

* **************************************************************** INSERT NEW ROOT SEGMENT* ****************************************************************

MOVE ’DATA FOR NEW SEGMENT INCLUDING KEY’ TO AREAA.EXEC DLI ISRT USING PCB(1) SEGMENT(SEGA) FROM(AREAA)

SEGLENGTH(80) END-EXEC.PERFORM TEST-DIB THRU OK.

** **************************************************************** RETRIEVE 3 SEGMENTS IN PATH AND REPLACE THEM* ****************************************************************

MOVE ’A200’ TO SEGKEYA.MOVE ’B240’ TO SEGKEYB.MOVE ’C241’ TO SEGKEYC.EXEC DLI GU USING PCB(1)

SEGMENT(SEGA) WHERE(KEYA=SEGKEYA) FIELDLENGTH(4) �7�INTO(AREAA)SEGLENGTH(80)

SEGMENT(SEGB) WHERE(KEYB=SEGKEYB) FIELDLENGTH(4)INTO(AREAB)SEGLENGTH(80)

SEGMENT(SEGC) WHERE(KEYC=SEGKEYC) FIELDLENGTH(4)INTO(AREAC)SEGLENGTH(80)

END-EXEC.PERFORM TEST-DIB THRU OK.

* UPDATE FIELDS IN THE 3 SEGMENTSEXEC DLI REPL USING PCB(1)

SEGMENT(SEGA) FROM(AREAA) SEGLENGTH(80)SEGMENT(SEGB) FROM(AREAB) SEGLENGTH(80)SEGMENT(SEGC) FROM(AREAC) SEGLENGTH(80)

END-EXEC.PERFORM TEST-DIB THRU OK.

** **************************************************************** INSERT NEW SEGMENT USING CONCATENATED KEY TO QUALIFY PARENT* ****************************************************************

MOVE ’DATA FOR NEW SEGMENT INCLUDING KEY’ TO AREAC.MOVE ’A200B240’ TO CONKEYB.EXEC DLI ISRT USING PCB(1)

SEGMENT(SEGB) KEYS(CONKEYB) KEYLENGTH(8)SEGMENT(SEGC) FROM(AREAC) SEGLENGTH(80)

END-EXEC.PERFORM TEST-DIB THRU OK.

*

Chapter 17. Writing your application programs for EXEC DLI 309

Page 334: IMS Application Programming.pdf

* **************************************************************** RETRIEVE SEGMENT DIRECTLY USING CONCATENATED KEY* AND THEN DELETE IT AND ITS DEPENDENTS* ****************************************************************

MOVE ’A200B230’ TO CONKEYB.EXEC DLI GU USING PCB(1)

SEGMENT(SEGB)KEYS(CONKEYB) KEYLENGTH(8)INTO(AREAB) SEGLENGTH(80)

END-EXEC.PERFORM TEST-DIB THRU OK.EXEC DLI DLET USING PCB(1)

SEGMENT(SEGB) SEGLENGTH(80) FROM(AREAB) END-EXEC.PERFORM TEST-DIB THRU OK.

** ***************************************************************

* RETRIEVE SEGMENT BY QUALIFYING PARENT WITH CONCATENATED KEY,* OBJECT SEGMENT WITH WHERE OPTION,* AND THEN SET PARENTAGE** USE VARIABLES FOR PCB INDEX, SEGMENT NAME, AND SEGMENT LENGTH* ****************************************************************

MOVE ’A200B230’ TO CONKEYB.MOVE ’C520’ TO SEGKEYC.MOVE ’SEGA’ TO SEGNAME.MOVE 80 TO SEGLEN.MOVE 1 TO PCBNUM.EXEC DLI GU USING PCB(PCBNUM)

SEGMENT((SEGNAME))KEYS(CONKEYB) KEYLENGTH(8) SETPARENT

SEGMENT(SEGC) INTO(AREAC) SEGLENGTH(SEGLEN)WHERE(KEYC=SEGKEYC) FIELDLENGTH(4) END-EXEC.

PERFORM TEST-DIB THRU OK.** **************************************************************** RETRIEVE DATABASE STATISTICS* ****************************************************************

EXEC DLI STAT USING PCB(1) INTO(AREASTAT)VSAM FORMATTED LENGTH(360) END-EXEC.

PERFORM TEST-DIB THRU OK.** **************************************************************** RETRIEVE ROOT SEGMENT USING BOOLEAN OPERATORS* ****************************************************************

MOVE ’A050’ TO SEGKEY1.MOVE ’A150’ TO SEGKEY2.MOVE ’A275’ TO SEGKEY3.MOVE ’A350’ TO SEGKEY4.EXEC DLI GU USING PCB(1) SEGMENT(SEGA) INTO(AREAA)

SEGLENGTH(80) FIELDLENGTH(4,4,4,4)WHERE(KEYA > SEGKEY1 AND KEYA < SEGKEY2 OR

KEYA > SEGKEY3 AND KEYA < SEGKEY4)END-EXEC.PERFORM TEST-DIB THRU OK.

** ***************************************************************

* TERMINATE PSB WHEN DLI PROCESSING IS COMPLETED* ****************************************************************

EXEC DLI TERM END-EXEC. �8�** **************************************************************** ***************************************************************

310 Application Programming Guide

Page 335: IMS Application Programming.pdf

* SEND OUTPUT MESSAGE* ****************************************************************

EXEC CICS SEND MAP(’SAMPMAP’) MAPSET(’MAPSET’) END-EXEC.EXEC CICS WAIT TERMINAL END-EXEC.

** **************************************************************** COMPLETE TRANSACTION AND RETURN TO CICS* ****************************************************************

EXEC CICS RETURN END-EXEC.** **************************************************************** CHECK STATUS IN DIB* ****************************************************************TEST-DIB.

IF DIBSTAT EQUAL TO ’ ’ THEN GO TO OK.OK. �9�ERRORS.* HANDLE ERROR CONDITIONSABENDS.* HANDLE ABENDS INCLUDING DLI ERROR STATUS CODES

Notes for the sample COBOL code:

�1�For a CICS online program containing EXEC DLI commands, you mustspecify the DLI and CICS options. For a batch or BMP program containingEXEC DLI, you must specify only the DLI option.�2� Define each of the areas the program uses—I/O areas, key feedback areas,and segment name areas—as 77- or 01-level working storage entries.�3�Define an I/O area for each segment you retrieve, add, or replace (in asingle command).�4�Do not code EXEC CICS commands in a batch or BMP program.�5�For CICS online programs, you use a SCHD PSB command to obtain a PSB.You do not schedule a PSB in a batch or BMP program.�6�This GU command retrieves the first occurrence of SEGA with a key of A300.KEYLENGTH and SEGLENGTH are optional for IBM COBOL for z/OS & VM(and VS COBOL II). For COBOL V4 and OS/VS COBOL, KEYLENGTH andSEGLENGTH are required.�7�This GU command is an example of a path command. You must use aseparate I/O area for each segment you retrieve.�8�For a CICS online program, the TERM command terminates the PSBscheduled earlier. You do not terminate the PSB in a batch or BMP program.�9�After issuing each command, you should check the status code in the DIB.

Coding a program in PL/IThe following sample program is written in PL/I. It shows how the different partsof a command-level program fit together and how the EXEC DLI commands arecoded.

Except for a few commands, this program applies to batch, BMP, and CICSprograms. Any differences are highlighted in the notes for the sample PL/I code.The numbering on the right of the sample code references those notes.*PROCESS INCLUDE,GN,XOPTS(CICS,DLI); �1�SAMPLE: PROCEDURE OPTIONS(MAIN);DCL SEGKEYA CHAR (4);DCL SEGKEYB CHAR (4); �2�

Chapter 17. Writing your application programs for EXEC DLI 311

Page 336: IMS Application Programming.pdf

DCL SEGKEYC CHAR (4);DCL SEGKEY1 CHAR (4);DCL SEGKEY2 CHAR (4);DCL SEGKEY3 CHAR (4);DCL SEGKEY4 CHAR (4);DCL CONKEYB CHAR (8);DCL SEGNAME CHAR (8);DCL PCBNUM FIXED BIN (15);DCL AREAA CHAR (80);

/* DEFINE SEGMENT I/O AREA */DCL AREAB CHAR (80);DCL AREAC CHAR (80); �3�DCL AREAG CHAR (250);DCL AREASTAT CHAR (360);

%INCLUDE MAPSET/* *//* *//* ************************************************************ *//* INITIALIZATION *//* HANDLE ERROR CONDITIONS IN ERROR ROUTINE *//* HANDLE ABENDS (DLI ERROR STATUS CODES) IN ABEND PROGRAM *//* RECEIVE INPUT MESSAGE *//* ************************************************************ *//* */EXEC CICS HANDLE CONDITION ERROR(ERRORS); �4�/* */EXEC CICS HANDLE ABEND PROGRAM(’ABENDS’); �4�/* */EXEC CICS RECEIVE MAP (’SAMPMAP’) MAPSET(’MAPSET’); �4�/* ANALYZE INPUT MESSAGE AND PERFORM NON-DLI PROCESSING *//* *//* ************************************************************ *//* SCHEDULE PSB NAMED ’SAMPLE1’ *//* ************************************************************ *//* */EXEC DLI SCHD PSB(SAMPLE1);CALL TEST_DIB; �5�

/* ************************************************************* *//* RETRIEVE ROOT SEGMENT AND ALL ITS DEPENDENTS *//* ************************************************************* *//* */SEGKEYA = ’A300’;EXEC DLI GU USING PCB(1) SEGMENT(SEGA) INTO(AREAA)WHERE(KEYA=SEGKEYA); �6�CALL TEST_DIB;

GNPLOOP:EXEC DLI GNP USING PCB(1) INTO(AREAG); �7�IF DIBSTAT = ’GE’ THEN GO TO LOOPDONE;CALL TEST_DIB;GO TO GNPLOOP;

LOOPDONE:/* *//* ************************************************************ *//* INSERT NEW ROOT SEGMENT *//* ************************************************************ *//* */AREAA = ’DATA FOR NEW SEGMENT INCLUDING KEY’;EXEC DLI ISRT USING PCB(1) SEGMENT(SEGA) FROM(AREAA);CALL TEST_DIB;/* *//* ************************************************************* *//* RETRIEVE 3 SEGMENTS IN PATH AND REPLACE THEM *//* ************************************************************* *//* */SEGKEYA = ’A200’;SEGKEYB = ’B240’;

312 Application Programming Guide

Page 337: IMS Application Programming.pdf

SEGKEYC = ’C241’;EXEC DLI GU USING PCB(1)

SEGMENT(SEGA) WHERE(KEYA=SEGKEYA) �8�INTO(AREAA)

SEGMENT(SEGB) WHERE(KEYB=SEGKEYB)INTO(AREAB)

SEGMENT(SEGC) WHERE(KEYC=SEGKEYC)INTO(AREAC);

CALL TEST_DIB;/* UPDATE FIELDS IN THE 3 SEGMENTS */EXEC DLI REPL USING PCB(1)

SEGMENT(SEGA) FROM(AREAA)SEGMENT(SEGB) FROM(AREAB)SEGMENT(SEGC) FROM(AREAC);

CALL TEST_DIB;/* *//* ************************************************************* *//* INSERT NEW SEGMENT USING CONCATENATED KEY TO QUALIFY PARENT *//* ************************************************************* *//* */AREAC = ’DATA FOR NEW SEGMENT INCLUDING KEY’;CONKEYB = ’A200B240’;EXEC DLI ISRT USING PCB(1)

SEGMENT(SEGB) KEYS(CONKEYB)SEGMENT(SEGC) FROM(AREAC);

CALL TEST_DIB;/* *//* ************************************************************ *//* RETRIEVE SEGMENT DIRECTLY USING CONCATENATED KEY *//* AND THEN DELETE IT AND ITS DEPENDENTS *//* ************************************************************ *//* */CONKEYB = ’A200B230’;EXEC DLI GU USING PCB(1)

SEGMENT(SEGB)KEYS(CONKEYB)INTO(AREAB);

CALL TEST_DIB;EXEC DLI DLET USING PCB(1)

SEGMENT(SEGB) FROM(AREAB);CALL TEST_DIB;/* */

/* ************************************************************* *//* RETRIEVE SEGMENT BY QUALIFYING PARENT WITH CONCATENATED KEY, *//* OBJECT SEGMENT WITH WHERE OPTION *//* AND THEN SET PARENTAGE *//* *//* USE VARIABLES FOR PCB INDEX, SEGMENT NAME *//* ************************************************************* *//* */CONKEYB = ’A200B230’;SEGNAME = ’SEGA’;SEGKEYC = ’C520’;PCBNUM = 1;EXEC DLI GU USING PCB(PCBNUM)

SEGMENT((SEGNAME))KEYS(CONKEYB) SETPARENT

SEGMENT(SEGC) INTO(AREAC)WHERE(KEYC=SEGKEYC);

CALL TEST_DIB;/* *//* ************************************************************* *//* RETRIEVE DATABASE STATISTICS *//* ************************************************************* *//* */EXEC DLI STAT USING PCB(1) INTO(AREASTAT) VSAM FORMATTED;CALL TEST_DIB;

Chapter 17. Writing your application programs for EXEC DLI 313

Page 338: IMS Application Programming.pdf

/* *//* ************************************************************ *//* RETRIEVE ROOT SEGMENT USING BOOLEAN OPERATORS *//* ************************************************************ *//* */SEGKEY1 = ’A050’;SEGKEY2 = ’A150’;SEGKEY3 = ’A275’;SEGKEY4 = ’A350’;EXEC DLI GU USING PCB(1) SEGMENT(SEGA) INTO(AREAA)

WHERE(KEYA &Ar; SEGKEY1 AND KEYA &Al; SEGKEY2 ORKEYA &Ar; SEGKEY3 AND KEYA &Al; SEGKEY4);

CALL TEST_DIB;/* *//* ************************************************************* *//* TERMINATE PSB WHEN DLI PROCESSING IS COMPLETED *//* ************************************************************* *//* */

EXEC DLI TERM;�9�

/* *//* ************************************************************* *//* SEND OUTPUT MESSAGE *//* ************************************************************* *//* */EXEC CICS SEND MAP(’SAMPMAP’) MAPSET(’MAPSET’); �4�EXEC CICS WAIT TERMINAL;/* *//* ************************************************************* *//* COMPLETE TRANSACTION AND RETURN TO CICS *//* ************************************************************* *//* */EXEC CICS RETURN; �4�/* *//* ************************************************************ *//* CHECK STATUS IN DIB *//* ************************************************************ *//* */

TEST_DIB: PROCEDURE;IF DIBSTAT = ’ ’ RETURN; �10�

/* HANDLE DLI STATUS CODES REPRESENTING EXCEPTIONAL CONDITIONS *//* */

OK:END TEST_DB;ERRORS:

/* HANDLE ERROR CONDITIONS *//* */

END SAMPLE;

Notes to the sample PL/I code:

�1�For a CICS online program containing EXEC DLI commands, you mustspecify the DLI and CICS options. For a batch or BMP program containingEXEC DLI, you must specify only the DLI option.�2�Define, in automatic storage, each of the areas; I/O areas, key feedbackareas, and segment name areas.�3�Define an I/O area for each segment you retrieve, add, or replace in a singlecommand.�4�Do not code EXEC CICS commands in a batch or BMP program.�5�For CICS online programs, you use a SCHD PSB command to obtain a PSB.You do not schedule a PSB in a batch or BMP program.

314 Application Programming Guide

Page 339: IMS Application Programming.pdf

�6�This GU command retrieves the first occurrence of SEGA with a key of A300.Notice that you do not need to include the KEYLENGTH and SEGLENGTHoptions.�7�This GNP command retrieves all dependents under segment SEGA. The GEstatus code indicates that no more dependents exist.�8�This GU command is an example of a path command. You must use aseparate I/O area for each segment you retrieve.�9�For a CICS online program, the TERM command terminates the PSBscheduled earlier. You do not terminate the PSB in a batch or BMP program.�10�After issuing each command, you should check the status code in the DIB.

Coding a program in CThe following sample program is written in C. It shows how the different parts ofa command-level program fit together and how the EXEC DLI commands arecoded.

Except for a few commands, this program applies to batch, BMP, and CICSprograms. Any differences are highlighted in the notes for the sample C code. Thenumbering on the right of the sample code references those notes.#include < string.h> �1�#include < stdio.h > �2�

char DIVIDER[120] = "-----------------------------------------\------------------------------------------------------------------";

char BLANK[120] = " \\0";

char BLAN2[110] = " \\0";

char SCHED[120] = "Schedule PSB(PC3COCHD) " �3�char GN1[120] = "GN using PCB(2) Segment(SE2ORDER) check dibstat \

is blank";char GNP1[120] = "GNP using PCB(2) check dibstat = GK or blank \

(or GE for last GNP)";char GU1[120] = "GU using PCB(2) Segment(SE2ORDER) where(\

FE2OGREF=000000’’) check dibstat blank";char GU2[120] = "GU using PCB(2) Segment(SE2ORDER) where(\

FE2OGREF=000999’’) check dibstat blank";char REP1[120] = "REPLACE using PCB(2) Segment(SE2ORDER) check \

dibstat is blank";char DEL1[120] = "DELETE using PCB(2) Segment(SE2ORDER) check \

dibstat is blank";char INS1[120] = "INSERT using PCB(2) Segment(SE2ORDER) where\

(FE2OGREF=’’000999’’) check dibstat is blank";char TERM[120] = "TERM - check dibstat is blank";char STAT[120] = "STAT USING PCB(2) VSAM FORMATTED";char DATAB[6] = "000999";char DATAC[114] = " REGRUN TEST INSERT NO1.";char START[120] = "PROGXIV STARTING";char OKMSG[120] = "PROGXIV COMPLETE";int TLINE = 120;int L11 = 11;int L360 = 11;struct {

char NEWSEGB[6];char NEWSEGC[54];

} NEWSEG;char OUTLINE[120]; �4�struct {

char OUTLINA[9];char OUTLINB[111];

} OUTLIN2;

Chapter 17. Writing your application programs for EXEC DLI 315

Page 340: IMS Application Programming.pdf

struct {char OUTLINX[9];char OUTLINY[6];char OUTLINZ[105];

} OUTLIN3;char GUIOA[60];char GNIOA[60];struct {

char ISRT1[6];char ISRT2[54];

} ISRTIOA;struct {

char REPLIO1[6];char REPLIO2[54];

} REPLIOA;struct {

char DLET1[6];char DLET2[54];

} DLETIOA;struct {

char STATA1[120];char STATA2[120];char STATA3[120];

} STATAREA;struct {

char DHPART[2];char RETCODE[2]

} DHABCODE;

main(){

EXEC CICS ADDRESS EIB(dfheiptr); �5�strcpy(OUTLINE,DIVIDER);SENDLINE();strcpy(OUTLINE,START);SENDLINE();

/* *//* SCHEDULE PSB *//* */

strcpy(OUTLINE,SCHED);SENDLINE();EXEC DLI SCHEDULE PSB(PC3COCHD); �6�SENDSTAT();TESTDIB();

/* *//* ISSUE GU REQUEST *//* */

strcpy(OUTLINE,GU1);SENDLINE();EXEC DLI GET UNIQUE USING PCB(2) �7�

SEGMENT(SE2ORDER)WHERE(FE2OGREF>="000000")INTO(&GUIOA) SEGLENGTH(60);

strcpy(OUTLIN2.OUTLINA,"SE2ORDER=");strcpy(OUTLIN2.OUTLINB,GUIOA);SENDLIN2();SENDSTAT();TESTDIB();

/* *//* ISSUE GNP REQUEST *//* */

do {strcpy(OUTLINE,GNP1);SENDLINE();EXEC DLI GET NEXT IN PARENT USING PCB(2) �8�

INTO(&GNIOA) SEGLENGTH(60);strcpy(OUTLIN2.OUTLINA,"SEGMENT=");

316 Application Programming Guide

Page 341: IMS Application Programming.pdf

strcpy(OUTLIN2.OUTLINB,GNIOA);SENDLIN2();SENDSTAT();if (strncmp(dibptr->dibstat,"GE",2) != 0) �9�

TESTDIB();} while (strncmp(dibptr->dibstat,"GE",2) != 0);

/* *//* ISSUE GN REQUEST *//* */

strcpy(OUTLINE,GN1);SENDLINE();EXEC DLI GET NEXT USING PCB(2)

SEGMENT(SE2ORDER) �10�INTO(&GNIOA) SEGLENGTH(60);

strcpy(OUTLIN2.OUTLINA,"SE2ORDER=");strcpy(OUTLIN2.OUTLINB,GNIOA);SENDLIN2();SENDSTAT();TESTDIB();

/* *//* INSERT SEGMENT *//* */

strcpy(OUTLINE,INS1);SENDLINE();strcpy(NEWSEG.NEWSEGB,DATAB); �11�strcpy(NEWSEG.NEWSEGC,DATAC);strcpy(ISRTIOA.ISRT1,NEWSEG.NEWSEGB);strcpy(ISRTIOA.ISRT2,NEWSEG.NEWSEGC);strcpy(OUTLIN3.OUTLINX,"ISRT SEG=");strcpy(OUTLIN3.OUTLINY,ISRTIOA.ISRT1);strcpy(OUTLIN3.OUTLINZ,ISRTIOA.ISRT2);SENDLIN3();EXEC DLI ISRT USING PCB(2)

SEGMENT(SE2ORDER)FROM(&ISRTIOA) SEGLENGTH(60);

SENDSTAT();if (strncmp(dibptr->dibstat,"II",2) == 0)

strncpy(dibptr->dibstat," ",2);TESTDIB();

/* *//* ISSUE GN REQUEST *//* */

strcpy(OUTLINE,GN1);SENDLINE();EXEC DLI GET NEXT USING PCB(2) �12�

SEGMENT(SE2ORDER)INTO(&GNIOA) SEGLENGTH(60);

strcpy(OUTLIN2.OUTLINA,"SE2ORDER=");strcpy(OUTLIN2.OUTLINB,GNIOA);SENDLIN2();SENDSTAT();TESTDIB();

/* *//* GET INSERTED SEGMENT TO BE REPLACED *//* */

strcpy(OUTLINE,GU2);SENDLINE();EXEC DLI GET UNIQUE USING PCB(2) �13�

SEGMENT(SE2ORDER)WHERE(FE2OGREF="000999")INTO(&ISRTIOA) SEGLENGTH(60);

strcpy(OUTLIN3.OUTLINX,"ISRT SEG=");strcpy(OUTLIN3.OUTLINY,ISRTIOA.ISRT1);strcpy(OUTLIN3.OUTLINZ,ISRTIOA.ISRT2);SENDLIN3();SENDSTAT();TESTDIB();

Chapter 17. Writing your application programs for EXEC DLI 317

Page 342: IMS Application Programming.pdf

/* *//* REPLACE SEGMENT *//* */

strcpy(OUTLINE,REP1);SENDLINE();strcpy(REPLIOA.REPLIO1,DATAB); �14�strcpy(REPLIOA.REPLIO2,"REGRUN REPLACED SEGMENT NO1.");strcpy(OUTLIN3.OUTLINX,"REPL SEG=");strcpy(OUTLIN3.OUTLINY,REPLIOA.REPLIO1);strcpy(OUTLIN3.OUTLINZ,REPLIOA.REPLIO2);SENDLIN3();EXEC DLI REPLACE USING PCB(2)

SEGMENT(SE2ORDER)FROM(&REPLIOA) SEGLENGTH(60);

SENDSTAT();TESTDIB();

/* *//* ISSUE GN REQUEST *//* */

strcpy(OUTLINE,GN1);SENDLINE();EXEC DLI GET NEXT USING PCB(2) �15�

SEGMENT(SE2ORDER)INTO(&GNIOA) SEGLENGTH(60);

strcpy(OUTLIN2.OUTLINA,"SE2ORDER=");strcpy(OUTLIN2.OUTLINB,GNIOA);SENDLIN2();SENDSTAT();TESTDIB();

/* *//* GET REPLACED SEGMENT *//* */

strcpy(OUTLINE,GU2);SENDLINE();EXEC DLI GET UNIQUE USING PCB(2) �16�

SEGMENT(SE2ORDER)WHERE(FE2OGREF="000999")INTO(&REPLIOA) SEGLENGTH(60);

strcpy(OUTLIN3.OUTLINX,"REPL SEG=");strcpy(OUTLIN3.OUTLINY,REPLIOA.REPLIO1);strcpy(OUTLIN3.OUTLINZ,REPLIOA.REPLIO2);SENDLIN3();SENDSTAT();TESTDIB();

/* *//* ISSUE DELETE REQUEST *//* */

strcpy(OUTLINE,DEL1);SENDLINE();strcpy(DLETIOA.DLET1,REPLIOA.REPLIO1); �17�strcpy(DLETIOA.DLET2,REPLIOA.REPLIO2);strcpy(OUTLIN3.OUTLINX,"DLET SEG=");strcpy(OUTLIN3.OUTLINY,DLETIOA.DLET1);strcpy(OUTLIN3.OUTLINZ,DLETIOA.DLET2);SENDLIN3();EXEC DLI DELETE USING PCB(2)

SEGMENT(SE2ORDER)FROM(&DLETIOA) SEGLENGTH(60);

SENDSTAT();TESTDIB();

/* *//* ISSUE STAT REQUEST *//* */

strcpy(OUTLINE,STAT);SENDLINE();EXEC DLI STAT USING PCB(2) �18�

VSAM FORMATTED

318 Application Programming Guide

Page 343: IMS Application Programming.pdf

INTO(&STATAREA);SENDSTT2();TESTDIB();

/* *//* ISSUE TERM REQUEST *//* */

strcpy(OUTLINE,TERM);SENDLINE();EXEC DLI TERM; �19�SENDSTAT();TESTDIB();strcpy(OUTLINE,DIVIDER);SENDLINE();SENDOK();

/* *//* RETURN TO CICS *//* */

EXEC CICS RETURN;}

/* *//* *//* */

SENDLINE(){

EXEC CICS SEND FROM(OUTLINE) LENGTH(120); �20�EXEC CICS WRITEQ TD QUEUE("PRIM") FROM(OUTLINE) LENGTH(TLINE);strcpy(OUTLINE,BLANK);return;

}

SENDLIN2(){

EXEC CICS SEND FROM(OUTLIN2) LENGTH(120);EXEC CICS WRITEQ TD QUEUE("PRIM") FROM(OUTLIN2) LENGTH(TLINE);strcpy(OUTLIN2.OUTLINA,BLANK,9);strcpy(OUTLIN2.OUTLINB,BLANK,111);return;

}

SENDLIN3(){

EXEC CICS SEND FROM(OUTLIN3) LENGTH(120);EXEC CICS WRITEQ TD QUEUE("PRIM") FROM(OUTLIN3) LENGTH(TLINE);strcpy(OUTLIN3.OUTLINX,BLANK,9);strcpy(OUTLIN3.OUTLINY,BLANK,6);strcpy(OUTLIN3.OUTLINZ,BLANK,105);return;

}

SENDSTAT(){

strncpy(OUTLIN2.OUTLINA,BLANK,9);strncpy(OUTLIN2.OUTLINB,BLAN2,110);strcpy(OUTLIN2.OUTLINA," DIBSTAT=");strcpy(OUTLIN2.OUTLINB,dibptr->dibstat);EXEC CICS SEND FROM(OUTLIN2) LENGTH(11);EXEC CICS WRITEQ TD QUEUE("PRIM") FROM(OUTLIN2) LENGTH(L11);strcpy(OUTLINE,DIVIDER);SENDLINE();return;

}

SENDSTT2(){

strncpy(OUTLIN2.OUTLINA,BLANK,9);strncpy(OUTLIN2.OUTLINB,BLAN2,110);strcpy(OUTLIN2.OUTLINA," DIBSTAT=");

Chapter 17. Writing your application programs for EXEC DLI 319

Page 344: IMS Application Programming.pdf

strcpy(OUTLIN2.OUTLINB,dibptr->dibstat);EXEC CICS SEND FROM(STATAREA) LENGTH(360);EXEC CICS WRITEQ TD QUEUE("PRIM") FROM(STATAREA)

LENGTH(L360);return;

}

SENDOK(){

EXEC CICS SEND FROM(OKMSG) LENGTH(120);EXEC CICS WRITEQ TD QUEUE("PRIM") FROM(OKMSG) LENGTH(TLINE);return;

}

TESTDIB() �21�{

if (strncmp(dibptr->dibstat," ",2) == 0)return;

else if (strncmp(dibptr->dibstat,"GK",2) == 0)return;

else if (strncmp(dibptr->dibstat,"GB",2) == 0)return;

else if (strncmp(dibptr->dibstat,"GE",2) == 0)return;

else{

EXEC CICS ABEND ABCODE("PETE"); �22�EXEC CICS RETURN;

}return;

}

Notes for the sample C code:

�1�You must include a standard header file string.h to gain access to stringmanipulation facilities.�2�You must include standard header file stdio.h to access the standard I/Olibrary.�3�Define DL/I messages.�4�Define the I/O areas.�5�Program start.�6�Define PSB PC3COCHD.�7�Issue the first command. Retrieves the first occurrence of segmentSE2ORDER and puts it into array OUTLIN2.�8�Issue the GNP command to get the next segment and put it into arrayOUTLIN2.�9�GE status codes indicate no more segments to get.�10�Get next segment SE2ORDER and put it into the array OUTLIN2.�11�Insert segment into array OUTLIN3.�12�Issue GN to retrieve next segment and put it into array OUTLIN2.�13�Get next segment that will be replaced and put it into OUTLIN3.�14�Replace the segment and put it into array OUTLIN3.�15�Get next segment and put it into array OUTLIN2.�16�Get the replaced segment and put it into array OUTLIN3.�17�Issue DELETE command after putting content of segment into arrayOUTLIN3.�18�Issue STAT REQUEST command.

320 Application Programming Guide

Page 345: IMS Application Programming.pdf

�19�Issue TERM command.�20�Output processing.�21�Check return code.�22�Do not code EXEC CICS commands in a batch or BMP program.

Preparing your EXEC DLI program for executionThe steps for preparing your program for execution are as follows:1. Run the CICS command language translator to translate the EXEC DLI and

EXEC CICS commands. COBOL, PL/I, and assembler language programs haveseparate translators.

2. Compile your program.3. Bind:v An online program with the appropriate CICS interface modulev A batch or BMP program with the IMS interface module.

You can use CICS-supplied procedures to translate, compile, and bind yourprogram. The procedure you use depends on the type of program (batch, BMP, orCICS online) and the language it is written in (COBOL, PL/I, or assemblerlanguage).

Translator options required for EXEC DLI

Even when you use the CICS-supplied procedures for preparing your program,you must supply certain translator options.

For a CICS online program containing EXEC DLI commands, you must specify theDLI and CICS options. For a batch or BMP program containing EXEC DLIcommands, you must specify the DLI option..

You can also specify the options on the EXEC job control statement that invokesthe translator; if you use both methods, the CBL and *PROCESS statementoverrides those in the EXEC statement. For more information on the translatoroptions, see CICS Transaction Server for z/OS V3.2 CICS Application ProgrammingGuide.

You must ensure that the translator options you use in a COBOL program do notconflict with the COBOL compiler options. When you translate an IBM COBOL forz/OS & VM program, you must use the COBOL for z/OS & VM translator option.Similarly, when you translate a VS COBOL II program, you must use the COBOL IItranslator option.

Compiler options required for EXEC DLIIf you want to compile your batch COBOL program with COBOL for z/OS & VMand then execute it AMODE(31) on z/OS, you must use the compiler optionRENT. If you want to compile your batch COBOL program with VS COBOL II andthen execute it AMODE(31) on z/OS, you must use the compiler options RES andRENT. For information on which compiler options should be used for a CICSprogram, see CICS Transaction Server for z/OS V3.2 CICS Application ProgrammingReference.

Chapter 17. Writing your application programs for EXEC DLI 321

Page 346: IMS Application Programming.pdf

Binder options required for EXEC DLI

If the compiler being used supports it, you can link a program written with EXECcommands as AMODE(31) RMODE(ANY).

322 Application Programming Guide

Page 347: IMS Application Programming.pdf

Chapter 18. Defining application program elements

This chapter describes how to use EXEC DLI commands with the applicationinterface block (AIB) and DL/I interface block (DIB). Defining feedback and I/Oareas is also discussed.

The following topics provide additional information:v “Specifying an application interface block (AIB)”v “Specifying the DL/I interface block (DIB)”v “Defining a key feedback area” on page 327v “Defining I/O areas” on page 327

Specifying an application interface block (AIB)EXEC DLI commands can use the AIB interface. For example, using the AIBinterface, the format for the GU command would be EXEC DLI GU AIB(aib), insteadof EXEC DLI GU USING PCB(n) using the PCB format.

With CICS Transaction Server 1.1 or later, the EXEC DLI commands in Chapter 19,“EXEC DLI commands for an application program,” on page 329 are supported inthe AIB format (as well as the PCB format).

With CICS Transaction Server 1.1 or later, and IMS/ESA® Version 5, the AIB-onlycommands, ICMD, RCMD, and GMSG are supported by using the EXEC DLIinterface.

The CICS EDF (execution diagnostic facility) debugging transaction supports AIBEXEC DLI requests, just as it handles PCB type requests.

AIB maskThe AIB mask must be supplied by the application and referenced in the EXEC callinstead of the PCB number (for example, EXEC DLI GU AIB(aib)).

The DIBSTAT field is set with a valid STATUS code when AIBRETRN =X'00000000' or X'00000900'. Applications should test AIBRETRN for any othervalues and respond accordingly.

CICS restrictions with AIB supportRestrictions due to function shipping include:v The AIBLEN field must be between 128 and 256 bytes. 128 is recommended.v LIST=NO must not be specified on any PCBs in the PSB.

Specifying the DL/I interface block (DIB)Each time your program executes a DL/I command, DL/I returns a status codeand other information to your program through the DL/I interface block (DIB),which is a subset of IMS PCB. Your program should check the status code to makesure the command executed successfully.

© Copyright IBM Corp. 1974, 2010 323

Page 348: IMS Application Programming.pdf

Each program's working storage contains its own DIB. The contents of the DIBreflect the status of the last DL/I command executed in that program. If theinformation in your program's DIB is required by another program used by yourtransaction, you must pass the information to that program.

To access fields in the DIB, use labels that are automatically generated in yourprogram by the translator.

Restriction: These labels are reserved; you must not redefine them.

In your COBOL, PL/I, assembler language, and C programs, some variable namesare mandatory.

For a COBOL program:DIBVER PICTURE X(2)DIBSTAT PICTURE X(2)DIBSEGM PICTURE X(8)DIBSEGLV PICTURE X(2)DIBKFBL PICTURE S9(4) COMPUTATIONALDIBDBDNM PICTURE X(8)DIBDBORG PICTURE X(8)

DIBVER CHAR(2)DIBSTAT CHAR(2)DIBSEGM CHAR(8)DIBSEGLV CHAR(2)DIBKFBL FIXED BINARY (15,0)DIBDBDNM CHAR(8)DIBDBORG CHAR(8)

For an assembler language program:DIBVER CL2DIBSTAT CL2DIBSEGM CL8DIBSEGLV CL2DIBKFBL HDIBDBDNM CL8DIBDBORG CL8

For a C program:unsigned char dibver {2} ;unsigned char dibstat {2} ;unsigned char dibsegm {8} ;unsigned char dibfic01 ;unsigned char dibfic02 ;unsigned char dibseglv {2} ;signed short int dibkfbl ;unsigned char dibdbdnm {8} ;unsigned char dibdborg {8} ;unsigned char dibfic03 {6} ;

The following notes explain the contents of each variable name. The name inparenthesis is the label used to access the contents.1. Translator Version (DIBVER)

This is the version of the DIB format your program is using. (DIBVER is usedfor documentation and problem determination.)

2. Status Codes (DIBSTAT)

DL/I places a 2-character status code in this field after executing each DL/Icommand. This code describes the results of the command.

324 Application Programming Guide

Page 349: IMS Application Programming.pdf

After processing a DL/I command, DL/I returns control to your program atthe next sequential instruction following the command. The first thing yourprogram should do after each command is to test the status code field and takeappropriate action. If the command was completely successful, this fieldcontains blanks.The status codes that can be returned to this field (they are the only statuscodes returned to your program) are:

�� (Blanks) The command was completely successful.

BA For GU, GN, GNP, DLET, REPL, and ISRT commands. Data was unavailable.

BC For DLET, REPL, and ISRT commands. A deadlock was detected.

FH For GU, GN, GNP, DLET, REPL, ISRT, POS, CHKP, and SYMCHKP commands. TheDEDB was inaccessible.

FW For GU, GN, GNP, DLET, REPL, ISRT, and POS commands. More buffer spaceis required than normally allowed.

GA For unqualified GN and GNP commands. DL/I returned a segment, butthe segment is at a higher level in the hierarchy than the last segmentthat was returned.

GB For GN commands. DL/I reached the end of the database trying tosatisfy your GN command and did not return a segment to yourprogram's I/O area.

GD For ISRT commands. The program issued an ISRT command that didnot have SEGMENT options for all levels above that of the segmentbeing inserted.

GE For GU, GN, GNP, ISRT, and STAT commands. DL/I was unable to find thesegment you requested, or one or more of the parents of the segmentyou are trying to insert.

GG For Get commands. DL/I returns a GG status code to a program with aprocessing option of GOT or GON when the segment that the programis trying to retrieve contains an invalid pointer.

GK For unqualified GN and GNP commands. DL/I returned a segment thatsatisfies an unqualified GN or GNP request, but the segment is of adifferent segment type (but at the same level) than the last segmentreturned.

II For ISRT commands. The segment you are trying to insert already existsin the database. This code can also be returned if you have notestablished a path for the segment before trying to insert it. Thesegment you are trying to insert might match a segment with the samekey in another hierarchy or database record.

LB For load programs only after issuing a LOAD command. The segmentyou are trying to load already exists in the database. DL/I returns thisstatus code only for segments with key fields.

NI For ISRT and REPL commands. The segment you are trying to insert orreplace requires a duplicate entry to be inserted in a secondary indexthat does not allow duplicate entries. This status code is returned forbatch programs that write log records to direct access storage. If a CICSprogram that does not log to disk encounters this condition, theprogram (transaction) is abnormally terminated.

Chapter 18. Defining application program elements 325

Page 350: IMS Application Programming.pdf

TG For TERM commands. The program tried to terminate a PSB when onewas not scheduled.

The listed 2 on page 324 indicate exceptional conditions, and are the only statuscodes returned to your program. All other status codes indicate error conditionsand cause your transaction or batch program to abnormally terminate. If youwant to pass control to an error routine from your CICS program, you can usethe CICS HANDLE ABEND command; the last 2 bytes of the abend code are theIMS status code that caused the abnormal termination. For more information onthe HANDLE ABEND command, see the application programming reference manualfor your version of CICS. Batch BMP programs abend with abend 1041.

3. Segment Name (DIBSEGM)

This is the name of the lowest-level segment successfully accessed. When aretrieval is successful, this field contains the name of the retrieved segment. Ifthe retrieval is unsuccessful, this field contains the last segment, along the pathto the requested segment, that satisfies the command.After issuing an XRST command, this field is either set to blanks (indicating asuccessful normal start), or a checkpoint ID (indicating the checkpoint ID fromwhich the program was restarted).You should test this field after issuing any of the following commands:v GNv GNPv GUv ISRTv LOADv RETRIEVEv XRST

4. Segment Level Number (DIBSEGLV)

This is the hierarchic level of the lowest-level segment retrieved. When IMS DBretrieves the segment you have requested, IMS DB places, in character format,the level number of that segment in this field. If you are issuing a pathcommand, IMS DB places the number of the lowest-level segment retrieved. IfIMS DB is unable to find the segment you have requested, it gives the levelnumber of the last segment it encountered that satisfied your command. This isthe lowest segment on the last path that IMS DB encountered while searchingfor the segment you requested.You should test this field after issuing any of the listed commands:v GNv GNPv GUv ISRTv LOADv RETRIEVE

5. Key Feedback Length (DIBKFBL)

This is a halfword field that contains the length of the concatenated key whenyou use the KEYFEEDBACK option with get commands. If your key feedbackarea is not long enough to contain the concatenated key, the key is truncated,and this area indicates the actual length of the full concatenated key.

6. Database Description Name (DIBDBDNM)

326 Application Programming Guide

Page 351: IMS Application Programming.pdf

This is the fullword field that contains the name of the DBD. The DBD is theDL/I control block that contains all information used to describe a database.The DIBDBDNM field is returned only on a QUERY command.

7. Database Organization (DIBDBORG)

This is the fullword field that names the type of database organization (HDAM,HIDAM, HISAM, HSAM, GSAM, SHSAM, INDEX, or DEDB) padded to theright with blanks. The DIBDBORG field is returned only on a QUERY command.

Defining a key feedback areaTo retrieve the concatenated key of a segment, you must define an area into whichthe key is placed. The concatenated key returned is that of the lowest-levelsegment retrieved. (The segment retrieved is indicated in the DIB by the DIBSEGMand DIBSEGLV fields.)

Specify the name of the area using the KEYFEEDBACK option on a GETcommand.

A concatenated key is made up of the key of a segment, plus the keys for all of itsparents. For example, say you requested the concatenated key of the ILLNESSsegment for January 2, 1988, for patient number 05142. 0514219880102 would bereturned to your key feedback field. This number includes the key field of theILLNESS segment, ILLDATE, concatenated to the key field of the PATIENTsegment, PATNO.

If you define an area that is not long enough to contain the entire concatenatedkey, the key is truncated.

Defining I/O areasYou use I/O areas to pass segments back and forth between your program and thedatabase. What an I/O area contains depends on the kind of command you areissuing:v When you retrieve a segment, DL/I places the segment you requested in the

I/O area.v When you add a new segment, you build the new segment in the I/O area

before issuing an ISRT command.v Before you modify a segment, you first retrieve the segment into the then issue

the DLET or REPL command.

Restriction: The I/O area must be long enough to contain the longest segment youretrieve from or add to the database. (Otherwise, you might experience storageoverlap.) If you are retrieving, adding, or replacing multiple segments in onecommand, you must define an I/O area for each segment.

As an example of what a segment looks like in your I/O area, say that youretrieved the ILLNESS segment for Robert James, who came to the clinic on March3, 1988. He was treated for strep throat. The data returned to your I/O area wouldlook like this:19880303STREPTHROA

COBOL I/O areaThe I/O area in a COBOL program should be defined as a 01 level workingstorage entry. You can further define the area with 02 entries.

Chapter 18. Defining application program elements 327

Page 352: IMS Application Programming.pdf

IDENTIFICATION DIVISION....DATA DIVISION.WORKING-STORAGE SECTION.01 INPUT-AREA.

02 KEY PICTURE X(6).02 FIELD PICTURE X(84).

PL/I I/O areaIn PL/I, the name for the I/O area used in the DL/I call can be the name of afixed-length character string, a major structure, a connected array, or an adjustablecharacter string. Restriction: The PL/I I/O area cannot be the name of a minorstructure or a character string with the attribute VARYING. If you want to define itas a minor structure, you can use a pointer to the minor structure as the parameter.

Your program should define the I/O area as a fixed-length character string andpass the name of that string, or define it in one of the other ways describedpreviously and then pass the pointer variable that points to that definition. If youwant to use substructures or elements of an array, use the DEFINED or BASEDattribute.DECLARE 1 INPUT_AREA,

2 KEY CHAR(6),2 FIELD CHAR(84);

Assembler language I/O area

The I/O area in an assembler language program is formatted as follows:

IOAREA DS 0CL90KEY DS CL6FIELD DS CL84

328 Application Programming Guide

Page 353: IMS Application Programming.pdf

Chapter 19. EXEC DLI commands for an application program

This chapter explains the program specification block (PSB) and the different kindsof program communication blocks (PCBs). It also lists and describes the EXEC DLIcommands. For each command, a syntax diagram is provided, along withinformation on options, restrictions, usage, and examples illustrating that usage.

The following topics provide additional information:v “PCBs and PSB”

See also the "EXEC DLI commands" section in the IMS Version 10: ApplicationProgramming API Reference.

PCBs and PSBA program specification block (PSB) used in a DBCTL environment can contain:v I/O PCBv Alternate PCBsv DB PCBsv GSAM PCBs

I/O PCBIn a DBCTL environment, an I/O PCB is needed to issue DBCTL service requests.Unlike the other types of PCB, it is not defined with PSB generation, but if theapplication program is using an I/O PCB, this has to be indicated in the PSBscheduling request.

Alternate PCBAn alternate PCB defines a logical terminal and can be used instead of the I/OPCB when it is necessary to direct a response to a terminal. Alternate PCBs appearin PSBs used in a CICS-DBCTL environment, but are used only in an IMS DCenvironment. CICS applications using DBCTL cannot successfully issue commandsthat specify an alternate PCB, an MSDB PCB, or a GSAM PCB. However, a PSBthat contains PCBs of these types can be scheduled successfully in a CICS-DBCTLenvironment.

Alternate PCBs are included in the PCB address list returned to a call levelapplication program. In an EXEC DLI application program, the existence ofalternate PCBs in the PSB affects the PCB number used in the PCB keyword.

DB PCBA database PCB (DB PCB) is the PCB that defines an application program'sinterface to a database. One DB PCB is needed for each database view used by theapplication program. It can be a full-function PCB, a DEDB PCB, or an MSDB PCB.

GSAM PCBA GSAM PCB defines an application program's interface for GSAM operations.

© Copyright IBM Corp. 1974, 2010 329

||

Page 354: IMS Application Programming.pdf

When using DBCTL, a CICS program receives, by default, a DB PCB as the firstPCB in the parameter list passed to it after scheduling. However, when yourapplication program can handle an I/O PCB, you indicate this using theSYSSERVE keyword on the SCHD command. The I/O PCB is then the first PCB inthe parameter address list passed back to your application program.

PCB summaryThis topic summarizes the information concerning I/O PCBs and alternate PCBs invarious types of application programs.

Recommendation: You should read this topic if you intend to issue system servicerequests.

DB batch programsAlternate PCBs are always included in the list of PCBs supplied to the program byDL/I irrespective of whether you have specified CMPAT=Y. The I/O PCB isreturned depending on the CMPAT option.

If you specify CMPAT=Y, the PCB list contains the address of the I/O PCB,followed by the addresses of any alternate PCBs, followed by the addresses of anyDB PCBs.

If you do not specify CMPAT=Y, the PCB list contains the addresses of anyalternate PCBs followed by the addresses of the DB PCBs.

BMP programs, MPPs, and IFPsI/O PCBs and alternate PCBs are always passed to BMP programs. I/O PCBs andalternate PCBs are also always passed to MPPs and to IFP application programs.

The PCB list contains the address of the I/O PCB, followed by the addresses ofany alternate PCBs, followed by the addresses of the DB PCBs.

CICS programs with DBCTLThe first PCB always refers to the first DB PCB whether you specify the SYSSERVEkeyword.

Table 56 summarizes the I/O PCB and alternate PCB information. The first columnlists different DB environments, the second and third column specify if the I/OPCB or alternate PCB, respectively, is valid in the specified environment.

Table 56. Summary of PCB information

Environment

EXEC DLI

I/O PCB count included inPCB(n)

Alternate PCB countincluded in PCB(n)

CICS DBCTL1 No No

CICS DBCTL2 No No

BMP Yes Yes

Batch3 No Yes

Batch4 Yes Yes

330 Application Programming Guide

Page 355: IMS Application Programming.pdf

Table 56. Summary of PCB information (continued)

Environment

EXEC DLI

I/O PCB count included inPCB(n)

Alternate PCB countincluded in PCB(n)

Notes:

1. SCHD command issued without the SYSSERVE option.

2. SCHD command issued with the SYSSERVE option for a CICS DBCTL command or for afunction-shipped command which is satisfied by a remote CICS system using DBCTL.

3. CMPAT=N specified on the PSBGEN statement.

4. CMPAT=Y specified on the PSBGEN statement.

Format of a PSBThe following is the format of a PSB.[IOPCB][Alternate PCB ... Alternate PCB][DBPCB ... DBPCB][GSAMPCB ... GSAMPCB]

Each PSB must contain at least one PCB. The I/O PCB must be addressable inorder to issue a system service command. An alternate PCB is used only for IMSonline programs, which can run only with the Transaction Manager. AlternatePCBs can be present even though your program does not run under theTransaction Manager. A DB PCB can be a full-function PCB, a DEDB PCB, or anMSDB PCB.

Chapter 19. EXEC DLI commands for an application program 331

Page 356: IMS Application Programming.pdf

332 Application Programming Guide

Page 357: IMS Application Programming.pdf

Chapter 20. Recovering databases and maintaining databaseintegrity

This chapter describes the commands you can use to help recover data accessed byyour program and maintain data integrity:v The Basic Checkpoint command, CHKP, which you can use to issue checkpoints

from a batch or BMP programv The Symbolic Checkpoint command, SYMCHKP, which you can use to issue

checkpoints from a batch or BMP program and to specify data areas that can berestored when you restart your program

v The Extended Restart command, XRST, which you can use along with symboliccheckpoints to start or restart your batch or BMP program

v The rollback commands, ROLL and ROLB, which you can use to dynamically backout database changes from a batch or BMP program

v The managing-backout-points commands, SETS and ROLS, which you can use toset multiple backout points and then return to these points later

v The Dequeue command, DEQ, which releases previously reserved segments

To use any of the commands, you must have defined an I/O PCB for yourprogram, except for the DEDB DEQ calls, which are issued against a DEDB PCB.

The following topics provide additional information:v “Issuing checkpoints in a batch or BMP program”v “Restarting your program and checking for position” on page 334v “Backing out database updates dynamically: the ROLL and ROLB commands”

on page 334v “Using intermediate backout points: the SETS and ROLS commands” on page

335

Issuing checkpoints in a batch or BMP programThe two kinds of commands that allow you to make checkpoints are: the CHKP, orBasic Checkpoint command, and the SYMCHKP, or Symbolic Checkpoint command.

Batch programs can use either the Symbolic Checkpoint or the Basic Checkpointcommand.

Both checkpoint commands make it possible for you to commit your program'schanges to the database and to establish places from which the batch or BMPprogram can be restarted, in cases of abnormal termination.

Requirement: You must not use the CHKPT=EOV parameter on any DD statementto take an IMS checkpoint.

Because both checkpoint commands cause a loss of database position at the timethe command is issued, you must reestablish position with a GU command or othermethods.

You cannot reestablish position in the midst of nonunique keys or nonkeyedsegments.

© Copyright IBM Corp. 1974, 2010 333

Page 358: IMS Application Programming.pdf

Issuing the CHKP commandWhen you issue a CHKP command, you must provide the code for restarting yourprogram and you must specify the ID for the checkpoint. You can supply either thename of a data area in your program that contains the ID, or you can supply theactual ID, enclosed in single quotes. For example, either of the followingcommands is valid:EXEC DLI CHKP ID(chkpid);

EXEC DLI CHKP ID('CHKP0007');

Issuing the SYMCHKP commandThe SYMCHKP command in batch and BMP programs:v Works with the Extended Restart (XRST) command to restart your program if it

terminates abnormally.v Can save as many as seven program data areas, which are restored when your

program is restarted. You can save variables, counters, and status information.

For examples of how to specify the SYMCHKP command, see the topic "SYMCHKPCommand" in IMS Version 10: Application Programming API Reference.

Restarting your program and checking for positionPrograms that issue Symbolic Checkpoint commands must also issue the ExtendedRestart (XRST) command. You must issue XRST once, as the first command in theprogram. You can use the XRST command to start your program normally, or torestart it in case of an abnormal termination. You can restart your program fromone of the following:v A specific checkpoint IDv A time/date stamp

Because the XRST command attempts to reposition the database, your program alsoneeds to check for correct position.

Backing out database updates dynamically: the ROLL and ROLBcommands

When a batch program determines that some of its processing is invalid, the ROLLand ROLB commands make it possible for the program to remove the effects of itsinaccurate processing.

You can use both ROLL and ROLB in batch programs. You can only use the ROLBcommand in batch programs if the system log is stored on direct access storageand if you have specified BKO=Y in the parm field of your JCL.

Issuing either of these commands causes DL/I to back out any changes yourprogram has made to the database since its last checkpoint, or since the beginningof the program if your program has not issued a checkpoint.

334 Application Programming Guide

Page 359: IMS Application Programming.pdf

Using intermediate backout points: the SETS and ROLS commandsUse the SETS and ROLS commands to define multiple points at which to preservethe state of DL/I full-function databases and to return to these points later. (Forexample, you can use them to allow your program to handle situations that canoccur when PSB scheduling complete without all of the referenced DL/I databasesbeing available.)

The SETS and ROLS commands apply only to DL/I full-function databases.Therefore, if a logical unit of work (LUW) is updating recoverable resources otherthan full-function databases (VSAM files, for example), the SETS and ROLS requestshave no effect on the non-DL/I resources. The backout points are not CICS commitpoints; they are intermediate backout points that apply only to DBCTL resources.Your program must ensure the consistency of all the resources involved.

Before initiating a set of DL/I requests to perform a function, you can use a SETScommand to define points in your application at which to preserve the state ofDL/I databases. Your application can issue a ROLS command later if it cannotcomplete the function. You can use the ROLS command to back out to the state allfull-function databases were in before either a specific SETS request or the mostrecent commit point.

Chapter 20. Recovering databases and maintaining database integrity 335

Page 360: IMS Application Programming.pdf

336 Application Programming Guide

Page 361: IMS Application Programming.pdf

Chapter 21. Processing Fast Path databases

Using EXEC DLI commands under DBCTL, a CICS program or a batch-orientedBMP program can access DEDBs. Parameters allow your program to use facilitiesof the DEDBs such as subset pointers.

A DEDB contains a root segment and as many as 127 types of dependent segment.One of these types can be a sequential dependent; the other 126 are directdependents. Sequential dependent segments are stored in chronological order.Direct dependent segments are stored hierarchically.

DEDBs provide high data availability. Each DEDB can be partitioned, or dividedinto multiple “areas.” Each area contains a different set of database records. Inaddition, you can make up to seven copies of each area data set. If an error existsin one copy of an area, application programs can access the data by using anothercopy of that area. This is transparent to the application program. When an erroroccurs to data in a DEDB, IMS does not stop the database. It makes the data inerror unavailable, but continues to schedule and process application programs.Programs that do not need the data in error are unaffected.

DEDBs can be shared among application programs in separate IMS systems.Sharing DEDBs is virtually the same as sharing full-function databases, and mostof the same rules apply. IMS systems can share DEDBs at the area level (instead ofat the database level as with full-function databases), or at the block level.

The following topics provide additional information:v “Processing DEDBs with subset pointers”v “The POS command” on page 347

Processing DEDBs with subset pointersSubset pointers and the options you use with them are optimization tools thatsignificantly improve the efficiency of your program when you need to processlong segment chains. Subset pointers divide a chain of segment occurrences underthe same parent into two or more groups, or subsets. You can define as many aseight subset pointers for any segment type. You then define the subset pointersfrom within an application program (see “Subset pointer options” on page 340).Each subset pointer points to the start of a new subset. For example, in Figure 71on page 338 suppose you defined one subset pointer that divided the last threesegment occurrences from the first four. Your program can then refer to that subsetpointer through options, and directly retrieve the last three segment occurrences.

© Copyright IBM Corp. 1974, 2010 337

Page 362: IMS Application Programming.pdf

You can use subset pointers at any level of the database hierarchy, except at theroot level. Subset pointers used for the root level are ignored.

Figure 72 and Figure 73 on page 339 show some of the ways you can set subsetpointers. Subset pointers are independent of one another, which means that youcan set one or more pointers to any segment in the chain. For example, you can setmore than one subset pointer to a segment, as shown in Figure 72.

Alternatively, you can define a one-to-one relationship between the pointers andthe segments, as shown in Figure 73 where each segment occurrence has onesubset pointer.

B1

P1

B2

B3

B4

B5

B6

B7

Figure 71. Processing a long chain of segment occurrences with subset pointers

B1

P2

P3P5

P6

P7

P8

B2

B3

B4

B5

B6

B7

B1

B2

B3

B4

B5

B6

B7

Figure 72. Examples of setting multiple subset pointers

338 Application Programming Guide

Page 363: IMS Application Programming.pdf

Figure 74 on page 339 shows how the use of subset pointers divides a chain ofsegment occurrences under the same parent into subsets. Each subset ends withthe last segment in the entire chain. For example, the last segment in the subsetdefined by subset pointer 1 is B7.

Preparing to use subset pointersFor your program to use subset pointers, the pointers must be defined in the DBDfor the DEDB, and in your program's PSB:v In the DBD, you specify the number of pointers for a segment chain. You can

specify as many as eight pointers for any segment chain.v In the PSB, you specify which pointers your program uses; you define this on

the SENSEG statement. (Each pointer is defined as an integer from 1 to 8.) Youalso specify on the SENSEG statement whether your program can set thepointers it uses. If your program has read-only sensitivity, it cannot set pointers,

B1

P1

P2

P3

P4

P5P6

B2

B3

B4

B5

B6

B7

B1

B2

B3

B4

B5

B6

B7

Figure 73. More examples of setting subset pointers

B1

P2

P1

B2

B3

B4

B5

B6

B7

Figure 74. How subset pointers divide a chain into subsets

Chapter 21. Processing Fast Path databases 339

Page 364: IMS Application Programming.pdf

but can only retrieve segments using subset pointers already set. If yourprogram has update sensitivity, it can update subset pointers by using the SET,SETCOND, MOVENEXT, and SETZERO options.

After the pointers are defined in the DBD and the PSB, an application program canset the pointers to segments in a chain. When an application program finishesexecuting, the subset pointers used by that program remain as they were set by theprogram and are not reset.

Designating subset pointersTo use subset pointers in your program, you must know the numbers for thepointers as they were defined in the PSB. Then, when you use the subset pointeroptions, you specify the number for each subset pointer you want to useimmediately after the option; for example, you would use P3 to indicate that youwant to retrieve the first segment occurrence in the subset defined by subsetpointer 3. No default exists, so if you do not include a number between 1 and 8,IMS considers your qualification statement invalid and returns an AJ status code toyour program.

Subset pointer options

To take advantage of subsets, application programs use five different options.

GETFIRST Allows you to retrieve the first segment in a subset.

SETZERO Sets a subset pointer to zero.

MOVENEXT Sets a subset pointer to the segment following the current segment.Current position is at the current segment.

SET Unconditionally sets a subset pointer to the current segment.Current position is at the current segment.

SETCOND Conditionally sets a subset pointer to the current segment. Currentposition is at the current segment.

Banking transaction application exampleThe examples in this chapter are based on a sample application, the recording ofbanking transactions for a passbook account. The transactions are written to adatabase as either posted or unposted, depending on whether they were posted tothe customer's passbook. For example, when Bob Emery does business with thebank, but forgets to bring in his passbook, an application program writes thetransactions to the database as unposted. The application program sets a subsetpointer to the first unposted transaction, so it can be easily accessed later. The nexttime Bob remembers to bring in his passbook, a program posts the transactions.The program can directly retrieve the first unposted transaction using the subsetpointer that was previously set. After the program has posted the transactions, itsets the subset pointer to zero; an application program that subsequently updatesthe database can determine that no unposted transactions exist. Figure 75 on page341 summarizes the processing performed when the passbook is unavailable.

340 Application Programming Guide

Page 365: IMS Application Programming.pdf

When the passbook is available, an application program adds the unpostedtransactions to the database, setting subset pointer 1 to the first unpostedtransaction. Figure 76 summarizes the processing performed when the passbook isavailable.

When the passbook is available, an application program retrieves the firstunposted transaction using the program, then posts all unposted transactions,setting subset pointer 1 to zero.

GETFIRST option: retrieving the first segment of a subset

To retrieve the first segment occurrence in the subset, your program issues a Getcommand with the GETFIRST option. The GETFIRST option does not set or movethe pointer, but indicates to IMS that you want to establish position on the first

B1

P1

B2

B3

B4

B5

B6

B7

Figure 75. Processing performed for the sample passbook example when the passbook isunavailable

B1

P1=10

B2

B3

B4

B5

B6

B7

Figure 76. Processing performed for the sample passbook example when the passbook isavailable

Chapter 21. Processing Fast Path databases 341

Page 366: IMS Application Programming.pdf

segment occurrence in the subset. The GETFIRST option is like the FIRST option,except that the GETFIRST option applies to the subset instead of to the entiresegment chain.

Using the “Banking transaction application example” on page 340, imagine thatBob Emery visits the bank with his passbook and you want to post all of theunposted transactions. Because subset pointer 1 was previously set to the firstunposted transaction, your program can use the following command to retrievethat transaction:EXEC DLI GU SEGMENT(A) WHERE(AKEY = ’A1’)

SEGMENT(B) INTO(BAREA) GETFIRST(’1’);

As shown in Figure 77, this command retrieves segment B5. To continue processingsegments in the chain, you can issue Get Next commands, as you would if youwere not using subset pointers.

If the subset does not exist (subset pointer 1 has been set to zero), IMS returns aGE status code, and your position in the database immediately follows the lastsegment in the chain. Using the passbook example, the GE status code indicatesthat no unposted transactions exist.

You can specify only one GETFIRST option per qualification statement; if you usemore than one GETFIRST in a qualification statement, IMS returns an AJ statuscode to your program. The rules for using the GETFIRST option are:1. You can use GETFIRST with all options except:v FIRSTv LOCKCLASSv LOCKED

2. Other options take effect after the GETFIRST option has, and position has beenestablished on the first segment in the subset.

3. If you use GETFIRST with LAST, the last segment in the segment chain isretrieved.

B1

P1

B2

B3

B4

B5

B6

B7

Figure 77. Retrieving the first segment in a chain of segments

342 Application Programming Guide

Page 367: IMS Application Programming.pdf

4. If the subset pointer specified with GETFIRST is not set, IMS returns a GEstatus code, not the last segment in the segment chain. See “SETZERO,MOVENEXT, SET, and SETCOND options: setting the subset pointers.”

5. Do not use GETFIRST with FIRST. This causes you to receive an AJ status code.6. GETFIRST overrides all insert rules, including LAST.

SETZERO, MOVENEXT, SET, and SETCOND options: setting thesubset pointersThe SETZERO, MOVENEXT, SET, and SETCOND options allow you to redefinesubsets by modifying the subset pointers. Before your program can set a subsetpointer, it must establish a position in the database. A command must be fullysatisfied before a subset pointer is set. The segment a pointer is set to depends onyour current position at the completion of the command. If a command to retrievea segment is not completely satisfied, and a position is not established, the subsetpointers remain as they were before the command was issued.v Setting the subset pointer to zero: SETZERO

The SETZERO option sets the value of the subset pointer to zero. After yourprogram issues a command with the SETZERO option, the pointer is no longerset to a segment; the subset defined by that pointer no longer exists. (IMSreturns a status code of GE to your program if you try to use a subset pointerhaving a value of zero.)Using the “Banking transaction application example” on page 340, say that youused the GETFIRST option to retrieve the first unposted transaction. You wouldthen process the chain of segments, posting the transactions. After posting thetransactions and inserting any new ones into the chain, you would use theSETZERO option to set the subset pointer to zero as shown in the followingcommand:EXEC DLI ISRT SEGMENT(A) WHERE(AKEY = ’A1’)

SEGMENT(B) FROM(BAREA) SETZERO(’1’);

After this command, subset pointer 1 would be set to zero, indicating to aprogram updating the database later on that no unposted transactions exist.

v Moving the subset pointer forward to the next segment after your currentposition: MOVENEXT

To move the subset pointer forward to the next segment after your currentposition, your program issues a command with the MOVENEXT option. Usingthe “Banking transaction application example” on page 340, say that you wantedto post some of the transactions, but not all, and that you wanted the subsetpointer to be set to the first unposted transaction. The following command setssubset pointer 1 to segment B6.EXEC DLI GU SEGMENT(A) WHERE(AKEY = ’A1’)

SEGMENT(B) INTO(BAREA) GETFIRST(’1’) MOVENEXT(’1’);

The process of moving the subset pointer with this command is shown inFigure 78 on page 344. If the current segment is the last in the chain, and youuse a MOVENEXT option, IMS sets the pointer to zero.

Chapter 21. Processing Fast Path databases 343

Page 368: IMS Application Programming.pdf

v Setting the subset pointer unconditionally: SET

You use the SET option to set a subset pointer. The SET option sets a subsetpointer unconditionally, regardless of whether or not it is already set. Whenyour program issues a command that includes the SET option, IMS sets thepointer to your current position.For example, to retrieve the first B segment occurrence in the subset defined bysubset pointer 1, and to reset pointer 1 at the next B segment occurrence, youwould issue the following commands:EXEC DLI GU SEGMENT(A) WHERE(AKEY = ’A1’)

SEGMENT(B) INTO(BAREA) GETFIRST(’1’);EXEC DLI GN SEGMENT(B) INTO(BAREA) SET(’1’);

After you have issued these commands, instead of pointing to segment B5,subset pointer 1 points to segment B6, as shown in Figure 79 on page 345.

Before the command:

After the command:

B1

P1

B2

B3

B4

B5

B6

B7

B1

P1

B2

B3

B4

B5

B6

B7

Figure 78. Moving the subset pointer to the next segment after your current position

344 Application Programming Guide

Page 369: IMS Application Programming.pdf

v Setting the subset pointer conditionally: SETCOND

Your program uses the SETCOND option to conditionally set the subset pointer.The SETCOND option is similar to the SET option; the only difference is that,with the SETCOND option, IMS updates the subset pointer only if the subsetpointer is not already set to a segment.Using the passbook example, say that Bob Emery visits the bank and forgets tobring his passbook; you add the unposted transactions to the database. Youwant to set the pointer to the first unposted transaction so that when you postthe transactions later, you can immediately access the first one. The followingcommand sets the subset pointer to the transaction you are inserting, if it is thefirst unposted one:EXEC DLI ISRT SEGMENT(A) WHERE(AKEY = ’A1’)

SEGMENT(B) FROM(BAREA) SETCOND(’1’);

As shown by Figure 80 on page 346, this command sets subset pointer 1 tosegment B5. If unposted transactions already existed, the subset pointer is not

Before the command:

After the command:

B1

P1

B2

B3

B4

B5

B6

B7

B1

P1

B2

B3

B4

B5

B6

B7

Figure 79. Unconditionally setting the subset pointer to your current position

Chapter 21. Processing Fast Path databases 345

Page 370: IMS Application Programming.pdf

changed.

Inserting segments in a subsetWhen you use the GETFIRST option to insert an unkeyed segment in a subset, thenew segment is inserted before the first segment occurrence in the subset.However, the subset pointer is not automatically set to the new segmentoccurrence. For example, the following command inserts a new B segmentoccurrence in front of segment B5, but does not set subset pointer 1 to point to thenew B segment occurrence:EXEC DLI ISRT SEGMENT(A) WHERE(AKEY = ’A1’)

SEGMENT(B) FROM(BAREA) GETFIRST(’1’);

To set subset pointer 1 to the new segment, you use the SET option along with theGETFIRST option, as shown in the following example:

Before the command:

After the command:

B1

B2

B3

B4

B1

P1

B2

B3

B4

B5

Figure 80. Conditionally setting the subset pointer to your current position

346 Application Programming Guide

Page 371: IMS Application Programming.pdf

EXEC DLI ISRT SEGMENT(A) WHERE(AKEY = ’A1’)SEGMENT(B) FROM(BAREA) GETFIRST(’1’) SET (’1’);

If the subset does not exist (subset pointer 1 has been set to zero), the segment isadded to the end of the segment chain.

Deleting the segment pointed to by a subset pointerIf you delete the segment pointed to by a subset pointer, the subset pointer pointsto the next segment occurrence in the chain. If the segment you delete is the last inthe chain, the subset pointer is set to zero.

Combining optionsYou can use the SET, MOVENEXT, and SETCOND options with other options, andyou can combine subset pointer options with each other, provided they do notconflict. For example, you can use GETFIRST and SET together, but you cannot useSET and SETZERO together because their functions conflict. If you combineoptions that conflict, IMS returns an AJ status code to your program.

You can use one GETFIRST option per qualification statement, and one updateoption (SETZERO, MOVENEXT, SET, or SETCOND) for each subset pointer.

Subset pointer status codesIf you make an error in a qualification statement that contains subset pointeroptions, IMS can return these status codes to your program:

AJ The qualification statement used a GETFIRST, SET, SETZERO, SETCOND,or MOVENEXT option for a segment for which there are no subsetpointers defined in the DBD.

The subset options included in the qualification statement are in conflict;for example, if one qualification statement contained a SET option and aSETZERO option for the same subset pointer, IMS would return an AJstatus code. S means to set the pointer to current position; Z means to setthe pointer to zero. You cannot use these options together in onequalification statement.

The qualification statement included more than one GETFIRST option.

The pointer number following a subset pointer option is invalid. You eitherdid not include a number, or included an invalid character. The numberfollowing the option must be between 1 and 8, inclusive.

AM The subset pointer referenced in the qualification statement was notspecified in the program's PSB. For example, if your program's PSBspecifies that your program can use subset pointers 1 and 4, and yourqualification statement referenced subset pointer 5, IMS would return anAM status code to your program.

Your program tried to use an option that updates the pointer (SET,SETCOND, or MOVENEXT) but the program's PSB did not specify pointerupdate sensitivity.

Your program attempted to open a GSAM database without specifying anIOAREA.

The POS commandYou can use the Position (POS) command (only with DEDBs) to:

Chapter 21. Processing Fast Path databases 347

Page 372: IMS Application Programming.pdf

v Retrieve the location of a specific sequential dependent segment, or retrieves thelocation of the last inserted sequential dependent segment.

v Tell you the amount of unused space within each DEDB area. For example, youcan use the position information that IMS returns for a POS command to scan ordelete the sequential dependent segments for a particular time period.

For the syntax of the POS command, see the topic "POS Command" in IMS Version10: Application Programming API Reference.

If the area the POS command specifies is unavailable, the I/O area is unchangedand the status code FH is returned.

Locating a specific sequential dependent segmentWhen you have position on a particular root segment, you can retrieve the positioninformation and the area name of a specific sequential dependent segment of thatroot. If you have a position established on a sequential dependent segment, thesearch starts from that position. IMS returns the position information for the firstsequential dependent segment that satisfies the command.

To retrieve this information, you issue a POS command with a qualificationstatement containing the segment name of the sequential dependent. The currentposition after this kind of POS command is in the same place that it is after a GNPcommand.

After a successful POS command, the I/O area contains:

LL A 2-byte field giving the total length of the data in the I/O area, inbinary.

Area Name An 8-byte field giving the ddname from the AREA statement.

Position An 8-byte field containing the position information for therequested segment.

If the sequential dependent segment that is the target of the POScommand is inserted in the same synchronization interval, noposition information is returned. Bytes 11-18 contain X'FF'; otherfields contain normal data.

Unused CIs A 4-byte field containing the number of unused CIs in thesequential dependent part.

Unused CIs A 4-byte field containing the number of unused CIs in theindependent overflow part.

Locating the last inserted sequential dependent segmentYou can also retrieve the position information for the most recently insertedsequential dependent segment of a given root segment. To do this, you issue a POScommand with a qualification statement containing the root segment as thesegment name. The current position after this type of command follows the samerules as position after a GU.

After a successful command, the I/O area contains:

LL A 2-byte field containing the total length of the data in the I/Oarea, in binary.

Area Name An 8-byte field giving the ddname from the AREA statement.

Position An 8-byte field containing the position information for the most

348 Application Programming Guide

Page 373: IMS Application Programming.pdf

recently inserted sequential dependent segment. This field containszeros provided no sequential dependent for this root exist.

Unused CIs A 4-byte field containing the number of unused CIs in thesequential dependent part.

Unused CIs A 4-byte field containing the number of unused CIs in theindependent overflow part.

Identifying free space with the POS commandTo retrieve the area name and the next available position within the sequentialdependent part from all online areas, you can issue an unqualified POS command.This type of command also retrieves the free space in the independent overflowand sequential dependent parts.

After a successful unqualified POS command, the I/O area contains the length (LL)followed by the same number of entries as areas within the database. Each entrycontains field two through five shown below:

LL A 2-byte field containing the total length of the data in the I/Oarea, in binary. The length includes the 2 bytes for the LL field,plus 24 bytes for each entry.

Area Name An 8-byte field giving the ddname from the AREA statement.

Position An 8-byte field giving the next available position within thesequential dependent part.

Unused CIs A 4-byte field containing the number of unused CIs in thesequential dependent part.

Unused CIs A 4-byte field containing the number of unused CIs in theindependent overflow part.

The P processing optionIf the P processing option has been specified (with the PROCOPT parameter) inthe PCB for your program, a GC status code is returned to your programwhenever a command to retrieve or insert a segment causes a Unit of Work (UOW)boundary to be crossed. Although crossing the UOW boundary probably has noparticular significance for your program, the GC status code indicates that this is agood time to issue a CHKP command. The advantages of doing this are:v Your position in the database is kept. Issuing a CHKP normally causes position in

the database to be lost, and the application program has to reestablish positionbefore it can resume processing.

v Commit points occur at regular intervals.

When a GC status code is returned, no data is retrieved or inserted. In yourprogram, you can either:v Issue a CHKP command, and resume database processing by reissuing the

command that caused the GC status code.v Ignore the GC status code and resume database processing by reissuing the

command that caused the status code.

Chapter 21. Processing Fast Path databases 349

Page 374: IMS Application Programming.pdf

350 Application Programming Guide

Page 375: IMS Application Programming.pdf

Chapter 22. Comparing command-level and call-levelprograms

This chapter summarizes some of the differences between command- and call-levelprograms. If you are familiar with DL/I calls but not with EXEC DLI commands,this information will help you understand the commands and options you can useto perform the tasks that you performed using calls.

The following topics provide additional information:v “DL/I calls for IMS and CICS”v “Comparing EXEC DLI commands and DL/I calls” on page 352v “Comparing command codes and options” on page 353

DL/I calls for IMS and CICSTable 57 provides a quick reference for using DL/I calls in a Batch, Batch-OrientedBMP, or CICS with DBCTL environment.

Table 57. DL/I calls available to IMS and CICS command-level application programs

Request Type

Program Characteristics

BatchBatch-

Oriented BMPCICS with

DBCTL1

CHKP call (symbolic) Yes Yes No

CHKP call (basic) Yes Yes No

GSCD call2 Yes No No

INIT call Yes Yes Yes

ISRT call (initial load) Yes No No

ISRT call Yes Yes Yes

LOG call Yes Yes Yes

SCHD call No No Yes

ROLB call Yes Yes No

ROLL call Yes Yes No

ROLS call (Roll Back to SETS)3 Yes Yes Yes

ROLS call (Roll Back to Commit) Yes Yes Yes

SETS call3 Yes Yes Yes

STAT call4 Yes Yes Yes

TERM call No No Yes

XRST call Yes Yes No

Notes:

1. In a CICS remote DL/I environment, CALLs in the CICS-DBCTL column are supported if you are shipping afunction to a remote CICS that uses DBCTL.

2. GSCD is a Product-sensitive programming interface.

3. SETS and ROLS calls are not valid when the PSB contains a DEDB.

4. STAT is a Product-sensitive programming interface.

© Copyright IBM Corp. 1974, 2010 351

Page 376: IMS Application Programming.pdf

Comparing EXEC DLI commands and DL/I callsTable 58 compares EXEC DLI commands with DL/I calls and explains what thecommands do. For example, in a command-level program, you use the LOADcommand instead of the ISRT call to initially load a database.

Table 58. Comparing call-level and command-level programs: commands and calls

Call-Level Command-Level Allows you to . . .

INIT call ACCEPT command Initialize for data availability status codes.

CHKP call (basic) CHKP command Issue a basic checkpoint.

DEQ call DEQ command Release segments retrieved using LOCKCLASS option or Qcommand code.

DLET call DLET command Delete segments from a database.

GU, GN, and GNPcalls

GU, GN, and GNPcommands1

Retrieve segments from a database.

GHU, GHN, andGHNP calls1

GU, GN, and GNPcommands1

Retrieve segments from a database for updating.

GSCD call GSCD call2 Retrieve system addresses.

ISRT call ISRT command Add segments to a database.

ISRT call LOAD command Initially load a database.

LOG call LOG command Write a message to the system log.

POS call POS command Retrieve positioning or space usage or positioning and space usagein a DEDB area.

INIT call ACCEPT command Initialize for data availability status.

INIT call QUERY command Obtain information of initial data availability.

INIT call REFRESH command Availability information after using a PCB.

REPL call REPL command Replace segments in a database.

XRST call RETRIEVE command Issue an extended restart.

ROLL or ROLB call ROLL or ROLBcommand

Dynamically back out changes.

ROLS call ROLS command Back out to a previously set backout point.

PCB call SCHD command Schedule a PSB.

SETS call SETS command Set a backout point.

SETU call SETU command Set a backout point even if unsupported PCBs (like DEDBs orMSDBs) are present.

STAT call3 STAT command Obtain system and buffer pool statistics.

CHKP call (extended) SYMCHKP command Issue a symbolic checkpoint.

TERM call TERM command Terminate a PSB.

XRST call XRST command Issue an extended restart.

Notes:

1. Get commands are just like Get Hold calls, and the performance of Get commands and Get calls is the same.

2. You can use the GSCD call in a batch command-level program. GSCD is a Product-sensitive programminginterface.

3. STAT is a Product-sensitive programming interface.

352 Application Programming Guide

Page 377: IMS Application Programming.pdf

Comparing command codes and optionsTable 59 compares the options you use with EXEC DLI commands with thecommand codes you use with DL/I calls. For example, the LOCKED optionperforms the same function as a Q command code.

Table 59. Comparing call-level and command-level programs: command codes and options

Call- Level Command-Level Allows You to . . .

C KEYS option Use the concatenated key of a segment to identify the segment.

D INTO or FROM specified onsegment level to beretrieved or inserted.

Retrieve or insert a sequence of segments in a hierarchic path usingonly one request, instead of having to use a separate request for eachsegment. (Path call or command).

F FIRST option Back up to the first occurrence of a segment under its parent whensearching for a particular segment occurrence. Disregarded for a rootsegment.

L LAST option Retrieve the last occurrence of a segment under its parent.

M MOVENEXT option Set a subset pointer to the segment following the current segment.

N Leave out the SEGMENToption for segments you donot want replaced.

Designate segments you do not want replaced, when replacingsegments after a get hold request. Usually used when replacing a pathof segments.

P SETPARENT Set parentage at a higher level than what it usually is (the lowesthierarchic level of the request).

Q LOCKCLASS, LOCKED Reserve a segment so that other programs are not able to update ituntil you have finished processing it.

R GETFIRST option Retrieve the first segment in a subset.

S SET option Unconditionally set a subset pointer to the current segment.

U No equivalent for commandlevel programs.

Limit the search for a segment to the dependents of the segmentoccurrence on which position is established.

V CURRENT option Use the hierarchic level of and levels above the current position asqualifications for the segment.

W SETCOND option Conditionally set a subset pointer to the current segment.

Z SETZERO option Set a subset pointer to zero.

– No command-levelequivalent.

Null. Use an SSA in command code format without specifying thecommand code. Can be replaced during execution with the commandcodes you want.

Chapter 22. Comparing command-level and call-level programs 353

Page 378: IMS Application Programming.pdf

354 Application Programming Guide

Page 379: IMS Application Programming.pdf

Chapter 23. Data availability enhancements

Your program might fail when it receives a status code indicating that a DL/Ifull-function database is unavailable. To avoid this, you can use data availabilityenhancements. After a PSB has been scheduled in DBCTL, your applicationprogram can issue requests to indicate to IMS that the program can handle dataavailability status codes and to obtain information about the availability of eachdatabase.

The following topics provide additional information:v “Accepting database availability status codes”v “Obtaining information about database availability”

Accepting database availability status codesThese status codes occur because PSB scheduling was completed without all of thereferenced databases being available. Use the ACCEPT command to tell DBCTL toreturn a status code instead of abending the program:EXEC DLI ACCEPT STATUSGROUP('A');

Obtaining information about database availability

You can put data availability status codes into each of the DB PCBs if:v In a CICS DBCTL environment, by using the PSB scheduling request command,

SCHD.v In a Batch or BMP environment, at initialization time.

You can obtain the data availability status codes within the DL/I interface block(DIB) by using the following QUERY command:EXEC DLI QUERY USING PCB(n);

n specifies the PCB.

The QUERY command is used after scheduling the PSB but before making the firstdatabase call. If the program has already issued a call using a DB PCB, then theQUERY command must follow the REFRESH command:EXEC DLI REFRESH DBQUERY

The REFRESH command updates the information in the DIB. You can only issue thiscommand one time.

For full-function databases, the DIBSTAT should contain NA, NU, TH, or blanks.For MSDBs and DEDBs, the DIBSTAT always contains blanks.

If a CICS command language translator has been used to translate the EXEC DLIcommands, then, in addition to data availability status, the DBDNAME will bereturned in the DIB field DIBDBDNM. Also, the name of the database organizationwill be returned in the DIB field DIBDBORG.

© Copyright IBM Corp. 1974, 2010 355

Page 380: IMS Application Programming.pdf

356 Application Programming Guide

Page 381: IMS Application Programming.pdf

Part 4. Java application development for IMS

Chapter 24. Where to find more informationabout IMS solutions for Java development . . 359

Chapter 25. Introduction to the Java classlibraries for IMS . . . . . . . . . . . . 361JDBC driver for IMS . . . . . . . . . . . 363Java API for IMS DB . . . . . . . . . . . 364

GSAM database access . . . . . . . . . 364IMS hierarchical database interface for Java . . 364

Java API for IMS TM . . . . . . . . . . . 364J2EE platform access to IMS DB . . . . . . . 365

Chapter 26. Developing Java applications thatwork with IMS. . . . . . . . . . . . . 367IMS IVP jobs, tasks, and sample applications . . . 367Developing JMP and JBP applications . . . . . 368

Developing JMP applications . . . . . . . 370Developing JBP applications . . . . . . . 380Enterprise COBOL interoperability with JMPand JBP applications . . . . . . . . . . 392Accessing DB2 for z/OS databases from JMP orJBP applications . . . . . . . . . . . 393Program switching in JMP and JBP applications 394Issuing synchronous callout requests from aJava dependent region . . . . . . . . . 395

Developing DB2 for z/OS stored procedures thataccess IMS . . . . . . . . . . . . . . 397

Java applications running in DB2 for z/OSstored procedures . . . . . . . . . . . 397DB2 for z/OS stored procedures programmingmodel . . . . . . . . . . . . . . . 398

Developing CICS applications that access IMS . . 399Java applications running on CICS TransactionServer for z/OS . . . . . . . . . . . 399CICS Transaction Server for z/OS programmingmodel . . . . . . . . . . . . . . . 400

Developing enterprise applications that access IMS 400Enterprise applications running in WebSphereApplication Server for z/OS . . . . . . . 401Enterprise applications running in WebSphereApplication Server . . . . . . . . . . 402Bean-managed EJB programming model . . . 403Container-managed EJB programming model 404Servlet programming model . . . . . . . 405Programming requirements for WebSphereApplication Server for z/OS . . . . . . . 405Deployment descriptor requirements for theJava class libraries for IMS . . . . . . . . 406Transaction semantics and server-side EJB types 406

Chapter 27. Problem determination . . . . . 409Exceptions thrown from IMS DL/I calls . . . . 409

How exceptions map to DL/I status codes . . 409SQLException objects. . . . . . . . . . 410

XML tracing for the Java class libraries for IMS . . 410

WebSphere Application Server securityrequirements for XML tracing . . . . . . . 411Enabling XML tracing . . . . . . . . . 411Enabling J2EE tracing . . . . . . . . . 413

© Copyright IBM Corp. 1974, 2010 357

|||||||||||||||

|||||||||||||||||||

|||

|||

Page 382: IMS Application Programming.pdf

358 Application Programming Guide

Page 383: IMS Application Programming.pdf

Chapter 24. Where to find more information about IMSsolutions for Java development

The following topics in the IMS library contain more information about IMSsolutions for Java development:v Chapter 2, “Defining application program elements for IMS DB,” on page 39v Chapter 12, “Defining application program elements for IMS TM,” on page 183v Part 4, “Java application development for IMS,” on page 357v The "How Java applications programs work with IMS" topic in the IMS Version

10: Application Programming Planning Guide

v The "Java class libraries for IMS" topic in the IMS Version 10: ApplicationProgramming API Reference

v The "DLIModel utility" topic in the IMS Version 10: System Utilities Reference.v The "Configuring external Java environments to access IMS databases" topic in

the IMS Version 10: Communications and Connections Guide.v The "IVP Jobs and Tasks" and "Samples for the IMS solutions for Java

development" topics in the IMS Version 10: Installation Guide.

The IMS Solutions for Java development Web site also contains current informationabout the Java class libraries for IMS and links to the resources that are describedin this topic. The Web site also has links to presentation materials from recentconferences, downloads, and announcements about enhancements for the IMSsolutions for Java development. Also, visit the IMS Support Web site for a broadrange of information about IMS, including IMS solutions for Java development.

The following Redbooks® contain information about IMS solutions for Javadevelopment and related technologies:v IMS Version 9 Implementation Guide: A Technical Overview (SG24-6398-00): Contains

an overview of the new functions and enhancements in IMS Version 9.v IMS Version 7 and Java Application Programming (SG24-6123-00): A book for

customers who want to exploit the Java language support that is provided byIMS Version 7.1.

v IMS Version 7 Java Update (SG24-6536): Contains IMS Version 7 level informationabout running applications from JMP regions, JBP regions, DB2 storedprocedures, and CICS.

v IMS Version 7 Release Guide (SG24-5753-00): A release guide that describes thenew features and enhancements that are provided in IMS Version 7.

v IMS e-business Connectors: A Guide to IMS Connectivity (SG24-6514): Contains achapter on setting up open database access (ODBA).

v ABCs of System Programming Volume 9 (SG24-6989): Describes UNIX SystemServices (z/OS UNIX) and how to install, tailor, configure, and use the z/OSVersion 1 Release 4 version of z/OS UNIX.

© Copyright IBM Corp. 1974, 2010 359

|

|

|

||

||

|

||

||

||||||

||

|||

||

Page 384: IMS Application Programming.pdf

360 Application Programming Guide

Page 385: IMS Application Programming.pdf

Chapter 25. Introduction to the Java class libraries for IMS

The Java class libraries for IMS provide a complete Java development solution forboth processing IMS transactions as well as accessing IMS databases. At aminimum, the libraries provide all traditional DL/I capabilities and IMS functionusing the Java programming language. The Java class libraries for IMS enableaccess to IMS databases from both within dependent regions and externaldevelopment environments. The Java class libraries for IMS also provide supportfor IMS transaction management, but only from within a JMP or JBP region.

The Java class libraries for IMS are capable of deployment in a variety of runtimeenvironments. These runtime environments include the IMS dependent regions,CICS Transaction Server for z/OS, DB2 for z/OS Java stored procedures,WebSphere Application Server for z/OS, and WebSphere Application Server ondistributed platforms.

The Java class libraries for IMS are built directly on top of existing assemblerinterfaces to IMS. For the IMS environment, the CEETDLI interface is used. DB2for z/OS and WebSphere Application Server use the AERTDLI interface. CICS usesthe AIBTDLI interface. The Java class libraries for IMS detect which environment isused and this enables the libraries to use the appropriate assembler interface toIMS at runtime. The ability for the libraries to detect this is transparent to theapplication

The following figure provides more details about the use of the Java class librariesto access an IMS database in external environments and process transactions in anIMS database from a JMP or JBP region:

© Copyright IBM Corp. 1974, 2010 361

|

|

|||||||

|||||

|||||||

||||

Page 386: IMS Application Programming.pdf

There are three major APIs that the libraries offer: the Java API for IMS DB, theJava API for IMS TM, and the JDBC driver for IMS. The Java API for IMS TMoffers transaction processing support, and the Java API for IMS DB offers databaseaccess support. The Java class libraries for IMS fulfills industry standards by alsocontaining a JDBC driver, which implements the standard JDBC 2.0 API. The JDBCdriver offers SQL support for IMS databases. All of the Java APIs are available foruse within the IMS dependent regions. The DB API and JDBC driver are availablefor use in external environments.

Javaapplication

Javaapplication

Javastored procedure

Javaapplication

JMP

CICS

IMS

DB2 for z/OS WebSphere Application Server

WebSphere Application Serverfor z/OS

IMS TM

IMS DB

JBP

Java classlibraries for IMS

Java classlibraries for

IMS DB

Java classlibraries for

IMS DB

IMS DB distributedresource adapter

IMS DBresource adapter

Java classlibraries for IMS

ODBA

ODBA

DRA

DRA

EJBcomponent

EJBcomponent

DRA

IIOP

Figure 81. Deploying Java applications in dependent regions and external developmentenvironments

362 Application Programming Guide

|

|||

||||||||

Page 387: IMS Application Programming.pdf

For IMS transaction processing support, the libraries provide interfaces that offercomplete message queue support (reading and writing), MFS support, programswitching support, transactional demarcation, conversational transaction support,and datatype conversion. For IMS database support, the libraries offer completeDL/I support, segment search argument support, command code support,database read/write support (includes all database types: full function, fastpath,HALDB), and datatype conversion.

For deployment on J2EE platforms, IMS provides two JCA resource adapters: theIMS DB resource adapter for the WebSphere Application Server running on a z/OSplatform, and the IMS DB distributed resource adapter running on a non-z/OSplatform. Both resource adapters are built on top of the existing JDBC driver forIMS.

The following topics will explain the roles of each of the class libraries in the Javaclass libraries as well as the resource adapters that are provided to access an IMSdatabase in a WebSphere Application Server development environment:v “JDBC driver for IMS”v “Java API for IMS DB” on page 364v “Java API for IMS TM” on page 364v “J2EE platform access to IMS DB” on page 365

Note: Java applications for IMS cannot run in an IMS batch environment.

Related reading: For information on configuring ODBA and DRA to access IMSdata, see the "Introduction to IMS databases" topic in the IMS Version 10: DatabaseAdministration Guide and the "Configuring external Java environments to accessIMS databases" topic in the IMS Version 10: Communications and Connections Guide.

JDBC driver for IMSThe JDBC driver provides the standard JDBC API for IMS database access. The APIsupports issuing SQL against an IMS database as opposed to IMS specific DL/Icalls. The driver implements the following JDBC interfaces:v Connection

v DatabaseMetaData

v Driver

v Statement

v ResultSet

v ResultSetMetaData

v PreparedStatement

Related reading: See the "Java class libraries for IMS enhancements" topic of theIMS Version 10: Release Planning Guide for details about the steps needed to use theJDBC driver. See the “JDBC access to IMS data" topic in the IMS Version 10:Application Programming API Reference for more details about implementation ofSQL statements and extensions, including XQuery statements, in your Javaapplication using the JDBC driver.

Chapter 25. Introduction to the Java class libraries for IMS 363

|||||||

|||||

|||

|

|

|

|

|

||||

||

|||

|

|

|

|

|

|

|

||||||

Page 388: IMS Application Programming.pdf

Java API for IMS DBThe Java API for IMS DB offers more granular database access than the JDBCdriver. For example, it allows IMS developers to build SSAs and issue any of thedatabase DL/I calls directly.v “GSAM database access”v “IMS hierarchical database interface for Java”

GSAM database accessJava application developers can fully utilize the existing data conversion routinesthat are offered in the Java class libraries for IMS when accessing GSAM databases.These Java class library classes enable all of the supported data types to be storedand read from a GSAM database record. The amount of specific databaseknowledge that an application developer must have is reduced when using theJava class libraries that access GSAM databases.

The following classes are provided for use with GSAM databases:v GSAMPCB

v GSAMConnection

v GSAMConnectionFactory

v GSAMRecord

Related readings: For more information about the methods of each class in thecom.ibm.ims.db package that provide access to GSAM databases, see the Java APIspecification for IMS.

IMS hierarchical database interface for JavaIf you need more controlled access than the higher-level JDBC package provides,you can use the non-JDBC API for IMS DB to perform qualified and unqualifiedsearch arguments in a hierarchical database. The following classes are provided toperform segment search arguments using Java:v DLIConnectionv DLISegmentv SSAv SSAListv DLIRecordv SSAQualificationStatement

Related Reading: See the com.ibm.ims.db package of the Java API specification forIMS for a full specification of the classes and methods in this topic that areassociated with the IMS hierarchical database interface for Java.

Java API for IMS TMThe libraries provide the following classes for processing IMS transactions:v IMSFieldMessage

v IMSMessageQueue

v IMSTransaction

v SaveArea

364 Application Programming Guide

||

|||

|

|

|

||||||

|

|

|

|

|

|||

|

||||

|

|

|

|

|

|

|||

||

|

|

|

|

|

Page 389: IMS Application Programming.pdf

Note: Processing of IMS transactions can only occur in an application that isrunning in a JMP or JBP region. It cannot occur in Java environments thatare external to IMS, such as a Websphere environment. See “DevelopingJMP and JBP applications” on page 368 for more details on using theseclasses.

Related reading: See the application package of the Java API specification for IMSfor a full specification as well as examples of implementation of the Java classlibraries that process IMS transactions.

J2EE platform access to IMS DBJava applications running on the J2EE platform can access IMS databases by usingeither the IMS DB resource adapter (for deployment in WebSphere ApplicationServer for z/OS) or the IMS DB distributed resource adapter (for deployment inWebSphere Application Server for distributed platforms).

Related reading:

v For more information about accessing IMS databases from your J2EEenvironment, see “Developing enterprise applications that access IMS” on page400.

v For more information regarding the configuration of your WebSphereenvironment to work with resource adapters, see the “Configuring WebSphereApplication Server for z/OS for the IMS DB resource adapter" and "Configuringthe application servers for IMS remote database services for Java" topics in theIMS Version 10: Communications and Connections Guide.

Chapter 25. Introduction to the Java class libraries for IMS 365

|||||

|||

||

||||

|

|||

|||||

Page 390: IMS Application Programming.pdf

366 Application Programming Guide

Page 391: IMS Application Programming.pdf

Chapter 26. Developing Java applications that work with IMS

You can develop your application so that it runs in a JMP or JBP region. You canalso develop your application in an environment external to IMS, including DB2,CICS, WebSphere Application Server for z/OS, as well as WebSphere ApplicationServer running on a non-z/OS platform.

The following topics provide more details:v “IMS IVP jobs, tasks, and sample applications”v “Developing JMP and JBP applications” on page 368v “Developing DB2® for z/OS® stored procedures that access IMS” on page 397v “Developing CICS applications that access IMS” on page 399v “Developing enterprise applications that access IMS” on page 400

Related Reading: See the "Java class libraries for IMS" topic in the IMS Version 10:Application Programming API Reference for a comprehensive list of Java classes andsupported SQL statements for use with Java applications that work with IMS. Forinformation on successful installation of Java support for IMS and verification ofJava support for IMS in JMP and JBP regions, see the "IVP jobs and tasks" and"Samples for the IMS solutions for Java development" topics in the IMS Version 10:Installation Guide. For information on successful verification of installation innon-IMS environments, such as DB2, CICS or with enterprise applications, see the"Configuring external Java environments to access IMS databases" topic in the IMSVersion 10: Communications and Connections Guide.

IMS IVP jobs, tasks, and sample applicationsAfter you have fulfilled the requirements for successful installation of Java in yourdevelopment environment, you can verify that your installation will work usingthe IMS installation verification program (IVP) . To use the IMS IVPs, run jobs andtasks in the base IMS IVPs for your JMP and JBP regions. These jobs, tasks, andsample applications in the base IVP to complete installation and verify thatreferences are set up correctly.

If you are using a development environment that is external to IMS, download thesample applications for all development environments as well as the IVPs forexternal environments from the IMS solutions for Java development Web site.

The following topics provide additional information about IMS IVP jobs, tasks, andsample applications:v The "IVP Jobs and Tasks" topic in the IMS Version 10: Installation Guide includes

details about the jobs and tasks that run the IMS IVP for JBP and JMP regions.v The "Samples for the IMS solutions for Java development" topic in the IMS

Version 10: Installation Guide provides information about the two sampleapplications that IMS provides for use with the IMS IVP for JBP and JMPregions.

v The "Configuring external Java environments to access IMS databases" topic inthe IMS Version 10: Communications and Connections Guide provides step-by-stepprocedures for running IMS IVPs with external Java environments.

© Copyright IBM Corp. 1974, 2010 367

|

||||||

|||

||

||

||||

|||

Page 392: IMS Application Programming.pdf

Related reading: For more information about the installation of Java support forIMS, see the "Hardware and software requirements" topic in the IMS Version 10:Release Planning Guide.

Developing JMP and JBP applicationsTwo IMS dependent regions provide a Java Virtual Machine (JVM) environment forJava applications:

Java message processing (JMP) regionsJMP regions are similar to MPP regions, but JMP regions allow thescheduling only of Java message-processing applications. A JMPapplication is started when there is a message in the queue for the JMPapplication and IMS schedules the message to be processed. JMPapplications are executed through transaction codes submitted by users atterminals and from other applications. Each transaction code represents atransaction that the JMP application processes. A single application canalso be started from multiple transaction codes.

JMP applications are very flexible in how they process transactions andwhere they send the output. JMP applications send any output messagesback to the message queues and process the next message with the sametransaction code. The program continues to run until there are no moremessages with the same transaction code. JMP applications share thefollowing characteristics:v They are small.v They can produce output that is needed immediately.v They can access IMS or DB2 data in a DB/DC environment and DB2

data in a DCCTL environment.

Java batch processing (JBP) regionsJBP regions run flexible programs that perform batch-type processingonline and can access the IMS message queues for output (similar tonon-message-driven BMP applications). JBP applications are started bysubmitting a job with JCL or from TSO. JBP applications are like BMPapplications, except that they cannot read input messages from the IMSmessage queue. For example, there is no IN= parameter in the startupprocedure. Similarly to BMP applications, JBP applications can usesymbolic checkpoint and restart calls to restart the application after anabend. JBP applications can access IMS or DB2 UDB for z/OS data in aDB/DC or DBCTL environment and DB2 for z/OS data in a DCCTLenvironment

Important: JMP and JBP regions are not necessary if your application runs inWebSphere Application Server, DB2 for z/OS , or CICS. JMP or JBPregions are needed only if your application is going to run in an IMSdependent region.

Figure 82 on page 369 shows a Java application that is running in a JMP or JBPregion. JDBC or IMS hierarchical database interface for Java are passed to the IMSBase API for Java, which converts the calls to DL/I calls.

368 Application Programming Guide

|||

|

||

|||||||||

||||||

|

|

||

||||||||||||

||||

||||

Page 393: IMS Application Programming.pdf

JMP and JBP regions can run applications written in Java, object-oriented COBOL,or a combination of the two. See “Enterprise COBOL interoperability with JMP andJBP applications” on page 392.

JMP and JBP applications can access DB2 for z/OS databases in addition to IMSdatabases. See “Accessing DB2 for z/OS databases from JMP or JBP applications”on page 393.

This chapter uses the sample applications that are shipped with IMS solutions forJava development to show how to write and deploy Java applications that run inJMP and JBP regions.

If you want to write and test Java applications that access IMS data, you can usethe sample application for IMS solutions for Java development, which is availableon the IMS Web site atIMS solutions for Java development website. This sampleapplication can be downloaded from the IMS Web site. The sample application forthe IMS solutions for Java development provides a working sample that is runagainst the Dealership database and helps application developers build Javaapplications. The Dealership database is built by the IMS IVP jobs and tasks whenyou verify your IMS installation. For more information on the IVP jobs and tasksfor the IMS sample application for XQuery support in IMS, see the IMS Version 10:Installation Guide.

The following topics provide additional information:v “Developing JMP applications” on page 370v “Developing JBP applications” on page 380v “Enterprise COBOL interoperability with JMP and JBP applications” on page 392v “Accessing DB2 for z/OS databases from JMP or JBP applications” on page 393v “Program switching in JMP and JBP applications” on page 394v “Issuing synchronous callout requests from a Java dependent region” on page

395

Figure 82. JMP or JBP application that is using the Java class libraries for IMS

Chapter 26. Developing Java applications that work with IMS 369

|

||||||

|||

|||

||||||||||

|

|

|

|

|

|

||

Page 394: IMS Application Programming.pdf

Developing JMP applicationsJMP applications access the IMS message queue to receive messages to process andto send output messages. You must define input and output message classessubclassing the IMSFieldMessage class. The Java class libraries for IMS provide thecapability to process IMSFieldMessage objects.

Related Reading: For details about the classes you use to develop a JMPapplication, see the Java API specification for IMS.

The following topics provide additional information:v “Subclassing the IMSFieldMessage class to define input messages”v “Subclassing the IMSFieldMessage class to define output messages”v “Implementing the main method” on page 371v “JMP programming models” on page 372v “Additional message handling considerations for JMP applications” on page 374

Subclassing the IMSFieldMessage class to define inputmessagesThe following figure shows an example of subclassing the IMSFieldMessage class.This class defines an input message that accepts a 2-byte type code of a car modelto query a car dealership database for available car models.

This example code subclasses the IMSFieldMessage class to make the fields in themessage available to the program and creates an array of DLITypeInfo objects forthe fields in the message. For the DLITypeInfo class, the code identifies first thefield name, then the data type, the position, and finally the length of the individualfields within the array. This allows the application to use the access functionswithin the IMSFieldMessage class hierarchy to automatically convert the data fromits format in the message to a Java type that the application can process. Inaddition to the message-specific fields it defines, the IMSFieldMessage classprovides access functions that allow it to determine the transaction code and thelength of the message.

Subclassing the IMSFieldMessage class to define outputmessagesThe following figure shows a sample of subclassing IMSFieldMessage to define anoutput message that displays the available car models from a type code query.

package dealership.application;import com.ibm.ims.db.*;import com.ibm.ims.base.*;import com.ibm.ims.application.*;

/* Subclasses IMSFieldMessage to define application's input messages */public class InputMessage extends IMSFieldMessage {

/* Creates array of DLITypeInfo objects for the fields in message */final static DLITypeInfo[]fieldInfo={

new DLITypeInfo("ModelTypeCode", DLITypeInfo.CHAR, 1, 2)};

public InputMessage() {super(fieldInfo, 2, false);

}}

Figure 83. Subclass IMSFieldMessage: input message sample code

370 Application Programming Guide

||||||||||||||||||||

|

||||

||

|

|

|

|

|

|

|||||

||||||||||||

||||

Page 395: IMS Application Programming.pdf

This sample code creates an array of DLITypeInfo objects and then passes thatarray, the byte array length, and the boolean value false, which indicates anon-SPA message, to the IMSFieldMessage constructor. For each DLITypeInfo object,you must first identify the field data type, then the field name, the field offset inthe byte array, and finally the length of the byte array.

Implementing the main methodThe main method (public static void main(String[] args)) is the entry pointinto all JMP and JBP applications.

The sample code and notes in the following figure describe how to implement themain method:

package dealership.application;import com.ibm.ims.db.*;import com.ibm.ims.base.*;import com.ibm.ims.application.*;

/*Subclasses IMSFieldMessage to define application's output messages */public class ModelOutput extends IMSFieldMessage {

/* Creates array of DLITypeInfo objects for the fields in message */final static DLITypeInfo[] fieldInfo={

new DLITypeInfo("Type", DLITypeInfo.CHAR, 1, 2),new DLITypeInfo("Make", DLITypeInfo.CHAR, 3, 10),new DLITypeInfo("Model", DLITypeInfo.CHAR, 13, 10),new DLITypeInfo("Year", DLITypeInfo.DOUBLE, 23, 4),new DLITypeInfo("CityMiles", DLITypeInfo.CHAR, 27, 4),new DLITypeInfo("HighwayMiles", DLITypeInfo.CHAR, 31, 4),new DLITypeInfo("Horsepower", DLITypeInfo.CHAR, 35, 4)

};

public ModelOutput() {super(fieldInfo, 38,false);

}

}

Figure 84. Subclass IMSFieldMessage: output message sample code

Chapter 26. Developing Java applications that work with IMS 371

|||||||||||||||||||||||||||

|||||||

|||

|||

Page 396: IMS Application Programming.pdf

1. The IMSMessageQueue.getUniqueMessage method returns true if a message wasread from the queue and false if one was not.

2. Query the database for a specific model that matches the input model typecode.

3. Return detailed information about that specific model as output if it is availableat the dealership.

4. The IMSTransaction.getTransaction().commit method must be called beforereceiving subsequent messages from the queue.

5. Return an error message if the model is not available at the dealership.

JMP programming modelsJMP applications get input messages from the IMS message queue, access IMSdatabases, commit transactions, and can send output messages.

JMP applications are started when IMS receives a message with a transaction codefor the JMP application and schedules the message. JMP applications end whenthere are no more messages with that transaction code to process.

JMP application: A transaction begins when the application gets an inputmessage and ends when the application commits the results from processing themessage. To get an input message, the application calls the getUniqueMessagemethod. Figure 86 on page 373 shows the main method sample code for processingan input message.

package dealership.ims;import com.ibm.ims.application.*;

public static void main(String args[]) {IMSMessageQueue messageQueue = null;InputMessage inputMessage = null;ModelOutput modelOutput = null;

messageQueue = new IMSMessageQueue();inputMessage = new InputMessage();modelOutput = new ModelOutput();

while(messageQueue.getUniqueMessage(inputMessage)) { // 1if (!inputMessage.getString

("ModelTypeCode").trim().equals("")){if (getModelDetails(inputMessage, modelOutput)) // 2

messageQueue.insertMessage(modelOutput); // 3,4}

else {reply("Invalid Input"); // 5

}}

public void reply(String errmsg) throws IMSException{ErrorMessage errorMessage = new ErrorMessage();errorMessage.setString("MessageText",errmsg);messageQueue.insertMessage(errorMessage);

}

}

Figure 85. main method sample code

372 Application Programming Guide

|||||||||||||||||||||||||||||||

|||||

||

||

||

|

|||

|||

||||||

Page 397: IMS Application Programming.pdf

JMP application that uses the rollback call: A JMP application can roll backdatabase processing and output messages any number of times during atransaction. A rollback call backs out all database processing and output messagesto the most recent commit.

The following example shows a JMP application that will roll back databaseprocessing.public static void main(String args[]) {

conn = DriverManager.getConnection(...); //Establish DB connection

while(MessageQueue.getUniqueMessage(...)){ //Get input message, which//starts transaction

results=statement.executeQuery(...); //Perform DB processing...MessageQueue.insertMessage(...); //Send output messages...IMSTransaction.getTransaction().rollback(); //Roll back DB processing

//and output messages

results=statement.executeQuery(...); //Perform more DB processing//(optional)

...MessageQueue.insertMessage(...); //Send more output messages

//(optional)}

conn.close(); //Close DB connectionreturn;

}

JMP application that accesses IMS or DB2 for z/OS data: When a JMPapplication accesses only IMS data, it must open a database connection only onceto process multiple transactions, as shown in “JMP application” on page 372.However, a JMP application that accesses DB2 for z/OS data must open and closea database connection for each message that is processed.

The following model is valid for both DB2 for z/OS database access and IMSdatabase access:

public static void main(String args[]) {

conn = DriverManager.getConnection(...); //Establish DB connection

while(MessageQueue.getUniqueMessage(...)){ //Get input message, which//starts transaction

results=statement.executeQuery(...); //Perform DB processing...MessageQueue.insertMessage(...); //Send output messages...

}

conn.close(); //Close DB connectionreturn;

}

Figure 86. main method sample code

Chapter 26. Developing Java applications that work with IMS 373

|||||||||||||||||

|||||||

||

||||||||||||||||||||||||

|||||

||

Page 398: IMS Application Programming.pdf

public static void main(String args[]) {

while(MessageQueue.getUniqueMessage(...)){ //Get input message, which//starts transaction

conn = DriverManager.getConnection(...); //Establish DB connection

results=statement.executeQuery(...); //Perform DB processing...MessageQueue.insertMessage(...); //Send output messages...conn.close(); //Close DB connection

}

return;}

Related Reading: For more information about accessing DB2 data from a JMPapplication, see “Accessing DB2 for z/OS databases from JMP or JBP applications”on page 393.

Additional message handling considerations for JMPapplicationsJMP applications access the IMS message queue in addition to IMS or DB2 UDBfor z/OS databases. This topic provides information about specific programmingconsiderations for the IMS message queue.

In this topic:v “Conversational transactions”v “Handling multi-segment messages” on page 376v “Coding and accessing messages with repeating structures” on page 377v “Flexible reading of multiple input messages” on page 378

Conversational transactions: A conversational program runs in a JMP region andprocesses conversational transactions that are made up of several steps. It does notprocess the entire transaction at the same time. A conversational program dividesprocessing into a connected series of terminal-to-program-to-terminal interactions.Use conversational processing when one transaction contains several parts.

A nonconversational program receives a message from a terminal, processes therequest, and sends a message back to the terminal. A conversational programreceives a message from a terminal and replies to the terminal, but it saves thedata from the transaction in a scratchpad Area (SPA). Then, when the person at theterminal enters more data, the program has the data it saved from the last messagein the SPA, so it can continue processing the request without the person at theterminal having to enter the data again. The application package classes enableapplications to be built using the Java class libraries for IMS.

Related Reading: For more information about conversational andnonconversational transaction processing, see IMS Version 10: Communications andConnections Guide.

Defining a SPA message in a conversational program: To define a SPA message in aconversational program:1. Define the SPA message (including the boolean as a SPA parameter). By default,

all messages going to (input) and from (output) a Java application aretransmitted as EBCDIC character data. To use a different type of encoding, youmust call the IMSFieldMessage class inherited method setDefaultEncoding and

374 Application Programming Guide

||||||||||||||||

|||

|||||

|

|

|

|

|

|||||

||||||||

|||

||

||||

Page 399: IMS Application Programming.pdf

provide the new encoding type. This encoding can be any Java-supportedencoding type. In Figure 87, the default encoding is specified as UTF-8.

2. Read the SPA message before reading the application messages:

3. Write the SPA message before sending any output messages:

public class SPAMessage extends IMSFieldMessage {static DLITypeInfo[] fieldInfo = {

new DLITypeInfo("SessionNumber",DLITypeInfo.SMALLINT,1, 2),new DLITypeInfo("ProcessCode", DLITypeInfo.CHAR, 3, 8),new DLITypeInfo("LastName", DLITypeInfo.CHAR, 11,10),new DLITypeInfo("FirstName", DLITypeInfo.CHAR, 21,10),new DLITypeInfo("Extension", DLITypeInfo.CHAR, 31,10),new DLITypeInfo("ZipCode", DLITypeInfo.CHAR, 41, 7),new DLITypeInfo("Reserved", DLITypeInfo.CHAR, 48,19) };

public SPAMessage() {super(fieldInfo, 66, true);setDefaultEncoding("UTF-8");

}}

Figure 87. Defining a SPA message

try {// Get the SPA datamsgReceived = msgQ.getUniqueMessage(spaMessage);

}catch (IMSException e){

if (e.getStatusCode() !=JavaToDLI.MESSAGE_QUEUED_PRIOR_TO_LAST_START)

throw e;}if (!msgReceived)

outputMessage.setString("Message","UNABLE TO READ SPA");else if (!msgQ.getNextMessage(inputMessage))

// No input message receivedoutputMessage.setString("Message","NO INPUT MESSAGE");

else if ((spaMessage.getShort("SessionNumber")==0)&& (!inputMessage.getString("ProcessCode").trim().equals("END"))&& (inputMessage.getString("LastName").trim().equals("")))// New Conversation. User has to specify last name.outputMessage.setString("Message","LAST NAME WAS NOT SPECIFIED");

else {{

Figure 88. Reading a SPA message

Chapter 26. Developing Java applications that work with IMS 375

|||||||||

||||||||

|||||||||||||||||||||||||

|||

||

||

Page 400: IMS Application Programming.pdf

4. End the conversation by using the version of the insertMessage method thatcontains a boolean isLast argument set to true:msgQ.insertMessage(spaMessage, true);

Conversational transaction sequence of events: When the message is a conversationaltransaction, the following sequence of events occurs:1. IMS removes the transaction code and places it at the beginning of a message

segment. The message segment is equal in length to the SPA that was definedfor this transaction during system definition. This is the first segment of theinput message that is made available to the program. The second through thenth segments from the terminal, minus the transaction code, become theremainder of the message that is presented to the application program.

2. After the conversational program prepares its reply, it inserts the SPA to IMS.The program then inserts the actual text of the reply as segments of an outputmessage.

3. IMS saves the SPA and routes the message to the input LTERM (logicalterminal).

4. If the SPA insert specifies that another program is to continue the sameconversation, the total reply (including the SPA) is retained on the messagequeue as input to the next program. This program then receives the message ina similar form.

5. A conversational program must be scheduled for each input exchange. Theother processing continues while the operator at the input terminal examinesthe reply and prepares new input messages.

6. To terminate a conversation, the program places blanks in the transaction codefield of the SPA and inserts the SPA to IMS. In the Java class libraries for IMS,this happens when you call IMSMessageQueue.insertMessage with the booleanparameter isLast set to true.

7. The conversation can also be terminated if the transaction code in the SPA isreplaced by any nonconversational program’s transaction code, and the SPA isinserted to IMS. After the next terminal input, IMS routes that message to theother program’s queue in the normal way.

Handling multi-segment messages: Message-driven applications can havemulti-segment input messages. That is, more than one message needs to be readfrom the message queue in order to retrieve the entire message. When this occurs,you must provide a mapping for each message that is to be read from the queueand use the appropriate methods available from the IMSMessageQueue class.

The following code defines two input messages that comprise a multi-segmentmessage:

// Set spa data fieldsspaMessage.setString("ProcessCode",

inputMessage.getString("ProcessCode"));spaMessage.setString("LastName",

inputMessage.getString("LastName"));spaMessage.setString("FirstName",

inputMessage.getString("FirstName"));spaMessage.setString("Extension",

inputMessage.getString("Extension"));spaMessage.setString("ZipCode",

inputMessage.getString("ZipCode"));spaMessage.incrementSessionNumber();msgQ.insertMessage(spaMessage);

Figure 89. Writing a SPA message

376 Application Programming Guide

||||||||||||||||||

|

||

||||||

|||

||

||||

|||

||||

||||

|||||

||

Page 401: IMS Application Programming.pdf

public class InputMessage1 extends IMSFieldMessage {

final static DLITypeInfo[] segmentInfo = {new DLITypeInfo("Field1", DLITypeInfo.CHAR, 1, 10),new DLITypeInfo("Field2", DLITypeInfo.INTEGER, 11, 4)

};

public InputMessage1() {super(segmentInfo, 14, false);

}}

public class InputMessage2 extends IMSFieldMessage {

final static DLITypeInfo[] segmentInfo = {new DLITypeInfo("Field1", DLITypeInfo.CHAR, 1, 10),new DLITypeInfo("Field2", DLITypeInfo.CHAR, 11, 8)

};

public InputMessage2() {super(segmentInfo, 18, false);

}}

The following code shows how the message queue is used to retrieve bothmessages://Create a message queueIMSMessageQueue messageQueue = new IMSMessageQueue();//Create the first input messageInputMessage1 input1 = new InputMessage1();//Create the second input messageInputMessage2 input2 = new InputMessage2();

try {//Read the first message from the queuemessageQueue.getUniqueMessage(input1);...//Read the second message from the queuemessageQueue.getNextMessage(input2);...

} catch (IMSException e) {...

}

Coding and accessing messages with repeating structures: Messages withrepeating structures can be defined by using the DLITypeInfoList class. With theDLITypeInfoList class, you can specify a repeating list of fields and the maximumnumber of times the list can be repeated. These repeating structures can containrepeating structures.

Figure 90 on page 378 is a sample output message that contains a set of Make,Model, and Color fields, with a count field to identify how many occurrences werestored:

Chapter 26. Developing Java applications that work with IMS 377

|||||||||||||||||||||||

||

|||||||||||||||||

|||||

||||

Page 402: IMS Application Programming.pdf

To access the nested structures that are defined in a DLITypeInfoList object, use adotted notation to specify the fields and the index of the field within a repeatingstructure. This dotted notation can use either the field names or field indexes. Forexample, the “Color” field in the fourth “Models” definition in the ModelOutputobject is accessed as “Models.4.Color” within the ModelOutput message. Thefollowing code sets the fourth “Color” in the ModelOutput message to “Red.”ModelOutput output= new ModelOutput();output.setString("Models.4.Color", "Red");

The following code uses field indexes instead of field names to make the samechange to the ModelOutput message:ModelOutput output= new ModelOutput();output.setString("2.4.3", "Red");

Flexible reading of multiple input messages: There are times when anapplication needs to process multiple input messages that require different inputdata types. For example, the car dealership sample application supports requests tolist models, show model details, find cars, cancel orders, and record sales. Each ofthese requests requires different input data. The following steps explain how todefine the messages to support these requests, and how to access the messagesfrom the application.1. Define the primary input message. The primary input message is the message

that you pass to the IMSMessageQueue.getUniqueMessage method to retrieve allof your input messages. Your primary input message must have an I/O areathat is large enough to contain any of the input requests that your applicationmight receive. It must also contain at least one field in common with all ofyour input messages. This common field allows you to determine the inputrequest. In the example in Figure 91, the common field is CommandCode, and themaximum length of each message is 64 (the number passed to theIMSFieldMessage constructor):

public class ModelOutput extends IMSFieldMessage {static DLITypeInfo[] modelTypeInfo = {

new DLITypeInfo("Make", DLITypeInfo.CHAR, 1, 20),new DLITypeInfo("Model", DLITypeInfo.CHAR, 21, 20),new DLITypeInfo("Color", DLITypeInfo.CHAR, 41, 20),};

static DLITypeInfo[] modelTypeInfoList = {new DLITypeInfo("ModelCount", DLITypeInfo.INTEGER, 1, 4),new DLITypeInfoList("Models", modelTypeInfo, 5, 60, 100),};

public ModelOutput() {super(modelOutputTypeInfo, 6004, false);

} }

Figure 90. Sample output message with repeating structures

public class InputMessage extends IMSFieldMessage {

final static DLITypeInfo[] fieldInfo = {

new DLITypeInfo("CommandCode", DLITypeInfo.CHAR, 1, 20), �A�};

public InputMessage(DLITypeInfo[] fieldInfo){

super(fieldInfo, 64, false); �B�}

}

Figure 91. Defining the primary input message

378 Application Programming Guide

||||||||||||||||

||||||||||||||

||||||

||

||

||

|||||||

||||||||||

Page 403: IMS Application Programming.pdf

2. Define separate input messages for each request. Each of these input messagescontains the same CommandCode field as its first field. Each of these inputmessages also uses an IMSFieldMessage constructor that takes anIMSFieldMessage object and a DLITypeInfo array. The IMSFieldMessageconstructor allows you to remap the contents of the primary input messageusing the same type of information with each request; therefore, you do notcopy the I/O area of the message, only a reference to this area. Figure 92illustrates code that creates the input messages for the requestsShowModelDetails, FindACar, and CancelOrder.

Note the following details about Figure 91 on page 378 and Figure 92:v The CommandCode field is defined within every class at lines �A�, �C�, �E�, and

�G�. This field must be defined in every message that reads the command code.If you do not define the field, you must adjust the offsets of the following fieldsto account for the existence of the CommandCode in the byte array. For

public class ShowModelDetailsInput extends IMSFieldMessage {

final static DLITypeInfo[] fieldInfo = {

new DLITypeInfo("CommandCode", DLITypeInfo.CHAR, 1, 20), �C�

new DLITypeInfo("ModelTypeCode", DLITypeInfo.CHAR, 21, 2),

};

public ShowModelDetailsInput(InputMessage inputMessage) { �D�

super(inputMessage, fieldInfo);

}}

public class FindACarInput extends IMSFieldMessage {

final static DLITypeInfo[] fieldInfo = {

new DLITypeInfo("CommandCode", DLITypeInfo.CHAR, 1, 20), �E�

new DLITypeInfo("Make", DLITypeInfo.CHAR, 21, 10),

new DLITypeInfo("Model", DLITypeInfo.CHAR, 31, 10),

new DLITypeInfo("Year", DLITypeInfo.CHAR, 41, 4),

new DLITypeInfo("LowPrice", DLITypeInfo.PACKEDDECIMAL, 45, 5),

new DLITypeInfo("HighPrice", DLITypeInfo.PACKEDDECIMAL, 50, 5),

new DLITypeInfo("Color", DLITypeInfo.CHAR, 55, 10),

};

public FindACarInput(InputMessage inputMessage) { �F�

super(inputMessage, fieldInfo);

}}

public class CancelOrderInput extends IMSFieldMessage {

final static DLITypeInfo[] fieldInfo = {

new DLITypeInfo("CommandCode", DLITypeInfo.CHAR, 1, 20), �G�

new DLITypeInfo("OrderNumber", DLITypeInfo.CHAR, 21, 6),

new DLITypeInfo("DealerNumber", DLITypeInfo.CHAR, 21, 6),

};

public CancelOrderInput(InputMessage inputMessage) �H�

{

super(inputMessage, fieldInfo);

}

Figure 92. Defining separate input messages for each request

Chapter 26. Developing Java applications that work with IMS 379

|

|

|

|

|

|

|

||

|

|

|

|

|

|

|

|

|

|

|

|

||

|

|

|

|

|

|

|

|

|

||||

||||||||||

|

||||

Page 404: IMS Application Programming.pdf

example, you can delete the DLITypeInfo entry for CommandCode in theCancelOrderInput class, but the OrderNumber field must still start at offset 21.

v The length of the base class InputMessage must be large enough to contain anyof its subclasses. In this example, the InputMessage class is 65 bytes because thefields of the FindACarInput method require it �B�.

v Each InputMessage subclass must provide a constructor to create itself from anInputMessage object, as in lines �D�, �F�, and �H�. This constructor uses a newconstructor in the IMSFieldMessage class, called a copy constructor.

Given this design, an application can provide message-reading logic similar to thatshown in Figure 93.

Developing JBP applicationsJBP applications do not access the IMS message queue. Therefore, you do not needto subclass the IMSFieldMessage class.

The following topics provide additional information:v “Symbolic checkpoint and restart”v “JBP programming models” on page 381

Related Reading: For details about the classes you use to develop a JBPapplication, see the Java API specification for IMS.

Symbolic checkpoint and restartSimilarly to BMP applications, JBP applications can use symbolic checkpoint andrestart calls to restart the application after an abend. The primary methods forsymbolic checkpoint and restart are:v IMSTransaction().checkpoint()

v IMSTransaction().restart()

These methods perform functions that are analogous to the DL/I system servicecalls: (symbolic) CHKP and XRST.

A JBP application connects to a database, makes a restart call, performs databaseprocessing, periodically checkpoints, and disconnects from the database at the endof the program. The program must issue a final commit before ending. On aninitial application start, the IMSTransaction().restart() method notifies IMS thatsymbolic checkpoint and restart is to be enabled for the application. Theapplication then issues periodic IMSTransaction().checkpoint() calls to takecheckpoints. The IMSTransaction().checkpoint() method allows the application to

while (getUniqueMessage(inputMessage)) {

string commandCode=inputMsg.getString("CommandCode").trim();

if (commandCode.equals("ShowModelDetails")) {showModelDetails(new ShowModelDetailsInput(inputMessage));

} else if(commandCode.equals("FindACar")) {findACar(new FindACarInput(inputMessage));

} else {//process an error

}

}

Figure 93. Message-reading logic

380 Application Programming Guide

||||||||||||||||||

||

|||

|||

||||

|

||

|

|

|

||

||||

|

|

||

|||||||

Page 405: IMS Application Programming.pdf

provide a com.ibm.ims.application.SaveArea object that contains one or moreother application Java objects whose state is to be saved with the checkpoint.

If a restart is required, it is initiated in a similar way to BMP applications: thecheckpoint ID is provided either with the IMSTransaction().restart() call(similarly to providing the ID to the XRST call in IMS), or with in the CKPTID=parameter of the JBP region JCL. The restart() method returns a SaveArea objectthat contains the application objects in the same order in which they wereoriginally checkpointed.

Symbolic checkpoint and restart calls may also be used with GSAM data, or z/OSdata sets. To restart using a basic z/OS checkpoint, you must identify the restartcheckpoint. However, if you use IMS symbolic checkpoint is used to access GSAMdata, you can use the LAST keyword to quickly locate the preferred point of restart.

Related Reading: For the programming model for symbolic checkpoint and restart,see “JBP application with symbolic checkpoint and restart.”

JBP programming modelsJBP applications are similar to JMP applications, except that JBP applications donot receive input messages from the IMS message queue.

Unlike BMP applications, JBP applications must be non-message-drivenapplications.

JBP application: A JBP application connects to a database, performs databaseprocessing, and disconnects from the database at the end of the program, as shownin the following example.public static void main(String args[]) {

conn = DriverManager.getConnection(...); //Establish DB connection

repeat {

repeat {results=statement.executeQuery(...); //Perform DB processing...MessageQueue.insertMessage(...); //Send output messages...

}}

conn.close(); //Close DB connectionreturn;

}

JBP application with symbolic checkpoint and restart: A JBP applicationconnects to a database, makes a restart call, performs database processing,periodically checkpoints, and disconnects from the database at the end of theprogram. The program must issue a final commit before ending.public static void main(String args[]) {

conn = DriverManager.getConnection(...); //Establish DB connection

IMSTransaction.getTransaction().retart(); //Restart application//after abend from last//checkpoint

repeat {

repeat {

Chapter 26. Developing Java applications that work with IMS 381

||

||||||

||||

||

|||

||

|||

|||||||||||||||||

||||

||||||||||

Page 406: IMS Application Programming.pdf

results=statement.executeQuery(...); //Perform DB processing...MessageQueue.insertMessage(...); //Send output messages...

}

IMSTransaction.getTransaction().checkpoint(); //Periodic checkpoints// divide work

}

conn.close(); //Close DB connectionreturn;

}

JBP application using rollback: Similarly to JMP applications, JBP applicationscan also roll back database processing and output messages, as shown in thefollowing example.public static void main(String args[]) {

conn = DriverManager.getConnection(...); //Establish DB connection

repeat {

repeat {

results=statement.executeQuery(...); //Perform DB processing...MessageQueue.insertMessage(...); //Send output messages...IMSTransaction.getTransaction().rollback(); //Roll out DB

//processing and output//messages

results=statement.executeQuery(...); //Perform more DB//processing (optional)

...MessageQueue.insertMessage(...); //Send more output

//messages (optional)...

}}

conn.close(); //Close DB connectionreturn;

}

JBP application that accesses DB2 for z/OS or IMS data: Similarly to a JBPapplication that accesses IMS data, a JBP application that accesses DB2 for z/OSdata connects to a database, performs database processing, and disconnects fromthe database at the end of the application.

The following model is valid for DB2 for z/OS database access, IMS databaseaccess, or both DB2 for z/OS and IMS database access.public void doBegin() ... { //Application logic runs

//doBegin methodconn = DriverManager.getConnection(...); //Establish DB connection

repeat {repeat {

results=statement.executeQuery(...); //Perform DB processing...MessageQueue.insertMessage(...); //Send output messages...

}

382 Application Programming Guide

|||||||||||||

|||

||||||||||||||||||||||||||||

||||

||

||||||||||

Page 407: IMS Application Programming.pdf

conn.close(); //Close DB connection

return;}

Related Reading: For more information about accessing DB2 for z/OS data from aJBP application, see “Accessing DB2 for z/OS databases from JMP or JBPapplications” on page 393.

JBP applications that access GSAM data: A JBP application that accesses GSAMdata connects to a GSAM database, performs database processing, periodicallycommits, and disconnects from the database at the end of the application. GSAMdata are frequently referred to as z\OS data sets or, more commonly, as flat files.This kind of data is non-hierarchical in structure.

A JBP application that access GSAM data relies upon the Java database metadataclass, which creates an array of DLISegmentInfo and DLITypeInfo objects that act asa container for segment information in a DL/I database.

The following Java code sample provides an example of the Java databasemetadata class:package samples.dealership.gsam;

import com.ibm.ims.application.*;import com.ibm.ims.db.*;import com.ibm.ims.base.*;import java.sql.*;import java.io.*;import java.util.*;import java.math.BigDecimal;

/*** This is a auto dealership sample application* demonstrating the use of the GSAM database* functionality support in the Java class libraries for IMS.**/public class GSAMAuto {

private final String readOnlyGSAMPCB = new String("GSAMRead");private final String writeOnlyGSAMPCB = new String("GSAMLoad");

/*** The entry point of the application*/public static void main(String[] args) {

GSAMAuto gsamLoadSample = new GSAMAuto();

gsamLoadSample.setup();

gsamLoadSample.runSample();

gsamLoadSample.closeDown();

}

/** This method does the set up for the application:* 1. Enable trace* 2. Creates dbConnection* 3. Creates GSAMConnection object*/void setup() {

XMLTrace.enable("GSAMAuto", XMLTrace.TRACE_DATA3);

Chapter 26. Developing Java applications that work with IMS 383

||||

|||

|||||

|||

||

||||||||||||||||||||||||||||||||||||||||||

Page 408: IMS Application Programming.pdf

try {XMLTrace.createOutputFile("/tmp/GSAMAuto.xml");

} catch (IOException e) {XMLTrace.setOutputStream(System.err);

}}

/*** This method does the clean up before application exit.* 1. Commits the database work done. IMS Dependent* regions require all applications to commit before* exiting.* 2. Close the XML tracing.** @exception Exception*/void closeDown() {

try {// Always commit any work before exitingIMSTransaction.getTransaction().commit();

} catch (IMSException e) {System.out.println("IMS commit failed. Reason: "+e.toString());

}

// Always close the traceXMLTrace.close();

}

/*** Demonstrates how to write to and read from a GSAM database.* Also shows different data types being stored into the GSAM* database using the internal data conversion methods of the

* Java class libraries for IMS.*/void runSample() {

if (XMLTrace.traceOn) {XMLTrace.currentTrace().logEntry(XMLTrace.TRACE_METHOD3,

"GSAMAuto.runSample()");}

final int dealerNo = 1171;final String dealerName = "ABC Autos";final String modelType = "LX";final String make = "Santro";final String model = "Zen";final java.sql.Date year = java.sql.Date.valueOf("2006-05-18");final BigDecimal msrp = new BigDecimal(17750.00);final short count = (short) 8;

try {// Create a GSAM Connection FactoryGSAMConnectionFactory gcf =

GSAMConnectionFactory.createInstance("samples.dealership.gsam.AUTOGSAMDatabaseView");

// Open a GSAM Connection to write the GSAM datasetGSAMConnection gsamConnection1 =

gcf.createConnection(this.writeOnlyGSAMPCB, GSAMConnection.WRITE);

GSAMRecord myGSAMRecord =gsamConnection1.getDBView().cloneGSAMRecord(

this.writeOnlyGSAMPCB);

// Clear the GSAM Record object data partchar [] blankArray = new char[myGSAMRecord.getIOAreaLength()];

384 Application Programming Guide

|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||

Page 409: IMS Application Programming.pdf

byte[] blankIOArea = (new String(blankArray)).getBytes();myGSAMRecord.setIOArea(blankIOArea);

// Set values to individual fields in a GSAM recordmyGSAMRecord.setInt("DealerNo", dealerNo);myGSAMRecord.setString("DealerName", dealerName);myGSAMRecord.setString("ModelType", modelType);myGSAMRecord.setString("Make", make);myGSAMRecord.setString("Model", model);myGSAMRecord.setDate("Year", year);myGSAMRecord.setBigDecimal("MSRP", msrp);myGSAMRecord.setShort("Counter", count);

// Insert the GSAM record data and save the RSA of the recordgsamConnection1.insert(myGSAMRecord);RSA rsa = gsamConnection1.getAIB().getGSAMPCB().getRSA();

// Close the GSAM database explicitly for writing/loading datagsamConnection1.close();

// Open a GSAM Connection to write the GSAM datasetGSAMConnection gsamConnection2 =

gcf.createConnection(this.readOnlyGSAMPCB, GSAMConnection.READ);

// Read the GSAM record data using the RSA stored earlierGSAMRecord gsamRecord = gsamConnection2.getUnique(rsa);

// Print the GSAM dataif (gsamRecord != null) {

System.out.println("Dealer Number: "+gsamRecord.getInt("DealerNo"));

System.out.println("Dealer Name: "+gsamRecord.getString("DealerName"));

System.out.println("Model Type: "+gsamRecord.getString("ModelType"));

System.out.println("Make: "+gsamRecord.getString("Make"));System.out.println("Model: "+gsamRecord.getString("Model"));System.out.println("Year: "+gsamRecord.getDate("Year"));System.out.println("MSRP: "+gsamRecord.getBigDecimal("MSRP"));System.out.println("Counter: "+gsamRecord.getShort("Counter"));

System.out.println("\nSuccessful completion of GSAM sample application");

}

} catch (IMSException e) {System.out.println("GSAM sample failed. Reason: "+e.toString());

}if (XMLTrace.traceOn) {

XMLTrace.currentTrace().logExit(XMLTrace.TRACE_DATA3, "GSAMAuto.runSample()");

}}

}

The following Java code sample is a JBP application that relies on the previouscode sample to access GSAM data.package samples.dealership.gsam;

import com.ibm.ims.db.*;import com.ibm.ims.base.*;

public class AUTOGSAMDatabaseView extends DLIDatabaseView {

// This class describes the data view of PSB: AUTOGSAM// PSB AUTOGSAM has database PCBs with 8-char PCBNAME or label:

Chapter 26. Developing Java applications that work with IMS 385

||||||||||||||||||||||||||||||||||||||||||||||||||||||

||

|||||||||

Page 410: IMS Application Programming.pdf

// AUTOLPCB// AUTS1PCB// AUTS2PCB// AUSI2PCB// EMPLPCB// PCBGSAMG// PCBGSAML

// The following describes Segment: DEALER ("DEALER") in PCB:// AUTOLPCB ("AUTOLPCB")

static DLITypeInfo[] AUTOLPCBDEALERArray= {new DLITypeInfo("DLRNO", DLITypeInfo.CHAR, 1, 4,

"DLRNO", DLITypeInfo.UNIQUE_KEY),new DLITypeInfo("DLRNAME", DLITypeInfo.CHAR, 5, 30, "DLRNAME"),new DLITypeInfo("CITY", DLITypeInfo.CHAR, 35, 10, "CITY"),new DLITypeInfo("ZIP", DLITypeInfo.CHAR, 45, 10, "ZIP"),new DLITypeInfo("PHONE", DLITypeInfo.CHAR, 55, 7, "PHONE")

};static DLISegment AUTOLPCBDEALERSegment= new DLISegment

("DEALER","DEALER",AUTOLPCBDEALERArray,61);

// The following describes Segment: MODEL ("MODEL") in PCB:// AUTOLPCB ("AUTOLPCB")

static DLITypeInfo[] AUTOLPCBMODELArray= {new DLITypeInfo("MODKEY", DLITypeInfo.CHAR, 3, 24,

"MODKEY", DLITypeInfo.UNIQUE_KEY),new DLITypeInfo("MODTYPE", DLITypeInfo.CHAR, 1, 2, "MODTYPE"),new DLITypeInfo("MAKE", DLITypeInfo.CHAR, 3, 10, "MAKE"),new DLITypeInfo("MODEL", DLITypeInfo.CHAR, 13, 10, "MODEL"),new DLITypeInfo("YEAR", DLITypeInfo.CHAR, 23, 4, "YEAR"),new DLITypeInfo("MSRP", DLITypeInfo.CHAR, 27, 5, "MSRP"),new DLITypeInfo("COUNT1", DLITypeInfo.CHAR, 32, 2, "COUNT")

};static DLISegment AUTOLPCBMODELSegment= new DLISegment

("MODEL","MODEL",AUTOLPCBMODELArray,37);

// The following describes Segment: ORDER ("ORDER1") in PCB:// AUTOLPCB ("AUTOLPCB")static DLITypeInfo[] AUTOLPCBORDERArray= {

new DLITypeInfo("ORDNBR", DLITypeInfo.CHAR, 1, 6,"ORDNBR", DLITypeInfo.UNIQUE_KEY),

new DLITypeInfo("LASTNME", DLITypeInfo.CHAR, 7, 25, "LASTNME"),new DLITypeInfo("FIRSTNME", DLITypeInfo.CHAR, 32, 25, "FIRSTNME"),new DLITypeInfo("DATE", DLITypeInfo.CHAR, 57, 10, "DATE"),new DLITypeInfo("TIME", DLITypeInfo.CHAR, 67, 8, "TIME")

};static DLISegment AUTOLPCBORDERSegment= new DLISegment

("ORDER1","ORDER",AUTOLPCBORDERArray,74);

// The following describes Segment: SALES ("SALES") in PCB:// AUTOLPCB ("AUTOLPCB")static DLITypeInfo[] AUTOLPCBSALESArray= {

new DLITypeInfo("SALENUM", DLITypeInfo.CHAR, 49, 4,"SALENUM", DLITypeInfo.UNIQUE_KEY),

new DLITypeInfo("SALDATE", DLITypeInfo.CHAR, 53, 8, "SALDATE"),new DLITypeInfo("LASTNME", DLITypeInfo.CHAR, 61, 25, "LASTNME"),new DLITypeInfo("STKVIN", DLITypeInfo.CHAR, 86, 20, "STKVIN"),new DLITypeInfo("COLOR", DLITypeInfo.CHAR, 106, 10, "COLOR"),new DLITypeInfo("PRICE", DLITypeInfo.CHAR, 116, 5, "PRICE"),new DLITypeInfo("LOT", DLITypeInfo.CHAR, 121, 10, "LOT"),new DLITypeInfo("WRNTY", DLITypeInfo.CHAR, 131, 1, "WRNTY")

};static DLISegment AUTOLPCBSALESSegment= new DLISegment

("SALES","SALES",AUTOLPCBSALESArray,131);

// The following describes Segment: STOCK ("STOCK") in PCB:// AUTOLPCB ("AUTOLPCB")

386 Application Programming Guide

|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||

Page 411: IMS Application Programming.pdf

static DLITypeInfo[] AUTOLPCBSTOCKArray= {new DLITypeInfo("STKVIN", DLITypeInfo.CHAR, 1, 20,

"STKVIN", DLITypeInfo.UNIQUE_KEY),new DLITypeInfo("COLOR", DLITypeInfo.CHAR, 21, 10, "COLOR"),new DLITypeInfo("PRICE", DLITypeInfo.CHAR, 31, 5, "PRICE"),new DLITypeInfo("LOT", DLITypeInfo.CHAR, 36, 10, "LOT"),new DLITypeInfo("WRNTY", DLITypeInfo.CHAR, 46, 1, "WRNTY")

};static DLISegment AUTOLPCBSTOCKSegment= new DLISegment

("STOCK","STOCK",AUTOLPCBSTOCKArray,46);

// The following describes Segment: STOCSALE ("STOCSALE") in PCB:// AUTOLPCB ("AUTOLPCB")static DLITypeInfo[] AUTOLPCBSTOCSALEArray= {

new DLITypeInfo("SALENUM", DLITypeInfo.CHAR, 29, 4,"SALENUM", DLITypeInfo.UNIQUE_KEY),

new DLITypeInfo("DLRNO", DLITypeInfo.CHAR, 1, 4,"DLRNO", DLITypeInfo.UNIQUE_KEY),

new DLITypeInfo("MODKEY", DLITypeInfo.CHAR, 5, 24, "MODKEY"),new DLITypeInfo("SALDATE", DLITypeInfo.CHAR, 33, 8, "SALDATE"),new DLITypeInfo("LASTNME", DLITypeInfo.CHAR, 41, 25, "LASTNME")

};static DLISegment AUTOLPCBSTOCSALESegment= new DLISegment

("STOCSALE","STOCSALE",AUTOLPCBSTOCSALEArray,113);

// The following describes Segment: SALESPER ("SALESPER") in PCB:// AUTOLPCB ("AUTOLPCB")static DLITypeInfo[] AUTOLPCBSALESPERArray= {

new DLITypeInfo("EMPNO", DLITypeInfo.CHAR, 1, 6,"EMPNO", DLITypeInfo.UNIQUE_KEY),

new DLITypeInfo("EMPNO", DLITypeInfo.CHAR, 7, 6, "EMPNO"),new DLITypeInfo("LASTNME", DLITypeInfo.CHAR, 13, 25, "LASTNME"),new DLITypeInfo("FIRSTNME", DLITypeInfo.CHAR, 38, 25, "FIRSTNME")

};static DLISegment AUTOLPCBSALESPERSegment= new DLISegment

("SALESPER","SALESPER",AUTOLPCBSALESPERArray,62);

// The following describes Segment: SALESINF ("SALESINF") in PCB:// AUTOLPCB ("AUTOLPCB")static DLITypeInfo[] AUTOLPCBSALESINFArray= {

new DLITypeInfo("QUOTA", DLITypeInfo.CHAR, 1, 5, "QUOTA"),new DLITypeInfo("SALESYTD", DLITypeInfo.CHAR, 6, 5, "SALESYTD"),new DLITypeInfo("COMSSION", DLITypeInfo.CHAR, 11, 5, "COMSSION")

};static DLISegment AUTOLPCBSALESINFSegment= new DLISegment

("SALESINF","SALESINF",AUTOLPCBSALESINFArray,15);

// The following describes Segment: EMPLINFO ("EMPLINFO") in PCB:// AUTOLPCB ("AUTOLPCB")static DLITypeInfo[] AUTOLPCBEMPLINFOArray= {

new DLITypeInfo("STATE", DLITypeInfo.CHAR, 51, 2,"STATE", DLITypeInfo.NON_UNIQUE_KEY),

new DLITypeInfo("ADDRESS", DLITypeInfo.CHAR, 1, 61, "ADDRESS"),new DLITypeInfo("STREET", DLITypeInfo.CHAR, 1, 25, "STREET"),new DLITypeInfo("CITY", DLITypeInfo.CHAR, 26, 25, "CITY"),new DLITypeInfo("ZIP", DLITypeInfo.CHAR, 53, 9, "ZIP")

};static DLISegment AUTOLPCBEMPLINFOSegment= new DLISegment

("EMPLINFO","EMPLINFO",AUTOLPCBEMPLINFOArray,61);

// An array of DLISegmentInfo objects follows to// describe the view for PCB: AUTOLPCB ("AUTOLPCB")static DLISegmentInfo[] AUTOLPCBarray = {

new DLISegmentInfo(AUTOLPCBDEALERSegment,DLIDatabaseView.ROOT),new DLISegmentInfo(AUTOLPCBMODELSegment,0),new DLISegmentInfo(AUTOLPCBORDERSegment,1),new DLISegmentInfo(AUTOLPCBSALESSegment,1),

Chapter 26. Developing Java applications that work with IMS 387

|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||

Page 412: IMS Application Programming.pdf

new DLISegmentInfo(AUTOLPCBSTOCKSegment,1),new DLISegmentInfo(AUTOLPCBSTOCSALESegment,4),new DLISegmentInfo(AUTOLPCBSALESPERSegment,0),new DLISegmentInfo(AUTOLPCBSALESINFSegment,6),new DLISegmentInfo(AUTOLPCBEMPLINFOSegment,6)

};

// PCB: AUTS1PCB specifies a secondary processing sequence// using index DBD: SINDEX11// The following describes the search fields for the secondary// index for PCB: AUTS1PCB ("AUTS1PCB")static String[] AUTS1PCBORDERKeys= {

"LASTNME","FIRSTNME","ORDNBR"

};// The following describes Segment: ORDER ("ORDER1") in PCB:// AUTS1PCB ("AUTS1PCB")static DLITypeInfo[] AUTS1PCBORDERArray= {

new DLITypeInfo("ORDNBR", DLITypeInfo.CHAR, 1, 6, "ORDNBR"),new DLITypeInfo("LASTNME", DLITypeInfo.CHAR, 7, 25, "LASTNME"),new DLITypeInfo("FIRSTNME", DLITypeInfo.CHAR, 32, 25, "FIRSTNME"),new DLITypeInfo("DATE", DLITypeInfo.CHAR, 57, 10, "DATE"),new DLITypeInfo("TIME", DLITypeInfo.CHAR, 67, 8, "TIME"),new SecondaryIndexInfo("XFLD1","ORDER1",AUTS1PCBORDERKeys, "XFLD1", 56)

};static DLISegment AUTS1PCBORDERSegment= new DLISegment

("ORDER1","ORDER",AUTS1PCBORDERArray,74);

// The following describes Segment: MODEL ("MODEL") in PCB:// AUTS1PCB ("AUTS1PCB")

static DLITypeInfo[] AUTS1PCBMODELArray= {new DLITypeInfo("MODKEY", DLITypeInfo.CHAR, 3, 24,

"MODKEY", DLITypeInfo.UNIQUE_KEY),new DLITypeInfo("MODTYPE", DLITypeInfo.CHAR, 1, 2, "MODTYPE"),new DLITypeInfo("MAKE", DLITypeInfo.CHAR, 3, 10, "MAKE"),new DLITypeInfo("MODEL", DLITypeInfo.CHAR, 13, 10, "MODEL"),new DLITypeInfo("YEAR", DLITypeInfo.CHAR, 23, 4, "YEAR"),new DLITypeInfo("MSRP", DLITypeInfo.CHAR, 27, 5, "MSRP"),new DLITypeInfo("COUNT1", DLITypeInfo.CHAR, 32, 2, "COUNT")

};static DLISegment AUTS1PCBMODELSegment= new DLISegment

("MODEL","MODEL",AUTS1PCBMODELArray,37);

// The following describes Segment: DEALER ("DEALER") in PCB:// AUTS1PCB ("AUTS1PCB")static DLITypeInfo[] AUTS1PCBDEALERArray= {

new DLITypeInfo("DLRNO", DLITypeInfo.CHAR, 1, 4,"DLRNO", DLITypeInfo.UNIQUE_KEY),

new DLITypeInfo("DLRNAME", DLITypeInfo.CHAR, 5, 30, "DLRNAME"),new DLITypeInfo("CITY", DLITypeInfo.CHAR, 35, 10, "CITY"),new DLITypeInfo("ZIP", DLITypeInfo.CHAR, 45, 10, "ZIP"),new DLITypeInfo("PHONE", DLITypeInfo.CHAR, 55, 7, "PHONE")

};static DLISegment AUTS1PCBDEALERSegment= new DLISegment

("DEALER","DEALER",AUTS1PCBDEALERArray,61);

// The following describes Segment: STOCK ("STOCK") in PCB:// AUTS1PCB ("AUTS1PCB")static DLITypeInfo[] AUTS1PCBSTOCKArray= {

new DLITypeInfo("STKVIN", DLITypeInfo.CHAR, 1, 20,"STKVIN", DLITypeInfo.UNIQUE_KEY),

new DLITypeInfo("COLOR", DLITypeInfo.CHAR, 21, 10, "COLOR"),new DLITypeInfo("PRICE", DLITypeInfo.CHAR, 31, 5, "PRICE"),new DLITypeInfo("LOT", DLITypeInfo.CHAR, 36, 10, "LOT"),new DLITypeInfo("WRNTY", DLITypeInfo.CHAR, 46, 1, "WRNTY")

};

388 Application Programming Guide

|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||

Page 413: IMS Application Programming.pdf

static DLISegment AUTS1PCBSTOCKSegment= new DLISegment("STOCK","STOCK",AUTS1PCBSTOCKArray,46);

// An array of DLISegmentInfo objects follows to// describe the view for PCB: AUTS1PCB ("AUTS1PCB")static DLISegmentInfo[] AUTS1PCBarray = {

new DLISegmentInfo(AUTS1PCBORDERSegment,DLIDatabaseView.ROOT),new DLISegmentInfo(AUTS1PCBMODELSegment,0),new DLISegmentInfo(AUTS1PCBDEALERSegment,1),new DLISegmentInfo(AUTS1PCBSTOCKSegment,1)

};

// PCB: AUTS2PCB specifies a secondary processing// sequence using index DBD: SINDEX22// The following describes the search fields for the secondary// index for PCB: AUTS2PCB ("AUTS2PCB")static String[] AUTS2PCBDEALERKeys= {

"MAKE","MODEL"

};// The following describes Segment: DEALER ("DEALER") in PCB:// AUTS2PCB ("AUTS2PCB")static DLITypeInfo[] AUTS2PCBDEALERArray= {

new DLITypeInfo("DLRNO", DLITypeInfo.CHAR, 1, 4, "DLRNO"),new DLITypeInfo("DLRNAME", DLITypeInfo.CHAR, 5, 30, "DLRNAME"),new DLITypeInfo("CITY", DLITypeInfo.CHAR, 35, 10, "CITY"),new DLITypeInfo("ZIP", DLITypeInfo.CHAR, 45, 10, "ZIP"),new DLITypeInfo("PHONE", DLITypeInfo.CHAR, 55, 7, "PHONE"),new SecondaryIndexInfo("XFLD2","MODEL",AUTS2PCBDEALERKeys, "XFLD2", 20)

};static DLISegment AUTS2PCBDEALERSegment= new DLISegment

("DEALER","DEALER",AUTS2PCBDEALERArray,61);

// The following describes Segment: MODEL ("MODEL") in PCB:// AUTS2PCB ("AUTS2PCB")static DLITypeInfo[] AUTS2PCBMODELArray= {

new DLITypeInfo("MODKEY", DLITypeInfo.CHAR, 3, 24,"MODKEY", DLITypeInfo.UNIQUE_KEY),

new DLITypeInfo("MODTYPE", DLITypeInfo.CHAR, 1, 2, "MODTYPE"),new DLITypeInfo("MAKE", DLITypeInfo.CHAR, 3, 10, "MAKE"),new DLITypeInfo("MODEL", DLITypeInfo.CHAR, 13, 10, "MODEL"),new DLITypeInfo("YEAR", DLITypeInfo.CHAR, 23, 4, "YEAR"),new DLITypeInfo("MSRP", DLITypeInfo.CHAR, 27, 5, "MSRP"),new DLITypeInfo("COUNT1", DLITypeInfo.CHAR, 32, 2, "COUNT")

};static DLISegment AUTS2PCBMODELSegment= new DLISegment

("MODEL","MODEL",AUTS2PCBMODELArray,37);

// The following describes Segment: STOCK ("STOCK") in PCB:// AUTS2PCB ("AUTS2PCB")static DLITypeInfo[] AUTS2PCBSTOCKArray= {

new DLITypeInfo("STKVIN", DLITypeInfo.CHAR, 1, 20,"STKVIN", DLITypeInfo.UNIQUE_KEY),

new DLITypeInfo("COLOR", DLITypeInfo.CHAR, 21, 10, "COLOR"),new DLITypeInfo("PRICE", DLITypeInfo.CHAR, 31, 5, "PRICE"),new DLITypeInfo("LOT", DLITypeInfo.CHAR, 36, 10, "LOT"),new DLITypeInfo("WRNTY", DLITypeInfo.CHAR, 46, 1, "WRNTY")

};static DLISegment AUTS2PCBSTOCKSegment= new DLISegment

("STOCK","STOCK",AUTS2PCBSTOCKArray,46);

// An array of DLISegmentInfo objects follows to describe// the view for PCB: AUTS2PCB ("AUTS2PCB")static DLISegmentInfo[] AUTS2PCBarray = {

new DLISegmentInfo(AUTS2PCBDEALERSegment,DLIDatabaseView.ROOT),new DLISegmentInfo(AUTS2PCBMODELSegment,0),new DLISegmentInfo(AUTS2PCBSTOCKSegment,1)

Chapter 26. Developing Java applications that work with IMS 389

|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||

Page 414: IMS Application Programming.pdf

};

// The following describes Segment: SINDXB ("SINDXB") in// PCB: AUSI2PCB ("AUSI2PCB")static DLITypeInfo[] AUSI2PCBSINDXBArray= {

new DLITypeInfo("XFLDB", DLITypeInfo.CHAR, 1, 28,"XFLDB", DLITypeInfo.UNIQUE_KEY),

new DLITypeInfo("COUNT1", DLITypeInfo.CHAR, 25, 2, "COUNT"),new DLITypeInfo("ENQUIRS", DLITypeInfo.CHAR, 25, 4, "ENQUIRS")

};static DLISegment AUSI2PCBSINDXBSegment= new DLISegment

("SINDXB","SINDXB",AUSI2PCBSINDXBArray,34);

// An array of DLISegmentInfo objects follows to describe// the view for PCB: AUSI2PCB ("AUSI2PCB")static DLISegmentInfo[] AUSI2PCBarray = {

new DLISegmentInfo(AUSI2PCBSINDXBSegment,DLIDatabaseView.ROOT)};

// The following describes Segment: EMPL ("EMPL") in// PCB: EMPLPCB ("EMPLPCB")static DLITypeInfo[] EMPLPCBEMPLArray= {

new DLITypeInfo("EMPNO", DLITypeInfo.CHAR, 1, 6,"EMPNO", DLITypeInfo.UNIQUE_KEY),

new DLITypeInfo("LASTNME", DLITypeInfo.CHAR, 7, 25, "LASTNME"),new DLITypeInfo("FIRSTNME", DLITypeInfo.CHAR, 32, 25, "FIRSTNME")

};static DLISegment EMPLPCBEMPLSegment= new DLISegment

("EMPL","EMPL",EMPLPCBEMPLArray,56);

// The following describes Segment: DEALER ("DEALER") in// PCB: EMPLPCB ("EMPLPCB")static DLITypeInfo[] EMPLPCBDEALERArray= {

new DLITypeInfo("DLRNO", DLITypeInfo.CHAR, 1, 4, "DLRNO"),new DLITypeInfo("DLRNAME", DLITypeInfo.CHAR, 5, 30, "DLRNAME"),new DLITypeInfo("CITY", DLITypeInfo.CHAR, 35, 10, "CITY"),new DLITypeInfo("ZIP", DLITypeInfo.CHAR, 45, 10, "ZIP"),new DLITypeInfo("PHONE", DLITypeInfo.CHAR, 55, 7, "PHONE")

};static DLISegment EMPLPCBDEALERSegment= new DLISegment

("DEALER","DEALER",EMPLPCBDEALERArray,61);

// The following describes Segment: SALESINF ("SALESINF")// in PCB: EMPLPCB ("EMPLPCB")static DLITypeInfo[] EMPLPCBSALESINFArray= {

new DLITypeInfo("QUOTA", DLITypeInfo.CHAR, 1, 5, "QUOTA"),new DLITypeInfo("SALESYTD", DLITypeInfo.CHAR, 7, 5, "SALESYTD")

};static DLISegment EMPLPCBSALESINFSegment= new DLISegment

("SALESINF","SALESINF",EMPLPCBSALESINFArray,11);

// The following describes Segment: EMPLINFO ("EMPLINFO")// in PCB: EMPLPCB ("EMPLPCB")static DLITypeInfo[] EMPLPCBEMPLINFOArray= {

new DLITypeInfo("STATE", DLITypeInfo.CHAR, 51, 2,"STATE", DLITypeInfo.NON_UNIQUE_KEY),

new DLITypeInfo("ADDRESS", DLITypeInfo.CHAR, 1, 61, "ADDRESS"),new DLITypeInfo("STREET", DLITypeInfo.CHAR, 1, 25, "STREET"),new DLITypeInfo("CITY", DLITypeInfo.CHAR, 26, 25, "CITY"),new DLITypeInfo("ZIP", DLITypeInfo.CHAR, 53, 9, "ZIP")

};static DLISegment EMPLPCBEMPLINFOSegment= new DLISegment

("EMPLINFO","EMPLINFO",EMPLPCBEMPLINFOArray,61);

// An array of DLISegmentInfo objects follows to describe the// view for PCB: EMPLPCB ("EMPLPCB")static DLISegmentInfo[] EMPLPCBarray = {

390 Application Programming Guide

|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||

Page 415: IMS Application Programming.pdf

new DLISegmentInfo(EMPLPCBEMPLSegment,DLIDatabaseView.ROOT),new DLISegmentInfo(EMPLPCBDEALERSegment,0),new DLISegmentInfo(EMPLPCBSALESINFSegment,1),new DLISegmentInfo(EMPLPCBEMPLINFOSegment,0)

};

// Warning: PCB: PCBGSAMG has no SENSEGS// The following describes GSAM Record: JAVGSAM1 ("JAVGSAM1")// in PCB: PCBGSAMG ("GSAMRead")static DLITypeInfo[] PCBGSAMGJAVGSAM1Array= {

new DLITypeInfo("DealerNo", DLITypeInfo.INTEGER, 1, 4),new DLITypeInfo("DealerName", DLITypeInfo.CHAR, 5, 30),new DLITypeInfo("ModelType", DLITypeInfo.CHAR, 35, 2),new DLITypeInfo("ModelKey", DLITypeInfo.CHAR, 37, 24),new DLITypeInfo("Make", DLITypeInfo.CHAR, 37, 10),new DLITypeInfo("Model", DLITypeInfo.CHAR, 47, 10),new DLITypeInfo("Year", "yyyy", DLITypeInfo.DATE, 57, 4),new DLITypeInfo("MSRP", "S999999V99", DLITypeInfo.PACKEDDECIMAL, 61, 5),new DLITypeInfo("Counter", DLITypeInfo.SMALLINT, 66, 2)

};static GSAMRecord PCBGSAMGRecord= new GSAMRecord

("PCBGSAMGRecord",PCBGSAMGJAVGSAM1Array,80);

// An array of DLISegmentInfo objects follows to describe// the view for PCB: PCBGSAMG ("GSAMRead")static DLISegmentInfo[] PCBGSAMGarray = {

new DLISegmentInfo(PCBGSAMGRecord, DLIDatabaseView.ROOT)};

// Warning: PCB: PCBGSAML has no SENSEGS// The following describes GSAM Record: JAVGSAM1 ("JAVGSAM1")// in PCB: PCBGSAML ("GSAMLoad")static DLITypeInfo[] PCBGSAMLJAVGSAM1Array= {

new DLITypeInfo("DealerNo", DLITypeInfo.INTEGER, 1, 4),new DLITypeInfo("DealerName", DLITypeInfo.CHAR, 5, 30),new DLITypeInfo("ModelType", DLITypeInfo.CHAR, 35, 2),new DLITypeInfo("ModelKey", DLITypeInfo.CHAR, 37, 24),new DLITypeInfo("Make", DLITypeInfo.CHAR, 37, 10),new DLITypeInfo("Model", DLITypeInfo.CHAR, 47, 10),new DLITypeInfo("Year", "yyyy", DLITypeInfo.DATE, 57, 4),new DLITypeInfo("MSRP", "S999999V99", DLITypeInfo.PACKEDDECIMAL, 61, 5),new DLITypeInfo("Counter", DLITypeInfo.SMALLINT, 66, 2)

};static GSAMRecord PCBGSAMLRecord= new GSAMRecord

("PCBGSAMLRecord",PCBGSAMLJAVGSAM1Array,80);

// An array of DLISegmentInfo objects follows to// describe the view for PCB: PCBGSAML ("GSAMLoad")static DLISegmentInfo[] PCBGSAMLarray = {

new DLISegmentInfo(PCBGSAMLRecord, DLIDatabaseView.ROOT)};

// Constructorpublic AUTOGSAMDatabaseView() {

super("2.0","AUTOGSAM", "AUTOLPCB", "AUTOLPCB", AUTOLPCBarray);addDatabase("AUTS1PCB", "AUTS1PCB", AUTS1PCBarray);addDatabase("AUTS2PCB", "AUTS2PCB", AUTS2PCBarray);addDatabase("AUSI2PCB", "AUSI2PCB", AUSI2PCBarray);addDatabase("EMPLPCB", "EMPLPCB", EMPLPCBarray);addDatabase("GSAMRead", "PCBGSAMG", PCBGSAMGarray);addDatabase("GSAMLoad", "PCBGSAML", PCBGSAMLarray);

} // end AUTOGSAMDatabaseView constructor

} // end AUTOGSAMDatabaseView class definition

Chapter 26. Developing Java applications that work with IMS 391

||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||

Page 416: IMS Application Programming.pdf

Enterprise COBOL interoperability with JMP and JBPapplications

Users wishing to take advantage of transactions using Java class libraries for IMSand OO COBOL that are executed in a Java Dependent Region and invoke COBOLcan do so without changing their existing traditional COBOL applications. IBMEnterprise COBOL for z/OS supports inter-operation between COBOL and Javalanguages when running in a JMP or JBP region. With this support, you can:v Call an object-oriented (OO) COBOL application from a Java application by

building the frontend application, which processes messages, in Java, and theback end, which processes databases, in OO COBOL.

v Build an OO COBOL application containing a main routine that can invoke Javaroutines.

Restriction: COBOL applications that run in an IMS dependent region must usethe AIB interface, which requires that all PCBs in a PSB definitionhave a name.

Alternatively, you can obtain PCB addresses by making an IMS INQYcall using the FIND subfunction and the PCB name as the resourcename. The INQY call returns the address of the PCB, which you canthen pass to a COBOL program. This approach still requires that thePCB name be defined as part of the PSBGEN, but the COBOLapplication does not have to use the AIB interface.

You can access COBOL code in a JMP or JBP region because Enterprise COBOLprovides object-oriented language syntax that enables you to:v Define classes with methods and data implemented in COBOLv Create instances of Java and COBOL classesv Invoke methods on Java and COBOL objectsv Write classes that inherit from Java classes or other COBOL classesv Define and invoke overloaded methods

In Enterprise COBOL programs, you can call the services provided by the JNI toobtain Java-oriented capabilities in addition to the basic OO capabilities availabledirectly in the COBOL language.

In Enterprise COBOL classes, you can code CALL statements that interface withprocedural COBOL programs. Therefore, COBOL class definition syntax can beespecially useful for writing wrapper classes for procedural COBOL logic, enablingexisting COBOL code to be accessed from Java.

Java code can create instances of COBOL classes, invoke methods of these classes,and can extend COBOL classes.

Related Reading: For details building applications that use Enterprise COBOL andthat run in an IMS dependent region, see Enterprise COBOL for z/OS V3R4Programming Guide.

The following topics provide additional information:v “Enterprise COBOL as a backend application in a JMP or JBP region” on page

393v “Enterprise COBOL as a frontend application in a JMP or JBP region” on page

393

392 Application Programming Guide

|

|

|||||

|||

||

|||

||||||

||

|

|

|

|

|

|||

||||

||

|||

|

||

||

Page 417: IMS Application Programming.pdf

Enterprise COBOL as a backend application in a JMP or JBPregionWhen you define an OO COBOL class and compile it with the Enterprise COBOLcompiler, the compiler generates a Java class definition with native methods andthe object code that implements the native methods. After compiling the class, youcan create an instance and invoke the methods of the class from a Java programthat runs in a JMP or JBP region. For example, you can define an OO COBOL classwith the appropriate DL/I call in COBOL to access an IMS database.

For example, you can define an OO COBOL class with the appropriate DL/I call inCOBOL to access an IMS database. To make the implementation of this classavailable to a Java application running with IMS:1. Compile the COBOL class with the Enterprise COBOL compiler to generate a

Java source file, which contains the class definition, and an object module,which contains the implementation of the native methods.

2. Compile the generated Java source file with the Java compiler to create theapplication class file.

3. Link the object module into a dynamic link library (DLL) in the HFS file (.so).4. Update the application class path (ibm.jvm.application.class.path) for the JMP

or JBP region to allow access to the Java class file.5. Update the library path for the JMP or JBP region to allow access to the DLL.

Enterprise COBOL as a frontend application in a JMP or JBPregionThe object-oriented syntax of Enterprise COBOL enables you to build COBOLapplications with a main method, which can be run directly in a JMP or JBP region.The JMP or JBP region locates, instantiates, and invokes this main method in thesame way it does for the main method of a Java application.

You can write an application for an JMP or JBP region entirely with OO COBOL,but a more likely use for a front-end COBOL application is to call a Java routinefrom a COBOL application.

When running within the JVM of an JMP or JBP region, Enterprise COBOLrun-time support automatically locates and uses this JVM to invoke methods onJava classes.

A front-end OO COBOL application with a main routine that runs in a JMP or JBPregion has the same requirements as a Java program that runs in a JMP or JBPregion.

Accessing DB2 for z/OS databases from JMP or JBPapplications

A JMP or JBP application can access DB2 for z/OS databases by using the DB2JDBC/SQLJ 2.0 driver or the DB2 JDBC/SQLJ 1.2 driver. The JMP or JBP regionthat the application is running in must also be defined with DB2 for z/OS attachedby the DB2 Recoverable Resource Manager Services attachment facility (RRSAF).Unlike other dependent regions, JMP and JBP regions do not use the ExternalSubsystem Attach Facility (ESAF).

Related Reading: For information about attaching DB2 for z/OS to IMS for JMP orJBP application access to DB2 for z/OS databases, see the "Preparing your systemto use the DB2 Attach Facility" topic in the IMS Version 10: Communications andConnections Guide.

Chapter 26. Developing Java applications that work with IMS 393

||||||||

|||

|||

||

|

||

|

||||||

|||

|||

|||

|

|

||||||

||||

Page 418: IMS Application Programming.pdf

Accessing DB2 for z/OS data from a JMP or JBP application is similar to accessingIMS data. When writing a JMP or JBP application that accesses DB2 for z/OS data,consider both the differences from IMS database access and the differences fromaccessing DB2 for z/OS data in other environments:v You must create a DB2 plan for each PSB (usually each Java application) that is

used to access DB2 for z/OS .v You can have only one active DB2 for z/OS connection open at any time.v For type-2 JDBC drivers, you must use the default connection URL in the

application program. For example, jdbc:db2os390: or db2:default:connection.v For type-4 JDBC drivers, you can use a specific connection URL in the

application program.v To commit or roll back work, you must use the

IMSTransaction.getTransaction().commit() method or theIMSTransaction.getTransaction().rollback() method. For JMP applications,theIMSTransaction.getTransaction().commit() method commits all work: SQLcalls and connection closures. For JBP applications, theIMSTransaction.getTransaction().commit() method commits SQL calls.

v Because RRS is the coordinator, you cannot use the Connection.setAutoCommit orConnection.commit method of the DB2 JDBC driver.

Note: If you access a DB2 database using both Java and COBOL in the sameapplication, you might experience unexpected behavior, but only if thecommit/rollback processing is done in COBOL while active cursors are inthe Java portion.

Related Reading: For a JMP programming model, see “JMP application thataccesses IMS or DB2 for z/OS data” on page 373. For a JBP programming model,see “JBP application that accesses DB2 for z/OS or IMS data” on page 382.

For information about setting up DB2 for z/OS for Java application access, see DB2Version 9.1 for z/OS Application Programming Guide and Reference for Java .

Program switching in JMP and JBP applicationsIMS allows you to switch programs in JMP and JBP applications. You can performimmediate program switches in JMP and JBP applications, and you can also makea deferred program switch in a conversational JMP application.

The following topics provide more details:v “Immediate program switching for JMP and JBP applications”v “Deferred program switching for conversational JMP applications” on page 395

Immediate program switching for JMP and JBP applicationsYou can make an immediate program switch in a JMP or JBP application. Animmediate program switch will pass the conversation directly to anotherconversational program that is specified by an alternate PCB to which an ISRT callhas been issued. When an application makes an immediate program switch, thefirst ISRT call sends the SPA to the other conversational program, but subsequentISRT calls will send messages to the new program. The program does not return orrespond to the original terminal.

The setModifiableAlternatePCB(String) method of thecom.ibm.ims.application.IMSMessageQueue class sets the name of the alternate PCBfor the program switch. The setModifiableAlternatePCB(String) method calls theDL/I CHNG call.

394 Application Programming Guide

||||

||

|

||

||

||||||

||

||||

|||

||

|

|||

|

|

|

||||||||

||||

Page 419: IMS Application Programming.pdf

To make an immediate program switch in a JMP or JBP application:1. Call the setModifiableAlternatePCB(String) method to set the name of the

alternate PCB.2. Call the insertMessage(IMSFieldMessage) method to send the message to the

alternate PCB.

For more information about these methods, see the Java API specification for IMS .

For more information about program switches, see “Passing the conversation toanother conversational program” on page 242.

Deferred program switching for conversational JMP applicationsYou can make a deferred program switch in a conversational JMP application. Adeferred program switch changes the transaction code in the SPA before the SPA isreturned to IMS. When an application makes a deferred program switch, theapplication replies to the terminal and passes the conversation to anotherconversational application.

The setTransactionID(String) method of thecom.ibm.ims.application.IMSFieldMessage class specifies the transaction code inthe SPA.

To make a deferred program switch in a conversational JMP application:1. Call the insertMessage(IMSFieldMessage) method to send the output message

to the terminal.2. Call the setTransactionID(String) method to set the name of the transaction

code in the SPA.3. Call the insertMessage(IMSFieldMessage) method to send the SPA to IMS.

For more information about these methods, see the Java API specification for IMS .

For more information about program switches, see “Passing the conversation toanother conversational program” on page 242.

Issuing synchronous callout requests from a Java dependentregion

IMS provides support for synchronous callout functionality from JMP or JBPapplications through an IMS implementation of the Java Message Service (JMS).

To use the JMP and JBP support for synchronous callout, the IMS Enterprise SuiteJMS API jms.jar file must be on your classpath. To download the IMS EnterpriseSuite JMS API, go to the following web URL: http://www-01.ibm.com/software/data/ims/soa-integration-suite/enterprise-suite/.

The IMS implementation of JMS is limited to supporting the Point-to-Point (PTP)messaging domain only. In addition, support is only provided for non-transactedQueueSession objects with Session.AUTO_ACKNOWLEDGE mode.

If the JMP or JBP application attempts to call any JMS method not supported byIMS or pass any unsupported argument to JMS method calls, a JMSExceptionexception will be thrown.

To send a message using the JMP/JBP support for synchronous callout andsynchronously receive a response:

Chapter 26. Developing Java applications that work with IMS 395

|

||

||

|

||

||||||

|||

|

||

||

|

|

||

|

|

||

||||

|||

|||

||

Page 420: IMS Application Programming.pdf

1. Create a com.ibm.ims.jms.IMSQueueConnectionFactory object. For moreinformation about the com.ibm.ims.jms.IMSQueueConnectionFactory class, seethe Javadoc documentation for IMS Callout Support in the IMS Version 10:Application Programming API Reference.

2. Create a JMS QueueConnection object by calling the createQueueConnectionmethod on the IMSQueueConnectionFactory object.

3. Create a JMS QueueSession object by calling the createQueueSession method onthe QueueConnection. In the method call, you must set the input parametervalues to false and Session.AUTO_ACKNOWLEDGE to specify that the generatedQueueSession is non-transacted and runs in AUTO_ACKNOWLEDGE mode.

4. Create a queue identity by calling the createQueue method on theQueueSession. In the method call, you must set the input parameter value tothe OTMA descriptor name for the synchronous callout operation.

5. Create a JMS QueueRequestor object and pass in the QueueSession object fromstep 3 and the Queue object from step 4 as input parameters to theQueueRequestor constructor method.

6. Create a TextMessage object by calling the createTextMessage method on theQueueSession object from step 3. Set the string containing this message's data.

7. To send the message and retrieve a response, call the request method on theQueueRequestor object from step 5. In the method call, pass in the TextMessageobject from step 6. You need to cast the return value from the request methodcall to a TextMessage. If the call is successful, the return value will be theresponse to the synchronous callout request.

The following code shows how to write a simple JMP/JBP application that sends amessage to an external application and synchronously receive a response message.In the example, a IMSQueueConnectionFactory object is created with a timeoutvalue of 10 seconds and with 128k of space allocated to hold response messages. AQueueSession object is created and is set to be a non-transacted session running inAUTO_ACKNOWLEDGE mode. A JMS Queue object is created, with theimport javax.jms.JMSException;import javax.jms.Queue;import javax.jms.QueueConnection;import javax.jms.QueueRequestor;import javax.jms.QueueSession;import javax.jms.Session ;import javax.jms.TextMessage;import com.ibm.ims.jms.IMSQueueConnectionFactory;

public class IMS_Sample{

public static void main(String argv[]){

IMSQueueConnectionFactory jmsConnectionFactory = new IMSQueueConnectionFactory();QueueConnection jmsConnection = null;QueueSession jmsQueueSession = null;Queue jmsQueue = null;QueueRequestor jmsQueueRequestor = null;

try {jmsConnectionFactory.setTimeout(1000); // set the timeout to 10 secondsjmsConnectionFactory.setResponseAreaLength(128000);

// allocate 128k to hold the response messagejmsConnection = jmsConnectionFactory.createQueueConnection();jmsQueueSession = jmsConnection.createQueueSession(false, Session.AUTO_ACKNOWLEDGE);

// specify that session is non-transacted and in AUTO_ACKNOWLEDGE modejmsQueue = jmsQueueSession.createQueue("OTMDEST1");

// pass in the OTMA descriptor name

396 Application Programming Guide

||||

||

||||

|||

|||

||

|||||

||||||

|||||||||||||||||||||||||||||

Page 421: IMS Application Programming.pdf

jmsQueueRequestor = new QueueRequestor(jmsQueueSession, jmsQueue);TextMessage sendMsg = jmsQueueSession.createTextMessage();sendMsg.setText("MyMessage");System.out.println("Sending message: "+sendMsg.getText());TextMessage replyMsg = (TextMessage)jmsQueueRequestor.request(sendMsg);

System.out.println("\nReceived message: "+replyMsg.getText());} catch (JMSException e) {

e.printStackTrace();}

}}

Developing DB2® for z/OS® stored procedures that access IMSYou can write DB2 for z/OS Java stored procedures that access IMS databaseswhen DB2 for z/OS and IMS are on the same logical partition (LPAR). Thefollowing topics provide illustration and programming model provide informationto help you get started:v “Java applications running in DB2 for z/OS stored procedures”v “DB2 for z/OS stored procedures programming model” on page 398

Related Reading: See the "Java class libraries for IMS" topic in the IMS Version 10:Application Programming API Reference for a comprehensive list of classes, interfaceand supported SQL statements for use with Java applications that work with IMS.

Java applications running in DB2 for z/OS stored proceduresFigure 94 on page 398 shows a DB2 for z/OS stored procedure that is using Javaclass libraries for IMS DB, ODBA, and DRA to access IMS databases.

Chapter 26. Developing Java applications that work with IMS 397

||||||||||||

|

||

Page 422: IMS Application Programming.pdf

To deploy a Java stored procedure on DB2 for z/OS , you must configure the Javaclass libraries for IMS DB, ODBA, and DRA. For details on completing these taskssee the "Loading and running the ODBA and DRA modules in the z/OSapplication region" topic in the IMS Version 10: Communications and ConnectionsGuide. For the steps that are required to configure DB2 for z/OS to run Java storedprocedures that access IMS databases, see the topic “Configuring DB2 for z/OS torun Java stored procedures that access IMS database” in the IMS Version 10:Communications and Connections Guide.

DB2 for z/OS stored procedures programming modelThe stored procedure must perform the following tasks in the order listed. Anexample is given for each step:1. Load the IMS JDBC driver:

Class.forName("com.ibm.ims.db.DLIDriver");

2. Create an IMS connection with the JDBC driver for IMS:connection = DriverManager.getConnection

("jdbc:dli:package.DatabaseViewName/DRAname");

3. Create a statement:Statement statement = connection.createStatement();

4. Query the IMS database:ResultSet results = statement.executeQuery(query);

5. Call the ResultSetConverter:ResultSetConverter converter = new ResultSetConverter();result2[0] = converter.getDB2ResultSet(results);

Figure 94. DB2 for z/OS stored procedure that uses Java class libraries for IMS DB

398 Application Programming Guide

||||||||

|

||

Page 423: IMS Application Programming.pdf

Note: In the ResultSetConverter class, you must specify whether to use adeclared global temporary table or a created global temporary table. TheResultSetConverter uses this temporary table in DB2 to convert theresult set.

6. Close the connection:connection.close();

Developing CICS applications that access IMSYou can write applications that run on CICS Transaction Server for z/OS andaccess IMS databases when CICS Transaction Server for z/OS and IMS are on thesame logical partition (LPAR). The following topics provide illustration andprogramming model provide information to help you get started:v “Java applications running on CICS Transaction Server for z/OS”v “CICS Transaction Server for z/OS programming model” on page 400

Related Reading: See the "Java class libraries for IMS" topic in the IMS Version 10:Application Programming API Reference for a comprehensive list of classes, interfaceand supported SQL statements for use with Java applications that work with IMS.

Java applications running on CICS Transaction Server forz/OS

Figure 95 shows a JCICS application that is accessing an IMS database using ODBAand Java class libraries for IMS DB.

Java applications use the Java class libraries for IMS DB to access IMS. Other thanJava class libraries for IMS DB, access to IMS from a Java application is the sameas for a non-Java application.

Figure 95. CICS application that uses the Java class libraries for IMS DB

Chapter 26. Developing Java applications that work with IMS 399

||||

Page 424: IMS Application Programming.pdf

To deploy a Java stored procedure on CICS Transaction Server for z/OS, you mustconfigure the Java class libraries for IMS DB and DRA. For details on completingthis task see the "Loading and running the ODBA and DRA modules in the z/OSapplication region" topic in the IMS Version 10: Communications and ConnectionsGuide. For the steps that are required to configure CICS Transaction Server forz/OS to run Java applications that access IMS databases, see the topic“Configuring CICS to run Java applications that access IMS databases,” in the IMSVersion 10: Communications and Connections Guide

CICS Transaction Server for z/OS programming modelThe following programming model outlines the supported structure for JCICSapplications that use the Java class libraries for IMS. The model is not complete,but it shows the normal flow of the application for both the JDBC and SSA accessmethods.

In a CICS environment, only one PSB can be allocated at a time. Therefore, anapplication can have only one active connection with the JDBC driver for IMS at atime. The application must close the connection with the JDBC driver for IMSbefore it opens another connection with the JDBC driver for IMS.public static void main(CommAreaHolder cah) { //Receives control

conn = DriverManager.getConnection(...); //Establish DB connection

repeat {results = statement.executeQuery(...); //Perform DB processing...//send output to terminal

}

conn.close(); //Close DB connectionreturn;

}

Developing enterprise applications that access IMSYou can write applications that run on WebSphere Application Server for z/OSand access IMS databases when WebSphere Application Server for z/OS and IMSare on the same logical partition (LPAR). However, you do not need to develop az/OS application or access a traditional z/OS application to have access to IMSdata. With the IMS DB distributed resource adapter for the Java class libraries, youcan develop and deploy applications that run on non-z/OS platforms and accessIMS databases remotely.

Enterprise applications that access IMS DB can be servlets or EJBs. The EJBs can bebean-managed or container-managed. This topic describes the programmingmodels for these different types of enterprise applications. These programmingmodels apply to enterprise applications that run on either WebSphere ApplicationServer for z/OS or WebSphere Application Server on a non-z/OS platform.

The following topics provide illustrations, programming models, requirements andsemantics for developing enterprise applications:v “Enterprise applications running in WebSphere Application Server for z/OS” on

page 401v “Enterprise applications running in WebSphere Application Server” on page 402v “Bean-managed EJB programming model” on page 403v “Container-managed EJB programming model” on page 404

400 Application Programming Guide

||||||||

|||||||

Page 425: IMS Application Programming.pdf

v “Servlet programming model” on page 405v “Programming requirements for WebSphere Application Server for z/OS” on

page 405v “Deployment descriptor requirements for the Java class libraries for IMS” on

page 406v “Transaction semantics and server-side EJB types” on page 406

Related Reading: See the "Java class libraries for IMS" topic in the IMS Version 10:Application Programming API Reference for a comprehensive list of classes, interfaceand supported SQL statements for use with Java applications that work with IMS.

Enterprise applications running in WebSphere ApplicationServer for z/OS

Figure 96 shows an Enterprise JavaBean (EJB) that is accessing IMS data. JDBC orIMS hierarchical database interface for Java calls are passed to the IMS Base APIfor Java, which converts the calls to DL/I calls. The IMS Base API for Java passesthese calls to ODBA, which uses the DRA to access the DL/I region in IMS.

To deploy an application on WebSphere Application Server for z/OS, you mustinstall the IMS JDBC resource adapter (the Java class libraries for IMS) onWebSphere Application Server for z/OS, and configure both IMS open databaseaccess (ODBA) and the database resource adapter (DRA). For more details onconfiguring ODBA and DRA to access IMS, see the topic "Loading and running theODBA and DRA modules in the z/OS application region" topic in the IMS Version10: Communications and Connections Guide.

Figure 96. WebSphere Application Server for z/OS EJB using IMS DB resource adapter

Chapter 26. Developing Java applications that work with IMS 401

|||||||

Page 426: IMS Application Programming.pdf

For the steps that are required to configure WebSphere Application Server forz/OS to run Java application programs that access IMS databases, see the topic“Configuring WebSphere Application Server for z/OS to run J2EE applications thataccess IMS databases,” in the IMS Version 10: Communications and Connections Guide.

Enterprise applications running in WebSphere ApplicationServer

Figure 97 shows the components that are required for an enterprise application (inthis case, an EJB) on a non-z/OS platform to access IMS DB.

For the steps that are required to configure WebSphere Application Server to runJava application programs that access IMS databases from non-z/OS environments,see the topic “Configuring WebSphere Application Server to run distributed Javaapplications that access IMS databases,” in the IMS Version 10: Communications andConnections Guide

IMS DB distributedresource adapter

WebSphere Application Server for z/OS

z/OS

WebSphere Application Server

IIOP

ODBA

DRA

Non-z/OS platform

IMS distributed DB EJB

EJB

IMS

DL/I

IMS database

IMS DB resource adapter

Figure 97. IMS DB distributed resource adapter and WebSphere Application Servercomponents

402 Application Programming Guide

|

|||

||||

|

|

|||

|||||

Page 427: IMS Application Programming.pdf

Bean-managed EJB programming modelIn bean-managed EJBs, you programmatically define the transaction boundaries. Todefine an EJB as bean-managed, set the transaction-type property, which is in theejb-jar.xml file of the EJB jar file, to Bean. You must manage the scope of thetransaction by using either the javax.transaction.UserTransaction orjava.sql.Connection interface. This topic describes how to use both interfaces:v “Transaction demarcation using the javax.transaction.UserTransaction interface”v “Transaction demarcation using the java.sql.Connection Interface”

Transaction demarcation using thejavax.transaction.UserTransaction interfaceThe programming model applies either to applications that run on WebSphereApplication Server on a non-z/OS platform or to applications that run onWebSphere Application Server for z/OS. With thejavax.transaction.UserTransaction interface, you can define when the scope ofthe transaction begins and ends, and when the transaction commits or rolls back.The EJB container supplies the EJB with a javax.ejb.SessionContext object thatallows the javax.transaction.UserTransaction interface to perform the requiredoperations to manage the transaction.try {

// Use the javax.ejb.SessionContext set by the EJB container to instantiate// a new UserTransactionjavax.transaction.UserTransaction userTransaction =

sessionContext.getUserTransaction();

// Begin the scope of this transactionuserTransaction.begin();

// Perform JNDI lookup to obtain the data source (the IVP datasource for// example) and castjavax.sql.DataSource dataSource = (javax.sql.DataSource)

initialContext.lookup("java:comp/env/jdbc/IMSIVP");

// Get a connection to the data sourcejava.sql.Connection connection = dataSource.getConnection();

// Create an SQL statement using the connectionjava.sql.Statement statement = connection.createStatement();

// Acquire a result set by executing the query using the statementjava.sql.ResultSet results = statement.executeQuery(...);

// Commit and complete the scope of this transactionuserTransaction.commit();

// Close the connectionconnection.close();

} catch (Throwable t) {

// If an exception occurs, roll back the transactionuserTransaction.rollback();

// Close the connectionconnection.close();

}

Transaction demarcation using the java.sql.Connection InterfaceThe programming model applies only to applications that run on WebSphereApplication Server on a non-z/OS platform and that use the remote database

Chapter 26. Developing Java applications that work with IMS 403

Page 428: IMS Application Programming.pdf

services of the Java class libraries for IMS. With the java.sql.Connection interface,you commit or roll back a transaction that is started by the creation of a datasource connection. The Java EJB for IMS that is on the server side automaticallystarts a transaction if one does not exist when a connection is created. You can thenuse this connection to commit or roll back the transaction without using thejavax.transaction.UserTransaction interface.

Use this programming model only if you do not use thejavax.transaction.UserTransaction interface.

When you perform the JNDI lookup, specify "java:comp/env/sourceName" wheresourceName is the name of the data source.try {

// Perform JNDI lookup to obtain the data source (the IVP data source// for example) and castjavax.sql.DataSource dataSource = (javax.sql.DataSource)

initialContext.lookup("java:comp/env/imsjavaRDSIVP");

// Get a connection to the data source and begin the transaction scopejava.sql.Connection connection = dataSource.getConnection();

// Create an SQL statement using the connectionjava.sql.Statement statement = connection.createStatement();

// Acquire a result set by executing the query using the statementjava.sql.ResultSet results = statement.executeQuery(...);

// Commit and complete the scope of this transactionconnection.commit();

// Close the connectionconnection.close();

} catch (Throwable t) {

// If an exception occurs, rollback the transactionconnection.rollback();

// Close the connectionconnection.close();

}

Container-managed EJB programming modelIn container-managed EJBs, the container manages the transaction demarcation.The demarcation is defined in the ejb-jar.xml file of the EJB. To define an EJB ascontainer-managed, set the transaction-type property, which is in the ejb-jar.xml fileof the EJB jar file, to Container. Because the container manages the transactiondemarcation, this programming model does not have any transaction logic.try {

// Perform JNDI lookup to obtain the data source (the IVP data source// for example) and castjavax.sql.DataSource dataSource = (javax.sql.DataSource)

initialContext.lookup("java:comp/env/jdbc/IMSIVP");

// Get a connection to the data sourcejava.sql.Connection connection = dataSource.getConnection();

// Create an SQL statement using the connectionjava.sql.Statement statement = connection.createStatement();

// Acquire a result set by executing the query using the statement

404 Application Programming Guide

Page 429: IMS Application Programming.pdf

java.sql.ResultSet results = statement.executeQuery(...);

// Close the connectionconnection.close();

} catch (Throwable t) {

// Close the connectionconnection.close();

}

Servlet programming modelSimilarly to the bean-managed EJBs, the servlet programming model uses theUserTransaction interface to begin, commit, or rollback the transaction. Becausethe servlet resides outside of the EJB container and cannot use an EJBContextobject, the initial context requires an additional JNDI lookup to locate andinstantiate the UserTransaction interface.try {

// Establish an initial context to manage the environment//properties and JNDI namesjavax.naming.InitialContext initialContext = new InitialContext();

// Locate and instantiate a UserTransaction object that is associated with// the initial context using JNDIjavax.transaction.UserTransaction userTransaction = (UserTransaction)

ic.lookup("java:comp/UserTransaction");

// Begin the scope of this transactionuserTransaction.begin();

// Perform JNDI lookup to obtain the data source (the IVP data source// for example) and castjavax.sql.DataSource dataSource = (javax.sql.DataSource)

initialContext.lookup("java:comp/env/jdbc/IMSIVP");

// Get a connection to the datasourcejava.sql.Connection connection = dataSource.getConnection();

// Create an SQL statement using the connectionjava.sql.Statement statement = connection.createStatement();

// Acquire a result set by executing the query using the statementjava.sql.ResultSet results = statement.executeQuery(...);

// Commit and complete the scope of this transactionuserTransaction.commit();

// Close the connectionconnection.close();

} catch (Throwable t) {

// If an exception occurs, roll back the transactionuserTransaction.rollback();

// Close the connectionconnection.close();

}

Programming requirements for WebSphere Application Serverfor z/OS

The following programming requirements apply to WebSphere Application Serverfor z/OS EJBs that access IMS databases:

Chapter 26. Developing Java applications that work with IMS 405

Page 430: IMS Application Programming.pdf

v The Java class libraries for IMS do not support component-managed signon.v The Java class libraries for IMS do not support shared connections.v The java.sql.Connection object must be acquired, used, and closed within a

transaction boundary.v A global transaction must exist before you create a Connection object from a

connection with the JDBC driver for IMS. Either specify container-demarcatedtransactions in the EJB deployment descriptor or explicitly begin a globaltransaction by calling thejavax.transaction.UserTransaction API beforecreating a connection with the JDBC driver for IMS.

Deployment descriptor requirements for the Java classlibraries for IMS

The deployment descriptor for an EJB or servlet has certain requirements for theJava class libraries for IMS. In an EJB, the deployment descriptor is the fileejb-jar.xml. In a servlet, the deployment descriptor is the file web.xml.

You must have a resource-ref element in the deployment descriptor. Theresource-ref element describes external resources. In the resource-ref element,you must have the following elements:<res-type>javax.sql.DataSource</res-type><res-sharing-scope>Unshareable</res-sharing-scope>

The <res-type>javax.sql.DataSource</res-type> element specifies the type ofdata source. The <res-sharing-scope>Unshareable</res-sharing-scope> elementspecifies that the connections are not shareable.

The following example is a resource-ref element from an EJB deploymentdescriptor:<resource-ref><res-ref-name>jdbc/DealershipSample</res-ref-name><res-type>javax.sql.DataSource</res-type><res-auth>Container</res-auth><res-sharing-scope>Unshareable</res-sharing-scope></resource-ref>

Transaction semantics and server-side EJB typesThere are two server-side EJB types: container managed and bean managed. TheseEJBs act as listeners for distributed requests that come from the IMS DB distributedresource adapter. The type of EJB that is created depends on whether there is atransaction context when the client-side EJB makes the first SQL call. Applicationsdo not manage these EJBs because they are created and managed by the IMS DBdistributed resource adapter.

When a client-side EJB executes the first SQL request to a database, the IMS DBdistributed resource adapter checks to see if there is a transaction started. If thereis a transaction context, global transaction semantics are followed. However, ifthere is no transaction context, then local transaction semantics are followed.

If there is a transaction context on the client side, the IMS DB distributed resourceadapter creates a container-managed EJB on the server side that joins the existingtransaction. Global transaction semantics are followed, meaning that if theclient-side application is container-managed, the container commits and rolls backwork, and if the client-side EJB is bean managed, the application commits and rollsback work with the UserTransaction class. All work is committed and rolled back.

406 Application Programming Guide

Page 431: IMS Application Programming.pdf

If there is no transaction context on the client side, the IMS DB distributed resourceadapter starts a bean-managed EJB on the server side, which starts a transactionfor each connection. Local transaction semantics are followed meaning that theclient application can commit and roll back individual connections using thejava.sql.Connection object.

Table 60 summarizes the relationship between the transaction context and thetransaction semantics.

Table 60. Relationship between the transaction context and the transaction semantics

Transactioncontext?

Server-side EJBtransaction type

Transactionsemantics Transaction boundary delimiter

Yes Container managed Global EJB container orjavax.transaction.UserTransaction

No Bean managed Local java.sql.Connection

Restriction: The IMS DB distributed resource adapter does not support sharedconnections.

Related reading: For more information about transaction contexts, see the JavaTransaction Service (JTA) Specification and the Java Transaction API (JTA) Specification.

Chapter 26. Developing Java applications that work with IMS 407

Page 432: IMS Application Programming.pdf

408 Application Programming Guide

Page 433: IMS Application Programming.pdf

Chapter 27. Problem determination

This chapter describes how to debug your Java applications that use the Java classlibraries for IMS and determine the source of problems within your applications.

The following topics provide additional information:v “Exceptions thrown from IMS DL/I calls”v “XML tracing for the Java class libraries for IMS” on page 410

Exceptions thrown from IMS DL/I callsExceptions are thrown as a result of non-blank status codes and non-zero returncodes (in cases when there were no PCBs to deliver status codes) from IMS DL/Icalls. Even though an exception is thrown by the JavaToDLI class for everynon-blank status code, some of these exceptions are caught by the application ordatabase packages and converted to return values.

How exceptions map to DL/I status codesThe com.ibm.ims.base.IMSException class extends the java.lang.Exception class.

The DLIException class extends the IMSException class. The DLIException classincludes all errors that occur within the Java class libraries for IMS that are not aresult of any call to IMS.

You can use the following methods to get information from an IMSExceptionobject:

getAIBReturns the IMS application interface block (AIB) from the DL/I call thatcaused the exception. The IMS AIB is null for the DLIException object. Themethods on the AIB can be called to return other information at the time ofthe failure, including the resource or PCB name and the PCB itself.

getStatusCodeReturns the IMS status code from the DL/I call that caused the exception.This method works with the JavaToDLI set of constants. The status code iszero (0) for a DLIException object.

getFunctionReturns the IMS function from the DL/I call that caused the exception. Thefunction is zero (0) for a DLIException object.

The following database access methods of the DLIConnection class return false ifthey receive a GB status code (no more such segments or segment not found) or aGE status code (no such segment or end of database):v DLIConnection.getUniqueSegment

v DLIConnection.getNextSegment

v DLIConnection.getUniqueRecord

v DLIConnection.getNextRecord

v DLIConnection.getNextSegmentInParent

© Copyright IBM Corp. 1974, 2010 409

Page 434: IMS Application Programming.pdf

The IMSMessageQueue.getUniqueMessage method returns false if it receives a QC(no more messages) status code. The IMSMessageQueue.getNextMessage methodreturns false if it receives a QD status code, which means that there are no moresegments for multi-segment messages.

The example in Figure 98 extracts information from an IMSException object:

Related Reading: For more information about DL/I status codes, see IMS Version10: Application Programming Planning Guide and IMS Version 10: ApplicationProgramming API Reference.

SQLException objectsAn SQLException object is thrown to indicate that an error has occurred either inthe Java address space or during database processing.

Each SQLException provides the following information:v A string that describes the error.

– This string is available through the use of the getMessage() method.v An “SQLstate” string that follows XOPEN SQLstate conventions.

– The values of the SQLstate string are described in the XOPEN SQLspecification.

v A link to the next SQL exception if more than one was generated.– The next exception is used as a source of additional error information.

XML tracing for the Java class libraries for IMSUsing the com.ibm.ims.base.XMLTrace class for z/OS applications orcom.ibm.ims.rds.XMLTrace for distributed applications, you can debug your Javaapplications by tracing, or documenting, the flow of control throughout yourapplication. By setting up trace points throughout your application for output, youcan isolate problem areas and, therefore, know where to make adjustments toproduce the results you expect. In addition, because the XMLTrace class supportswriting input parameters and results, and the methods within the Java classlibraries for IMS use this feature, you can verify that correct results occur acrossmethod boundaries.

The following topics provide more information about XML tracing in environmentsfor Java and enterprise applications:v “WebSphere Application Server security requirements for XML tracing” on page

411v “Enabling XML tracing” on page 411v “Enabling J2EE tracing” on page 413

try {DealerDatabaseView dealerView = new DealerDatabaseView();DLIConnection connection = DLIConnection.createInstance(dealerView);connection.getUniqueSegment(dealerSegment, dealerSSAList);

} catch (IMSException e ) {short statusCode = e.getStatusCode();String failingFunction = e.getFunction();

}

Figure 98. IMSException class example

410 Application Programming Guide

|||

Page 435: IMS Application Programming.pdf

Note: The XMLTrace class is different from the DLIModel utility trace. Forinformation about how to enable tracing for the DLIModel utility, see theOPTIONS statement of the DLIModel utility in IMS Version 10: SystemUtilities Reference.

Note: The XMLTrace class replaces the IMSTrace class. However, applications thatuse the IMSTrace class will still function properly.

WebSphere Application Server security requirements for XMLtracing

Before you can trace your application that runs on WebSphere Application ServerV5.0 for z/OS or WebSphere Application Server V5.0 on a non-z/OS platform, youmust add permissions to the WebSphere Application Server for z/OS server.policyfile and create a was.policy for the application EAR file.

To add permissions to the WebSphere Application Server for z/OS server.policyfile:1. Open the WebSphere Application Server for z/OS server.policy file, which is in

the properties directory of the WebSphere Application Server installationdirectory, and find the following code, which was added when you installedthe custom service (if this code is not in the file, add it):grant codeBase "file:/imsjava/-" {

permission java.util.PropertyPermission "*", "read, write";permission java.lang.RuntimePermission "loadLibrary.JavTDLI";permission java.io.FilePermission "/tmp/*", "read, write";

};

2. Below permission java.io.FilePermission "/tmp/*", "read, write";, add thefollowing permission, replacing traceOutputDir with the directory name for thetrace output file:permission java.io.FilePermission "/traceOutputDir/*", "read, write";

To create the was.policy file:1. Create a new file named was.policy that contains the following code, replacing

traceOutputDir with the directory name for the trace output file:grant codeBase "file:${application}" {

permission java.io.FilePermission "/traceOutputDir/*", "read, write";};

2. Put the was.policy file in the META-INF directory of your application's EARfile.

Enabling XML tracingTo debug with XMLTrace, you must first turn on the tracing function by calling oneof the XMLTrace.enable methods. Because tracing does not occur until this variableis set, it is best to do so within a static block of your main application class. Then,you must decide how closely you want to trace the your java application’s flow ofcontrol and how much tracing you want to add to your application code.

You can determine the amount of tracing in your Java application by providing thetrace level in the XMLTrace.enable method. By default, this value is set toXMLTrace.TRACE_EXCEPTIONS, which traces the construction of exceptions providedby the Java class libraries for IMS. XMLTrace also defines constants for three typesof additional tracing. These constants provide successively more tracing fromIMSTrace.TRACE_CTOR1 (level-one tracing of constructions) to IMSTrace.TRACE_DATA3(level-three tracing of data).

Chapter 27. Problem determination 411

Page 436: IMS Application Programming.pdf

XMLTrace has the following trace levels:

Trace level Description

TRACE_EXCEPTIONSTraces exceptions

TRACE_CTOR1 Traces level-1 constructors

TRACE_METHOD1Traces level-1 parameters, return values, methods, and constructors

TRACE_DATA1 Traces level-1 parameters, return values, methods, and constructors

TRACE_CTOR2 Traces level-2 constructors

TRACE_METHOD2Traces level-2 parameters, return values, methods, and constructors

TRACE_DATA2 Traces level-2 parameters, return values, methods, and constructors

TRACE_CTOR3 Traces level-3 constructors

TRACE_METHOD3Traces level-3 parameters, return values, methods, and constructors

TRACE_DATA3 Traces level-3 parameters, return values, methods, and constructors

Tracing the methods of the Java class libraries for IMSTo enable the tracing that is shipped with the methods of the Java class libaries forIMS:1. Call the XMLTrace.enable method and specify the root element name and the

trace level. For example:XMLTrace.enable("MyTrace", XMLTrace.TRACE_METHOD1);

2. Set an output stream (a print stream or a character output writer) as the currenttrace stream. For example:a. Set the system error stream as the current trace stream:

XMLTrace.setOutputStream(System.err);

b. Set a StringWriter object (or any other type of writer) as the current tracestream:StringWriter stringWriter = new StringWriter();XMLTrace.setOutputWriter(stringWriter);

3. Close the XML trace:XMLTrace.close();

Steps 1 and 2 are best implemented within a static block of your main applicationclass, as shown in Figure 99.

Tracing your applicationYou can add trace statements to your application, similar to those provided by theJava class libraries for IMS, by defining an integer variable that you test prior towriting trace statements. Using a variable other than XMLTrace.libTraceLevel

public static void main(String args[]){static {

XMLTrace.enable("MyTrace", XMLTrace.TRACE_METHOD1);XMLTrace.setOutputStream(System.err);

}}

Figure 99. Setting a trace within a static method

412 Application Programming Guide

Page 437: IMS Application Programming.pdf

enables you to control the level of tracing in your application independently of thetracing in the Java class libraries for IMS. For example, you can turn off the tracingof the routines of the Java class libraries for IMS by settingXMLTrace.libTraceLevel to zero, but still trace your application code.

To enable tracing for your application:1. Define an integer variable to contain the trace level for application-provided

code:public int applicationTraceLevel = XMLTrace.TRACE_CTOR3;

2. Set up the XMLTrace method to trace methods, parameters, and return values asnecessary.

Enabling J2EE tracingYou can trace the IMS library classes by using the WebSphere Application Servertracing service.

To enable tracing if you have not yet specified the level of tracing:1. “Specifying the level of tracing”2. “Specifying the application server and the package to trace” on page 414

To enable tracing if you have already specified the level of tracing:1. “Specifying at runtime the application server and the package to trace” on page

414

You can also trace the IMS library classes or your applications using thecom.ibm.ims.base.XMLTrace class. The XMLTrace class is class provided by the Javaclass libraries for IMS that represents the trace as an XML document. You can tracedifferent levels of the code depending on the trace level.

The Java API specification for IMS is available in the Information ManagementSoftware for z/OS Solutions Information Center under “Application programmingAPIs” at http://publib.boulder.ibm.com/infocenter/imzic.

Specifying the level of tracingTo use the WebSphere Application Server for z/OS tracing service, you must firstspecify the level of tracing.

To specify the level of tracing:1. In the left frame of the WebSphere Application Server for z/OS administrative

console, click Resources, and then click Resource Adapters.A list of resource adapters is displayed.

2. Click the name of the IMS DB resource adapter.A configuration dialog is displayed.

3. Under Additional Properties, click J2C connection factories.A list of connection factories is displayed.

4. Click the name of the J2C connection factory for which you want to enabletracing.A configuration dialog is displayed.

5. Under Additional Properties, click Custom Properties.Properties are listed in a table.

6. Click TraceLevel row.

Chapter 27. Problem determination 413

Page 438: IMS Application Programming.pdf

7. In the Value field, type the trace level.8. Click OK.

The properties table displays the trace level that you just entered.9. In the messages box, click Save.

The save page is displayed.10. Click Save to update the master repository with your changes.

Specifying the application server and the package to traceAfter you specify the level of tracing, specify the application server and package totrace and then restart the server.

To specify the application server and the package to trace:1. In the left frame of the WebSphere Application Server for z/OS administrative

console, click Servers, and then click Application Servers.A list of application servers is displayed.

2. Click the name of the server on which you want to enable tracing.3. Under Troubleshooting, click Diagnostic Trace Service.

A configuration dialog for Diagnostic Trace Service is displayed.4. Select the Enable Log check box and click OK.5. Under Troubleshooting, click Change Log Detail Levels.6. If you are using WebSphere Application Server for z/OS, click the plus sign

(+) next to com.ibm.connector2.7. If you are using WebSphere Application Server (non-z/OS), click the plus sign

(+) next to com.ibm.ims.*.8. If you are using WebSphere Application Server for z/OS, click

com.ibm.connector2.ims.*.9. If you are using WebSphere Application Server (non-z/OS), click

com.ibm.ims.rds.*.10. From the list of trace detail levels, click all.11. If you are using WebSphere Application Server for z/OS, verify that

com.ibm.connector2.ims.*=all appears in the text box and click OK.12. If you are using WebSphere Application Server (non-z/OS), verify that

com.ibm.ims.rds.*=all appears in the text box and click OK.13. In the messages box, click Save.

The save page is displayed.14. Click Save to update the master repository with your changes.15. Restart the server.

Specifying at runtime the application server and the package totraceYou can turn tracing on and off by specifying at runtime the server and package totrace. You do not need to restart your server each time.

To specify the application server and the package to trace at runtime:1. In the left frame of the WebSphere Application Server for z/OS administrative

console, click Servers, and then click Application Servers.A list of application servers is displayed.

2. Click the name of the server on which you want to enable tracing.3. Under Troubleshooting, click Change Log Detail Levels.

414 Application Programming Guide

||

||

||

||

||

||

Page 439: IMS Application Programming.pdf

A configuration dialog for Change Log Detail Levels is displayed.4. Click the Runtime tab.5. If you are using WebSphere Application Server for z/OS, click the plus sign

(+) next to com.ibm.connector2.6. If you are using WebSphere Application Server (non-z/OS), click the plus sign

(+) next to com.ibm.ims.rds.7. If you are using WebSphere Application Server for z/OS, click

com.ibm.connector2.ims.*

8. If you are using WebSphere Application Server (non-z/OS), clickcom.ibm.ims.rds.*

9. From the list of trace detail levels, click all.10. If you are using WebSphere Application Server for z/OS, verify that

com.ibm.connector2.ims.*=all appears in the text box and click OK.11. If you are using WebSphere Application Server (non-z/OS), verify that

com.ibm.ims.rds.*=all appears in the text box and click OK.12. Click OK.

Chapter 27. Problem determination 415

||

||

||

||

||

||

Page 440: IMS Application Programming.pdf

416 Application Programming Guide

Page 441: IMS Application Programming.pdf

Notices

This information was developed for products and services offered in the U.S.A.

IBM may not offer the products, services, or features discussed in this document inother countries. Consult your local IBM representative for information on theproducts and services currently available in your area. Any reference to an IBMproduct, program, or service is not intended to state or imply that only that IBMproduct, program, or service may be used. Any functionally equivalent product,program, or service that does not infringe any IBM intellectual property right maybe used instead. However, it is the user's responsibility to evaluate and verify theoperation of any non-IBM product, program, or service.

IBM may have patents or pending patent applications covering subject matterdescribed in this document. The furnishing of this document does not give youany license to these patents. You can send license inquiries, in writing, to:

IBM Director of LicensingIBM CorporationNorth Castle DriveArmonk, NY 10504-1785U.S.A.

For license inquiries regarding double-byte (DBCS) information, contact the IBMIntellectual Property Department in your country or send inquiries, in writing, to:

Intellectual Property LicensingLegal and Intellectual Property LawIBM Japan Ltd.1623-14, Shimotsuruma, Yamato-shiKanagawa 242-8502 Japan

The following paragraph does not apply to the United Kingdom or any othercountry where such provisions are inconsistent with local law:INTERNATIONAL BUSINESS MACHINES CORPORATION PROVIDES THISPUBLICATION “AS IS” WITHOUT WARRANTY OF ANY KIND, EITHEREXPRESS OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIEDWARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY OR FITNESSFOR A PARTICULAR PURPOSE. Some states do not allow disclaimer of express orimplied warranties in certain transactions, therefore, this statement may not applyto you.

This information could include technical inaccuracies or typographical errors.Changes are periodically made to the information herein; these changes will beincorporated in new editions of the publication. IBM may make improvementsand/or changes in the product(s) and/or the program(s) described in thispublication at any time without notice.

Any references in this information to non-IBM Web sites are provided forconvenience only and do not in any manner serve as an endorsement of those Websites. The materials at those Web sites are not part of the materials for this IBMproduct and use of those Web sites is at your own risk.

© Copyright IBM Corp. 1974, 2010 417

||

|||||

|

Page 442: IMS Application Programming.pdf

IBM may use or distribute any of the information you supply in any way itbelieves appropriate without incurring any obligation to you.

Licensees of this program who wish to have information about it for the purposeof enabling: (i) the exchange of information between independently createdprograms and other programs (including this one) and (ii) the mutual use of theinformation which has been exchanged, should contact:

IBM CorporationJ46A/G4555 Bailey AvenueSan Jose, CA 95141-1003U.S.A.

Such information may be available, subject to appropriate terms and conditions,including in some cases, payment of a fee.

The licensed program described in this information and all licensed materialavailable for it are provided by IBM under terms of the IBM Customer Agreement,IBM International Program License Agreement, or any equivalent agreementbetween us.

Any performance data contained herein was determined in a controlledenvironment. Therefore, the results obtained in other operating environments mayvary significantly. Some measurements may have been made on development-levelsystems and there is no guarantee that these measurements will be the same ongenerally available systems. Furthermore, some measurement may have beenestimated through extrapolation. Actual results may vary. Users of this documentshould verify the applicable data for their specific environment.

Information concerning non-IBM products was obtained from the suppliers ofthose products, their published announcements or other publicly available sources.IBM has not tested those products and cannot confirm the accuracy ofperformance, compatibility or any other claims related to non-IBM products.Questions on the capabilities of non-IBM products should be addressed to thesuppliers of those products.

All statements regarding IBM's future direction or intent are subject to change orwithdrawal without notice, and represent goals and objectives only.

This information is for planning purposes only. The information herein is subject tochange before the products described become available.

This information contains examples of data and reports used in daily businessoperations. To illustrate them as completely as possible, the examples include thenames of individuals, companies, brands, and products. All of these names arefictitious and any similarity to the names and addresses used by an actual businessenterprise is entirely coincidental.

COPYRIGHT LICENSE:

This information contains sample application programs in source language, whichillustrates programming techniques on various operating platforms. You may copy,modify, and distribute these sample programs in any form without payment toIBM, for the purposes of developing, using, marketing or distributing applicationprograms conforming to the application programming interface for the operatingplatform for which the sample programs are written. These examples have not

418 Application Programming Guide

Page 443: IMS Application Programming.pdf

been thoroughly tested under all conditions. IBM, therefore, cannot guarantee orimply reliability, serviceability, or function of these programs. You may copy,modify, and distribute these sample programs in any form without payment toIBM for the purposes of developing, using, marketing, or distributing applicationprograms conforming to IBM's application programming interfaces.

Each copy or any portion of these sample programs or any derivative work, mustinclude a copyright notice as follows:

© (your company name) (year). Portions of this code are derived from IBM Corp.Sample Programs. © Copyright IBM Corp. _enter the year or years_. All rightsreserved.

Programming interface informationThis information is intended to customers write applications. This informationdocuments Product-sensitive Programming Interface and Associated GuidanceInformation provided by IMS.

Product-sensitive Programming Interfaces allow the customer installation toperform tasks such as diagnosing, modifying, monitoring, repairing, tailoring, ortuning of this software product. Use of such interfaces creates dependencies on thedetailed design or implementation of the IBM software product. Product-sensitiveProgramming Interfaces should be used only for these specialized purposes.Because of their dependencies on detailed design and implementation, it is to beexpected that programs written to such interfaces may need to be changed in orderto run with new product releases or versions, or as a result of service.Product-sensitive Programming Interface and Associated Guidance Information isidentified where it occurs, either by an introductory statement to a section or topic,or by a Product-sensitive programming interface label. IBM requires that thepreceding statement, and any statement in this information that refers to thepreceding statement, be included in any whole or partial copy made of theinformation described by such a statement.

TrademarksIBM, the IBM logo, and ibm.com are trademarks or registered trademarks ofInternational Business Machines Corp., registered in many jurisdictions worldwide.Other product and service names might be trademarks of IBM or other companies.A current list of IBM trademarks is available on the Web in the topic “Copyrightand trademark information” at http://www.ibm.com/legal/copytrade.shtml.

The following terms are trademarks or registered trademarks of other companies,and have been used at least once in this information:v Adobe, the Adobe logo, PostScript, and the PostScript logo are either registered

trademarks or trademarks of Adobe Systems Incorporated in the United States,and/or other countries.

v Microsoft, Windows, Windows NT, and the Windows logo are trademarks ofMicrosoft Corporation in the United States, other countries, or both.

v Java and all Java-based trademarks are trademarks of Sun Microsystems, Inc., inthe United States, other countries, or both.

v Linux is a registered trademark of Linus Torvalds in the United States, othercountries, or both.

v UNIX is a registered trademark of The Open Group in the United States andother countries.

Notices 419

Page 444: IMS Application Programming.pdf

Other company, product, or service names may be trademarks or service marks ofothers.

420 Application Programming Guide

Page 445: IMS Application Programming.pdf

Bibliography

This bibliography lists all of the publications inthe IMS Version 10 library, supplementarypublications, publication collections, andaccessibility titles cited in the IMS Version 10library.

IMS Version 10 library

Note: Because the IBM strategy is to deliverproduct information in Eclipse informationcenters, IMS Version 10 is the last versionof the IMS library that will be available inBookManager format.

Title Acronym Ordernumber

IMS Version 10: ApplicationProgramming Planning Guide

APP SC18-9697

IMS Version 10: ApplicationProgramming Guide

APG SC18-9698

IMS Version 10: ApplicationProgramming API Reference

APR SC18-9699

IMS Version 10: CommandReference, Volume 1

CR1 SC18-9700

IMS Version 10: CommandReference, Volume 2

CR2 SC18-9701

IMS Version 10: CommandReference, Volume 3

CR3 SC18-9702

IMS Version 10: Communicationsand Connections Guide

CCG SC18-9703

IMS Version 10: DatabaseAdministration Guide

DAG SC18-9704

IMS Version 10: Database UtilitiesReference

DUR SC18-9705

IMS Version 10: Diagnosis Guide DG GC18-9706IMS Version 10: DiagnosisReference

DR GC18-9707

IMS Version 10: Exit RoutineReference

ERR SC18-9708

IMS Version 10: IMSplexAdministration Guide

IAG SC18-9709

IMS Version 10: Installation Guide IG GC18-9710IMS Version 10: LicensedProgramming Specifications

LPS GC18-9782

IMS Version 10: Master Index andGlossary

MIG SC18-9711

IMS: Messages and CodesReference, Volume 1: DFSMessages

MC1 GC18-9712

IMS: Messages and CodesReference, Volume 2: Non-DFSMessages

MC2 GC18-9713

IMS: Messages and CodesReference, Volume 3: IMS AbendCodes

MC3 GC18-9714

Title Acronym Ordernumber

IMS: Messages and CodesReference, Volume 4: IMSComponent Codes

MC4 GC18-9715

IMS Version 10: Operations andAutomation Guide

OAG SC18-9716

IMS Version 10: Release PlanningGuide

RPG GC18-9717

IMS Version 10: SystemAdministration Guide

SAG SC18-9718

IMS Version 10: System DefinitionGuide

SDG GC18-9998

IMS Version 10: System DefinitionReference

SDR GC18-9966

IMS Version 10: SystemProgramming API Reference

SPR SC18-9967

IMS Version 10: System UtilitiesReference

SUR SC18-9968

Supplementary publicationsDocumentation for the following supplementarypublications is available in the InformationManagement Software for z/OS SolutionsInformation Center at http://publib.boulder.ibm.com/infocenter/imzic.

Title Order numberIMS TM Resource Adapter User's Guide andReference

SC19-1211

IMS SOAP Gateway User's Guide andReference

SC19-1290

IMS Version 10: Fact Sheet GC19-1064IRLM Messages and Codes GC19-2666IMS and SOA Executive Overview GC19-2516

Documentation for the following IMS SOAIntegration Suite functions and tools that aresupported by IMS Version 10 is also available inthe Information Management Software for z/OSSolutions Information Center athttp://publib.boulder.ibm.com/infocenter/imzic:v IMS DLIModel utilityv IMS Enterprise Suitev IMS MFS Web Solutionsv IMS SOAP Gatewayv IMS TM Resource Adapterv IMS Web 2.0 Solution

© Copyright IBM Corp. 1974, 2010 421

|||||

|||||

||||||

|

|

|

|

|

|

Page 446: IMS Application Programming.pdf

Publication collections

Title Format Ordernumber

IMS Version 10 Product Kit CD SK5T-7327z/OS Software ProductsCollection

CD SK3T-4270

z/OS and Software ProductsDVD Collection

DVD SK3T-4271

Accessibility titles cited in theIMS Version 10 library

Title Order numberz/OS V1R1.0 TSO Primer SA22-7787z/OS V1R5.0 TSO/E User’s Guide SA22-7794z/OS V1R5.0 ISPF User’s Guide, Volume 1 SC34-4822

422 Application Programming Guide

Page 447: IMS Application Programming.pdf

Index

Special characters/FORMAT command 289/TEST MFS command 289

Numerics12-byte time stamp, field in I/O PCB 56, 201274X

defining to operate with MFS 2903270P Printer

defining to operate with MFS 2903290 Display Panel 290

defining to operate with MFS 2903601 workstation, defining to operate with MFS 2903770 Data Communication System

defining to operate with MFS 2903790 Communication System

defining to operate with MFS 2906670 Printer, defining to operate with MFS 290

Aabend codes

S201 174U261 174U476 174

abnormal termination 326accessibility

features xvkeyboard shortcuts xv

accessing GSAM databases 131AD/Cycle C/370 78addressability to UIB, establishing 64addressing mode (AMODE) 80, 211adjustable character string 328AIB (application interface block)

address return 75, 208AIB identifier (AIBID) 204

description 59AIBERRXT (reason code) 60, 204AIBOALEN (maximum output area length) 60, 204AIBOAUSE (used output area length) 204

description 60AIBREASN (reason code) 60, 204, 205AIBRSA1 (resource address) 60, 204AIBRSNM1 (resource name) 204

description 60AIBSFUNC (subfunction code) 204

description 60and program entry statement 208defining storage 206description 72, 205DFSAIB allocated length (AIBLEN) 60, 204fields 59, 203mask 59, 60, 204, 205program entry statement 75specifying 59, 203storage, defining 72

AIB (Application Interface Block)AIB mask 323

AIB (Application Interface Block) (continued)restrictions 323supported commands 323

AIB mask, specifying 59AIBERRXT (reason code) 60, 204AIBID (AIB identifier) field, AIB mask 59, 204AIBLEN (DFSAIB allocated length) field, AIB mask 60, 204AIBOALEN (maximum output area length) field, AIB

mask 60, 204AIBOAUSE (used output area length) field, AIB mask 60, 204AIBREASN (reason code)

AIB mask, field 204AIBREASN (reason code) AIB mask, field 60AIBREASN (reason code) field, AIB mask 60, 205AIBRSA1 (resource address) field, AIB mask 60, 204AIBRSNM1 (resource name) field, AIB mask 60, 204AIBSFUNC (subfunction code) field, AIB mask 60, 204AIBTDLI interface

See AIB (application interface block)AJ status code 347alternate destinations, sending messages to 229alternate PCB 329

defining in ISRT call 228express

See express alternate PCB.modifiable

description 228use 229using the CHNG call with 230

response 242SAMETRM=YES 242sending messages to other terminals 229to alternate destinations 229types and uses 202use with program-to-program message switching 231using the PURG call with 229

alternate PCB maskdescription 202format 202

alternate terminals, responding to 229AM status code 347AMODE 80AMODE(31) 321AND operators

dependent 118independent 119logical 8

Another terminalMessage Type 213

APPCAPSB (allocate program specification block) 175DPSB (deallocate program specification block) 176RRS/MVS 173

APPC conversational programCPI-C driven 249ending the conversation 247message switching 245modified IMS application 248

application interface block (AIB)See AIB (application interface block)

© Copyright IBM Corp. 1974, 2010 423

Page 448: IMS Application Programming.pdf

Application Interface Block (AIB)AIB mask 323restrictions 323supported commands 323

application programHALDB environment, scheduling 79I/O areas, specifying 205sync point 101

Application ProgramMessage Type 213

application programs 184assembler language 184C language 186COBOL 189Pascal 192PL/I 195

application programs, IFP 330application sample, subset pointers 340applications

message processing, building 370APSB (allocate program specification block) 175areas, I/O 66array, connected 328assembler language

application programming for 184DL/I call format, example 42DL/I call formats 186DL/I call-level sample 18DL/I command-level sample 304DL/I program structure 15entry statement 73I/O area 328MPP coding 259parameters, DL/I call format 41program entry 73, 206register 1 at program entry 206register 1, program entry 73return statement 73skeleton MPP 259SSA definition examples 68syntax diagram, DL/I call format 40UIB, specifying 63

assembler language programDIB fields 324variable names, mandatory 324

automatic storage 314availability enhancements, data 355

BBA status code 325backing out

database changes 334, 335backout point

description 250intermediate 335intermediate (SETS/SETU) 254ROLB, ROLL, ROLS 250

backout point, intermediate 112basic checkpoint

issuing 334Basic edit

IMS TM 279Basic Edit

input message 219output message 220translation to uppercase 219

batch message processing (BMP) programsissuing checkpoints 333PCBs 330

batch programsassembler language 15C language 20COBOL 22command-level samples

assembler 304C 315COBOL 308PL/I 311

issuing checkpoints 333maintaining integrity 111Pascal 31PL/I 32

BC status code 325binder options with EXEC DLI 322binding, reference 18, 35BMP (batch message processing) programs

issuing checkpoints 333PCBs 330

BMPs, transaction-orientedROLB 110

Boolean operatorsdependent AND 118independent AND 119logical AND operator 8logical OR 8SSA, coding 67

CC code standard header file 320C language 73

__pcblist 73, 206application programming 186batch program, coding 20DL/I call formats 189DL/I call formats, example 45DL/I program structure 20entry statement 73, 206exit 73, 206I/O area 45longjmp 206parameters, DL/I call format 43passing PCBs 206PCBs, passing 73return 206return statement 73skeleton MPP 259SSA definition examples 68syntax diagram, DL/I call format 42system function 74, 207

C programDIB fields 324DL/I command-level sample 315variable names, mandatory 324

C/C++ 78call-level programs

comparing with command-level programscommand codes and options 353commands and calls 352

DL/I calls available to IMS and CICS command-level 351calls, system service

SETS/SETU (set a backout point)backing out to an intermediate backout point 112

424 Application Programming Guide

Page 449: IMS Application Programming.pdf

calls,system serviceSETS/SETU (set a backout point)

using 113CEETDLI 78

address return 75, 208interface to IMS 78program entry statement 39, 75, 208

change callSee CHNG call

character stringadjustable 328fixed-length 328

checkpoint (CHKP)command

description, in a Batch or BMP Program 334issuing in a Batch or BMP Program 334

EXEC DLI command 334basic 334current position 333

symbolic, description 334checkpoint (CHKP) calls

considerations 12description 107issuing 107

checkpointsrelationship to commit point and sync point 101

CHKP (Checkpoint)command

description, in a Batch or BMP Program 334issuing in a Batch or BMP Program 334

EXEC DLI command 334basic 334current position 333

symbolic, description 334CHKP (checkpoint) call, considerations 12CHKP (symbolic checkpoint) call

with GSAM 137CHNG call

description 230usage 269using PURG with 230with directed routing 235

CICSapplications

writing 400command language translator 321HANDLE ABEND command 326Java applications overview 399writing applications 400

CICS DL/I call program, compiling 14CICS online programs

assembler language, sample 18COBOL, sample 25PL/I, sample 36

CIMS 175closing a GSAM database explicitly 135CMPAT option 330COBOL

See also Enterprise COBOLapplication programming 189compiler 308DL/I call formats 192DL/I call formats, example 48DL/I call-level, sample 25DL/I command-level sample 308DL/I program structure 22entry statement 73

COBOL (continued)I/O area 327II translator 321Language Environment 78OS/VS 311parameters, DL/I call format 46program

DIB fields 324variable names, mandatory 324

return statement 73skeleton MPP 261SSA definition examples 69syntax diagram, DL/I call format 45UIB, specifying 63V4 311

COBOL/370 and Language Environment 78codes, status

logical relationships 123coding DC calls and data areas 257

in assembler language 259in C Language 259in COBOL 261in Pascal 263in PL/I 265skeleton MPP 258, 259, 261, 263, 265

coding rules, SSA 67command codes

CSSAs (segment search arguments) 5

Dexamples 10

DEDBs 12F

restrictions 163overview 10Q 115qualified SSAs 11restrictions 67SSAs (segment search arguments) 5subset pointers 12, 157, 158unqualified SSAs 11

command language translator, CICS 321command-level programs

comparing with call-level programscommand codes and options 353commands and calls 352

DIB (DL/I interface block) 323DL/I calls available to IMS and CICS 351I/O area, defining 327key feedback area, defining 327preparing EXEC DL/I program for execution 321samples

assembler language 304C 315COBOL 308PL/I 311

status codes, checking 324commands

SCHD PSB 314commit

single-phase 105two-phase 103UOR 104

commit pointSee also backout pointprocess 101relationship to check point and sync point 101

Index 425

Page 450: IMS Application Programming.pdf

commit point processingDEDB 161MSDB 152

committing your program’s changes to a database 333communicating with other IMS TM systems 233comparing EXEC DLI

commands with DL/I calls 352options with command codes 353

compiler, COBOL 308compiling, options with EXEC DLI 321concatenated data sets, GSAM 141concatenated key and PCB mask 59, 133concatenated key, segment 327concatenated segments, logical relationships 122connected array 328control blocks, MFS 281

summary 281testing 289

conversational processingby deferred switch 242by immediate switch 243coding necessary information 247continuing the conversation 241ending the conversation and passing control 244example 237for APPC/IMS 246message formats 241overview 236passing control and continuing the conversation 242, 243replying to the terminal 242restrictions 241, 243ROLB call 238ROLL call 238ROLS call 238steps in a conversational program 239structure 238using ROLB, ROLL and ROLS in 242

conversational programdefinition 237

conversational transactions 374CPI Communications driven program

sync point 102CPI Resource Recovery calls 102crossing a unit of work (UOW) boundary when processing

DEDBs 349current position

determining 83multiple positioning 93unsuccessful calls 89

Ddata areas, coding 12data availability enhancements 355data availability, status codes 57data capture

See AIB (application interface block)data entry database

See DEDB (data entry database)data entry database (DEDB)

See DEDB (data entry database)data locking 153data propagation

sync point 106data redundancy, reducing 121data structures 13

databaseavailability

obtaining information 355status codes, accepting 355

callsFast Path 171

DB PCB, name 57, 133description name field, DIB (DL/I interface block) 326integrity, maintaining 333organization field, DIB (DL/I interface block) 327position

determining 83multiple positioning 93unsuccessful calls 89

processing, Fast Path 337recovery 333recovery with ROLL call 110recovery, back out changes 109recovery, planning for

backing out database changes 334checkpoints, CHKP command 334checkpoints, taking 334restarting your program, XRST command 334

typesGSAM 327HDAM 327HIDAM 327HISAM 327HSAM 327INDEX 327SHSAM 327

database recoverybacking out 251, 252

Database Resource Adapter (DRA) 173DB Control

DRA (Database Resource Adapter) 175DB Control DRA (Database Resource Adapter) 173DB PCB

definition 329DB PCB (database program communication block)

database name 57, 133entry statement, pointer 132fields 56, 57key feedback area 133key feedback area length field 58, 133mask 57

fields 133fields, GSAM 132general description 56GSAM reference 72name 132relation 56specifying 56

masksDB PCB 56

multiple DB PCBs 99number of sensitive segments field 58processing options field 58, 133relation to DB PCB 56secondary indexing, contents 120segment level number field 57segment name field 58sensitive segments 58status code field 57, 133

DB2 (DATABASE 2)with IMS TM 227, 267

426 Application Programming Guide

Page 451: IMS Application Programming.pdf

DB2 for z/OS accessapplication programming 393committing work 394drivers 393IMS databases, compared to 394JBP region, from a

programming model 382JMP region, from a

programming model 373rolling back work 394

DB2 for z/OS stored proceduresdeveloping 398overview with IMS solutions for Java development 397

DBCTL (Database Control)single-phase commit 105two-phase commit 103

DBCTL facilitiesACCEPT command 355data availability 355QUERY command 355REFRESH command 355ROLS (Roll Back to SETS or SETU) command 335SETS (Set a Backout Point) command 335

DBCTLID parameter 175DBD, defining subset pointers 340debugging

XMLTrace 410DEDB (data entry database) 147

call restrictions 163crossing a unit of work (UOW) boundary when

processing 349data locking 153DL/I calls 163multiple qualification statements 10processing

commit point 161data locking 153fast path 145H option 162overview 147, 337P option 162POS (Position) command 347POS call 159subset pointers 154, 337

updating segments 147updating with subset pointers 154

deferred program switchin conversational programs 242passing control to another 239

defining application program elements to IMSAIB 323DIB 323I/O area 327key feedback area 327

Delete (DLET) callwith MSDB, DEDB or VSO DEDB 147

dependent AND operator 118dependent segments

sequentialfree space, identifying 349in DEDBs 337locating a specific dependent 348locating the last inserted dependent 348

dependents, direct 147deployment descriptor

example 406requirements for Java class libraries for IMS 406

design efficiency, programs 303destination of modifiable alternate PCBs 230device input format

See DIF (device input format)device output format

See DOF (device output format)devices supported by MFS 290DFHEIENT 307DFHEIRET 308DFHEISTG 307DFSAPPC 245

format 245message switching 245option keywords 246

DFSHALDBselective partition processing 125

DFSUDT0x (device characteristics table) 289diagnosing multiple parsing error return codes 269DIB (DL/I interface block)

accessing information 323database description name field 326database organization field 327fields 324key feedback length field 326label restriction 324labels 324segment level field 326segment name field 326status code field 324structure 323translator version 324

DIF (device input format) 281description 281

direct dependent segments, in DEDBs 337directed routing 233, 234distributed commit calls

ATRBACK 176ATRCMIT 176RRS/MVS 176SRRBACK 176SRRCMIT 176

distributed presentation managementSee DPM (distributed presentation management)

DL/I call formats, examplesassembler language 42C language 45COBOL 48Pascal 50PL/I 53

DL/I calls 186, 197relationships to PCB types

I/O PCBs 197sample call formats 186

assembler language 186C language 189COBOL 192Pascal 195PL/I 197

DL/I calls (general information)qualified calls 4qualifying calls

command codes 10field 5segment type 5

segment search arguments (SSAs) 4types 5unqualified calls 4

Index 427

Page 452: IMS Application Programming.pdf

DL/I calls, general informationcoding 12

DL/I calls, system serviceROLB 110ROLL 109

DL/I interface blockSee DIB (DL/I interface block)

DL/I language interfaces 183overview 39, 183supported interfaces 39, 183

DL/I optionslogical relationships 121secondary indexing 117

DL/I status codesmapping to exceptions 409

DLET (Delete) callwith MSDB, DEDB or VSO DEDB 147

DLI option 321DLIConnection class 409DLIException class 409DLITCBL 74, 207DLITPLI 75, 208DLITypeInfoList class 377DOF (device output format) 281

description 281DPM (distributed presentation management)

using 292with ISC 292

DPSB (deallocate program specification block) 176DRA (Database Resource Adapter)

description 173startup table 175

dynamic backout 334

Eedit routines

Basic Edit 219ISC 219MFS 219

editing messages 219See message, editing

efficient program design 303EIBREG parameter 307EJB (Enterprise JavaBean)

deployment descriptor requirements 406enabling

data availability status codes 57ending a conversation and passing control to another

program 244Enterprise COBOL 392

back end 392implementing 393

CALL statement 392compiler 393front end 392, 393JVM, locating 393main method 393object oriented syntax 392

entry and return conventions 73entry point

assembler language 206C language 206COBOL 207overview 206Pascal 207PL/I 208

equal-to relational operator 5examples

Boolean operators 9conversational processing 237D command code 10FLD/CHANGE 151FLD/VERIFY 151multiple qualification statements 9path call 10SSA, secondary indexing 118UIB, defining 64

exceptionsdescription 409IMSException object

getAIB method 409getFunction method 409getStatusCode method 409

mapping to DL/I status codes 409EXEC DLI

binder options, required 322compiler options, required 321options, using with subset pointers 340preparing program for execution 321recovery commands

CHKP (Checkpoint) 334SYMCHKP (Symbolic Checkpoint) 334XRST (Extended Restart) 334

translator options, required 321execution diagnostic facility 323explicitly opening and closing a GSAM database 135express alternate PCB 228

FF command code, restrictions 163Fast Path

database calls 145database, processing 337databases, processing 145DEDB (data entry database) 145MSDB (main storage database) 145P (position) processing option 349processing MSDBs and VSO DEDBs 147subset pointers with DEDBs 337subset pointers, using with DEDBs 154types of databases 145

FH status code 325field

changing contents 150checking contents: FLD/VERIFY 148

Field (FLD) callSee FLD (Field) call

field nameFSA 149SSA, qualification statement 5

field search argument (FSA)description 148with DL/I calls 148

field valueFSA 149SSA, qualification statement 5, 6

fieldsin DIB 324

fields in a DB PCB 133fields in a DB PCB mask 57FIN (Finance Communication System)

defining to operate with MFS 290

428 Application Programming Guide

Page 453: IMS Application Programming.pdf

fixed-length character string 328fixed-length records 136FLD (Field) call

description 147FLD/CHANGE 150FLD/VERIFY 148

format settesting

/FORMAT command 289/TEST MFS command 289

formatsPSB 331

free space, identifying 161, 349FSA (field search argument)

description 148with DL/I calls 148

FW status code 325

GGA status code 325GB status code 325GC status code 349GD status code 325GE status code 315, 320, 325general programming guidelines 303generalized sequential access method (GSAM)

See GSAM (generalized sequential access method)generated program specification block (GPSB), format 76getAIB method 409GETFIRST option

examples 341retrieving first segment in subset 341

getFunction method 409getNextException 410getStatusCode method 409GG status code 325GK status code 325GPSB (generated program specification block), format 76, 209greater-than relational operator 5greater-than-or-equal-to relational operator 5group name, field in I/O PCB 55, 201GSAM (generalized sequential access method)

accessing databases 131BMP region type 142call summary 138CHKP 137coding considerations 138data areas 72data set

attributes, specifying 142characteristics, origin 139concatenated 141DD statement DISP parameter 140extended checkpoint restart 140

database, explicitly opening and closing 135DB PCB mask, fields 132DB PCB masks 72DBB region type 142description 131designing a program 131DLI region types 142fixed-length records 136I/O areas 136record formats 136records, retrieving and inserting 134restrictions on CHKP and XRST 137

GSAM (generalized sequential access method) (continued)RSA 72, 134status codes 137undefined-length records 136variable-length records 136XRST 137

GSAM database 327GSAM PCB 329guidelines, general programming 303guidelines, programming 3

HH processing option 162HALDB

selective partition processing 125HALDB (High Availability Large Database)

application programs, scheduling against 79initial load of 79

HANDLE ABEND command, CICS 326HDAM

multiple qualification statements 10HDAM database 327HIDAM database 327hierarchy

data structures 13High Availability Large Database (HALDB)

application programs, scheduling against 79initial load of 79

HISAM database 327HSAM database 327

II/O area

assembler language 328C language 45COBOL 327coding 66, 327command-level program 327description 66in C language 189PL/I 328restriction 327specifying 66, 205symbolic CHKP 334XRST 334

I/O PCB 329mask

12-byte time stamp 56general description 53group name field 55input message sequence number 55logical terminal name field 54message output descriptor name 55specifying 53status code field 54userid field 55userid indicator field 56

I/O PCB mask12-byte time stamp 201general description 198group name field 201input message sequence number 200logical terminal name field 199message output descriptor name 201

Index 429

Page 454: IMS Application Programming.pdf

I/O PCB mask (continued)specifying 198status code field 199userid field 201userid indicator field 202

IBM COBOL for z/OS & VM 311IFP application programs 330II status code 325immediate program switch 239

in conversational programs 243IMS application programs, standard 248IMS conversations

conversational program 237nonconversational program 237

IMS solutions for Java developmentRedbooks 359

IMS TMDB2 considerations 227, 267Message Type 213

IMS.FORMAT 289compression 288use 289

IMS.REFERAL 289compression 288handling of ITBs 289

IMS.TFORMAT, use 288IMSException class 409IMSFieldMessage 379IMSFieldMessage class

subclassing 370IMSMessageQueue 410in-doubt UOR

definition 104in-flight UOR

definition 104independent AND operator 119INDEX database 327INDEX function (service utility), overview 289indexed field in SSA 118indexing, secondary

DL/I Returns 120effect on program 117multiple qualification statements 118SSAs 117status codes 120

input for a DL/I program 12input message

format 214MFS 221

input message sequence number, field in I/O PCB 55, 200input messages, defining 370inserting a segment

GSAM records 134integrity

batch programs 111maintaining,database 108using ROLB 109

MPPs and transaction-oriented BMPs 110using ROLL 109using ROLS 111

interfaces, DL/I 78interfaces, DL/I.

See DL/I interfacesintermediate backout point

backing out 112intermediate backout points 335

ISC (intersystem communication)defining to operate with MFS 292editing output messages 220

ISRT (Insert) callwith MSDB, DEDB or VSO DEDB 147

ISRT callissuing to other terminals 228message call

in conversational programs 241referencing alternate PCBs 228usage 228

issuingcheckpoints in batch or BMP programs 333

ITB (intermediate text block), relationship between ITBs andcontrol blocks 288

JJava batch processing (JBP) regions

DB2 UDB for z/OS accessapplication programming 393programming model 382

description 368programming models 381restart 380symbolic checkpoint 380

Java Batch Processing (JBP) regionsprogram switching 394

Java class librariesIMS DB distributed resource adapter

about 402Java class libraries for IMS

administering 13exceptions 409problem determination 409

Java Environment 78Java message processing (JMP) regions

DB2 for z/OS accessapplication programming 393programming model 373

description 368programming models 372

Java Message Processing (JMP) regionsprogram switching 394

JBP (Java batch processing) regionsDB2 UDB for z/OS access

application programming 393programming model 382

description 368program switching 394programming models 381restart 380symbolic checkpoint 380synchronous callout support 395

JMP (Java message processing) regionsDB2 for z/OS access

application programming 393programming model 373

description 368program switching 394programming models 372synchronous callout support 395

JMP applicationsmessage handling

conversational transactions 374multi-segment messages 376multiple input messages 378

430 Application Programming Guide

Page 455: IMS Application Programming.pdf

JMP applications (continued)message handling (continued)

repeating structures 377programming models 372

Kkey feedback area

command-level program 327DB PCB, length field 58length field in DB PCB 133length field in DIB 326overview 59

keyboard shortcuts xv

LLANG= Option on PSBGEN for PL/I Compatibility with

Language Environment 210Language Environment 78

characteristics of CEETDLI 209LANG = option for PL/I compatibility 78, 210supported languages 209

Language Environment, with IMS 209language interfaces, DL/I 78language interfaces, DL/I.

See DL/I interfaceslanguage utility

See MFS language utilityLarge Data Sets 142LB status code 325length of key feedback area 133less-than relational operator 5less-than-or-equal-to relational operator 5level number field in DIB 326level number, field in DB PCB 57link editing, EXEC DLI 322LL field 240

in input message 214in output message 215

locatinga specific sequential dependent 348last inserted sequential dependent 348

locating dependents in DEDBslast-inserted sequential dependent, POS call 159POS call 160specific sequential dependent, POS call 159

lock management 115log

recordssync points 105

logical AND, Boolean operator 8logical child 121logical OR, Boolean operator 8logical parent 121logical relationships

effect on programming 123introduction 121logical child 121logical parent 121physical parent 121processing segments 121programming, effect 121status codes 123

logical structure 121logical terminal name, field in I/O PCB 54, 199

LU 6.2conversations 246

LU 6.2 User Edit Exitusing 227

Mmain storage database (MSDB)

See MSDB (main storage database)main() method 371maintaining database integrity 333major structure 328managing subset pointers in DEDBs with command

codes 146mask

AIB 59DB PCB 56

master terminalissuing timeout 233

messageediting

description 219input message 219, 221output 220output message 220, 227skipping line 219using Basic Edit 219using ISC Edit 220using LU 6.2 User Edit Exit 227using MFS Edit 220

from terminals 213I/O PCB 218in conversations 241input 214, 221

fields, contents of 214output 215, 227

fields, contents of 215printing 219processing of 213

summary 217receiving by program 213result 218sending to other application programs 231types 213

MessageType

Application Program 213IMS TM 213Message switch service 214

TypesAnother terminal 213

message editorSee MFS message editor

message format serviceSee MFS (message format service)

message formatting service. See MFS (message formatservice 219

Message InputSegment Format 214

message input descriptorSee MID (message input descriptor)

message output descriptorSee MOD (message output descriptor)

message output descriptor name, field in I/O PCB 55, 201message processing application

building 370

Index 431

Page 456: IMS Application Programming.pdf

message processing programSee MPP (message processing program)

Message switch serviceMessage Type 214

messagesinput, defining 370multi-segment 376output, defining 370repeating structures

defining in the Java class libraries for IMS 377SPA 374subsequent 376

MFS (message format service)components 287editing message 219editing output messages 220example 284input message

formats 221introduction 279message editor 288online performance 280output message

formats 227pool manager 288remote programs 292supported devices 290

MFS language utility 288functions 288modes 288statistics maintained 288use of MFS libraries 288

MFS libraries 288IMS.TFORMAT 288online change function 288

MFS message editor 289MFS pool manager

storage management 289MFS service utility, INDEX function 289MFSTEST procedure (language utility)

pool manager 288, 290use of IMS.TFORMAT library 288

MID (message input descriptor) 281description 281

minor structure 328mixed-language programming 79, 210MOD (message output descriptor) 281

description 281modifiable alternate PCBs 107

changing the destination 230CHNG call 230description 229

modified application programMSC 249remote execution, MSC 249

MOVENEXT optionexamples 343use when moving subset pointer forward 343

moving subset pointer forward 343MPP (message processing program)

coding in assembler language 259coding in C language 259coding in COBOL 261coding in Pascal 263coding in PL/I 265coding necessary information 258input 258

MPP (message processing program) (continued)skeleton MPP 258

MPPs 330ROLB 110

MSC (multiple systems coupling)conversational programming 244description 233directed routing 234receiving messages from other IMS TM systems 234sending messages to other IMS TM systems 235

MSDB (main storage database)call restrictions 154commit point processing 152data locking 153processing 147

data locking 153updating segments 147

MSDBs (main storage database)processing commit points 152

MSDBs (main storage databases)nonrelated 146terminal related 146types

description 146multi-segment messages 376multiple

DB PCBs 99positioning 93processing 93qualification statements 8qualification statements, DEDB 10qualification statements, HDAM 10qualification statements, PHDAM 10

multiple positioningadvantages of 96effecting your program 96resetting position 98

multiple systems couplingSee MSC (multiple systems coupling)

MVS/ESA, extended addressing capabilitiesaddressing mode (AMODE) 211DCCTL environment 211preloaded program 211residency mode (RMODE) 211

MYLTERM 154

Nname field, segments 5NI status code 325nonconversational program

definition 237nonrelated (non-terminal-related) MSDBs 146not-equal-to relational operator 5not-found status code

description 89position after 89

NTO (Network Terminal Option)See SLU

OODBA

application execution environmentestablishing 174, 178

432 Application Programming Guide

Page 457: IMS Application Programming.pdf

ODBA (continued)application programs

writing 173APSB (allocate program specification block) 175CIMS 175DB2 for z/OS Stored Procedures 178DPSB (deallocate program specification block) 176DRA (Database Resource Adapter) 173, 175RRS/MVS 173server program 177

ODBA (Open Database Access) 173online change function, description 288online performance 280online programs, command-level samples

assembler 304C 315COBOL 308PL/I 311

operatorFSA 149SSA 5

operatorsBoolean 8relational 8

optionsCMPAT 330MOVENEXT 343P processing 349

options for subset pointersGETFIRST 341MOVENEXT 343SET 344SETCOND 345SETZERO 343

options, processing; field in DB PCB 58, 133OR, logical 8OS/VS COBOL 311OS/VS COBOL and Language Environment 78OTMA, processing conversations with 250output message

format 215printing 219sending 233to other application programs 231to other IMS TM systems 235using Basic Edit 220using MFS 227with directed routing 236

output messages, defining 370overlap, storage 327overrides, PROCESS statement 321

PP processing option 162, 349parameters

assembler language, DL/I call format 41C language, DL/I call format 43COBOL, DL/I call format 46DBCTLID 175EIBREG 307Pascal, DL/I call format 49PL/I, DL/I call format 52RCREG 308

parmcount 266parsing error return codes 269

Pascalapplication programming 192batch program, coding 31DL/I call formats 195DL/I call formats, example 50DL/I program structure 31entry statement 73, 74, 207parameters, DL/I call format 49passing PCBs 207PCBs, passing 74skeleton MPP 263SSA definition examples 70syntax diagram, DL/I call format 48

passing a conversation to another IMS TM system 244passing control

restrictions 243to a conversational program 242to another program in a conversation 242

path calldefinition 10example 10overview 10

PCB (program communication block)address list, accessing 63alternate 329in application programs, summary 330masks

GSAM databases 132I/O PCB 53, 198

modifiable alternate PCBs 107types 76, 209, 329

PCB lists 208PCB parameter list in assembler language MPPs 259PCB, express alternate

See express alternate PCB.PCBs, alternate

See modifiable alternate PCBsPCBs, modifiable

See modifiable alternate PCBsPHDAM

multiple qualification statements 10physical parent 121PL/I

application programming 195batch program, coding 32DL/I call formats 197DL/I call formats, example 53DL/I call-level sample 36DL/I command-level sample 311DL/I program, multitasking restriction 32entry statement 73entry statement restrictions 266I/O area 328MPP coding notes 266optimizing compiler 266parameters, DL/I call format 52passing PCBs 208PCBs, passing 75pointers in entry statement 75, 208program variable names, mandatory 324return statement 73skeleton MPP 265SSA definition examples 71syntax diagram, DL/I call format 51UIB, specifying 63

PL/I and Language Environment 78

Index 433

Page 458: IMS Application Programming.pdf

PL/I CompatibilityLANG= Option 78

PLITDLI 113PLITDLI procedure

description 81pointers, subset

DBD, defining 340description 337GETFIRST option 341MOVENEXT option 343preparation for using 339PSB, defining 340sample application 340SET option 344SETCOND option 345SETZERO option 343status codes 347

pool manager 288MFS 288

buffer pool 289control block management 289description 288

MFSTEST, description 288, 290POS (Position) call

description 159POS (Position) command

free space, identifying 349locating a specific sequential dependent 348locating the last inserted sequential dependent 348using with DEDBs 347

POS(positioning)=MULT(multiple) 93Position (POS) command

free space, identifying 349locating a specific sequential dependent 348locating the last inserted sequential dependent 348using with DEDBs 347

positioningafter DLET 85after ISRT 87after REPL 87after retrieval calls 85after unsuccessful calls 89after unsuccessful DLET or REPL call 89after unsuccessful retrieval or ISRT call 90CHKP, effect 107current, after unsuccessful calls 88determining 83multiple 93understanding current 83

preloaded programs 80preparing programs

for EXEC DLI 303for EXEC DLI execution 321

Problem Determination 409procedures

CBLTDLI 81PLITDLI 81

PROCESS statement overrides 321processing

commit-point in DEDB 161commit-point in MSDB 152database, several views 99DEDBs 154, 337Fast Path databases 145Fast Path, P (position) option 349GSAM databases 131MSDBs and VSO DEBDs 147

processing (continued)multiple 93options

field in DB PCB 58, 133H (position), for Fast Path 162P (position), for Fast Path 162

segments in logical relationships 121processing a message 217program

design 12design efficiency 303restarting 107

program communication blockSee also DB (database program communication block)See PCB (program communication block)

program structureconversational 238

program switches 394program-to-program message switching

conversational 242nonconversational 231restrictions 231security checks 231

programmingguidelines 3mixed language 79secondary indexing 117

programming guidelines, general 303programming models

JBP applicationssymbolic checkpoint and restart 381with rollback 382without rollback 381

JMP applications 372DB2 for z/OS data access 373IMS data access 373with rollback 373without rollback 372

WebSphere Application Server (non-z/OS) applicationsbean-managed EJBs 403container-managed EJBs 404servlets 405

WebSphere Application Server for z/OS applicationsbean-managed EJBs 403container-managed EJBs 404servlets 405

programs, BMP 330PSB (program specification block)

APSB (allocate program specification block) 175defining subset pointers 340DPSB (deallocate program specification block) 176format 76, 331PCB, types of 329

PSB (program specification block), format 208PSBGEN

LANG= Option 78PURG call

description 229using CHNG with 230

QQ command code 115qualification statement

coding 67field name 5field value 5, 6

434 Application Programming Guide

Page 459: IMS Application Programming.pdf

qualification statement (continued)multiple qualification statements 8multiple qualification statements, DEDB 10multiple qualification statements, HDAM 10multiple qualification statements, PHDAM 10relational operator 5segment name 5structure 5

qualification statementsoverview 5

qualified callsdefinition 5overview 4

qualified SSAstructure with command code 11

qualified SSAs (segment search arguments)qualification statement 5structure 5

qualifyingDL/I calls with command codes 10SSAs 5

RRACF signon security 55, 201RACROUTE SAF 55, 201randomizing routine

exit routine 10RCREG parameters 308reading segments in MSDBs 148, 154receiving messages, from other IMS TM systems 234record search argument

See RSA (record search argument)recoverable in-doubt structure.

See RISrecovering databases 333recovery

RIS 105token

definition 105recovery EXEC DLI commands

basic CHKP 334SYMCHKP 334XRST 334

reentrance 307reentry 307REFRESH command 355related (terminal related) MSDBs 146relational operators

Boolean operators 8independent AND 8list 5logical AND 8logical OR 8overview 5SSA, coding 67SSA, qualification statement 5

remote programs, defining 292repeating structures

accessing 377DLITypeInfoList class 377dotted notation 378sample output message 377

REPL (Replace) callwith MSDB, DEDB or VSO DEDB 147

replying to one alternate terminal 229replying to the terminal in a conversation 242

reportsHALDB selective partition processing 126

res-sharing-scope element 406res-type element 406reserving

place for command codes 163segment

command code 115lock management 115

resetting a subset pointer 344residency mode (RMODE) 80, 211Resource Recovery Services/Multiple Virtual Storage

(RRS/MVS)ODBA interface 173

Resource Recovery Services.See RRS

resource-ref elementexample 406requirements for Java class libraries for IMS 406

restarting your program, basic checkpoints 107restarting your program, with EXEC DLI XRST

command 334restrictions

AIB 323CHKP and XRST with GSAM 137database calls

to DEDBs 163to MSDBs 154

DIB label 324I/O area 327I/O area, PL/I 328

return codesUIB 63

RIS (recoverable in-doubt structure) 105RMODE 80ROLB

in MPPs and transaction-oriented BMPs 110ROLB (Roll Back) call

compared to ROLL call 109description 110maintaining database integrity 108usage 110

ROLB callcomparison to ROLL and ROLS call 250description 252use in conversations 238

ROLL (Roll) callcompared to ROLB call 109description 109maintaining database integrity 108

roll back pointSee backout point

ROLL callcomparison to ROLB and ROLS call 250description 251use in conversations 238

ROLSbacking out to an intermediate backout point 112

ROLS (Roll Back to SETS) callmaintaining database integrity 108TOKEN 111

ROLS (Rollback to SETS or SETU) commandbackout point, intermediate 335

ROLS callcomparison to ROLL and ROLB call 250use in conversations 238with LU 6.2 253

Index 435

Page 460: IMS Application Programming.pdf

ROLS call (continued)with TOKEN 253without TOKEN 253

RRS/MVS (Resource Recovery Services/Multiple VirtualStorage) 173

RRS/MVS (Resource Recovery Services) 102, 103RSA (record search argument)

description 134GSAM, reference 72overview 133

rulescoding an SSA 67

SSAA resource recovery interface calls 102SAMETRM=YES 242sample application, subset pointers 340sample programs

call-level assembler language, CICS online 18call-level COBOL, CICS online 25call-level PL/I, CICS online 36

sample programs, command levelassembler language 304C 315COBOL 308PL/I 311

samplesmessage processing application 370

SCHD PSB command 307, 314scheduling HALDBs

application programs, against 79SCS1 devices

meaning of designation 291SCS2 devices

meaning of designation 291secondary indexes

multiple qualification statements 118secondary indexing

DB PCB contents 120effect on programming 117information returned by DL/I 120SSAs 117status codes 120

secondary logical unitSee SLU

secondary processing sequence 118security checks in program-to-program switching 231segment

concatenated key 327level number field 326name field, DIB (DL/I interface block) 326sequential dependent

free space, identifying 349in DEDBs 337locating a specific dependent 348locating the last inserted dependent 348

segment level number field 57segment name

DB PCB, field 58SSA, qualification statement 5

segment search argument (SSA)coding rules 67

segment search arguments (SSAs) 4segment, information needed 12Segments

Message Input Format 214

selective partition processingHALDB 125

sending messagesdefining alternate PCBs for 228overview 213to other application programs 231to other IMS TM systems 233, 235to several alternate destinations 229using alternate PCBs 229using ISRT 228using the PURG call 229

sensitive segments in DB PCB 58sequence field

virtual logical child, in 6sequential dependent segments

free space, identifying 349how stored 147in DEDBs 337locating a specific dependent 348locating the last inserted dependent 348POS (Position) command 347

sequential dependents 147overview 147

service utilitySee MFS service utility, INDEX function

SET optionexamples 344resetting a subset pointer 344

SETCOND optionexamples 345setting a subset pointer conditionally 345

setModifiableAlternatePCB(String) method 394SETO call

usage 269SETS

backing out to an intermediate backout point 112SETS (Set a Backout Point) call

description 113SETS call

description 255setting a subset pointer

conditionally 345to zero 343

SETUbacking out to an intermediate backout point 112

SETU (Set a Backout Point Unconditional) calldescription 113

SETU, call function 113SETZERO option

examples 343setting a subset pointer to zero 343

SHSAM database 327signon security, RACF 55, 201single positioning 93skeleton programs 265

assembler language 15, 259C language 20, 259COBOL 22, 261Pascal 31, 263PL/I 32, 265

SLU 290type 1, defining to operate with MFS 290type 2, defining to operate with MFS 290type 4, defining to operate with MFS 290type 6.1, defining to operate with MFS 290type P, defining to operate with MFS 290

SPA 374

436 Application Programming Guide

Page 461: IMS Application Programming.pdf

SPA (continued)message, defining 374

SPA (scratchpad area) 240, 241and program-to-program switches 243contents 240format 240inserting 241restrictions on using 241saving information 241

SPA (scratchpad Area) 374conversational transactions for the Java class libraries for

IMS 376specifying

command codes for DEDBs 157DB PCB mask 56GSAM data set attributes 142processing options for DEDBs 162

Spool APICHNG call, keywords 269error codes

description 269diagnosis, examples 271

parsing errorsdiagnosis, examples 271error codes 269status codes 269

print data set characteristics 269SETO call, keywords 269status codes 269

SQLException 410SQLstate 410SSA (segment search argument)

codingformats 68restrictions 68rules 66

coding rules 67command codes 10qualification statement 67reference 66relational operators 5restrictions 66segment name field 67structure with command code 11usage

command codes 11guidelines 7multiple qualification statements 8

virtual logical child, in 6SSAs (segment search argument)

overview 4segment name field 5

SSAs (segment search arguments) 4definition 4qualified 5unqualified 5usage

secondary indexing 117staging library

See IMS.FORMATstandard application programs and MSC 248standard header file, C code 320status codes

AJ 347AM 347BA 325BC 325

status codes (continued)checking in a command-level program 324FH 325field in DB PCB 57, 133field in DIB 324FSA 149FW 325GA 325GB 325GD 325GE 315, 320, 325GG 325GK 325GSAM 137H processing option 162II 325LB 325logical relationships 123mapping 409NI 325P processing option 162, 349subset pointers 158, 347TG 325

status codes, field in I/O PCB 54, 199storage overlap 327stored procedures

See DB2 for z/OS stored proceduresstructure

major 328minor 328

subset pointer command codesrestrictions 12

subset pointersDBD, defining 340DEDB, managed by command codes 12defining, DBD 157defining, PCB 157description 154, 337GETFIRST option 341MOVENEXT option 343moving forward 343preparation for using 339preparing to use 156PSB, defining 340resetting 344sample application 158, 340SET option 344SETCOND option 345SETZERO option 343status codes 158, 347using 154

summary of command codes 10Symbolic Checkpoint (SYMCHKP) command

restart 334XRST 334

SYMCHKP (Symbolic Checkpoint) commanddescription 334restart 334XRST 334

sync pointapplication program 101CPI Communications driven programs 102data propagation 106log records 105relationship to commit point and check point 101

SYNC_LEVEL 102

Index 437

Page 462: IMS Application Programming.pdf

synchronization pointSee backout point

syntax diagramassembler language, DL/I call format 40C language, DL/I call format 42COBOL, DL/I call format 45how to read xiiiPascal, DL/I call format 48PL/I, DL/I call format 51

system service callsAPSB (allocate program specification block) 175DPSB (deallocate program specification block) 176ROLB call 238, 252ROLL call 238, 251ROLS call 238

Ttermination, abnormal 326TG status code 325timeout

activating 233tracing

methods of the Java class libraries for IMS 412Trace statements, adding 412XMLTrace 410

Transaction Manager 331Transaction Server, CICS 323transaction-oriented BMPs

ROLB 110transactions

conversational 374translating, EXEC DLI program 321translator

COBOL II 321options required for EXEC DLI 321version, DIB (DL/I interface block) 324z/OS & VM 321

two-phase commitoverview 103single-phase 105UOR 104

UUIB (user interface block)

defining, in program 63field names 65PCB address list, accessing 63return codes, accessing 63

UIBDLTRintroduction 64

UIBFCTRintroduction 64

UIBPCBALintroduction 64

undefined-length records 133unit of recovery (UOR)

definition 104unit of work (UOW)

crossing a boundary when processing DEDBs 349unqualified calls

definition 5overview 4

unqualified SSAstructure with command code 11

unqualified SSA (continued)usage with command codes 11

unqualified SSAssegment name field 5

UOR (unit of recovery)definition 104in-doubt

definition 104in-flight

definition 104UOW (unit of work)

crossing a boundary when processing DEDBs 349UOW boundary, processing DEDB 162updating

segments in an MSDB, DEDB or VSO DEDB 147uppercase, using Basic Edit 219user interface block

See UIB (user interface block)userid indicator, field in I/O PCB 56, 202userid, field in I/O PCB 55, 201

Vvariable names, mandatory 324variable-length records 133virtual logical child 6virtual storage option data entry database (VSO DEDB)

See VSO DEDB (virtual storage option data entry database),processing

VS COBOL II 311VS COBOL II and Language Environment 78VSO DEDB (virtual storage option data entry database),

processing 147VTAM I/O facility

effects on VTAM terminals 233VTAM terminal

activating a timeout 233

WWebSphere Application Server (non-z/OS)

deployment descriptor 406EJB

server side 406, 407WebSphere Application Server for z/OS

applications 401deployment descriptor 406overview 401restrictions

container-managed signon 405java.sql.Connection object 406shared connections 406

XXMLTrace

application 412enabling 411

XMLTrace class 410XMLTrace.enable 411XMLTrace.libTraceLevel 412XMLTrace.methods of the Java class libraries for IMS 412XRST (Extended Restart) call

with GSAM 137

438 Application Programming Guide

Page 463: IMS Application Programming.pdf

Zz/OS & VM 321z/OS & VM translator 321Z1 field 215Z2 field 215ZZ field

in input message 214in output message 215

Index 439

Page 464: IMS Application Programming.pdf

440 Application Programming Guide

Page 465: IMS Application Programming.pdf
Page 466: IMS Application Programming.pdf

����

Program Number: 5635-A01

Printed in USA

SC18-9698-02

Page 467: IMS Application Programming.pdf

Spineinformation:

IMS

Vers

ion

10Ap

plic

atio

nPr

ogra

mm

ing

Guid

e��