+ All Categories

IMS DB

Date post: 01-Dec-2015
Category:
Upload: narasimha-rao-siram
View: 248 times
Download: 21 times
Share this document with a friend
Description:
Introduction to IMS Database
Popular Tags:
175
© 2009 Wipro Ltd - Confidential IMS DB
Transcript
Page 1: IMS DB

© 2009 Wipro Ltd - Confidential

IMS – DB

Page 2: IMS DB

© 2009 Wipro Ltd - Confidential2

To develop an understanding of the processing available under IMS/DB.

To develop the ability to write programs that access and update IMS database.

Objectives

Page 3: IMS DB

© 2009 Wipro Ltd - Confidential3

§ Introduction

§ IMS DB Terminology

§ IMS DB Coding

§ Getting Started

§ Additional Database Functions

§ Additional Features

§ Advanced Topics

§ AIB Interface

§ Recovery Functions

§ Fast Path

§ Appendices

Agenda

Page 4: IMS DB

© 2009 Wipro Ltd - Confidential4

WHAT IS A DATABASE ?

‘A collection of inter-related data stored together with controlled redundancy to serve one or more applications in an optimal fashion; the data are stored so that they are independent of the program which use the data ; a common and controlled approach is used in adding new data and modifying and retrieving existing data within the data base.’

Introduction To Databases

Loan System

DDA System

Customer Database

Account

Addr Addr2 Branch

Page 5: IMS DB

© 2009 Wipro Ltd - Confidential5

Why Use A Database

Before databases were used, data definition problems were rampant.Confusion resulted from data elements which had these characteristics:

Same name, Different MeaningDifferent name, Same meaningSame name, Same meaning, Different Format

With the advent of database, these problems were solved.Database elements have these characteristics:

One nameOne storage locationOne formatOne meaning

Page 6: IMS DB

© 2009 Wipro Ltd - Confidential6

Database Management System

A database management system is a software that controls databases. A DBMS performs the following functions, thus removing that processing from application programs:

Controls concurrent access to data by many users

Ensures the integrity of data at all times

Provide some security

Separate the application program from the physical storage of the data (program-data independence)

Provides data relationship flexibility

Provides a database tool kit.

Page 7: IMS DB

© 2009 Wipro Ltd - Confidential7

Components Of A DBMS

The components which constitute a DBMS are as follows :Data security facility

Restricted access to dataProvides for recovery of data Allows multiple concurrent updates

Interface LanguageRetrieves data randomly and sequentiallyAdd and delete data on databaseUpdate existing data on database

Database tool kitCreate the databaseBacks up/recovers the databaseExpands/refines the database

Page 8: IMS DB

© 2009 Wipro Ltd - Confidential8

Types Of Database Structures

The data elements which comprise a database must be connected together.This is known as the data relationship .The most common formats for the definition of data relationships are:

Hierarchical : A tree structure

Relationship of data is predefined by its structure

Program traverses the structure to access the data

Relation : Table of data

Program defines the relationship of the data

Program selects rows and/or columns from the table or from a group of tables.

Page 9: IMS DB

© 2009 Wipro Ltd - Confidential9

Relational VS. Hierarchical

Because the data relationships in a hierarchical structure are pre-defined., its major

advantage is speed of access. The major disadvantage is the reduced flexibility

inherent in a pre-defined structure. The IBM hierarchical product is IMS/DB.

Relational databases are much more flexible and are generally easy to use.However ,

The increased flexibility can result in slower access times .The IBM relational

product is DB2

Page 10: IMS DB

© 2009 Wipro Ltd - Confidential10

IMS DB TerminologyHierarchical Database Terminology

Characteristics of an IMS Database

Database Definition (DBD)

Program Communication Block (PCB)

Program Specification Block (PSB)

Application Control Block (ACB)

Page 11: IMS DB

© 2009 Wipro Ltd - Confidential11

IMS Database (DB)

IMS databases are hierarchical, or tree structures. All access is through the predefined paths which comprise the tree structure.

All access to IMS database is through the interface modules called DL/I. Every time a database is read or updated, the DLI interface must be called.

Page 12: IMS DB

© 2009 Wipro Ltd - Confidential12

Components Of An IMS System

Application program -the user module written in ALC, COBOL or PL/IDatabase-the data to be accessed by one or many applications.DL/I software -the modules which interface between the MVS access module and the application program.DL/I control blocks -the executable modules which define the database and the application program’s view.

Databases

DBDLIBPSBLIB

MVS

MVS AccessModule

DL/IModule

ApplicationProgram Control

Block

Page 13: IMS DB

© 2009 Wipro Ltd - Confidential13

Hierarchical Database

SEGMENT : Smallest unit of data that an application can retrieve form a database; contains one or more fields of data

ROOT: The entry point to the database ; has no parent segment.

PARENT: a segment which has a dependent segment beneath it.

CHILD: A segment which is the dependent segment of a parent.

TWIN: Multiple occurrence of a dependent segment.

TWIN CHAIN :All twins of the same parent

KEY: Unique identifier of a segment

Page 14: IMS DB

© 2009 Wipro Ltd - Confidential14

Hierarchical Database Contd..

CONCATENATED KEY: The concatenation of all the keys of the parent with the key of the segment

DATABASE RECORD: One root with all of its children

DL/I: Data Language/I - the language used when programming with IMS

SEARCH FIELD: any filed defined in the database definition ; The application programmer can request IMS to process

only segments matching a specific value in the search field.

Sequential processing sequences of an IMS database is top-to-bottom, left-to-right

Page 15: IMS DB

© 2009 Wipro Ltd - Confidential15

Loan Database

ACCOUNT

BILLINGADVANCE

PAYMENT

FEES

RATE

Page 16: IMS DB

© 2009 Wipro Ltd - Confidential16

Loan Database Contd..

ACCOUNT Segment :Account no-key

Customer no. Current balanceTotal Interest AccruedTotal Interest RepaidTotal Principal Repaid

BILLING Segment:Bill Date-keyPayment amount Due

FEES Segment : UnkeyedFee TypeAmount Fee

Page 17: IMS DB

© 2009 Wipro Ltd - Confidential17

Loan Database Contd..

. ADVANCE Segment : Advance Date-keyAdvance Seq. Number-keyAmount of advance

PAYMENT Segment :Payment Date-keyPayment Sequence Number-keyPrincipal RepaidInterest Repaid

RATE Segment : Rate Date -keyInterest Rate Rate BasisSpread

Page 18: IMS DB

© 2009 Wipro Ltd - Confidential18

Characteristics Of An IMS Database

An IMS database consists of some number of database records. The size of the database is limited only by the constraint of

VSAM and DASD.

A maximum of 15 levels are allowed; a level can be defined as all segments that have the same number of segments above

them. The root segment is always level one. Each immediate child of the root is level two and so on .

IMS allows up to 255 different segment types in a single database.

Page 19: IMS DB

© 2009 Wipro Ltd - Confidential19

DB Positioning

The sequential processing of an IMS Hierarchy is always top-to-bottom , left-to-right. IMS keeps track of its place in the database after every call.

Before the first call , the position is prior to the first root segment. The current position if defined as the place just before the segment that DL/I would retrieve next during unrestricted sequential processing.

After any read or write ,the position is after the segment just processed.

It is important to keep database position in mind when processing a database sequentially. IMS moves only forward, never backward. If the program asks for a segment which has already been passed. IMS will not find the segment.

Page 20: IMS DB

© 2009 Wipro Ltd - Confidential20

Database Terminology

DBD(Database Definition):Defines the physical structure of database.

PCB(Program Communication Block): Defines the application view of the database

PSB(Program Specification Block): Contains all the PCB for a specific program

ACB (Application Control Block): An internal control block containing DBD and PSB information.

Page 21: IMS DB

© 2009 Wipro Ltd - Confidential21

IMS/Program Communication

.

Databases

DBDLIBPSBLIB

MVS

MVS AccessModules

DL/I Modules

ApplicationProgram

DBD

PCB (in PSB)

PCBMask

ACB

Page 22: IMS DB

© 2009 Wipro Ltd - Confidential22

Database Definition(DBD)

The DBD contains the name of the database and defines the actual tree structure.The information needed by application programmer includes:

Database name

Segment names

Key field names, lengths and locations

Search field names, lengths and locations

The DBD contains the IMS and MVS access methods and defines how many datasets and DD statements are required . The DDNAMES for the database are also found in the DBDs.

DBDs are assembled (DBDGEN) and reside in DBDLIBs.

LOAN DATABASE DBD

Page 23: IMS DB

© 2009 Wipro Ltd - Confidential23

Data Dictionary

A Data Dictionary acts as a repository for information about all data in an environment.

Some common data dictionary products are CA10, IBM’s Data Dictionary and Data Manager

Page 24: IMS DB

© 2009 Wipro Ltd - Confidential24

DBD Generation (DBDGEN)

.

Data Dict.

DBDGEN

DBDLIB

DBDSRCE

Page 25: IMS DB

© 2009 Wipro Ltd - Confidential25

Program Communication Block

The PCB is the program’s view of database .It defines the database to be accessed and the scope of the program’s access.

The PCB defines the “Segment Sensitivity” ( i.e. segments available to the program). If a PCB does not contain one or more of the segment in the database, the program is “Not Sensitive “ to these segments.

A program’s view of the database may be the same or different than the “physical view” of the database.

Page 26: IMS DB

© 2009 Wipro Ltd - Confidential26

PCB processing options

PCB also states processing option available ( i.e. ADD, UPDATE, DELETE or READ).

The processing options allowed in a PCB are :I - To add a segmentR - To change (replace) a segmentD - To delete a segmentG - To read a segmentA - All except load L - To load a databaseLS - To load (data must be in key sequence)

There is an additional option of ‘O’, for ONLY,which is used with the get option when the program is going to ‘read only’.The ‘O’option allows a program to read a segment,even if another program is updating it.

Page 27: IMS DB

© 2009 Wipro Ltd - Confidential27

PCB Processing Option Contd..

‘GO’ may be used with ‘N’ as in ‘GON’ requesting that IMS notify the application program if a pointer error is encountered.

‘GO’ may be used with ’T’ as in ‘GOT’ requesting that IMS retry the call (once) if a pointer error is encountered.

Multiple of the options can be defined as in GI, meaning that the program can get and/or insert segments.

The processing option can be coded at the database level applicable to all sensitive segments. It can be defined at the segment level; to vary the options by segment.

Another feature specified in the PCB is the processing sequence ( i.e. secondary indexes).

Page 28: IMS DB

© 2009 Wipro Ltd - Confidential28

