ims version 13 - ibm · contents about this information .....xi prerequisite knowledge .....xi ims...

831
IMS Version 13 Application Programming SC19-3646-01

Upload: phamthien

Post on 21-Apr-2018

242 views

Category:

Documents


7 download

TRANSCRIPT

  • IMSVersion 13

    Application Programming

    SC19-3646-01

  • IMSVersion 13

    Application Programming

    SC19-3646-01

  • NoteBefore using this information and the product that it supports, be sure to read the general information under Notices onpage 785.

    This edition applies to IMS Version 13 (program number 5635-A04), IMS Database Value Unit Edition, V13.1(program number 5655-DSM), IMS Transaction Manager Value Unit Edition, V13.1 (program number 5655-TM2),and to all subsequent releases and modifications until otherwise indicated in new editions.

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

  • Contents

    About this information . . . . . . . . xiPrerequisite knowledge . . . . . . . . . . xiIMS function names used in this information . . . xiHow new and changed information is identified . . xiiHow to read syntax diagrams . . . . . . . . xiiAccessibility features for IMS Version 13 . . . . xivHow to send your comments . . . . . . . . xiv

    Part 1. Application programmingdesign . . . . . . . . . . . . . . . 1

    Chapter 1. Designing an application:Introductory concepts. . . . . . . . . 3Storing and processing information in a database . . 3

    Database hierarchy examples . . . . . . . . 5Your program's view of the data . . . . . . 10Processing a database record . . . . . . . 12

    Tasks for developing an application . . . . . . 13

    Chapter 2. Designing an application:Data and local views. . . . . . . . . 15An overview of application design . . . . . . 15Identifying application data . . . . . . . . . 17

    Listing data elements . . . . . . . . . . 17Naming data elements. . . . . . . . . . 19Documenting application data . . . . . . . 20

    Designing a local view . . . . . . . . . . 22Analyzing data relationships . . . . . . . 22Local view examples . . . . . . . . . . 29

    Chapter 3. Analyzing IMS applicationprocessing requirements . . . . . . . 35Defining IMS application requirements . . . . . 35Accessing databases with your IMS applicationprogram . . . . . . . . . . . . . . . 36Accessing data: the types of programs you can writefor your IMS application . . . . . . . . . . 38

    DB batch processing . . . . . . . . . . 39TM batch processing . . . . . . . . . . 40Processing messages: Message ProcessingPrograms . . . . . . . . . . . . . . 40Processing messages: IMS Fast Path Programs . . 41Batch message processing: BMPs . . . . . . 42Java message processing: JMPs . . . . . . . 45Java batch processing: JBPs . . . . . . . . 45

    IMS programming integrity and recoveryconsiderations . . . . . . . . . . . . . 46

    How IMS protects data integrity: commit points 46Planning for program recovery: checkpoint andrestart . . . . . . . . . . . . . . . 49Data availability considerations. . . . . . . 53Use of STAE or ESTAE and SPIE in IMSprograms . . . . . . . . . . . . . . 55

    Dynamic allocation for IMS databases . . . . . 56

    Chapter 4. Analyzing CICS applicationprocessing requirements . . . . . . . 57Defining CICS application requirements . . . . . 57Accessing databases with your CICS applicationprogram . . . . . . . . . . . . . . . 58Writing a CICS program to access IMS databases . . 60

    Writing a CICS online program . . . . . . . 60Using data sharing for your CICS program . . . . 61Scheduling and terminating a PSB (CICS onlineprograms only) . . . . . . . . . . . . . 62Linking and passing control to other programs(CICS online programs only) . . . . . . . . 62How CICS distributed transactions access IMS . . 63Maximizing the performance of your CICS system 63Programming integrity and database recoveryconsiderations for your CICS program . . . . . 64

    How IMS protects data integrity for CICS onlineprograms . . . . . . . . . . . . . . 64Recovering databases accessed by batch and BMPprograms . . . . . . . . . . . . . . 64

    Data availability considerations for your CICSprogram . . . . . . . . . . . . . . . 69

    Unavailability of a database . . . . . . . . 69Unavailability of some data in a database . . . 70The SETS or SETU and ROLS functions . . . . 70

    Use of STAE or ESTAE and SPIE in IMS batchprograms . . . . . . . . . . . . . . . 71Dynamic allocation for IMS databases . . . . . 71

    Chapter 5. Gathering requirements fordatabase options . . . . . . . . . . 73Analyzing data access . . . . . . . . . . . 73

    Direct access . . . . . . . . . . . . . 74Sequential access . . . . . . . . . . . 78Accessing z/OS files through IMS: GSAM . . . 80Accessing IMS data through z/OS: SHSAM andSHISAM . . . . . . . . . . . . . . 80

    Understanding how data structure conflicts areresolved . . . . . . . . . . . . . . . 81

    Using different fields: field-level sensitivity . . . 81Resolving processing conflicts in a hierarchy:secondary indexing . . . . . . . . . . . 82Creating a new hierarchy: logical relationships . 86

    Providing data security . . . . . . . . . . 91Keeping a program from accessing the data: datasensitivity . . . . . . . . . . . . . . 91Preventing a program from updating data:processing options . . . . . . . . . . . 93

    Read without integrity. . . . . . . . . . . 95

    Copyright IBM Corp. 1974, 2014 iii

  • Chapter 6. Gathering requirements formessage processing options . . . . . 99Identifying online security requirements . . . . . 99Analyzing screen and message formats . . . . . 101

    An overview of MFS . . . . . . . . . . 102An overview of basic edit . . . . . . . . 102Editing considerations in your application. . . 102

    Gathering requirements for conversationalprocessing . . . . . . . . . . . . . . 103

    What happens in a conversation . . . . . . 104Designing a conversation . . . . . . . . 104Important points about the scratchpad area(SPA) . . . . . . . . . . . . . . . 105Recovery considerations in conversations . . . 105

    Identifying output message destinations . . . . 106The originating terminal. . . . . . . . . 107To other programs and terminals . . . . . . 107

    Chapter 7. Designing an applicationfor APPC . . . . . . . . . . . . . 111Overview of APPC and LU 6.2 . . . . . . . 111Application program types . . . . . . . . . 111Application objectives . . . . . . . . . . 113Conversation type . . . . . . . . . . . . 114Conversation state . . . . . . . . . . . . 115Synchronization level . . . . . . . . . . . 115Introduction to resource recovery . . . . . . . 116Summary of z/OS Resource Recovery Servicessupport . . . . . . . . . . . . . . . 119Distributed sync point . . . . . . . . . . 120Application programming interface for LU type 6.2 121LU 6.2 partner program design . . . . . . . 122

    LU 6.2 flow diagrams . . . . . . . . . 122Integrity tables . . . . . . . . . . . . 142DFSAPPC message switch . . . . . . . . 144

    Chapter 8. Testing an IMS applicationprogram . . . . . . . . . . . . . 147Recommendations for testing an IMS program . . 147Testing DL/I call sequences (DFSDDLT0) beforetesting your IMS program . . . . . . . . . 147Using BTS to test your IMS program . . . . . 148Tracing DL/I calls with image capture for yourIMS program . . . . . . . . . . . . . 148

    Using image capture with DFSDDLT0 . . . . 149Restrictions on using image capture output . . 149Running image capture online. . . . . . . 149Running image capture as a batch job . . . . 150Retrieving image capture data from the log dataset . . . . . . . . . . . . . . . . 150

    Requests for monitoring and debugging your IMSprogram . . . . . . . . . . . . . . . 151

    Retrieving database statistics: the STAT call . . 151Writing Information to the system log: the LOGrequest . . . . . . . . . . . . . . 165

    What to do when your IMS program terminatesabnormally . . . . . . . . . . . . . . 165

    Chapter 9. Testing a CICS applicationprogram . . . . . . . . . . . . . 169Recommendations for testing a CICS program . . 169Testing your CICS program. . . . . . . . . 169

    Tracing DL/I calls with image capture . . . . 170Requests for monitoring and debugging your CICSprogram . . . . . . . . . . . . . . . 174What to do when your CICS program terminatesabnormally . . . . . . . . . . . . . . 174

    Chapter 10. Documenting yourapplication program . . . . . . . . 177Documentation for other programmers . . . . . 177Documentation for end users . . . . . . . . 177

    Part 2. Application programmingfor IMS DB . . . . . . . . . . . . 179

    Chapter 11. Writing your applicationprograms for IMS DB . . . . . . . . 181Programming guidelines . . . . . . . . . 181Segment search arguments (SSAs) . . . . . . 182

    SSA guidelines . . . . . . . . . . . . 185Multiple qualification statements . . . . . . 186SSAs and command codes . . . . . . . . 189

    Considerations for coding DL/I calls and dataareas . . . . . . . . . . . . . . . . 191Preparing to run your CICS DL/I call program . . 192Examples of how to code DL/I calls and data areas 192

    Coding a batch program in assembler language 192Coding a CICS online program in assemblerlanguage . . . . . . . . . . . . . . 194Coding a batch program in C language. . . . 196Coding a batch program in COBOL . . . . . 199Coding a CICS online program in COBOL. . . 202Coding a program in Java . . . . . . . . 206Coding a batch program in Pascal . . . . . 206Coding a batch program in PL/I . . . . . . 208Coding a CICS online program in PL/I. . . . 210

    Chapter 12. Defining applicationprogram elements for IMS DB . . . . 213Formatting DL/I calls for language interfaces . . 213Assembler language application programming . . 213C language application programming . . . . . 215COBOL application programming . . . . . . 218Java application programming for IMS . . . . . 221Pascal application programming . . . . . . . 221Application programming for PL/I . . . . . . 224Specifying the I/O PCB mask . . . . . . . . 226Specifying the DB PCB mask . . . . . . . . 230Specifying the AIB mask . . . . . . . . . 232Specifying the AIB mask for ODBA applications 234Specifying the UIB (CICS online programs only) 237Specifying the I/O areas. . . . . . . . . . 240Formatting segment search arguments (SSAs) . . 240

    SSA coding rules . . . . . . . . . . . 240SSA coding formats . . . . . . . . . . 242

    iv Application Programming

  • Data areas in GSAM databases . . . . . . . 246AIBTDLI interface . . . . . . . . . . . . 246Language specific entry points . . . . . . . 247Program communication block (PCB) lists . . . . 250The AERTDLI interface . . . . . . . . . . 251Language environments . . . . . . . . . . 252Special DL/I situations for IMS DB programming 253Application programming with the IMS catalog 254

    Chapter 13. Database versioning andapplication programming . . . . . . 257

    Chapter 14. Establishing a DL/Iinterface from COBOL or PL/I . . . . 259

    Chapter 15. Current position in thedatabase after each call . . . . . . . 261Current position after successful calls . . . . . 261

    Position after retrieval calls . . . . . . . . 263Position after DLET . . . . . . . . . . 263Position after REPL . . . . . . . . . . 265Position after ISRT. . . . . . . . . . . 265

    Current position after unsuccessful calls . . . . 267Multiple processing . . . . . . . . . . . 271

    Advantages of using multiple positioning . . . 275Multiple DB PCBs . . . . . . . . . . . 278

    Chapter 16. Using IMS applicationprogram sync points . . . . . . . . 279Commit process . . . . . . . . . . . . 279Two-phase commit in the synchronization process 280

    Unit of recovery . . . . . . . . . . . 282DBCTL single-phase commit . . . . . . . 283

    Sync-point log records . . . . . . . . . . 283Sync points with a data-propagation manager . . 284

    Chapter 17. Recovering databasesand maintaining database integrity . . 287Issuing checkpoints . . . . . . . . . . . 287Restarting your program from the latest checkpoint 288Maintaining database integrity (IMS batch, BMP,and IMS online regions) . . . . . . . . . . 288

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

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

    Chapter 18. Secondary indexing andlogical relationships . . . . . . . . 297How secondary indexing affects your program . . 297

    SSAs with secondary indexes . . . . . . . 297Multiple qualification statements withsecondary indexes . . . . . . . . . . . 298DL/I returns with secondary indexes . . . . 300Status codes for secondary indexes . . . . . 301

    Processing segments in logical relationships . . . 301

    How logical relationships affect yourprogramming . . . . . . . . . . . . 303Status codes for logical relationships . . . . 304

    Chapter 19. HALDB selective partitionprocessing . . . . . . . . . . . . 305

    Chapter 20. Processing GSAMdatabases . . . . . . . . . . . . . 309Accessing GSAM databases. . . . . . . . . 309

    PCB masks for GSAM databases . . . . . . 309Retrieving and inserting GSAM records . . . 312Explicit open and close calls to GSAM . . . . 313

    GSAM record formats . . . . . . . . . . 314GSAM I/O areas . . . . . . . . . . . . 314GSAM status codes . . . . . . . . . . . 315Symbolic CHKP and XRST with GSAM . . . . 316GSAM coding considerations . . . . . . . . 316Origin of GSAM data set characteristics . . . . 317

    DD statement DISP parameter for GSAM datasets. . . . . . . . . . . . . . . . 318Extended checkpoint restart for GSAM data sets 319Concatenated data sets used by GSAM . . . . 320Specifying GSAM data set attributes. . . . . 320DLI, DBB, and BMP region types and GSAM 321

    Chapter 21. Processing Fast Pathdatabases . . . . . . . . . . . . . 323Fast Path database calls . . . . . . . . . . 324Main storage databases (MSDBs) . . . . . . . 325

    Restrictions on using calls for MSDBs . . . . 325Data entry databases (DEDBs) . . . . . . . . 326Updating segments: REPL, DLET, ISRT, and FLD 326

    Checking the contents of a field: FLD/VERIFY 327Changing the contents of a field:FLD/CHANGE. . . . . . . . . . . . 329Example of using FLD/VERIFY andFLD/CHANGE. . . . . . . . . . . . 330Commit-point processing in MSDBs and DEDBs 331

    Processing DEDBs (IMS and CICS with DBCTL) 332Processing Fast Path DEDBs with subset pointercommand codes . . . . . . . . . . . 332Processing DEDBs with a secondary index . . 337Retrieving location with the POS call (for DEDBonly) . . . . . . . . . . . . . . . 347Commit-point processing in a DEDB . . . . 350P processing option . . . . . . . . . . 350H processing option . . . . . . . . . . 350

    Calls with dependent segments for DEDBs . . . 351DEDB DL/I calls to extract DEDB information . . 352

    AL_LEN Call . . . . . . . . . . . . 356DI_LEN Call . . . . . . . . . . . . 357DS_LEN Call . . . . . . . . . . . . 357AREALIST Call. . . . . . . . . . . . 357DEDBINFO Call . . . . . . . . . . . 358DEDSTR Call . . . . . . . . . . . . 359

    Fast Path coding considerations . . . . . . . 359

    Contents v

    |||

  • Chapter 22. Writing ODBA applicationprograms . . . . . . . . . . . . . 361General application program flow of ODBAapplication programs . . . . . . . . . . . 361Server program structure . . . . . . . . . 364

    DB2 for z/OS stored procedures use of ODBA 365Testing an ODBA application program . . . . . 366

    Tracing DL/I calls with image capture to testyour ODBA program . . . . . . . . . . 367Using image capture with DFSDDLT0 to testyour ODBA program . . . . . . . . . . 368Running image capture online. . . . . . . 368Retrieving image capture data from the log dataset . . . . . . . . . . . . . . . . 369Requests for monitoring and debugging yourODBA program. . . . . . . . . . . . 369What to do when your ODBA programterminates abnormally . . . . . . . . . 370

    Chapter 23. Programming with theIMS support for DRDA . . . . . . . 373DDM commands for data operations with the IMSsupport for DRDA . . . . . . . . . . . 374

    Part 3. Application programmingfor IMS TM . . . . . . . . . . . . 377

    Chapter 24. Defining applicationprogram elements for IMS TM . . . . 379Formatting DL/I calls for language interfaces . . 379Application programming for assembler language 379Application programming for C language . . . . 382Application programming for COBOL . . . . . 384Java application programming for IMS . . . . . 387Application programming for Pascal . . . . . 387Application programming for PL/I . . . . . . 390Relationship of calls to PCB types . . . . . . 392Specifying the I/O PCB mask . . . . . . . . 393Specifying the alternate PCB mask . . . . . . 397Specifying the AIB mask . . . . . . . . . 398Specifying the I/O areas. . . . . . . . . . 400AIBTDLI interface . . . . . . . . . . . . 400Specifying language-specific entry points . . . . 401Program communication block (PCB) lists . . . . 403Language environments . . . . . . . . . . 404Special DL/I situations for IMS TM programming 405

    Chapter 25. Message processing withIMS TM . . . . . . . . . . . . . . 409How your program processes messages . . . . 409

    Message types . . . . . . . . . . . . 409When a message is processed . . . . . . . 412Results of a message: I/O PCB . . . . . . 414

    How IMS TM edits messages . . . . . . . . 414Printing output messages . . . . . . . . 415Using Basic Edit . . . . . . . . . . . 415Using Intersystem Communication Edit . . . 416Using Message Format Service . . . . . . 416

    Using LU 6.2 User Edit exit routine (optional) 423Message processing considerations for DB2 . . . 423Sending messages to other terminals and programs 424

    Sending messages to other terminals . . . . 425Sending messages to other IMS applicationprograms . . . . . . . . . . . . . . 427How the VTAM I/O facility affects your VTAMterminal . . . . . . . . . . . . . . 429

    Communicating with other IMS TM systems usingMultiple Systems Coupling . . . . . . . . . 429

    Implications of MSC for program coding . . . 430Receiving messages from other IMS TM systems 430Sending messages to alternate destinations inother IMS TM systems . . . . . . . . . 432

    IMS conversational processing. . . . . . . . 433A conversational example . . . . . . . . 433Conversational structure. . . . . . . . . 434Replying to the terminal. . . . . . . . . 438Conversational processing using ROLB, ROLL,and ROLS . . . . . . . . . . . . . 438Passing the conversation to anotherconversational program . . . . . . . . . 439Message switching in APPC conversations . . 442

    Processing conversations with APPC . . . . . 443Ending the APPC conversation . . . . . . 444Coding a conversational program . . . . . 444Standard IMS application programs . . . . . 444Modified IMS application programs . . . . . 445CPI-C driven application programs . . . . . 446

    Processing conversations with OTMA . . . . . 447Backing out to a prior commit point: ROLL, ROLB,and ROLS calls . . . . . . . . . . . . . 447

    Comparison of ROLB, ROLL, and ROLS . . . 447ROLL . . . . . . . . . . . . . . . 448ROLB . . . . . . . . . . . . . . . 449ROLS . . . . . . . . . . . . . . . 450

    Backing out to an intermediate backout point:SETS/SETU and ROLS . . . . . . . . . . 451Writing message-driven programs . . . . . . 454Coding DC calls and data areas . . . . . . . 454

    Before coding your program . . . . . . . 455MPP code examples . . . . . . . . . . 455Message processing considerations for DB2 . . 462

    Chapter 26. IMS Spool API . . . . . . 463Managing the IMS Spool API overall design . . . 463

    IMS Spool API design . . . . . . . . . 463Sending data to the JES spool data sets . . . . 464IMS Spool API performance considerations . . 464IMS Spool API application codingconsiderations . . . . . . . . . . . . 465

    Understanding parsing errors . . . . . . . . 468Diagnosis examples . . . . . . . . . . 469

    Understanding allocation errors . . . . . . . 472Understanding dynamic output for print data sets 472Sample programs using the Spool API . . . . . 473

    Chapter 27. IMS Message FormatService . . . . . . . . . . . . . . 477Advantages of using MFS . . . . . . . . . 477

    vi Application Programming

  • MFS control blocks . . . . . . . . . . . 478MFS examples . . . . . . . . . . . . 479Relationship between MFS control blocks andscreen format . . . . . . . . . . . . 483

    Overview of MFS components. . . . . . . . 484Devices and logical units that operate with MFS 486Using distributed presentation management (DPM) 488

    Chapter 28. Callout requests forservices or data . . . . . . . . . . 489Callout request approaches . . . . . . . . . 490Resume tpipe protocol . . . . . . . . . . 492Implementing the synchronous callout function 493Implementing the asynchronous callout function 496

    Part 4. Application programmingfor EXEC DLI . . . . . . . . . . . 499

    Chapter 29. Writing your applicationprograms for EXEC DLI . . . . . . . 501Programming guidelines . . . . . . . . . 501

    Coding a program in assembler language . . . 502Coding a program in COBOL . . . . . . . 506Coding a program in PL/I . . . . . . . . 509Coding a program in C . . . . . . . . . 513

    Preparing your EXEC DLI program for execution 519Translator, compiler, and binder optionsrequired for EXEC DLI . . . . . . . . . 519

    Chapter 30. Defining applicationprogram elements . . . . . . . . . 521Specifying an application interface block (AIB) . . 521Specifying the DL/I interface block (DIB) . . . . 521Defining a key feedback area . . . . . . . . 525Defining I/O areas . . . . . . . . . . . 525

    Chapter 31. EXEC DLI commands foran application program . . . . . . . 527PCBs and PSB . . . . . . . . . . . . . 527

    Chapter 32. Recovering databasesand maintaining database integrity . . 531Issuing checkpoints in a batch or BMP program 531Restarting your program and checking for position 532Backing out database updates dynamically: theROLL and ROLB commands . . . . . . . . 532Using intermediate backout points: the SETS andROLS commands . . . . . . . . . . . . 532

    Chapter 33. Processing Fast Pathdatabases . . . . . . . . . . . . . 535Processing Fast Path DEDBs with subset pointeroptions . . . . . . . . . . . . . . . 535

    Preparing to use subset pointers . . . . . . 537Designating subset pointers . . . . . . . 538Subset pointer options . . . . . . . . . 538Subset pointer status codes . . . . . . . . 545

    The POS command . . . . . . . . . . . 546Locating a specific sequential dependentsegment . . . . . . . . . . . . . . 546Locating the last inserted sequential dependentsegment . . . . . . . . . . . . . . 547Identifying free space with the POS command 547The P processing option . . . . . . . . . 548

    Chapter 34. Comparingcommand-level and call-levelprograms . . . . . . . . . . . . . 549DL/I calls for IMS and CICS . . . . . . . . 549Comparing EXEC DLI commands and DL/I calls 549Comparing command codes and options . . . . 551

    Chapter 35. Data availabilityenhancements . . . . . . . . . . . 553

    Part 5. Application programmingfor SQL . . . . . . . . . . . . . 555

    Chapter 36. SQL considerations andrestrictions for COBOL . . . . . . . 557

    Chapter 37. Writing applicationprograms for SQL . . . . . . . . . 559Coding SQL statements in application programs:General information . . . . . . . . . . . 559

    Defining the items that your program can use tocheck whether an SQL statement executedsuccessfully . . . . . . . . . . . . . 559Defining SQL descriptor areas . . . . . . . 560Declaring host variables and indicator variables 560Using SQL statements in your application . . . 561Checking the execution of SQL statements. . . 572

    Coding SQL statements in COBOL applicationprograms . . . . . . . . . . . . . . . 574

    Defining the SQL communications area inCOBOL . . . . . . . . . . . . . . 575Defining SQL descriptor areas in COBOL . . . 575Declaring host variables and indicator variablesin COBOL . . . . . . . . . . . . . 575Equivalent SQL and COBOL data types . . . 582SQL statements in COBOL programs . . . . 583

    Adding and modifying data . . . . . . . . 586Inserting rows . . . . . . . . . . . . 586Updating segment data . . . . . . . . . 587Deleting data from segments . . . . . . . 589

    Accessing data . . . . . . . . . . . . . 589Retrieving data by using the SELECT statement 589Retrieving a set of rows by using a cursor . . . 595

    Commit or roll back data . . . . . . . . . 597Preparing an application to run on IMS . . . . 598

    Processing SQL statements . . . . . . . . 598

    Part 6. Java applicationdevelopment for IMS . . . . . . . 601

    Contents vii

    |

    ||

    |||

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

  • Chapter 38. IMS solutions for Javadevelopment overview . . . . . . . 603

    Chapter 39. Comparison ofhierarchical and relational databases . 607

    Chapter 40. Programming with theIMS Universal drivers . . . . . . . . 613IMS Universal drivers overview . . . . . . . 613

    Distributed and local connectivity with the IMSUniversal drivers . . . . . . . . . . . 614Comparison of IMS Universal driversprogramming approaches for accessing IMS . . 617Support for variable-length database segmentswith the IMS Universal drivers . . . . . . 619Generating the runtime Java metadata class . . 620Hospital database example . . . . . . . . 621

    Programming using the IMS Universal Databaseresource adapter . . . . . . . . . . . . 624

    Overview of the IMS Universal Databaseresource adapter . . . . . . . . . . . 625Transaction types and programming interfacessupported by the IMS Universal Databaseresource adapter . . . . . . . . . . . 625Connecting to IMS with the IMS UniversalDatabase resource adapter . . . . . . . . 626Sample EJB application using the IMS UniversalDatabase resource adapter CCI programminginterface . . . . . . . . . . . . . . 636Accessing IMS data with the DLIInteractionSpecclass . . . . . . . . . . . . . . . 637Accessing IMS data with theSQLInteractionSpec class . . . . . . . . 642Accessing IMS data with the IMS UniversalJCA/JDBC driver . . . . . . . . . . . 645

    Programming with the IMS Universal JDBC driver 647Supported drivers for JDBC . . . . . . . 648Connecting to IMS using the IMS UniversalJDBC driver . . . . . . . . . . . . . 648Sample application for the IMS Universal JDBCdriver . . . . . . . . . . . . . . . 659Writing SQL queries to access an IMS databasewith the IMS Universal JDBC driver. . . . . 660Writing DL/I calls to access an IMS databasewith the IMS Universal JDBC driver. . . . . 674IMS Universal JDBC driver support for XML 677Data transformation support for JDBC . . . . 681

    Programming with the IMS Universal DL/I driver 687Basic steps in writing a IMS Universal DL/Idriver application . . . . . . . . . . . 687Java packages for IMS Universal DL/I driversupport . . . . . . . . . . . . . . 688Connecting to an IMS database by using theIMS Universal DL/I driver . . . . . . . . 688IMS Universal DL/I driver interfaces forexecuting DL/I operations . . . . . . . . 691Inspecting the PCB status code and relatedinformation using the com.ibm.ims.dli.AIBinterface . . . . . . . . . . . . . . 707Committing or rolling back DL/I transactions 708

    Configuring the IMS Universal drivers for SSLsupport . . . . . . . . . . . . . . . 710

    Configuring the IMS Universal Databaseresource adapter for SSL support in acontainer-managed environment . . . . . . 711Configuring IMS Universal drivers for SSLsupport in a stand-alone environment . . . . 711

    Tracing IMS Universal drivers applications . . . 712

    Chapter 41. Programming Javadependent regions . . . . . . . . . 715Overview of the IMS Java dependent regions. . . 715Programming with the IMS Java dependent regionresource adapter . . . . . . . . . . . . 716

    Developing JMP applications with the IMS Javadependent region resource adapter . . . . . 717Developing JBP applications with the IMS Javadependent region resource adapter . . . . . 726Program switching in JMP and JBP applications 734

    IBM Enterprise COBOL for z/OS interoperabilitywith JMP and JBP applications . . . . . . . 742

    IBM Enterprise COBOL for z/OS backendapplications in a JMP or JBP region . . . . . 743IBM Enterprise COBOL for z/OS frontendapplications in a JMP or JBP region . . . . . 743

    Accessing DB2 for z/OS databases from JMP orJBP applications . . . . . . . . . . . . 744Issuing synchronous callout requests from a Javadependent region . . . . . . . . . . . . 745

    Chapter 42. Programming with theclassic Java APIs for IMS . . . . . . 747Programming enterprise Java applications withclassic Java APIs for IMS resource adapters . . . 747

    Accessing IMS data from WebSphereApplication Server for z/OS with the classicJava APIs for IMS . . . . . . . . . . . 747Bean-managed EJB programming model . . . 748Container-managed EJB programming model 750Servlet programming model . . . . . . . 751Requirements for WebSphere Application Serverfor z/OS with the classic Java APIs for IMS . . 751Deployment descriptor requirements for theclassic Java APIs for IMS . . . . . . . . 752

    Programming Java applications in DB2 for z/OSstored procedures with the classic Java APIs forIMS . . . . . . . . . . . . . . . . 753

    Accessing IMS data from DB2 for z/OS storedprocedures using the classic Java APIs for IMS . 753DB2 for z/OS stored procedures programmingmodel with the classic Java APIs for IMS . . . 754

    Programming Java applications for CICS with theclassic Java APIs for IMS . . . . . . . . . 754

    Accessing IMS data from CICS with the classicJava APIs for IMS . . . . . . . . . . . 754CICS programming model with the classic JavaAPIs for IMS . . . . . . . . . . . . 755

    Programming with the IMS classic JDBC driver 756Data transformation support for JDBC . . . . 756Connections to IMS databases . . . . . . . 762

    viii Application Programming

    |||

  • JDBC interfaces supported by the IMS classicJDBC driver . . . . . . . . . . . . . 762SQL keywords and extensions for the IMSclassic JDBC driver . . . . . . . . . . 764Sample application that uses the IMS classicJDBC driver . . . . . . . . . . . . . 775

    Problem determination for Java applications . . . 776Exceptions thrown from IMS DL/I calls . . . 776XML tracing for the classic Java APIs for IMS 777

    Part 7. Appendixes . . . . . . . . 783

    Notices . . . . . . . . . . . . . . 785Programming interface information . . . . . . 787Trademarks . . . . . . . . . . . . . . 787Privacy policy considerations . . . . . . . . 788

    Bibliography. . . . . . . . . . . . 789

    Index . . . . . . . . . . . . . . . 791

    Contents ix

    ||

  • x Application Programming

  • About this information

    These topics provide guidance information for writing application programs thataccess IMS databases or IMS transactions. The topics describe how to gather andanalyze program requirements, and how to develop and debug IMS applicationprograms. They also describe how to use different programming languages to issueDL/I calls, and include information about the IMS solutions for SQL and Java

    development. They also describe how to use different programming languages toissue EXEC DL/I calls. Application programming interface (API) information is inIMS Version 13 Application Programming APIs.

    This information is available in IBM Knowledge Center at www.ibm.com/support/knowledgecenter.

    Prerequisite knowledgeThis information is a guide to IMS application programming for any of thefollowing environments:v IMS Database Manager (IMS DB), including IMS Database Control (DBCTL)v IMS Transaction Manager (IMS TM)v CICS EXEC DLIv WebSphere Application Server for z/OS

    v WebSphere Application Server for distributed platformsv Java dependent regions (JMP and JBP)v Any environment for stand-alone Java application development

    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 IMSVersion 13 Application Programming APIs.

    You can learn more about z/OS by visiting the z/OS basic skills education topicsin IBM Knowledge Center.

    You can gain an understanding of basic IMS concepts by reading An Introduction toIMS, an IBM Press publication. An excerpt from this publication is available in theIBM Knowledge 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 atibm.com/ims and link to the Training and Certification page.

    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 13,unless otherwise indicated.

    Copyright IBM Corp. 1974, 2014 xi

    http://www.ibm.com/support/knowledgecenter/http://www.ibm.com/support/knowledgecenter/http://www.ibm.com/support/knowledgecenter/http://www.ibm.com/support/knowledgecenter/http://www.ibm.com/software/data/ims/

  • How new and changed information is identifiedNew and changed information in most IMS library PDF publications is denoted bya character (revision marker) in the left margin. The first edition (-00) of ReleasePlanning, as well as the Program Directory and Licensed Program Specifications, do notinclude revision markers.

    Revision markers follow these general conventions:v Only technical changes are marked; style and grammatical changes are not

    marked.v If part of an element, such as a paragraph, syntax diagram, list item, task step,

    or figure is changed, the entire element is marked with revision markers, eventhough only part of the element might have changed.

    v If a topic is changed by more than 50%, the entire topic is marked with revisionmarkers (so it might seem to be a new topic, even though it is not).

    Revision markers do not necessarily indicate all the changes made to theinformation because deleted text and graphics cannot be marked with revisionmarkers.

    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

    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.

    xii Application Programming

  • 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:

    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.

    About this information xiii

  • 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 13Accessibility features help a user who has a physical disability, such as restrictedmobility or limited vision, to use information technology products successfully.

    Accessibility features

    The following list includes the major accessibility features in z/OS products,including IMS Version 13. 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.

    Keyboard navigation

    You can access IMS Version 13 ISPF panel functions by using a keyboard orkeyboard shortcut keys.

    For information about navigating the IMS Version 13 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 Volume 1. These guides describe how to navigate each interface,including the use of keyboard shortcuts or function keys (PF keys). Each guideincludes the default settings for the PF keys and explains how to modify theirfunctions.

    Related accessibility information

    Online documentation for IMS Version 13 is available in IBM Knowledge Center.

    IBM and accessibility

    See the IBM Human Ability and Accessibility Center at www.ibm.com/able for moreinformation about the commitment that IBM has to accessibility.

    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 Click the Feedback link at the bottom of any IBM Knowledge Center topic.v Send an email to [email protected]. Be sure to include the book title and the

    publication number.

    xiv Application Programming

    http://www.ibm.com/ablehttp://www.ibm.com/support/knowledgecenter/

  • Part 1. Application programming design

    To design an application program for IMS, you need to identify the applicationdata and analyze requirements for application processing. You may also need toperform other tasks, such as gathering requirements for database and messageprocessing options, and testing an application program.

    Copyright IBM Corp. 1974, 2014 1

  • 2 Application Programming

  • Chapter 1. Designing an application: Introductory concepts

    This section provides an introduction to designing application programs. Itexplains some basic concepts about processing a database, and gives an overviewof the tasks covered in this information.

    Storing and processing information in a databaseThe advantages of storing and processing data in a database are that all of the dataneeds to appear only once and that each program must process only the data thatit needs.

    One way to understand this is to compare three ways of storing data: in separatefiles, in a combined file, and in a database.

    Storing data in separate files

    If you keep separate files of data for each part of your organization, you canensure that each program uses only the data it needs, but you must store a lot ofdata in multiple places simultaneously. Problems with keeping separate files are:v Redundant data takes up space that could be put to better usev Maintaining separate files can be difficult and complex

    For example, suppose that a medical clinic keeps separate files for each of itsdepartments, such as the clinic department, the accounting department, and theophthalmology department:v The clinic department keeps data about each patient who visits the clinic, such

    as:Identification numberNameAddressIllnessesDate of each illnessDate patient came to clinic for treatmentTreatment given for each illnessDoctor that prescribed treatmentCharge for treatment

    v The accounting department also keeps information about each patient. Theinformation that the accounting department might keep for each patient is:

    Identification numberNameAddressCharge for treatmentAmount of payments

    v The information that the ophthalmology department might keep for each patientis:

    Identification number

    Copyright IBM Corp. 1974, 2014 3

  • NameAddressIllnesses relating to ophthalmologyDate of each illnessNames of members in patient's householdRelationship between patient and each household member

    If each of these departments keeps separate files, each department uses only thedata that it needs, but much of the data is redundant. For example, everydepartment in the clinic uses at least the patient's number, name, and address.Updating the data is also a problem, because if a department changes a piece ofdata, the same data must be updated in each separate file. Therefore, it is difficultto keep the data in each department's files current. Current data might exist in onefile while defunct data remains in another file.

    Storing data in a combined file

    Another way to store data is to combine all the files into one file for alldepartments to use. In the medical example, the patient record that would be usedby each department would contain these fields:

    Identification numberNameAddressIllnessesDate of each illnessDate patient came to clinic for treatmentTreatment given for each illnessDoctor that prescribed treatmentCharge for treatmentAmount of paymentsNames of members in patient's householdRelationship between patient and each household member

    Using a combined file solves the updating problem, because all the data is in oneplace, but it creates a new problem: the programs that process this data mustaccess the entire file record to get to the part that they need. For example, toprocess only the patient's number, charges, and payments, an accounting programmust access all of the other fields also. In addition, changing the format of any ofthe fields within the patient's record affects all the application programs, not justthe programs that use that field.

    Using combined files can also involve security risks, because all of the programshave access to all of the fields in a record.

    Storing data in a database

    Storing data in a database gives you the advantages of both separate files andcombined files: all the data appears only once, and each program has access to thedata that it needs. This means that:v When you update a field, you do it in one place only.

    4 Application Programming

  • v Because you store each piece of information only in one place, you cannot havean updated version of the information in one place and an out-of-date version inanother place.

    v Each program accesses only the data it needs.v You can prevent programs from accessing private or secured information.

    In addition, storing data in a database has two advantages that neither of the otherways has:v If you change the format of part of a database record, the change does not affect

    the programs that do not use the changed information.v Programs are not affected by how the data is stored.

    Because the program is independent of the physical data, a database can store allthe data only once and yet make it possible for each program to use only the datathat it needs. In a database, what the data looks like when it is stored is differentfrom what it looks like to an application program.

    Database hierarchy examplesIn an IMS DB, a record is stored and accessed in a hierarchy. A hierarchy showshow each piece of data in a record relates to other pieces of data in the record.

    IMS connects the pieces of information in a database record by defining therelationships between the pieces of information that relate to the same subject. Theresult is a database hierarchy.

    Medical hierarchy example

    The medical database shown in following figure contains information that amedical clinic keeps about its patients. The hierarchies used in the medicalhierarchy example are used with full-function databases and Fast Path data entrydatabases (DEDBs).

    Each piece of data represented in the figure above is called a segment in thehierarchy. Each segment contains one or more fields of information. The PATIENTsegment, for example, contains all the information that relates strictly to thepatient: the patient's identification number, name, and address.

    Definitions: A segment is the smallest unit of data that an application program canretrieve from the database. A field is the smallest unit of a segment.

    The PATIENT segment in the medical database is the root segment. The segmentsbelow the root segment are the dependents, or children, of the root. For example,

    Figure 1. Medical hierarchy

    Chapter 1. Designing an application: Introductory concepts 5

  • ILLNESS, BILLING, and HOUSHOLD are all children of PATIENT. ILLNESS,BILLING, and HOUSHOLD are called direct dependents of PATIENT; TREATMNTand PAYMENT are also dependents of PATIENT, but they are not directdependents, because they are at a lower level in the hierarchy.

    A database record is a single root segment (root segment occurrence) and all of itsdependents. In the medical example, a database record is all of the informationabout one patient.

    Definitions: A root segment is the highest-level segment. A dependent is a segmentbelow a root segment. A root segment occurrence is a database record and all of itsdependents.

    Each database record has only one root segment occurrence, but it might haveseveral occurrences at lower levels. For example, the database record for a patientcontains only one occurrence of the PATIENT segment type, but it might containseveral ILLNESS and TREATMNT segment occurrences for that patient.

    The tables that follow show the layouts of each segment in the hierarchy.

    The segments field names are in the first row of each table. The number beloweach field name is the length in bytes that has been defined for that field.v PATIENT Segment

    The following table shows the PATIENT segment.It has three fields: The patients number (PATNO) The patients name (NAME) The patient's address (ADDR)PATIENT has a unique key field: PATNO. PATIENT segments are stored inascending order based on the patient number. The lowest patient number in thedatabase is 00001 and the highest is 10500.

    Table 1. PATIENT segment

    Field name Field length

    PATNO 10

    NAME 5

    ADDR 30

    v ILLNESS SegmentThe following figure shows the ILLNESS segment.It has two fields: The date when the patient came to the clinic with the illness (ILLDATE) The name of the illness (ILLNAME)The key field is ILLDATE. Because it is possible for a patient to come to theclinic with more than one illness on the same date, this key field is non-unique,that is, there may be more than one ILLNESS segment with the same (an equal)key field value.Usually during installation, the database administrator (DBA) decides the orderin which to place the database segments with equal or no keys. The DBA canuse the RULES keyword of the SEGM statement of the DBD to specify the orderof the segments.

    6 Application Programming

  • For segments with equal keys or no keys, RULES determines where the segmentis inserted. Where RULES=LAST, ILLNESS segments that have equal keys arestored on a first-in-first-out basis among those with equal keys. ILLNESSsegments with unique keys are stored in ascending order on the date field,regardless of RULES. ILLDATE is specified in the format YYYYMMDD.

    Table 2. ILLNESS segment

    Field name Field length

    ILLDATE 8

    ILLNAME 10

    v TREATMNT SegmentThe following table shows the TREATMNT segment.It contains four fields: The date of the treatment (DATE) The medicine that was given to the patient (MEDICINE) The quantity of the medicine that the patient received (QUANTITY) The name of the doctor who prescribed the treatment (DOCTOR)The TREATMNT segments key field is DATE. Because a patient may receivemore than one treatment on the same date, DATE is a non-unique key field.TREATMNT, like ILLNESS, has been specified as having RULES=LAST.TREATMNT segments are also stored on a first-in-first-out basis. DATE isspecified in the same format as ILLDATEYYYYMMDD.

    Table 3. TREATMNT segment

    Field name Field length

    DATE 8

    MEDICINE 10

    QUANTITY 4

    DOCTOR 10

    v BILLING SegmentThe following table shows the BILLING segment. It has only one field: theamount of the current bill. BILLING has no key field.

    Table 4. BILLING segment

    Field name Field length

    BILLING 6

    v PAYMENT SegmentThe following table shows the PAYMENT segment. It has only one field: theamount of payments for the month. The PAYMENT segment has no key field.

    Table 5. PAYMENT segment

    Field name Field length

    PAYMENT 6

    v HOUSHOLD SegmentThe following table shows the HOUSHOLD segment.It contains two fields:

    Chapter 1. Designing an application: Introductory concepts 7

  • The names of the members of the patient's household (RELNAME) How each member of the household is related to the patient (RELATN)The HOUSHOLD segments key field is RELNAME.

    Table 6. HOUSHOLD segment

    Field name Field length

    RELNAME 10

    RELATN 8

    Bank account hierarchy example

    The bank account hierarchy is an example of an application program that is usedwith main storage databases (MSDBs). In the medical hierarchy example, thedatabase record for a particular patient comprises the PATIENT segment and all ofthe segments underneath the PATIENT segment. In an MSDB, such as the one inthe bank account example, the segment is the whole database record. The databaserecord contains only the fields that the segment contains.

    The two types of MSDBs are related and nonrelated. In related MSDBs, each segmentis owned by one logical terminal. The "owned" segment can only be updated bythe terminal that owns it. In nonrelated MSDBs, the segments are not owned bylogical terminals. The following examples of a related MSDB and a nonrelatedMSDB illustrate the differences between the two types of databases.

    Related MSDBs

    Related MSDBs can be fixed or dynamic. In a fixed related MSDB, you can storesummary data about a particular teller at a bank. For example, you can have anidentification code for the teller's terminal. Then you can keep a count of thatteller's transactions and balance for the day. This type of application requires asegment with three fields:

    TELLERIDA two-character code that identifies the teller

    TRANCNTThe number of transactions the teller has processed

    TELLBALThe balance for the teller

    The following table shows what the segment for this type of application programlooks like.

    Table 7. Teller segment in a fixed related MSDB

    TELLERID TRANCNT TELLBAL

    Some of the characteristics of fixed related MSDBs include:v You can only read and replace segments. You cannot delete or insert segments.

    In the bank teller example, the teller can change the number of transactionsprocessed, but you cannot add or delete any segments. You never need to add ordelete segments.

    v Each segment is assigned to one logical terminal. Only the owning terminal canchange a segment, but other terminals can read the segment. In the bank teller

    8 Application Programming

  • example, you do not want tellers to update the information about other tellers,but you allow the tellers to view each others information. Tellers are responsiblefor their own transactions.

    v The name of the logical terminal that owns the segment is the segment's key.Unlike non-MSDB segments, the MSDB key is not a field of the segment. It isused as a means of storing and accessing segments.

    v A logical terminal can only own one segment in any one MSDB.

    In a dynamic related MSDB, you can store data summarizing the activity of allbank tellers at a single branch. For example, this segment contains:

    BRANCHNOThe identification number for the branch

    TOTALThe bank branch's current balance

    TRANCNTThe number of transactions for the branch on that day

    DEPBALThe deposit balance, giving the total dollar amount of deposits for thebranch

    WTHBALThe withdrawal balance, giving the dollar amount of the withdrawals forthe branch

    The following table shows what the branch summary segment looks like in adynamic related MSDB.

    Table 8. Branch summary segment in a dynamic related MSDB

    BRANCHNO TOTAL TRANCNT DEPBAL WTHBAL

    How dynamic related MSDBs differ from fixed related MSDBs:v The owning logical terminal can delete and insert segments in a dynamic related

    MSDB.v The MSDB can have a pool of unassigned segments. This kind of segment is

    assigned to a logical terminal when the logical terminal inserts it, and isreturned to the pool when the logical terminal deletes it.

    Nonrelated MSDBs

    A nonrelated MSDB is used to store data that is updated by several terminalsduring the same time period. For example, you might store data about anindividuals' bank accounts in a nonrelated MSDB segment, so that the informationcan be updated by a teller at any terminal. Your program might need to access thedata in the following segment fields:

    ACCNTNOThe account number

    BRANCHThe name of the branch where the account is

    TRANCNTThe number of transactions for this account this month

    Chapter 1. Designing an application: Introductory concepts 9

  • BALANCEThe current balance

    The following table shows what the account segment in a nonrelated MSDBapplication program looks like.

    Table 9. Account segment in a nonrelated MSDB

    ACCNTNO BRANCH TRANCNT BALANCE

    The characteristics of nonrelated MSDBs include:v Segments are not owned by terminals as they are in related MSDBs. Therefore,

    IMS programs and Fast Path programs can update these segments. Updatingsegments is not restricted to the owning logical terminal.

    v Your program cannot delete or insert segments.v Segment keys can be the name of a logical terminal. A nonrelated MSDB exists

    with terminal-related keys. The segments are not owned by the logical terminals,and the logical terminal name is used to identify the segment.

    v If the key is not the name of a logical terminal, it can be any value, and it is inthe first field of the segment. Segments are loaded in key sequence.

    Your program's view of the dataIMS uses two kinds of control blocks to enable application programs to beindependent of your method of storing data in the database, the databasedescription (DBD), and the database program communication block (DB PCB).

    Database Description (DBD)

    A database description (DBD) is physical structure of the database. The DBD alsodefines the appearance and contents, or fields, that make up each of the segmenttypes in the database.

    For example, the DBD for the medical database hierarchy shown in Medicalhierarchy example describes the physical structure of the hierarchy and each ofthe six segment types in the hierarchy: PATIENT, ILLNESS, TREATMNT, BILLING,PAYMENT, and HOUSHOLD.

    Related Reading: For more information on generating DBDs, see IMS Version 13Database Utilities.

    Database Program Communication Block (DB PCB)

    A database program communication block (DB PCB) is a control block that defines anapplication program's view of the database. An application program often needs toprocess only some of the segments in a database. A PCB defines which of thesegments in the database the program is allowed to accesswhich segments theprogram is sensitive to.

    The data structures that are available to the program contain only segments thatthe program is sensitive to. The PCB also defines how the application program isallowed to process the segments in the data structure: whether the program canonly read the segments, or whether it can also update them.

    10 Application Programming

  • To obtain the highest level of data availability, your PCBs should request thefewest number of sensitive segments and the least capability needed to completethe task.

    All the DB PCBs for a single application program are contained in a programspecification block (PSB). A program might use only one DB PCB (if it processes onlyone data structure) or it might use several DB PCBs, one for each data structure.

    Related Reading: For more information on generating PSBs, see IMS Version 13Database Utilities.

    The following figure illustrates the concept of defining a view for an applicationprogram. An accounting program that calculates and prints bills for the clinic'spatients would need only the PATIENT, BILLING, and PAYMENT segments. Youcould define the data structure shown in the following figure in a DB PCB for thisprogram.

    A program that updates the database with information on patients' illnesses andtreatments, in contrast, would need to process the PATIENT, ILLNESS, andTREATMNT segments. You could define the data structure shown in the followingfigure in a DB PCB for this program.

    Figure 2. Accounting program's view of the database

    Chapter 1. Designing an application: Introductory concepts 11

  • Sometimes a program needs to process all of the segments in the database. Whenthis is true, the program's view of the database as defined in the DB PCB is thesame as the database hierarchy that is defined in the DBD.

    An application program processes only the segments in a database that it requires;therefore, if you change the format of a segment that is not processed, you do notchange the program. A program is affected only by the segments that it accesses. Inaddition to being sensitive to only certain segments in a database, a program canalso be sensitive to only certain fields within a segment. If you change a segmentor field that the program is not sensitive to, it does not affect the program. Youdefine segment and field-level sensitivity during PSBGEN.

    Definition: Field-level sensitivity is when a program is sensitive to only certainfields within a segment.

    Related Reading: For more information, see IMS Version 13 Database Administration.

    Processing a database recordTo process the information in the database, your application programcommunicates with IMS in three ways: by passing control, by communicatingprocessing requests, and by exchanging information using DL/I calls.v Passing controlIMS passes control to your application program through an

    entry statement in your program. Your program returns control to IMS when ithas finished its processing.When you are running a CICS online program, CICS passes control to yourapplication program, and your program schedules a PSB to make IMS requests.Your program returns control to CICS. If you are running a batch or BMPprogram, IMS passes control to your program with an existing PSB scheduled.

    v Communicating processing requestsYou communicate processing requests toIMS in one of two ways: In IMS, you issue DL/I calls to process the database. In CICS, you can issue either DL/I calls or EXEC DLI commands. EXEC DLI

    commands more closely resemble a higher-level language than do DL/I calls.

    PATIENT

    TREATMNT

    ILLNESS

    Figure 3. Patient illness program's view of the database

    12 Application Programming

  • v Exchanging information using DL/I callsYour program exchanges informationin two areas: A DL/I call reports the results of your request in a control block and the AIB

    communication block when using one of the AIB interfaces. For programswritten using DL/I calls, this control block is the DB PCB. For programswritten using EXEC DLI commands, this control block is the DLI interfaceblock (DIB). The contents of the DIB reflect the status of the last DL/Icommand executed in the program. Your program includes a mask of theappropriate control block and uses this mask to check the results of therequest.

    When you request a segment from the database, IMS returns the segment toyour I/O area. When you want to update a segment in the database, youplace the new value of the segment in the I/O area.

    An application program can read and update a database. When you update adatabase, you can replace, delete, or add segments. In IMS, you indicate in theDL/I call the segment you want to process, and whether you want to read orupdate it. In CICS, you can indicate what you want using either a DL/I call or anEXEC DLI command.

    Tasks for developing an applicationThe following tasks are involved in developing an IMS application, and theprograms that are part of the application.

    Designing the application

    Application program design varies from place to place, and from one applicationto another.

    Therefore, this information does not try to cover the early tasks that are part ofdesigning an application program. Instead, it covers only the tasks that you areconcerned with after the early specifications for the application have beendeveloped. The tasks for designing the application are:v Analyzing Application Data Requirements

    Two important parts of application design are defining the data that each of thebusiness processes in the application requires and designing a local view foreach of the business processes.

    v Analyzing Application Processing RequirementsWhen you understand the business processes that are part of the application,you can analyze the requirements of each business process in terms of theprocessing that is available with different types of application programs.

    v Gathering Requirements for Database OptionsYou then need to look at the database options that can most efficiently meet therequirements, and gather information about your application's data requirementsthat relates to each of the options.

    v Gathering Requirements for Message Processing OptionsIf your application communicates with terminals and other applicationprograms, look at the message processing options and the requirements theysatisfy.

    For more information about designing a CICS application, see CICS TransactionServer for z/OS CICS Application Programming Guide.

    Chapter 1. Designing an application: Introductory concepts 13

  • Developing specifications

    Developing specifications involves defining what your application will do, andhow it will be done. The task of developing specifications is not described in thisinformation because it depends entirely on the specific application and yourstandards.

    Implementing the design

    When the specifications for each of the programs in the application are developed,you can structure and code the programs according to those specifications. Thetasks of implementing the design are:v Writing the Database Processing Part of the Program

    When the program design is complete, you can structure and code your requestsand data areas based on the programming specifications that have beendeveloped.

    v Writing the Message Processing Part of the ProgramIf you are writing a program that communicates with terminals and otherprograms, you need to structure and code the message processing part of theprogram.

    v Analyzing APPC/IMS RequirementsThe LU 6.2 feature of IMS TM enables your application to be distributedthroughout the network.

    v Testing an Application ProgramWhen you finish coding your program, test it by itself and then as part of asystem.

    v Documenting an Application ProgramDocumenting a program continues throughout the project and is most effectivewhen done incrementally. When the program is completely tested, informationmust be suppled to those who use and maintain your program.

    14 Application Programming

  • Chapter 2. Designing an application: Data and local views

    Designing an application that meets the requirements of end users involves avariety of tasks and, usually, people from several departments. Application designbegins when a department or business area communicates a need for some type ofprocessing. Application design ends when each of the parts of the applicationsystemfor example, the programs, the databases, the display screens, and themessage formatshave been designed.

    An overview of application designThe application design process varies from place to place and from application toapplication. The overview that is given in this section and the suggestions aboutdocumenting application design and converting existing applications are not theonly way that these tasks are performed.

    The purpose of this overview is to give you a frame of reference so that you canunderstand where the techniques and guidelines explained in this section fit intothe process. The order in which you perform the tasks described here, and theimportance you give to each one, depend on your settings. Also, the individualsinvolved in each task, and their titles, might differ depending on the site. The tasksare as follows:v Establish your standards

    Throughout the design process, be aware of your established standards. Some ofthe areas that standards are usually established for are: Naming conventions (for example, for databases and terminals) Formats for screens and messages Control of and access to the database Programming and conventions (for common routines and macros)

    Setting up standards in these areas is usually an ongoing task that is theresponsibility of database and system administrators.

    v Follow your security standardsSecurity protects your resources from unauthorized access and use. As withdefining standards, designing an adequate security system is often an ongoingtask. As an application is modified or expanded, often the security must bechanged in some way also. Security is an important consideration in the initialstages of application design.Establishing security standards and requirements is usually the responsibility ofsystem administration. These standards are based on the requirements of yourapplications.Some security concerns are: Access to and use of the databases Access to terminals Distribution of application output Control of program modification Transaction and command entry

    v Define application data

    Copyright IBM Corp. 1974, 2014 15

  • Identifying the data that an application requires is a major part of applicationdesign. One of the tasks of data definition is learning from end users whatinformation will be required to perform the required processing.

    v Provide input for database designTo design a database that meets the requirements of all the applications that willprocess it, the database administrator (DBA) needs information about the datarequirements of each application. One way to gather and supply thisinformation is to design a local view for each of the business processes in yourapplication. A local view is a description of the data that a particular businessprocess requires.

    v Design application programsWhen the overall application flow and system externals have been defined, youdefine the programs that will perform the required processing. Some of the mostimportant considerations involved in this task are: standards, securityrequirements, privacy requirements, and performance requirements. Thespecifications you develop for the programs should include: Security requirements Input and output data formats and volumes Data verification and validation requirements Logic specifications Performance requirements Recovery requirements Linkage requirements and conventions Data availability considerationsIn addition, you might be asked to provide some information about yourapplication to the people responsible for network and user interface design.

    v Document the application design processRecording information about the application design process is valuable to otherswho work with the application now and in the future. One kind of informationthat is helpful is information about why you designed the application the wayyou did. This information can be helpful to people who are responsible for thedatabase, your IMS system, and the programs in the applicationespecially ifany part of the application must be changed in the future. Documentingapplication design is done most thoroughly when it is done during the designprocess, instead of at the end of it.

    v Convert an existing applicationOne of the main aspects in converting an existing application to IMS is to knowwhat already exists. Before starting to convert the existing system, find outeverything you can about the way it works currently. For example, the followinginformation can be of help to you when you begin the conversion: Record layouts of all records used by the application Number of data element occurrences for each data element Structure of any existing related databases

    Related concepts:Providing data security on page 91Identifying online security requirements on page 99Identifying application data on page 17Designing a local view on page 22

    16 Application Programming

  • Identifying application dataTwo important aspects of application design are identifying the application dataand describing the data that a particular business process requires.

    One of the steps of identifying application data is to thoroughly understand theprocessing the user wants performed. You need to understand the input data andthe required output data in order to define the data requirements of theapplication. You also need to understand the business processes that are involvedin the user's processing needs. Three of the tasks involved in identifyingapplication data are:v Listing the data required by the business processv Naming the datav Documenting the data

    When analyzing the required application data, you can categorize the data aseither an entity or a data element.

    Definitions: An entity is anything about which information can be stored. A dataelement is the smallest named unit of data pertaining to an entity. It is informationthat describes the entity.

    Example: In an education application, students and courses are both entities;these are two subjects about which you collect and process data. The followingtable shows some data elements that relate to the student and course entities. Theentity is listed with its related data elements.

    Table 10. Entities and data elements.

    Entity Data elements

    Student Student Name

    Student Number

    Course Course Name

    Course Number

    Course Length

    When you store this data in an IMS database, groups of data elements are potentialsegments in the hierarchy. Each data element is a potential field in that segment.Related concepts:An overview of application design on page 15

    Listing data elementsTo identify application data, you list its data elements.

    For example, to identify application data, consider a company that providestechnical education to its customers. The education company has one headquartersoffice, called Headquarters, and several local education centers, called Ed Centers.

    A class is a single offering of a course on a specific date at a particular Ed Center.One course might have several offerings at different Ed Centers; each of these is aseparate class. Headquarters is responsible for developing all the courses that willbe offered, and each Ed Center is responsible for scheduling classes and enrollingstudents for its classes.

    Chapter 2. Designing an application: Data and local views 17

  • Suppose that one of the education company's requirements is for each Ed Center toprint weekly current rosters for all classes at the Ed Center. The current roster is togive information about the class and the students enrolled in the class.Headquarters wants the current rosters to be in the format shown in the followingfigure.

    To list the data elements for a particular business process, look at the requiredoutput. The current roster shown in the previous figure is the roster for the class,Transistor Theory to be given in the Chicago Ed Center, starting on January 14,2004, for ten days. Each course has a course code associated with itin this case,41837. The code for a particular course is always the same. For example, ifTransistor Theory is also offered in New York, the course code is still 41837. Theroster also gives the names of the instructors who are teaching the course.Although the example only shows one instructor, a course might require more thanone instructor.

    For each student, the roster keeps the following information: a sequence numberfor each student, the student's name, the student's company (CUST), the company'slocation, the student's status in the class, and the student's absences and grade. Allthe above information on the course and the students is input information.

    The current date (the date that the roster is printed) is displayed in the upper rightcorner (01/04/04). The current date is an example of data that is output only data;it is generated by the operating system and is not stored in the database.

    The bottom-left corner gives a summary of the class status. This data is notincluded in the input data. These values are determined by the program duringprocessing.

    When you list the data elements, abbreviating them is helpful, because you will bereferring to them frequently when you design the local view.

    The data elements list for current roster is:

    EDCNTRName of Ed Center giving class

    DATE Date class starts

    CHICAGO 01/04/04

    TRANSISTOR THEORY 4183710 DAYSINSTRUCTOR(S): BENSON, R.J. DATE: 01/14/04

    STUDENT CUST LOCATION STATUS ABSENT GRADE1.ADAMS, J.W. XYZ SOUTH BEND, IND CONF2.BAKER, R.T. ACME BENTON HARBOR, MICH WAIT3.DRAKE, R.A. XYZ SOUTH BEND, IND CANC

    .

    .

    .33.WILLIAMS, L.R. BEST CHICAGO, ILL CONF

    CONFIRMED = 30WAITLISTED = 1CANCELED = 2

    Figure 4. Current roster for technical education example

    18 Application Programming

  • CRSNAMEName of course

    CRSCODECourse code

    LENGTHLength of course

    INSTRSNames of instructors teaching class

    STUSEQ#Student's sequence number

    STUNAMEStudent's name

    CUST Name of student's company

    LOCTNLocation of student's company

    STATUSStudent's status in classconfirmed, wait list, or cancelled

    ABSENCENumber of days student was absent

    GRADEStudent's grade for the course

    After you have listed the data elements, choose the major entity that theseelements describe. In this case, the major entity is class. Although a lot ofinformation exists about each student and some information exists about thecourse in general, together all this information relates to a specific class. If theinformation about each student (for example, status, absence, and grade) is notrelated to a particular class, the information is meaningless. This holds true for thedata elements at the top of the list as well: The Ed Center, the date the class starts,and the instructor mean nothing unless you know what class they describe.

    Naming data elementsSome of the data elements your application uses might already exist and benamed. After you have listed the data elements, find out if any of them exist bychecking with your database administrator (DBA).

    Before you begin naming data elements, be aware of the naming standards thatyou are subject to. When you name data elements, use the most descriptive namespossible. Remember that, because other applications probably use at least some ofthe same data, the names should mean the same thing to everyone. Try not to limitthe name's meaning only to your application.

    Recommendation: Use global names rather than local names. A global name is aname whose meaning is clear outside of any particular application. A local name isa name that, to be understood, must be seen in the context of a particularapplication.

    One of the problems with using local names is that you can develop synonyms,two names for the same data element.

    Chapter 2. Designing an application: Data and local views 19

  • For example, in the current roster example, suppose the student's company wasreferred to simply as company instead of customer. But suppose theaccounting department for the education company used the same piece of data ina billing applicationthe name of the student's companyand referred to it ascustomer. This would mean that two business processes were using two differentnames for the same piece of data. At worst, this could lead to redundant data if noone realized that customer and company contained the same data. To solvethis, use a global name that is recognized by both departments using this dataelement. In this case, customer is more easily recognized and the better choice.This name uniquely identifies the data element and has a specific meaning withinthe education company.

    When you choose data element names, use qualifiers so that each name can meanonly one thing.

    For example, suppose Headquarters, for each course that is taught, assigns anumber to the course as it is developed and calls this number the sequencenumber. The Ed Centers, as they receive student enrollments for a particularclass, assign a number to each student as a means of identification within the class.The Ed Centers call this number the sequence number. Thus Headquarters andthe Ed Centers are using the same name for two separate data elements. This iscalled a homonym. You can solve the homonym problem by qualifying the names.The number that Headquarters assigns to each course can be called course code(CRSCODE), and the number that the Ed Centers assign to their students can becalled student sequence number (STUSEQ#).

    HomonymOne word for two different things.

    Choose data element names that identify the element and describe it precisely.Make your data element names:

    UniqueThe name is clearly distinguishable from other names.

    Self-explanatoryThe name is easily understood and recognized.

    ConciseThe name is descriptive in a few words.

    UniversalThe name means the same thing to everyone.

    Documenting application dataAfter you have determined what data elements a business process requires, recordas much information about each of the data elements as possible.

    This information is useful to the DBA. Be aware of any standards that you aresubject to regarding data documentation. Many places have standards concerningwhat information should be recorded about data and how and where thatinformation should be recorded. The amount and type of this information variesfrom place to place. The following list is the type of information that is oftenrecorded.

    20 Application Programming

  • The descriptive name of the data elementData element names should be precise, yet they should be meaningful topeople who are familiar and also to those who are unfamiliar with theapplication.

    The length of the data elementThe length of the data element determines segment size and segmentformat.

    The character formatThe programmer needs to know if the data is alphanumeric, hexadecimal,packed decimal, or binary.

    The range of possible values for the elementThe range of possible values for the element is important for validitychecking.

    The default valueThe programmer also needs the default value.

    The number of data element occurrencesThe number of data element occurrences helps the DBA to determine therequired space for this data, and it affects performance considerations.

    How the business process affects the data elementWhether the data element is read or updated determines the processingoption that is coded in the PSB for the application program.

    You should also record control information about the data. Such informationshould address the following questions:v What action should the program take when the data it attempts to access is not

    available?v If the format of a particular data element changes, which business processes

    does that affect? For example, if an education database has as one of its dataelements a five-digit code for each course, and the code is changed to six digits,which business processes does this affect?

    v Where is the data now? Know the sources of the data elements required by theapplication.

    v Which business processes make changes to a particular data element?v Are there security requirements about the data in your application? For example,

    you would not want information such as employees' salaries available toeveryone?

    v Which department owns and controls the data?

    One way to gather and record this information is to use a form similar to the oneshown in the following table. The amount and type of data that you recorddepends on the standards that you are subject to. For example, the following tablelists the ID number, data element name, length, the character format, the allowed,null, default values, and the number of occurrences.

    Chapter 2. Designing an application: Data and local views 21

  • Table 11. Example of data elements information form

    ID #

    Dataelementname Length

    Char.format Allowed values

    Nullvalues

    Defaultvalue Number of occurrences

    5 CourseCode

    5 bytes Hexa-decimal

    0010090000 00000 N/A There are 200 courses inthe curriculum. Anaverage of 10 are new orrevised per year. Anaverage of 5 are droppedper year.

    25 Status 4 bytes Alpha-numeric

    CONF WAITCANC

    blanks WAIT 1 per student

    36 StudentName

    20 bytes Alpha-numeric

    Alpha only blanks N/A There are 3 to 100students per class withan average of 40 perclass.

    A data dictionary is a good place to record the facts about the application's data.When you are analyzing data, a dictionary can help you find out whether aparticular data element already exists, and if it does, its characteristics. With theIBM OS/VS DB/DC Data Dictionary, you can determine online what segmentsexist in a particular database and what fields those segments contain. You can useeither tool to create reports involving the same information.

    Designing a local viewA local view is a description of the data that an individual business processrequires.

    It includes the following:v A list of the data elementsv A conceptual data structure that shows how you have grouped data elements by

    the entities that they describev The relationships between each of the groups of data elements

    Definitions: A data aggregate is a group of data elements. When you have groupeddata elements by the entity they describe, you can determine the relationshipsbetween the data aggregates. These relationships are called mappings. Based on themappings, you can design a conceptual data structure for the business process. Youshould document this process as well.Related concepts:An overview of application design on page 15

    Analyzing data relationshipsWhen you analyze data relationships, you are developing conceptual datastructures for the business processes in your application.

    This process, called data structuring, is a way to analyze the relationships amongthe data elements a business process requires, not a way to design a database. Thedecisions about segment formats and contents belong to the DBA. The informationyou develop is input for designing a database.

    Data structuring can be done in many different ways.

    22 Application Programming

  • Grouping data elements into hierarchiesThe data elements that describe a data aggregate, the student, might berepresented by the descriptive names STUSEQ#, STUNAME, CUST, LOCTN,STATUS, ABSENCE, and GRADE. We call this group of data elements the studentdata aggregate.

    Data elements have values and names. In the student data elements example, thevalues are a particular student's sequence number, the student's name, company,company location, the student's status in the class, the student's absences, andgrade. The names of the data aggregate are not uniquethey describe all thestudents in the class in the same terms. The combined values, however, of a dataaggregate occurrence are unique. No two students can have the same values ineach of these fields.

    As you group data elements into data aggregates and data structures, look at thedata elements that make up each group and choose one or more data elements thatuniquely identify that group. This is the data aggregate's controlling key, which isthe data element or group of data elements in the aggregate that uniquelyidentifies the aggregate. Sometimes you must use more than one data element forthe key in order to uniquely identify the aggregate.

    By following the three steps explained in this section, you can develop aconceptual data structure for a business process's data. However, you are notdeveloping the logical data structure for the program that performs the businessprocess. The three steps are:1. Separate repeating data elements in a single occurrence of the data aggregate.2. Separate duplicate values in multiple occurrences of the data aggregate.3. Group each data element with its controlling keys.

    Step 1. separating repeating data elements

    Look at a single occurrence of the data aggregate. The following table shows whatthis looks like for the class aggregate; the data element is listed with the classaggregate occurrence.

    Table 12. Single occurrence of class aggregate

    Data element Class aggregate occurrence

    EDCNTR CHICAGO

    DATE(START) 1/14/96

    CRSNAME TRANSISTOR THEORY

    CRS CODE 41837

    LENGTH 10 DAYS

    INSTRS multiple

    STUSEQ# multiple

    STUNAME multiple

    CUST multiple

    LOCTN multiple

    STATUS multiple

    ABSENCE multiple

    GRADE multiple

    Chapter 2. Designing an application: Data and local views 23

  • The data elements defined as multiple are the elements that repeat. Separate therepeating data elements by shifting them to a lower level. Keep data elements withtheir controlling keys.

    The data elements that repeat for a single class are: STUSEQ#, STUNAME, CUST,LOCTN, STATUS, ABSENCE, and GRADE. INSTRS is also a repeating dataelement, because some classes require two instructors, although this class requiresonly one.

    When you separate repeating data elements into groups, you have the structureshown in the following figure.

    In the following figure, the data elements in each box form an aggregate. Theentire figure depicts a data structure. The data elements include the Courseaggregate, the Student aggregate, and the Instructor aggregate.

    The following figure shows these aggregates with the keys indicated with leadingasterisks (*).

    The keys for the data aggregates are shown in the following table.

    Table 13. Data aggregates and keys for current roster after step 1

    Data aggregate Keys

    Course aggregate EDCNTR, DATE, CRSCODE

    Student aggregate EDCNTR, DATE, CRSCODE, STUSEQ#

    Instructor aggregate EDCNTR, DATE, CRSCODE, INSTRS

    Instructoraggregate

    Studentaggregate

    Course aggregate

    *EDCNTR*DATECRSNAME

    *CRSCODELENGTH

    *INSTRS* STUSEQ#STUNAMECUSTLOCTNABSENCEGRADESTATUS

    Figure 5. Current roster after step 1

    24 Application Programming

  • The asterisks in the previous figure identify the key data elements. For the Classaggregate, it takes multiple data elements to identify the course, so you needmultiple data elements to make up the key. The data elements that comprise theClass aggregate are:v Controlling key element, STUSEQ#v STUNAMEv CUSTv LOCTNv STATUSv ABSENCEv GRADE

    The data elements that comprise the Instructor aggregate are:v Key element, INSTRS

    The Course aggregate and the Instructor aggregate inherit the following keys fromthe root segment, Course aggregate:v EDCNTRv DATEv CRSCODE

    After you have shifted repeating data elements, make sure that each element is inthe same group as its controlling key. INSTRS is separated from the group of dataelements describing a student b