IO-PCBsThere is another type of PCB, the IO-PCB (also called a TP-PCB). It is used in online transactions to process messages

To/From the terminal and in batch programs to take checkpoint.

Additional TP PCB can be used to send messages to terminals other than the terminal which initiated the program.

Page 29: IMS DB

© 2009 Wipro Ltd - Confidential29

Program Specification Block(PSB)

A PSB is the set of all PCBs that a program is going to use.The program can access only database which are defined in the PSB.

PSBs are assembled(PSBGEN) and reside in a PSBLIB.TEST PSB

PCB TYPE=DB,NAME=BMALOAN1,PROCOPT=A, XKEYLEN16

SENSEG NAME=ACCOUNT,PARENT=0SENSEG NAME=BILLING,PARENT=ACCOUNTSENSEG NAME=FEES,PARENT=BILLING,PROCOPT=GSENSEG NAME=ADVANCE,PARENT=ACCOUNTSENSEG NAME=PAYMENT,PARENT=ACCOUNTSENSEG NAME=RATE,PARENT=ACCOUNTPSBGEN PSBNAME=BMA001,CMPAT=YESNote: CMPAT = Y, To guarantee that the program using the PSB will always be given an IO-PCB at run time.

Page 30: IMS DB

© 2009 Wipro Ltd - Confidential30

PSB-Database Views

PSB1

PSB2

PSB3

Account

Rate

Account

Billing

Fees

Account

Payment

PCB DBD=BMALOAN1SENSEG=ACCOUNTSENSEG=RATE

PCB DBD=BMALOAN1SENSEG=ACCOUNTSENSEG=BILLINGSENSEG=FEES

PCB DBD=BMALOAN1SENSEG=ACCOUNTSENSEG=PAYMENT

Page 31: IMS DB

© 2009 Wipro Ltd - Confidential31

PSB Generation (PSBGEN)

.

DATA DICT.

PSBGEN

PSBSRCE

PSBLIB

Page 32: IMS DB

© 2009 Wipro Ltd - Confidential32

Application Control Block (ACB)

When IMS executes an application program, it uses an ACB. An ACB is the run-time control block that is a consolidation of PSBs and DBDs.

For batch programs , IMS dynamically creates the ACB from PSB and DBD.For online programs, an ACB gen is run which merges the DBD and PSB and creates the ACB.

ACB GENERATION(ACBGEN)

PSBLIB

ACBLIB

DBDLIB

ACBGEN

Page 33: IMS DB

© 2009 Wipro Ltd - Confidential33

IMS DB Coding

§ Program ENTRY statement

§ Communication with IMS

§ PCB Masks

§ IO-AREAS

§ SSA

§ Some IMS database access commands

§ GN,

§ GHN

§ GNP

Page 34: IMS DB

© 2009 Wipro Ltd - Confidential34

Program Entry Statement

The program entry statement, a starting point of the program, should be the first executable statement in the program. In COBOL, it follows the Procedure Division statement.

IMS passes control to application program at the entry statement in the program; the application program returns control to IMS when finished (by issuing a GOBACK).

ENTRY ’DLITCBL’ USING IO-PCB LOAN-PCB.

Note :PCBs are passed by IMS to program in the same order they are listed in the PSB. The IO-PCB must be listed first.

For IMS program that also uses DB2, the entry statement is not specified. Instead, the PCBs are coded on the PROCEDURE DIVISION statement:

PROCEDURE DIVISION USING IO-PCB

LOAN-PCB.

Page 35: IMS DB

© 2009 Wipro Ltd - Confidential35

Communication With IMS

IMS database is accessed through the Data Language Interface ( i.e. DLI).

The DLI interface may be invoked in one of two ways:

§ By making a call to IBM supplied program CBLTDLI / ASMTDLI / PLITDLI (most commonly used method) byPassing a PCB, orPassing an AIB

§ By invoking the EXEC-DLI CICS interface byPassing a PCB, orPassing an AIB

Page 36: IMS DB

© 2009 Wipro Ltd - Confidential36

Using CBLTDLI

CALL ‘CBLTDLI’ USING PARM-COUNT FUNCTION PCB IO-AREA SSA.

The program passes these parms to IMS describing the action to take palace and what to do with the results.Parm-count : How many parameters followFunction : What type of call to makePCB : Tells IMS what database to process and has return information from IMS IO-AREA : Tells IMS where to place the data(for retrieval) and where to find the data(for updates)SSA : Segment Search Arguments steer IMS to correct segment by supplying

details such as segment name and key values

Page 37: IMS DB

© 2009 Wipro Ltd - Confidential37

PARM-COUNT

The PARM-COUNT, a 4-byte binary field, is seldom used parameter which tells IMS how many parameters follow and is

optional for COBOL.

01 PARM-COUNT PIC S9(8) COMP.

Page 38: IMS DB

© 2009 Wipro Ltd - Confidential38

PCBs

The PCB describes the result of each call made to IMS. There should be a one-to-one relationship between the PCBs defined in the PSB and the PCBs defined in the program.

The PCBs are listed on the ENTRY statement and then defined in the LINKAGE SECTION.

Each PCB is an 01 level in the linkage section. While the order of the PCBs is critical on the ENTRY statement , the order of the PCBs in the linkage section is of no consequences.

The PCB is physically outside the program; it resides in the IMS. The PCB is how IMS communicates with the program. The application program must interrogate the PCB to determine the success or failure of the call.

Page 39: IMS DB

© 2009 Wipro Ltd - Confidential39

IMS PCB

.

DBD PSBPCB

DATABASE

APPLLICATION PROGRAM....

LINKAGE SECTION.01 PCB-MASK.

PROCEDURE DIVISION.ENTRY ‘DLITCBL’ USING PCB-MASK..DL/I CALLS

Page 40: IMS DB

© 2009 Wipro Ltd - Confidential40

PCB Mask

.Pos Description

1-89-10

11-1213-16

17-20

21-28

29-3233-36

37-xx

Database Name

Segment Level

Status Code

Processing Option

Reserved For DL/I

Segment Name

Key Feedback Length

No. Of Sensitive Segs.

Key Feedback Area

PCB Example

Page 41: IMS DB

© 2009 Wipro Ltd - Confidential41

PCB Information

The status code is most important. It should ALWAYS be checked after EVERY call. The application program can never assume that the call was successful.

The segment-level and the segment-name contain the level and the name of the last segment IMS processed. This can be interrogated to determine which segment in a hierarchical path does not exist.

The key-feedback are contains the full key of the last segment processed. It can be interrogated if necessary.

The remaining information in the PCB is of little value except during de-bugging.

REMEMBER: IMS fills in the PCB with information; the application programmer NEVER moves anything to the PCB.

Page 42: IMS DB

© 2009 Wipro Ltd - Confidential42

IO-Areas

The Io-area passed to IMS is the storage location for the segment to be processed. Io-areas are a two way communication.

For retrieval calls, IMS places the segment retrieved in the Io-area.

For update calls, the program must place updated segment in the Io-area and IMS will use it to update the database.

The length of the Io-area is very important. IMS takes the segment length from the DBD, not form the Io-area; if the Io-area in the program is too short, IMS will overlay the subsequent storage after Io-area, It’s ok if the Io-area is too long; IMS will ignore the extra positions.

To update or delete a segment in IMS, the application program must first read and hold the segment . Then the application program can update or delete it.

Page 43: IMS DB

© 2009 Wipro Ltd - Confidential43

Segment Search Arguments

SSAs allow the application program to define to IMS the type of database access required.

There are two types of calls to IMS:

Qualified Call: The application program provides an SSA telling IMS what segment to access.

Unqualified Call: The application does not provide an SSA. IMS will determine what segment to process. For retrieval calls, IMS reads the next segment in the database; for update call, IMS processes the segment which has been held.

For qualified calls, there are two types of SSAs:

Unqualified SSA: Only the segment name is provided by the application program.

Qualified SSA: More information than just the segment name is provided by the application.

Page 44: IMS DB

© 2009 Wipro Ltd - Confidential44

Unqualified SSA

.

POS DESCRIPTION

1-8

9

SEGMENT NAME

BLANK

01 UNQUAL-SSA.

05 SEGMENT-NAME PIC X(9) VALUE ‘ACCOUNT ‘.

Page 45: IMS DB

© 2009 Wipro Ltd - Confidential45

Qualified SSA

.

POS DESCRIPTION

1-8

9-9

10-17

18-19

20-XX

XX+1

SEGMENT NAME

LEFT PARANTHESES

KEY NAME FROM DBD

RELATIONAL OPERATOR

VALUE OF KEY FIELD MUST BE LENGTH OF KEY

RIGHT PARANTHESES

Page 46: IMS DB

© 2009 Wipro Ltd - Confidential46

Relational Operators

Relational operators define the equation for the segment access. The valid operators are as follows.

EQUAL: ‘= ‘ OR ‘ =‘ OR ‘EQ’

GREATER THAN: ‘> ‘ OR ‘ >‘ OR ‘GT’

LESS THAN : ‘< ‘ OR ‘ < ‘ OR ‘LT’

GREATER THAN OR EQUAL TO : ‘>=‘ OR ‘=>‘ OR ‘GE’

LESS THAN OR EQUAL TO : ‘<=‘ OR ‘=<‘ OR ‘LE’

NOT EQUAL TO : ‘/=‘ OR ‘=/‘ OR ‘NE’

Page 47: IMS DB

© 2009 Wipro Ltd - Confidential47

Qualified SSA Example

01 ACCOUNT-SSA.03 SEG-NAME PIC X(8) VALUE 'ACCOUNT'.03 LEFT-PAREN PIC X ALUE '('.03 KEY-FIELD PIC X(8) VALUE 'ACCOUNT#'.03 FILLER PIC X(2) VALUE 'EQ'.03 KEY-VALUE PIC X(6) VALUE '123456'.03 FILLER PIC X ALUE ')'.

NOTE: Field lengths must be exact.IMPORTANT : For better efficiency use –

» Fully qualified calls, and» Relational operator of equal.

Page 48: IMS DB

© 2009 Wipro Ltd - Confidential48

Making Call Using CBLTDLI

The example below will retrieve exactly one segment with a specific key value supplied by the call.CALL ‘CBLTDLI’ USING WS-GU

LOAN-PCB BILLING-IO-AREAACCOUNT-SSA BILLING-SSA.

WS-GU: A function code defined in working storage as ‘GU’ to get a unique segment from database specified by PCB.LOAN-PCB : PCB for the database to be accessed ( i.e. Loan Database).BILLING-TO-AREA : Location where the retrieved billing segment will be placed.ACCOUNT-SSA : SSA for ACCOUNT segment.BILLING-SSA : SSA for BILLING segment.

Working-Storage & Linkage Section

Page 49: IMS DB

© 2009 Wipro Ltd - Confidential49

IMS Functions

Segments in an IMS database can be Retrieved in one of two ways.

Sequential processing:

The data base is processed in sequence from some starting point. The order of the retrieval of the segments is determined by their physical order on the database.

Random processing:

The database is not retrieved in any order. The application program asks for a specific segment identified by some field in the segment (usually the key)

In addition to retrieval, an application can Add, Change or Delete segments.

Page 50: IMS DB

© 2009 Wipro Ltd - Confidential50

Sequential Processing

The segment retrieved is always based on the prior segment retrieved; the search for the next segment starts at the current position.

The segment is retrieved based on several factors:

The hierarchy of the database.The qualification coded in the application.The segments which have been defined in the PCB, i.e., segment sensitivity.

Page 51: IMS DB

© 2009 Wipro Ltd - Confidential51

Sequential Processing Functions

GN : ‘Get Next’ - To retrieve the next segment in the database.

GNP: ‘Get Next Within Parent’ - To retrieve the next dependent segment of this parent.

GHN: ‘Get Hold Next’ - To retrieve and hold (for update) the next segment.

GHNP: ‘Gete Hold Next Within Parent’ - To retrieve and hold (for update) the next dependent segment of this parent.

An unqualified get next retrieves the next sensitive segment in the hierarchy.A qualified next retrieves the next sensitive segment matching the search criteria. IMS chooses to place a hold based on the processing options in the PCB.

Ex GN With CBLTDLI

Page 52: IMS DB

© 2009 Wipro Ltd - Confidential52

Sequential Processing Functions Contd..

GHN

The only change needed to read the record and hold it for update is to change the function from ‘GN’ to ‘GHN’.

CALL 'CBLTDLI' USING WS-GHNLOAN-PCBACCOUNT-AREAACCOUNT-UNQUAL-SSA.

This call would read the next account segment on the database; the segment is held for possible update.

Page 53: IMS DB

© 2009 Wipro Ltd - Confidential53

IMS Status Codes

After every call, IMS returns a status code in the PCB that describes the success or failure or the call.

The status code should be tested after EVERY call to IMS.

The application program should test for expected status codes; if an unexpected status code is encountered, the program should abend.

Before the application program abends, it should display the PCB, AIB or DIB and a descriptive message.

Page 54: IMS DB

© 2009 Wipro Ltd - Confidential54

Status Code Types

Three types of IMS status codes :

Informational : The status code returned by the IMS is neither good nor bad; the application program must determine if the result is good or bad. For example end-of-file status.

Program Error : The call itself was not attempted because the information passed to DL/I is invalid. This is always an abend condition and should only be encountered during testing. For example the segment name is misspelled.

IO Error : The call was attempted but an IO Error was encountered. An unusual occurrence, should cause an abend.

Page 55: IMS DB

© 2009 Wipro Ltd - Confidential55

Common Database Status Codes

Informational status codes: BLANKS - The call was successful‘GA’ - During unqualified sequential processing, IMS crossed to a higher level of the hierarchy‘GB’ - End of database (file) was reached.‘GE’ - No segment was found which matches the criteria specified. ‘GK’ - During unqualified sequential processing, IMS crossed to a different segment type at the same level

Program Error Status Codes: ‘AD’ - The function code is invalid‘AK’ - The field name does not match the name in the DBD‘AJ’ - The SSA is coded incorrectly

I/O error status Codes:‘AI’ - Open error; probably a missing DD statement.

Page 56: IMS DB

© 2009 Wipro Ltd - Confidential56

Parentage

GNP and GHNP sequentially process the database but limit the segments to dependent segments of the established parent. Parentage is said to be ‘set’ at the parent segment.

The sequential search for segments begins at the current position and stops at the dependent segment of the parent.

Parentage must have been set prior to issuing the GNP/GHNP request. Hold function is not needed for EXEC DLI.

Parentage can be set in two ways:

– By retrieving a parent segment: parentage is set at the last segment retrieved.

– By using command codes.

Ex : GNP WITH CBLTDLI

Page 57: IMS DB

© 2009 Wipro Ltd - Confidential57

Parentage Contd..

GHNP

The only change needed to read the record and hold it for update is to change the function from ‘GNP’ to ‘GHNP’.

CALL 'CBLTDLI' USING WS-GHNPLOAN-PCBADVANCE-AREAADVANCE-UNQUAL-SSA.

This call would read and hold the next advance segment which is a child of the account segment.

Page 58: IMS DB

© 2009 Wipro Ltd - Confidential58

Scheduling A PSB

When using EXEC DLI command in a CICS transaction, before any database may be accessed, the application must first schedule the PSB.

EXEC DLISCHDPSB (psbname)

END-EXEC

SYSSERVE, an optional parameter requests DLI to establish the first PCB as the IO-PCB. This is necessary to issue system service requests.

Scheduling is only necessary for a CICS transaction. BMPs do not schedule a PSB.

Page 59: IMS DB

© 2009 Wipro Ltd - Confidential59

Terminating A PSB

The TERM command may used to terminate the PSB in a CICS transaction. The TERM command causes all database updates to be committed.

The TERM command is optional - returning to CICS has the same effect as the TERM.

The TERM command is useful when the application needs to schedule a different PSB. Before a new PSB may be scheduled, the current PSB must be released.

TERM should be avoided : • It causes a CICS sync point future backouts will only process to this point

• It causes additional logging to occur.

Instead, let the CICS RETURN end the PSB whenever possible.

Page 60: IMS DB

© 2009 Wipro Ltd - Confidential60

PSB Scheduling

• A PSB remains scheduled until the transaction returns to CICS, or until a TERM request is made.

• A PSB remains scheduled across programs:

– Called via CICS LINK, when the linked program returns to the caller, the PSB is still scheduled

– Called via CICS XCTL, when the XCTL program receives control, the PSB is still scheduled; the first CICS RETURN command terminates the PSB.

However, the programs will be simpler if all DL/I requests are contained in a single module. Ex: Putting It All Together (CBLTDLI)

Page 61: IMS DB

© 2009 Wipro Ltd - Confidential61

Getting Started

• Creating a database

• BMP vs DLI

• IMS JCL requirements.

Page 62: IMS DB

© 2009 Wipro Ltd - Confidential62

Creating A Database

Steps to create an IMS database :

• Design the database

• Gen the DBD, PSB, ACB

• Build datasets for the database

• Load the database with a load PSB

• Code the program

• Code the JCL

• Test the program with BTS

• Test the program without BTS

Page 63: IMS DB

© 2009 Wipro Ltd - Confidential63

Defining The Database Datasets

While building a database, MVS datasets must be defined. IMS physically stores information in each record that enables IMS to process the datasets as a database. This is the second parameter on the ACCESS parameter on the DBD statement

DBD NAME = BMALOAN1, X

ACCESS=(HDAM,VSAM), X

RMNAME=(DFSHDC40,001,00000135), X

PASSWD=NO

Most IMS databases are defined as VSAM datasets (can also be a flat sequential file i.e. QSAM).

The MVS access method determines how the datasets must be created (using IDCAMS or coding DISP=(NEW,CATLG)).

Page 64: IMS DB

© 2009 Wipro Ltd - Confidential64

VSAM Dataset Creation

The definition of a VSAM dataset is done using the IBM utility, IDCAMS.

IDCAMS requires several parameters which it uses to define the VSAM components, or cluster. The definition of these parameters is critical.

The IMS DBDGEN provides a sample of the IDCAMS control cards containing the parameters to create a VSAM cluster which will house the database.

Sample IDCAMS job to create the IMS database for our loan DBD.

Ex: DELEET/DEFINE JCL

Page 65: IMS DB

© 2009 Wipro Ltd - Confidential65

Loading The Database

The database must be loaded after allocating the dataset. Database can be loaded by:

• Using a utility program to add and delete a dummy segment; this initializes the database, allowing update programs to add segments without using a load PSB

• Writing an application program (typically done in conversion situations)

• Using IMS reload utility to load from an existing database backup.

The first two options require a PSB with the processing option of ‘L’ for load.

The IMS reload utility does not require a load PSB, but assumes that the database already exists (it must have been initially created sometime with option 1 or 2.)

Page 66: IMS DB

© 2009 Wipro Ltd - Confidential66

Utility Program Database Load

IMS utility program DFSDDLT0 is the most commonly used utility program for loading database. It is provided by IBM with IMS product and is therefore available in all IMS environments.

The purpose of DFSDDLT0 is to manipulate IMS databases. It allows the application programmer to issue DL/I calls via control statements.

Additionally it provides these features:

– Compares the results of database calls with expected results

– Builds a dataset containing segment images and PCB information

DFSDDLT0 is commonly called DLTO or ‘diddletoe’

Page 67: IMS DB

© 2009 Wipro Ltd - Confidential67

IMS Configurations IMS/DLI

APPLICATION PROGRAM

IMS

DASD

DATABASESDB2

TABLES

JCL

PRINTOUT LOG

Page 68: IMS DB

© 2009 Wipro Ltd - Confidential68

IMS TM

FPTRAN

IMSTRAN

MSQGDEDB IMS

DB RECON

MSDB

MSGQ

EMH

IMSCTRL DLI DBRC IFP MPR BMP

Page 69: IMS DB

© 2009 Wipro Ltd - Confidential69

IMS DBCTL

IMS LOGS

DBCTL(IMS) DLISAS DBRC BMP BMP

CICS/ESA

TRANS

TRANS

DATA+ LOG

DEDB FULL FUNCDATABASES

TERM ALL DATABASE UPDATESRECORDED ON THE IMS

LOGS

Page 70: IMS DB

© 2009 Wipro Ltd - Confidential70

BMP VS. DLI

IMS programs can be run two ways: under IMS’s control, as a BMP, or as a stand-alone batch job, known as DLI.

BMP jobs have these features: • Run in conjunction with an IMS control region, an MVS started task that controls all online and BMP programs• Require no DD statements for the databases; the IMS control region contains the knowledge of the databases.• Require an ACB gen to process.• Require the IMS DBDLIB in the JCL ONLY when GSAM databases are being used• Does not require the allocation of a log dataset, as there is one log dataset of all of IMS

BMP jobs must run on the machine which is processing the IMS control region. This is controlled by job class. Most installations have specific job classes for BMP jobs.

Page 71: IMS DB

© 2009 Wipro Ltd - Confidential71

BMP VS. DLI Contd..

DLI jobs have these features:

• Run as stand-alone jobs with no communication or knowledge of the online IMS system

• Require DD statements for all databases

• Can be run with an ACB, or with the DBD and PSB (IMS will dynamically create the ACB at execution time)

• Require the DBDLIB or ACBLIB DD statement

• Require the allocation of a log dataset if recovery is to be performed

Page 72: IMS DB

© 2009 Wipro Ltd - Confidential72

IMS JCL RequirementsAll DL/I programs actually run as subroutines to the IMS. The IMS program is named DFSRRC00 and the application program and PSB are parameters coded on the execution statement.

// EXEC PGM=DFSRR00,// PARAM=(BMP,BMA001,BMAPSB,,,,,,1,,IMSS,,,N)

EXECUTION TYPEAPPLICATION PROGRAMPSBTIMEOUT OPTIONCONTROL REGION IDDBRC INDICATOR

Page 73: IMS DB

© 2009 Wipro Ltd - Confidential73

IMS JCL Requirements Contd..

The execution type parameter defines how the program should be processed: BMP, DLI, or DBB. BMP specifies that the program will be run as BMP.

DLI and DBB both specify that the program will be run as DLI, but DBB informs IMS that an ACB gen has been done with DBB, IMS uses the ACB instead of the DBD and PSB.

Page 74: IMS DB

© 2009 Wipro Ltd - Confidential74

IMS DD Statements

DFSRESLB - Defines the dataset containing the IMS system software.IMSLOGR - Defines the input IMS log dataset for restart.IEFRDER - Defines the dataset in which IMS records log records.IMS - Defines the DBD and PSB libs.

OR IMSACB - Defines the ACB lib (for DBB execution).DFSVSAMP - Defines buffer allocations for databases with VSAM access method; must allow for the largest control

interval of any database being accessed.

In addition, you need all the usual JCL statements for any non-IMS datasets including STEPLIB, SYSUDUMP, and so on.

Page 75: IMS DB

© 2009 Wipro Ltd - Confidential75

Samples

Sample DLI Execution JCL

Sample BMP Execution JCL

Page 76: IMS DB

© 2009 Wipro Ltd - Confidential76

Additional Database Functions

•GU, GHU

•ISRT

•REPL

•DLET

Page 77: IMS DB

© 2009 Wipro Ltd - Confidential77

Random Processing

With random processing, the segment is always retrieved directly; database position has no impact on the call. The retrieval moves forward, backward, or stays in the same place.

The segment is retrieved based on two factors:• When a key is specified, the segment returned matches that key• When only the segment name is used, IMS returns the first segment of that type• When no qualification is specified, IMS returns the first segment in the database

A random retrieval accomplishes these things:• Sets parentage• Sets database position after the retrieved segment• Retrieves the segment(s)

Page 78: IMS DB

© 2009 Wipro Ltd - Confidential78

Random Processing Functions

GU(Get Unique) - To retrieve a specific(unique) segment in the database.

GHU(Get Hold Unique) - To retrieve a specific segment in the database, and to hold the segment for possible update.

Remember that when using EXEC DLI, no hold is necessary.

EXAMPLE: GU USING CBLTDLI

Page 79: IMS DB

© 2009 Wipro Ltd - Confidential79

GHU

The only change needed to read the record and hold it for update is to change the function from GU to GHU.

CALL ‘CBLTDLI’ USING WS-GHULOAN-PCBACCOUNT-AREAACCOUNT-SSA.

This call would read and hold for the update the account segment whose key is 560011.Remember that when issuing GU calls, your database position does not matter. IMS will calculate the location of the

segment and find it (if it exists!).Example: Putting All Together (CBLTDLI)

Page 80: IMS DB

© 2009 Wipro Ltd - Confidential80

Adding Segments

• Segments are added to an IMS database by using the insert call, ISRT. • IMS puts the segment in the proper position in the database, based on the value in the key field of the io-area.• When inserting a child, or dependent, segment, the key of the parent may be or may not be provided. If the parent

is not qualified, the segment will be inserted at the current database position, as a child of the last parent processed.

• If the parent is qualified, the segment will be inserted as a child of the specified parent, regardless of the database position.

• The type of segment to be inserted must always be specified. IMS takes The information from the io-area.• IMS will use the information in the io-area to create the new segment on the database and will use the segment

length from the DBD.

Example: Sample Insert Calls With CBLTDLI

Page 81: IMS DB

© 2009 Wipro Ltd - Confidential81

Changing Segments

• Segments on an IMS database can be changed by using the replace call, REPL.

• When replacing any segment, the application must have first read and held the segment for update (GHU, GHN, GHNP). No qualification is allowed on a replace. IMS replaces the segment which has been held.

• IMS will use the information in the io-area to change the existing segment on the database and will use the segment length from the DBD.

• The key field on a segment can never be changed. To change the key, the program must add a new segment and delete the old one.

Example: Sample Replace Calls With CBLTDLI

Page 82: IMS DB

© 2009 Wipro Ltd - Confidential82

Removing Segments

• Segments on an IMS database can be removed by using the delete call, DLET. • Before deleting any segment, the target segment must have first read and held for update (GHU, GHN,GHNP). • Like the replace, no key is allowed on a delete. IMS deletes the segment which has been held.• When a parent segment is deleted, all dependent segments are always deleted automatically even if the application

program is not sensitive to the dependent segments in the PCB of the PSB.

Example: Sample Delete Calls With CBLTDLI

Page 83: IMS DB

© 2009 Wipro Ltd - Confidential83

Additional IMS Status Codes

• ‘DA’ – An attempt to modify the key field on a replace or delete call

• ‘DJ’ – An attempt to replace/delete a segment that had not been held

• ‘II’ – An attempt insert a duplicate

Page 84: IMS DB

© 2009 Wipro Ltd - Confidential84

Variable Length Segments

• IMS supports the use of variable length segments. Variable length segments are specified in the DBD:

SEGM NAME=BILLING,PARENT=ACCOUNT,BYTES=(150,100)

• Here, the max segment size is 150, the min is 100.

• When variable length segments are defined, the segment data must begin with a 2 byte binary field that contains the length field.

• For read functions, IMS returns the length of the segment in the length field.

• For update function, the application program must set the length field.

• For native IMS calls, no other change is necessary to process variable length segments.

Page 85: IMS DB

© 2009 Wipro Ltd - Confidential85

Additional Features Using Command Codes

• Path calls

• Retrieving first and last dependent segments

• Setting parentage

• Null command codes.

Page 86: IMS DB

© 2009 Wipro Ltd - Confidential86

Additional Features Using CBLTDLI

Command codes are used to :

• Expand the scope of database calls or to more precisely define the segments to be accessed.

• Process a leg (or path) of a database record

• Retrieve the first or last record in a twin chain

• Set parentage.

Command codes are coded in either qualified or unqualified SSAs. They can be used with all functions except delete.

Page 87: IMS DB

© 2009 Wipro Ltd - Confidential87

Unqualified SSA W/CC

Note: The ‘*’ in position 9 separates the segment name from the command code and is required. There can be multiple command codes. A blank is required for termination.

COMMAND CODE10

BLANK11

*9

SEGMENT NAME1 - 8

DESCRIPTIONPOS

Page 88: IMS DB

© 2009 Wipro Ltd - Confidential88

Qualified SSA W/CC

RIGHT PARENTHESESXX + 1

VALUE OF KEY FIELD MUST BE LENGTH OF LEY20 – XX

RELATIONAL OPERATOR18 – 19

KEY NAME FROM DBD10 – 17

LEFT PARENTHESES11

COMMAND CODE10

*9

SEGMENT NAME1 – 8

DESCRIPTIONPOS

Page 89: IMS DB

© 2009 Wipro Ltd - Confidential89

NULL Command Code

• A null command code is available which means ‘no command code’.

• It is used as a placeholder in those programs which dynamically change the command code during

processing.

• It allows the programmer to turn command codes on and off.

• The null command code is a ‘-’.

Page 90: IMS DB

© 2009 Wipro Ltd - Confidential90

Path Calls

• Path calls are used to retrieve or update an entire path of the hierarchy, or a portion of a path.

• A path call is requested by using the ‘D’ Command Code.

Page 91: IMS DB

© 2009 Wipro Ltd - Confidential91

Command Code ‘D’

• The ‘D’ command code is used to make a path call. A path call processes down a path of the hierarchy.

• A path call is used when the program needs to process several segments in the hierarchical path.

• The program can retrieve, insert and update segments in the path with one call to IMS.

• The program can selectively update segments in the path using a different command code.

• For full function database, path call processing requires a special processing option for the data base in the PSB.

Example: Test PSB

Page 92: IMS DB

© 2009 Wipro Ltd - Confidential92

Retrieval Path Calls

• A retrieval path call, (GU, GHU, GN, or GHN), is used to read some or all segments in a hierarchical path.• DL/I places the segments in the io-area, one after the other, left to right. The io-area must be at least as long as the

sum of the lengths of the segments to be retrieved.• To retrieve a segment in the path, code a D in the command code of the SSA; to skip a segment in the path, code a ‘-’

in the command code of the SSA.• DL/I will always retrieve the lowest level segment in the path; hence, no ‘D’ command code is required on the lowest

level.• Path calls are more efficient that coding several calls to retrieve segments in a path. However, care must be taken: if

the length of a higher level segment changes, you must change the length of the io-area to accommodate it.Example: Retrieval PATH Call

Page 93: IMS DB

© 2009 Wipro Ltd - Confidential93

Insert Path Calls

• An insert path call, ISRT, is used to insert an entire path of segments, or selected segments in a path, in one database

call.

• DL/I expects the segment in the io-area to be one after the other, left to right.

• The segments must be in the order of the path, and each segment must be exactly as long as defined in the DBD.

• The entire path must be inserted.

• To insert a path of segments, code a D in the command code of the SSA of the first segment to be inserted.

Example: Insert PATH Call

Page 94: IMS DB

© 2009 Wipro Ltd - Confidential94

Update Path Calls

• A replace path call, REPL, is used to replace an entire path of segments at once.

• DL/I expects the segments in the io-area to be one after the other, left to right.

• The segments must be in order of the path, and each segment must be exactly as long as defined in the DBD. The

entire path does not have to be replaced.

• The command code ‘N’ is used to indicate segments that are not to be updated.

• The SSAs for the REPL must be unqualified.

• DL/I will not update segments whose SSA have the command code ‘N’.

Example: Update PATH Call

Page 95: IMS DB

© 2009 Wipro Ltd - Confidential95

Path Call Usage

• It is generally more efficient to use path calls; one call to IMS can accomplish what might take several calls.

• However, there is a trade-off. The application program becomes less ‘data independent’.

• Considering that the program has all the segment io-areas concatenated together in one big io-area, what happens if

the length of a segment in the middle of the path changes?

Page 96: IMS DB

© 2009 Wipro Ltd - Confidential96

Retrieving First And Last Dependent Segments

• Two command codes allow to access segments without regard to current database position.

• These command codes can be used with GN,GU,GNP and ISRT.

• Command code ‘F’ defines access to the first occurrence of a dependent segment; with GN, GNP, the first dependent segment is retrieved; with ISRT, the segment will be added to the beginning of the chain of dependents (for non-keyed or non-unique-keyed segments.). This is the only way to move backward in an IMS database.

• Command Code ‘L’ with GU, GN, or GNP is used to retrieve the last occurrence of a dependent segment type; with ISRT, to add the segment as the last occurrence (for non-keyed or non-unique, keyed segments.)

Example: Get Last

Page 97: IMS DB

© 2009 Wipro Ltd - Confidential97

Setting Parentage

• Parentage can be set using the command code ‘P’. The ‘P’ command code can be used with GN, GU, and GNP and can be defined at only one level, parentage will be set at the lowest level.

• Parentage is set at the segment level indicated by the command code. Without the command code, parentage would be set at the lowest level retrieved.

• If the level which had the ‘P’ command code definition was satisfied, parentage is set; if not, no parentage is set, and any subsequent GNP calls will receive a status code of ‘GP’, parentage not set.

• Parentage will remain in effect until another call with a ‘P’ command code until any GU, GN, GHU, or GHN.

Example: Set PARENTAGE

Page 98: IMS DB

© 2009 Wipro Ltd - Confidential98

Concatenated Key Command Code

The key of a segment may be specified using a ‘C’ command code instead of an SSA.

The ‘C’ command code specifies the concatenated key as follows:WORKING-STORAGE SECTION.01 ACCOUNT-SSA.

05 FILLER PIC X(8) VALUE ‘ACCOUNT’.05 FILLER PIC X VALUE ‘*’.05 CC-ACCOUNT PIC X VALUE ‘C’.

05 FILLER PIC X VALUE ‘(‘ .05 ACCT-KEY PIC X(6) VALUE ‘101205’.05 FILLER PIC X VALUE ‘)’.

01 ACCOUNT-IO-AREA PIC X (200).01 GU PIC X(4) VALUE ‘GU’.

Page 99: IMS DB

© 2009 Wipro Ltd - Confidential99

Concatenated Key Command Code Contd..

LINKAGE-SECTION01 IO-PCB PIC X.01 LOAN-PCB.

05 FILLER PIC X(10).05 STATUS-CODE PIC XX.

PROCEDURE DIVISION.ENTRY ‘DLITCBL’ USING IO-PCB

LOAN-PCB.CALL ‘CBLTDLI’ USING GU

LOAN-PCBACCOUNT-IO-AREAACCOUNT-SSA.

Page 100: IMS DB

© 2009 Wipro Ltd - Confidential100

Advanced Topics

• Database Position

• IMS Access Methods

• Secondary Indexes

Page 101: IMS DB

© 2009 Wipro Ltd - Confidential101

More About Database Position

The database position is determined :• For successful calls:

– Before any calls are made, the position is before the first segment in the database.– After GU, GN, and GNP, the position is after the segment just retrieved.– After ISRT, the position is after the segment just added.– For DLET, the position is after the segment just deleted.– After REPL, no change to position.– After CHKP, the position is back to the beginning of the database.

• For unsuccessful calls:– After GU, GN, GNP, and ISRT, The position is after the last segment which satisfied the call.– After DLET, and REPL there is no change to position.

Page 102: IMS DB

© 2009 Wipro Ltd - Confidential102

Multiple Database Positioning

This can be accomplished in one of the two ways:

– Defining multiple PCBs for the same database. IMS maintains its position for each PCB.

– Defining a PCB with multi-positioning option. IMS maintains several positions in the one database in different

paths. The first option is preferred to the second.

Page 103: IMS DB

© 2009 Wipro Ltd - Confidential103

Multi-positioning PCB

With a multi-positioning PCB, IMS maintains a separate database position for each hierarchical path in one database

record.

Multi-positioning is specified on the PCB in the PSB:

PCB TYPE = DB,NAME=BMLOAN1,PROCOPT=A, XKEYLEN = 16,POS = M

Page 104: IMS DB

© 2009 Wipro Ltd - Confidential104

Multi-positioning PCB…. Contd.

100056123451

ACCOUNT

1991010519901008

19900905

BILLING

19900623011990042601

ADVANCE

1990052501

PAYMENT

2

FEES

B

1991010319901227

19901101

19901031

RATE

Page 105: IMS DB

© 2009 Wipro Ltd - Confidential105

Multi-positioning PCB…. Contd.

CALL MULTI SINGLE

GN ACCOUNT 123451 123451

GN BILLING 19900905 19900905

GN ADVANCE 1990042601 1990042601

GN BILLING 19901008 --(Under next root)

An unqualified GN, causes IMS to lose all positions except that of the segment just read.

Page 106: IMS DB

© 2009 Wipro Ltd - Confidential106

IMS Access Methods

There are several types of IMS databases which can be defined by the DBA. Each type has its own access method. The access method determines the characteristics of the database. Database order – the order in which the root segments are stored (Sequenced and non-sequenced). A non-sequenced access method means that if the roots are sequentially retrieved, they will be in no particular order; with sequenced access method, roots are retrieved in ascending sequence.Database structure – how database are physically structured. For example, the sequenced access methods have an index database which keeps track of root segments. Database relationship management – how the relationships between segments are maintained. For example, some access methods require that the dependent segments be stored physically adjacent to the parents.

The access method is defined in the DBD.

Page 107: IMS DB

© 2009 Wipro Ltd - Confidential107

HDAM Access Method

HDAM (Hierarchical, Direct Access Method) is the most commonly used. It is the most efficient method for random processing. The key of the root is randomized (converted to some number by an algorithm) and the random number is used to determine the address of the record in the database.

It’s features are: • The database are unordered. Sequential processing at the root level will result in no predictable sequence of data; the

records will be retrieved in the order in which their keys randomized.

• The database structure consists of one or more dataset groups. Each dataset group is an MVS dataset which contains all occurrences of one or more segment types. There must be at least one dataset group; the DBAs choose the number of dataset groups as part of their performance tuning and the dataset groups are defined in the DBD.

Page 108: IMS DB

© 2009 Wipro Ltd - Confidential108

HDAM Access Method Contd..

• The relationships of the segments are maintained via pointers. IMS maintains pointers from one segment to the next in the hierarchy. As a result, IMS does not need to store dependent segments with their parents.

• DASD space is immediately reusable; the space occupied by segments which are deleted is available for immediate use.

• An HDAM database is usually implemented as a VSAM ESDS.

Page 109: IMS DB

© 2009 Wipro Ltd - Confidential109

HIDAM Access Method

HIDAM (Hierarchical, Indexed, Direct Access Method) combines the random processing of HDAM with an index to order the database. It is the most efficient method for sequential processing which requires the database to be ordered. IMS maintains an index which contains the key of the root and its address.

Its features are:• The database are ordered. Sequential processing at the root level will result in the database records being retrieved in

ascending sequence based on the key value. • Two DBDs are required; one DBD is for the data area and one is for the index area. The index itself can be processed

as database.• The database structure consists of two MVS datasets; the database (or prime area) and the index dataset.• As in HDAM, the relationships of the the segments are maintained via pointers.

Page 110: IMS DB

© 2009 Wipro Ltd - Confidential110

HIDAM Access Method Contd..

• DASD space is immediately reusable; the space occupied by segments which are deleted is available for immediate

use.

• A HIDAM database is usually implemented as a VASM KSDS for the index database and an ESDS for the prime

database.

Page 111: IMS DB

© 2009 Wipro Ltd - Confidential111

HISAM Access Method

HISAM (Hierarchical, Indexed, Sequential Access Method) is another ordered database access method. It is most commonly used for low insert activity.

Its features are:• The databases are ordered. Sequential processing at the root level will result in the database records being retrieved in

ascending sequence based on the key value.• The database segments are stored sequentially. A parent and all its children will be sorted in physical sequence. An

overflow area is maintained for the addition of segments, and pointers are used when a dependent segment is stored in the overflow area.

• DASD space is not immediately reusable; a re-organization utility must be run against the database before the space occupied by deleted segments can be used.

• A HISAM database is implemented as a VSAM KSDS for the prime area and an ESDS for overflow.

Page 112: IMS DB

© 2009 Wipro Ltd - Confidential112

General Sequential Access Method (GSAM)

GSAM is a special IMS access method that allows IMS applications to process ordinary MVS sequential files as an IMS database. These applications can run as batch or BMPs.

GSAM is treated like a sequential, nonhierarchical database. It has no segments, no keys, and no parentage. The program does not have to define the file, open or close it, and can process it using the standard IMS CALL interface.

In addition, IMS automatically repositions the file for the program during restart processing.There are two MVS access methods that support the GSAM database:• BSAM for DASD, tape, or unit record datasets. Record format can be blocked or unblocked fixed-length, variable-

length or undefined. • VSAM ESDS for DASD datasets. Record format can be blocked or unblocked fixed-length or variable-length.

Page 113: IMS DB

© 2009 Wipro Ltd - Confidential113

Processing A GSAM Database

Programs that process a GSAM database:• Retrieve records in the order in which they were written.• Add records to the end of the data set.

IMS automatically OPENs the GSAM database when the program issues the first call to it and CLOSEs it when the program ends. It may be useful to explicitly OPEN and CLSE the GSAM database.

The program should explicitly CLSE GSAM after loading it if, in the same step, the program reads it as input:

CALL ‘CBLTDLI’ USING CLSEGSAM-PCB.

Page 114: IMS DB

© 2009 Wipro Ltd - Confidential114

Processing A GSAM Database Contd..

IF GSAM is an output database and the program doesn’t ISRT any records, the database is not created. Subsequently attempts to read the database will result in an error. To avoid this, the program should explicitly OPEN the database:

CALL ‘CBLTDLI’ USING OPENGSAM-PCB.

The only function codes available for GSAM are GN for reading and ISRT for adding segments:

CALL ‘CBLTDLI’ USING WS-GNGSAM-PCBSEGMENT-AREA.

CALL ‘CBLTDLI’ USING WS-ISRTGSAM-PCBSEGMENT-AREA.

Page 115: IMS DB

© 2009 Wipro Ltd - Confidential115

GSAM DBD And PSB

An example of a GSAM DBD: DBD NAME=BMAGSAM,ACCESS=(GSAM,BSAM)DATASET DD1=BMAGS001,SIZE=00000,RECFM=FBDBDGENFINISHEND

An example of PSB referencing the above GSAM database: PCB TYPE=DB,NAME=BMALOAN1….

…….PCB TYPE=GSAM,NAME=BMAGSAM,PROCCOPT=GPSSBGEN LANG=COBOL,PSBNAME=BMA001,COMPAT=YES

Page 116: IMS DB

© 2009 Wipro Ltd - Confidential116

Data Entry DataBase

The Data Entry Data Base is a high-capacity direct access organization.

The DEDB features are:• The database records are unordered; unique keys are required. • A randomizing module is used to locate the root of the database record, using its unique key.• Segment relationships are maintained by pointers. • The database consists of one or more areas; each area is a separate VSAM ESDS; each area can hold a maximum of 4

gigabytes; up to 240 areas can be defined. • Initialization, backup and recovery are performed at the area level.

DEDBs support full hierarchical structures up to 15 levels deep and up to127 segment types.

Page 117: IMS DB

© 2009 Wipro Ltd - Confidential117

DEDB Structure DEDB Areas

One of the key features of the DEDB is its ability to be partitioned into areas. Each area is a separate physical dataset and can be manipulated as if it were a separate database.

Records are placed into areas of the DEDB based on the randomization of the key. Unlike dataset groups, which contain all occurrences of specific segment types, area contain entire database records.

Areas must be preformatted using a DEDB utility program. The database can then be loaded by an application program doing insert calls.

A feature called dataset replication provides high data availability. Multiple copies of an area, (up to seven) can be maintained simultaneously by Fast Path. If I/O error occurs in one area, no other area is affected.

Backup and recovery can be performed at the area level; the DEDB utilities are run at the area level.

Page 118: IMS DB

© 2009 Wipro Ltd - Confidential118

ACCOUNT

BILLING ADVANCE PAYMENT INTERESTRATE

FEES ACCOUNT

BILLING ADVANCE PAYMENT INTERESTRATE

FEES

ACCOUNT

BILLING ADVANCE PAYMENT INTERESTRATE

FEES

DEDB AREASDEDB AREASAccts 1-5(Area 1)

Accts 6- 10(Area 2)

Accts 11-20(Area 3)

Page 119: IMS DB

© 2009 Wipro Ltd - Confidential119

Access Method Summary

ACCESS METHOD

ORDER DATABASE STRUCTURE

DATA RELATIONSHIP

HDAM UNORDERED ONE ESDS/ DS GROUP

POINTERS

HIDAM ORDERED INDEX-KSDS PRIME-ESDS/GP

POINTERS

HISAM ORDERED KSDS/ESDS SEQUENTIAL

GSAM ORDER WRITTEN

MVS QSAM SEQUENTIAL

DEDB RANDOM ONE ESDS/AREA

POINTERS

Page 120: IMS DB

© 2009 Wipro Ltd - Confidential120

Secondary Indexes

Databases often require multiple types of processing. For example, one online program may need to process a database in sequence, while all others need random access. A facility called secondary indexing exists which can be used to provide multiple access routes to one database.

Some of the functions that secondary indexes can be used for are as follows:• Retrieval of database records in an alternate sequence• Retrieval of a segment based on a condition in one of its dependent segments• Ordering of a non-ordered database.

Page 121: IMS DB

© 2009 Wipro Ltd - Confidential121

Secondary Index Terminology

The segment to be retrieved via the secondary index is called the target segment. The segment used to build the secondary index is called the Source segment. The target is retrieved based upon data in the

source segment. The secondary index itself is actually a database. The segments in the index database are called pointer segments.

ACCOUNTTARGET SEGMENT

FEE SECONDARY

INDEXPOINTER SEGMENT

BILLING ADVANCE PAYMENT RATE

FEES SOURCE SEGMENT

Page 122: IMS DB

© 2009 Wipro Ltd - Confidential122

Secondary Index Features

• Any segment within a hierarchy can be specified as the target of a secondary index.

• When the source segment is not a root, the hierarchy is in effect, inverted.

• A secondary index is not implemented as its own database and must be a VSAM dataset.

• The source and target segment can be the same segment.

Page 123: IMS DB

© 2009 Wipro Ltd - Confidential123

Loan Database With Secondary Index (Source = Target)

The Secondary index pointer segment is built from these fields on the source segment: Customer Number, Account Number.

By accessing via the secondary index, the accounts will now be in order by customer number and account number.

ACCOUNTTARGET SEGMENTSOURCE SEGMENT

CUSTOMER NO SECONDARY

INDEXPOINTER SEGMENT

BILLING ADVANCE PAYMENT RATE

FEES SOURCE SEGMENT

Page 124: IMS DB

© 2009 Wipro Ltd - Confidential124

Normal Vs. Indexed AccessNormal Access Access thru Index

A=3,C=1

A=4,C=5

A=5,C=2

A=2,C=3

A=1,C=5

C=5,A=4

C=5,A=1

C=3,A=2

C=2,A=5

C=1,A=3

Page 125: IMS DB

© 2009 Wipro Ltd - Confidential125

Normal Vs. Indexed Access Contd..

Normal Access: Indexed Access:

Random read gets account only Random read gets index and accountsegment

Sequential Access: Segments are retrieved in Segments are retrieved in customer, unknown sequence account sequence

Page 126: IMS DB

© 2009 Wipro Ltd - Confidential126

Secondary Index Definition

Steps:

• Define the secondary index DBD; use the LCHILD statement to establish the relationship between the secondary index and the target segment.

• In the original database DBD under the SEGM statement for the target segment:

– Use the LCHILD statement to establish the relationship between the target segment and the secondary index.

– Use XDFLD statement to define which fields from the source segment will be used to build the secondary index (pointer segments).

Ex: Loan Secondary Index

Page 127: IMS DB

© 2009 Wipro Ltd - Confidential127

PSB With Secondary Index

In the PSB, it must be defined that the secondary index will be used. This is the PROCSEQ, or processing sequence parameter and must be set to the secondary index DBD name.

In the application program itself, the SSA must use the XDFLD name instead of the key-field name.

PCB TYPE = DB, NAME=BPGLOAN2,PROCOPT=G, XKEYLEN=21,PROCSEQ=BPLOAN1

SENSEG NAME=ACCOUNT,PARENT= 0SENSEG NAME=BILLING,PARENT=ACCOUNTSENSEG NAME=FEES,PARENT=BILLINGSENSEG NAME=ADVANCE,PARENT=ACCOUNTSENSEG NAME=PAYMENT,PARENT=ACCOUNTSENSEG NAME=RATE,PARENT=ACCOUNT

PCB TYPE=DB,NAME=BMAGSAM,PRODUCT=GPSBGEN LANG=ASSEM,PSBNAME=BPG002,CMPT=YES

Page 128: IMS DB

© 2009 Wipro Ltd - Confidential128

Processing As A Stand-alone Database

• The secondary index database can itself be processed. It is possible to have IMS replicate information from the source segment into the pointer segment.this is known as duplicate data. By using duplicate data, it may be possible to eliminate the prime database altogether in some simple queries.

• The application program sees the entire data portion of the pointer segment. This includes the search, subsequence and duplicate data fields.

• The index database should never be updated directly. All updates should be done to the prime database and IMS will maintain the index.

Ex: Loan Secondary Index DBD

Page 129: IMS DB

© 2009 Wipro Ltd - Confidential129

PSB With Secondary Index As Stand-alone DB

To process the secondary index database itself, the PSB must reference the secondary index database.

PCB TYPE=DB,NAME=BPGLOAN1,PROCOPT=G, X

KEYLEN=11

SENSEG NAME= ACCTINDX,PARENT=0

PSBGEN LANG=ASSEM,PSBNAME=BPG22,CMPAT=YES

Page 130: IMS DB

© 2009 Wipro Ltd - Confidential130

Secondary Data Structure

When a secondary index has a target segment that is not the root, the processing sequence changes:– The target segment becomes the root. – All depends on the target stay on the right of the hierarchy.– All parents of the target become dependents of the target and are placed on the left in the hierarchy.

The target segment and its parents cannot be inserted or deleted in this view of the database.

This new view of the database is called a secondary data structure and the database processing sequence is called the secondary processing sequence.

To process using the secondary data structure, a PCB is used that defines the new structure. From the application programs perspective, accessing the secondary data structure is exactly the same as if it were the physical structure.

Page 131: IMS DB

© 2009 Wipro Ltd - Confidential131

ACCOUNT

BILLINGADVANCE

TARGET SEGMENTSOURCE SEGMENT

PAYMENT INTERESTRATE

FEES ADVANCE SECONDARYINDEX POINTER SEGMENT

ACCOUNT

BILLINGADVANCE

TARGET SEGMENTSOURCE SEGMENT

PAYMENT INTERESTRATE

FEES

ADVANCE

ACCOUNT

BILLINGADVANCE

TARGET SEGMENTSOURCE SEGMENT

PAYMENT INTERESTRATE

FEESADVANCE SECONDARYINDEX POINTER SEGMENT

ACCOUNT

BILLING ADVANCETARGET SEGMENTSOURCE SEGMENT

PAYMENT INTERESTRATE

FEES

ADVANCE

Page 132: IMS DB

© 2009 Wipro Ltd - Confidential132

Sparse Secondary Indexing

IMS provides the capability to suppress the generation of secondary index segments (if required).

A value can be defined on the XDFLD statement that IMS will use when updating the secondary index. If the contents of the secondary index field are equal to the null parameter, no pointer segment will be created in the secondary index for this source segment.

Another option to suppress the generation of secondary index pointers is to write a user exit and request its execution by coding EXTRN=userexit on the XDFLD segment. IMS will then pass control to the user exit before updating the secondary index.

Ex: Loan Database DBD with Sparse Index

Ex. Secondary Index Using CBLTDLI

Page 133: IMS DB

© 2009 Wipro Ltd - Confidential133

Boolean SSAs (CBLTDLI)

To retrieve a segment based on multiple criteria, the selection criteria are combined in the SSA. Criteria can be combined

using two Boolean operators:

AND - segment must meet all selection criteria; coded ‘*’ or ‘&’

OR - segment can meet any of the selection criteria; coded ‘+’ or ‘|’

Ex: Boolean SSAS

Page 134: IMS DB

© 2009 Wipro Ltd - Confidential134

Secondary Index Options

SECONDARY INDEX PROCESSING PTIONS

RETRIEVE SEGMENTS IN SECONDARY INDEX SEQUENCE

GN UNQUALIFIED (PROCESQ IN PSB)

RETRIEVE TARGET BASED ON VALUE IN SECONDARY INDEX

GU XDFLD (PROCSEQ IN PSB)

RETRIEVE SEGMENT BASED ON KEY VALUE

GU SEQUENCE FIELD

PROCESS SECONDARY INDEX AS STANDALONE DATABASE

GN/GU PCB = SECONDARY INDEX

PROCESS USING SECONDARY STRUCTURE

GN/GU PCB = SECONDARY INDEX

Page 135: IMS DB

© 2009 Wipro Ltd - Confidential135

Application Interface Block-AIB

Use of the AIB allows the application program to reference PCB’s by name. The

name of a database PCB is defined in the PSB:

Example

PCBNAME = LOANS assigns the name of LOANS to this PCB. The application

can then reference the PCB by name, instead of by position in the PSB.

LIST = YES requests that the PCB be included in the parameter list to the

application.

The IO-PCB may be referenced via the name IOPCB.

These PCBS are known as named PCBs.

Page 136: IMS DB

© 2009 Wipro Ltd - Confidential136

Advantages Of The AIB Interface

• Removes the dependence of the application program on the order of PCBs in the PSB. • The PCB can be identified by its name instead of its order in PSB.• The AIB interface is required to utilize several of the new application program functions:

DQUERYENVIRONFINDINQY.

• For xxxTDLI applications, use of the AIB removes these programming requirements:– ENTRY ‘DLITCBL’ USING…– Definition of PCB masks in Linkage Section.

• For EXEC DLI applications use of the AIB removes the need to know the PCB number.

Page 137: IMS DB

© 2009 Wipro Ltd - Confidential137

Using The AIB Interface

To use the AIB interface in existing applications:

– Modify the PSB to define names for the PCBs

– Define an AIB in the application program working storage

– For xxxTDLI

• Replace call to ‘xxxTDLI’ with call to ‘DFSAIBLI’

• Replace PCB in call parameter list with AIB as defined in the application’s working storage

– For EXEC DLI

• Replace USING PCB(number) with AIB(aibname)

– Evaluate the return and reasons codes in the AIB to determine the success or failure of the call.

Page 138: IMS DB

© 2009 Wipro Ltd - Confidential138

Using The AIB Interface Contd..

When LIST = YES is specified for a PCB, IMS updates the PCB with the results of the call, as well as the AIB. In this

scenario, the PCB status code may be evaluated to determine the success or failure of the call.

NOTE : The return code for end-of database (status-code = ‘GB’), is 2304.

Page 139: IMS DB

© 2009 Wipro Ltd - Confidential139

AIB Definition

The layout for the AIB is as follows:

PCB name.ApplPIC X(8).AIB-RESOURCE-NAME

PIC X(16).Filler

Requested sub function.ApplPIC X(8).AIB-SUBFUNCTION

ApplPIC S9(8)COMP VALUE 128.

AIB-LENGTH

AIB eye-catcherApplPIC X(8)VALUE ‘DFSAIB’.

AIB-IDENTIFIER

DescriptionUpdated by?

DefinitionField

Page 140: IMS DB

© 2009 Wipro Ltd - Confidential140

AIB Definition Contd..

IMS reason code.IMSPIC S9(8)COMP.

AIB-REASON-CODE

IMS return code.IMSPIC S9(8)COMP.

AIB-RETURN-CODE

IMSPIC X(12).Filler

The actual length of the data retrieved.IMSPIC S9(8)COMP.

ACTUAL-OUTPUT-AREA-LENGTH

For data retrievals (GU, etc.), the length of the requested data

ApplPIC S9(8)COMP.

REQUESTED-OUTPUT-AREA-LENGTH

DescriptionUpdated by?

DefinitionField

Page 141: IMS DB

© 2009 Wipro Ltd - Confidential141

AIB Definition Contd..

Address of the PCB named in the call.IMS.PIC S9(8)AIB-RESOURCE-ADDR

PIC X(4).Filler

PIC X(48).Filler

DescriptionUpdated by?

DefinitionField

Example: PSB With Named PCBs

Example: Sample Program With AIB And DFSAIBLI

Page 142: IMS DB

© 2009 Wipro Ltd - Confidential142

INQY Function

The INQY function is used to obtain information regarding the PCBs, status of the databases, the run-time environment or the address of a PCB.

The type of information requested is identified via the sub function:Null - Information such as the status of the IO-PCB or a named alternate PCBDBQUERY - Availability status of the databaseENVIRON - Information on the run-time environmentFIND - Address of a specific PCBPROGRAM - The name of the program being executed.

For all AIB calls, a return code of zero reflects that the call was successful.Example: INQY With DFSAIBLI

Page 143: IMS DB

© 2009 Wipro Ltd - Confidential143

Recovery Functions

– Checkpoint

– Restart

Page 144: IMS DB

© 2009 Wipro Ltd - Confidential144

IMS Checkpoint

Reads, Adds,Deletes,Updates

Buffers

Enq TableFF Database

Appl.Program

DL/I

Updated Segment

Info

DEDBUpdates

Updated,Not

Committed

Page 145: IMS DB

© 2009 Wipro Ltd - Confidential145

IMS Checkpoint Contd..Checkpoint,Sync Point

Buffers

Log File Enq TableDatabase

App.Program

DL / I

ClearsSegmentUpdates

Before/AfterImages

FF UpdatesCommitted

DEDBUpdatesWritten

Cleared

Page 146: IMS DB

© 2009 Wipro Ltd - Confidential146

IMS Checkpoint Contd..

All database updates as reversible, or ‘uncommitted’, until the application notifies IMS that all updates are permanent or committed. This is known as a synchronization point; IMS synchronizes all database updates for the program.The application commits by issuing a checkpoint call.

At the time of the checkpoint, three actions take place:IMS commits all the database updates and releases the records for the checkpointIMS sends a message to the operator containing the ID of the checkpointIMS writes a log record containing checkpoint information, before and after images of the updated segments and

the checkpoint id.Until the application issues the checkpoint, all segments which have been updated are ‘enqueued’ meaning any other programs attempting to access them will be forced to wait. If no checkpoints are taken, the commit will occur when the program completes.

Page 147: IMS DB

© 2009 Wipro Ltd - Confidential147

Checkpoint Frequency

The frequency of checkpoint is determined based on one of several factors:

– A specified time interval

– A specified number of database records were processed

– A specified number of database updates were done

Option second is the most common one.

DEDB databases have another option for determining the check point frequency, the unit of the work(UOW) boundary.

Page 148: IMS DB

© 2009 Wipro Ltd - Confidential148

UOW Boundaries

When a BMP is processing a DEDB, it is possible to have IMS notify the application when a UOW boundary is crossed.

Defining the crossing of a boundary as the checkpoint interval triggers the application program to issue a checkpoint. This approach has two major advantages:

– Database position is not lost; (In full-function database processing, issuing a checkpoint causes the loss of all database position)

– Database position is not lost when an ‘FR’ status code (NBA exhausted) is returned.

Page 149: IMS DB

© 2009 Wipro Ltd - Confidential149

UOW Boundaries Contd..

To receive notification of the crossing of a UOW boundary, the PSB must have a processing option of ‘P’. (PROCOPT = P for full function means Path call.)

With a processing option of ‘P’ defined on the PSB, Fast Path returns a status code of ‘GC’ whenever a BMP issues a get call to a root segment which would cause a UOW boundary to be crossed. The segment is NOT returned.

The application can choose to:

– Ignore the ‘GC’ status and re-issue the same call to retrieve the segment.

– Issue a checkpoint and re-issue the same call to retrieve the segment.

Page 150: IMS DB

© 2009 Wipro Ltd - Confidential150

Checkpoint Information

While issuing a checkpoint call, the following information must be provided to IMS:• The ID of the checkpoint, an 8 character field which uniquely identifies the checkpoint. It is application program

generated and usually consists of a combination of the program name and a counter, eg., BMA05001.• Up to seven areas of working storage in the application program, that the program needs recovered in the event of a

restart. IMS will save these storage areas on the log file when the check point is taken.• The length of the largest IMS database io-area used by the program.

When a checkpoint is issued, all database position is lost. IMS sets the position to the start of the database. The application program re-establish position after a checkpoint call. This is done by issuing a GU to the last segment accessed before the checkpoint.

Page 151: IMS DB

© 2009 Wipro Ltd - Confidential151

ABEND

Abend,Rollback

Buffers

Log File PI Enq Pool Database

Appl.Program

Cleared

DL / I

Abend infoClears

SegmentUpdates

Unchanged

Page 152: IMS DB

© 2009 Wipro Ltd - Confidential152

IMS Restart

Restart

Log File

Databases and GSAM Files

Checkpoint information

Appl.Program

DL / I

IMS Repositions

Page 153: IMS DB

© 2009 Wipro Ltd - Confidential153

IMS Restart Contd..

The IMS restart call allows a program which has not completed to be started again, beginning at the last checkpoint. This is

especially useful in long-running programs.

When a restart is issued the following actions take place:

• IMS places the checkpoint ID in a field designated by the application program.

• IMS repositions all databases to the last check point.

• IMS refreshes the application programs checkpoint areas.

Page 154: IMS DB

© 2009 Wipro Ltd - Confidential154

Checkpoint Call

CALL ‘CBLTDLI’ USING WS-CHKPIO-PCBIO-AREA-LEN(length of largest db io-area)IO-AREA ( 8 digit checkpoint id)WS-LENGTH-n (length of ws area)WS-AREA-n (ws area to be saved)

Up to seven areas of working storage can be checkpointed.

Note: In IMS V5, the IO-AREA-LEN is no longer needed and is a placeholder to maintain compatibility. Any storage address may be specified.

Page 155: IMS DB

© 2009 Wipro Ltd - Confidential155

Restart Call

CALL ‘CBLTDLI’ USING WS-XRSTIO-PCBIO-AREA-LEN(length of largest db io-area)XRST-AREA (12 digit checkpoint area, initialized to spaces)WS-LENGTH-n (length of ws area)WS-AREA-n (ws area to be saved)

The WS length and areas must match the checkpoint WS length and areas.

Note: In IMS V5, the IO-AREA-LEN is no longer needed.

Page 156: IMS DB

© 2009 Wipro Ltd - Confidential156

Using Checkpoint / Restart

It is quite easy! Follow a few SIMPLE rules:

• The first call to IMS must be an XRST call.

• The next call to IMS should be a CHKP call.

• Check the XSRT-AREA; if it is spaces, no restart has occurred. Continue on. If it is not spaces, a restart has occurred.

You are now positioned where you were at the time the last checkpoint was taken.

That’s it!

Page 157: IMS DB

© 2009 Wipro Ltd - Confidential157

Design Considerations

Two types of IMS programs:

• Database-driven programs – The programs which sequentially read an IMS database; it is said the database ‘drives’ the processing. These programs may or may not create MVS output files which are defined as GSAM databases.

• File-driven programs – The programs which use an input file to randomly process an IMS databases. A GSAM database must drive a restartable program.

It is customary to take an initial checkpoint at the beginning of the program, before processing any databases.

Also take care to ensure that the restart will work after the initial checkpoint as well as after subsequent checkpoints.

Page 158: IMS DB

© 2009 Wipro Ltd - Confidential158

Database-Driven Programs

• Database driven program sequentially process an IMS database. • After every checkpoint call, position in the database is lost (unless the checkpoint was after a ‘GC’ status code was

received; the program must reposition itself to continue processing.• Repositioning is accomplished in the steps:

– Save the key of the last record processed before the checkpoint.– Issue the checkpoint call.– Use the saved key to issue a GU to the same record. Continue processing with a GN.

• The restart logic is as follows:– IMS repositions the databases as of the last checkpoint call. – Continue processing by doing a GN.

For the initial checkpoint: Initialize the key save-area to spaces; in the reposition routine. If the key save-area is spaces, bypass the GU call.

Page 159: IMS DB

© 2009 Wipro Ltd - Confidential159

File-Driven Programs

• File-driven programs sequentially process an input file, or GSAM database. The GSAM is used to randomly process an IMS database.

• When a GSAM file is used, position is never lost. Therefore, there is no need to reposition.

• Restart logic:

– Issue the restart call. If the restart-id is not spaces, continue processing with a GN.

Page 160: IMS DB

© 2009 Wipro Ltd - Confidential160

Testing Checkpoint Restart

• Testing Checkpoint Restart– First, the program should be tested thoroughly as it would normally execute.– The program must be forced to abend.– Restart the program.– The results of the restart should be compared to the result of the test with no restart.– Make sure that no records were dropped, that none were duplicated, and that all counts and totals are accurate.

• How to abend a program? – Modify data one of the segments to contain invalid packed data, causing an OC7.– Set the time on the step to one second, causing a time out.– If all else fails, add a statement that will divide some number by zero, causing an OCB.

Page 161: IMS DB

© 2009 Wipro Ltd - Confidential161

Testing Checkpoint Restart Contd..

• Fix the cause of the abend, either by correcting the data allocating time, or deleting the divide by zero.

• Restart the program:

– If the program is running under IMS’s control as a BMP, restart it.

– If the program is running as a DLI, first run a program called batch backout to reverse any updates posted since

the last checkpoint (IMS does this automatically for BMP programs.) then restart the program.

Page 162: IMS DB

© 2009 Wipro Ltd - Confidential162

Restart JCL Requirements

• All output files must have an abnormal disposition of CATLG.

That’s the only requirement for programs run as BMP.

One of the major differences between BMP and DLI, is that in DLI, the application programmer is responsible for the IMS log file; the log file is used by IMS when a program is executing. IMS uses it to record the before and after images of segments, program checkpoint areas and checkpoint id information. That is the IEFRDER dataset.

All BMPS (and online transactions) share the log file associated with the control region. DLI programs must create their own log file. This is sequential dataset which must be kept to use as input in the event of a restart.

Page 163: IMS DB

© 2009 Wipro Ltd - Confidential163

Restart JCL Requirements Contd..

Let’s look at the JCL for a restartable program. Note that this is the JCL for the original execution; we will review the JCL for the restart shortly.

Example: JCL For A Restartable Program

Example: Batch Backout JCL

Example: Restart JCL

Example: BMP Restart JCL

Page 164: IMS DB

© 2009 Wipro Ltd - Confidential164

Validation Of Test Results

• Test the program with no abends. Save all output files. Make a copy of the database or unload it. (Test 1).

• Retest the program forcing an abend. Then restart the program. Make a copy of the database or unload it. (Test 2)

• Compare results:

– Compare all output files from test 1 to test 2.

– Compare all reports, totals and counts.

– Compare the databases.

Page 165: IMS DB

© 2009 Wipro Ltd - Confidential165

Converting Batch Programs To BMP

• PSB name must be added to the IMS system definition.• Any batch file used by the program must be converted to GSAM.• Do GSAM PSB changes.• Identify all program variables that are required to retain values in the event of a restart. • Code the checkpoint/restart WORKING-STORAGE variables.• Make changes to the LINKAGE SECTION for the GSAM files, and for the IO-PCB if necessary.• Modify the ENTRY or PROCEDURE DIVISION USING statement to include IO-PCB/GSAM PCBs.• Make Procedure Division changes for CKPT/XRST calls.• Modify the JCL to run as a BMP.

Page 166: IMS DB

© 2009 Wipro Ltd - Confidential166

Do I Need A Restartable Program?

• Not all BMP programs are required to be restartable:

– Programs that are read-only and are not long-running

– Programs that can be re-run from the top, even though they are updating, e.g., a conversion program that

initializes new fields.

This does not mean that the program doesn’t need checkpoints.

* If a BMP does not updates, it need to take checkpoints. IMS resources must be released or the BMP runs the risk of

crashing the entire IMS system.

Page 167: IMS DB

© 2009 Wipro Ltd - Confidential167

Fast Path Buffers

DEDBs require the definition of special buffers:• Normal Buffer Allocation (NBA).• Overflow Buffer Allocation (OBA).

The fastpath buffers are used to hold updated DEDB Cls prior to commit processing.For BMPs, the NBA and OBA are defined in the execution statement of the JCL. The NBA should be large enough to hold

all database updates prior to syncpoint.Fastpath uses the overflow buffers when no more NBA buffers are available; the overflow buffers should be used only on

an exception basis. If overflow buffers are continually being allocated, the normal buffer allocation should be increased.

For a BMP://EXEC PGM=DFSRRCOOO,//PARM=(BMP,PGM,PSB,,,,,,,NBA,OBA)

Page 168: IMS DB

© 2009 Wipro Ltd - Confidential168

Fast Path Status Codes

‘FW’ : When the normal buffers are exhausted for a BMP, Fast Path returns a status code of ‘FW’.

The ‘FW’ status code is merely a warning. The application program may choose to :

– Issue a checkpoint to release buffers.

– Ignore the warning.

When ‘FW’ status codes are being issued frequently.

– The application should be modified to issue checkpoints more often.

– The NBA buffer allocation should be increased.

Page 169: IMS DB

© 2009 Wipro Ltd - Confidential169

Fast Path Status Codes Contd..

‘FR’ : When the normal buffer allocation is exhausted, Fast Path uses overflow buffers. When there are simply not enough buffers to continue processing, IMS returns a status code of ‘FR’ and rolls out all changes since the last checkpoint or syncpoint.

At this point, the program has two options:

– Terminate and restart with more buffers.

– Issue checkpoints more frequently.

The ‘FR’ status code has an additional impact: because of the rollback of the changes to the last checkpoint or syncpoint, all database position will be lost except against DEDBs with PROCOPT=P or H, in the latter case, position is re-established after the last commit process.

Page 170: IMS DB

© 2009 Wipro Ltd - Confidential170

Fast Path Status Codes Contd..

‘FD’ : The FD status is returned when two Fast Path processes are in contention. Fast Path chooses one to process and returns a status of ‘FD’ and rolls out all changes since the last checkpoint.

At this point, the program has two options:

– Abend.

– Continue processing (a retry), and hope that the program in contention has completed processing.

The long term solution is to evaluate why the two programs are in a deadly embrace situation and redesign one of the programs to avoid it.

Page 171: IMS DB

© 2009 Wipro Ltd - Confidential171

Fast Path Status Codes Contd..

‘FS’ : The ‘FS’ status code is returned when the DEDB area is out of space. This status can be returned on a database ISRT

or GU messages call.

The ‘FS’ is returned to a BMP on the ISRT call for a root, direct dependent or sequential dependent segment.

The only response is to abend and expand the area; note, the independent overflow part can be expanded with the database

online but the area must be offline.

Page 172: IMS DB

© 2009 Wipro Ltd - Confidential172

Fast Path Status Codes Contd..

‘FH’ : The ‘FH’ status code is returned when the DEDB area is unavailable. This status code can be returned on a database

access or checkpoint call.

When an ‘FH’ status code is returned as a result of a CKKP call, IMS rolls out all updates to the last syncpoint.

The only response is to abend and bring up the database or area or have alternative coding.

Page 173: IMS DB

© 2009 Wipro Ltd - Confidential173

DEDB Area Selection

Some uses for DEDB area selection are:• Limiting batch processes, (BMP), to specific areas to facilitate parallel processing.• Limiting online processes, (MPP, IFP), to specific areas for performance improvement.

The facility to select area for processing is known as range control. Range control is accomplished through the use of control statements.

To implement range control:– The PSB must identify the areas to be selected.– The range control statements must be defined.– A DD statement must be added to the JCL(//DFSCTL).

Page 174: IMS DB

© 2009 Wipro Ltd - Confidential174

PSB Requirements

The PSB must assign a name or label to the areas to be selected. This is done on the PCB statement in one of two ways:PCB=BPGLOAN1,PROCOPT=A,KEYLEN=16,PCBNAME=PCB1 XSENSEG ………...

OrPCB1 PCB=BPGLOAN1,PROCOPT=A,KEYLEN=16 X

SENSEG …………...DEDB DBD

DBD NAME=BPGLOAN1,ACCESS=DEDB, XRMNAME=RMODULE

A1 AREA DD1=BPGAREA1,ROOT=(5,2),UOW=(15,4)A2 AREA DD1=BPGAREA2,ROOT=(5,2),UOW=(15,4)A3 AREA DD1=BPGAREA3,ROOT=(5,2),UOW=(15,4)

Page 175: IMS DB

© 2009 Wipro Ltd - Confidential175

Range Control Statements

Range control statements are placed in the execution JCL to specify the areas to be processed.SETR DB=BPGLOAN1,PCB=PCB1,AREA=(A1)

KEYWORD DEFINITIONS:DB=dbdname – Identifies the database to which the selection applies.PCB=pcbname –The PCB name to which the selection applies; this name must match the name in the PSB.AREA=(areaname1,areaname2,…) – Identifies the area(s) to be selected; range may be specified as areaname1 – areaname3.

Example : //DFSCTL DD *SETR DB=BPGLOAN1,PCB=PCB1,AREA=(A1-A3)

/*


Recommended