Вы находитесь на странице: 1из 175

IMS DB

2009 Wipro Ltd - Confidential

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

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

2009 Wipro Ltd - Confidential

Agenda
Introduction IMS DB Terminology IMS DB Coding Getting Started Additional Database Functions Additional Features Advanced Topics AIB Interface Recovery Functions Fast Path Appendices

2009 Wipro Ltd - Confidential

Introduction To Databases
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.

Customer Database Loan System Account DDA System Addr Addr2 Branch

2009 Wipro Ltd - Confidential

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 Meaning Different name, Same meaning Same name, Same meaning, Different Format With the advent of database, these problems were solved. Database elements have these characteristics: One name One storage location One format One meaning

2009 Wipro Ltd - Confidential

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 Provides data relationship flexibility Provides a database tool kit. (program-data independence)

2009 Wipro Ltd - Confidential

Components Of A DBMS
The components which constitute a DBMS are as follows : Data security facility Restricted access to data Provides for recovery of data Allows multiple concurrent updates Interface Language Retrieves data randomly and sequentially Add and delete data on database Update existing data on database Database tool kit Create the database Backs up/recovers the database Expands/refines the database

2009 Wipro Ltd - Confidential

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.

2009 Wipro Ltd - Confidential

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

2009 Wipro Ltd - Confidential

IMS DB Terminology
Hierarchical Database Terminology Characteristics of an IMS Database Database Definition (DBD) Program Communication Block (PCB) Program Specification Block (PSB) Application Control Block (ACB)

10

2009 Wipro Ltd - Confidential

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.

11

2009 Wipro Ltd - Confidential

Components Of An IMS System


Application program -the user module written in ALC, COBOL or PL/I Database-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 programs view.

MVS MVS Access Module Databases Application Program DL/I Module DBDLIB PSBLIB

Control Block

12

2009 Wipro Ltd - Confidential

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

13

2009 Wipro Ltd - Confidential

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

14

2009 Wipro Ltd - Confidential

Loan Database

ACCOUNT

PAYMENT ADVANCE BILLING RATE

15

FEES

2009 Wipro Ltd - Confidential

Loan Database Contd..

ACCOUNT Segment : Account no-key Customer no. Current balance Total Interest Accrued Total Interest Repaid Total Principal Repaid BILLING Segment: Bill Date-key Payment amount Due FEES Segment : Unkeyed Fee Type Amount Fee

16

2009 Wipro Ltd - Confidential

Loan Database Contd..


. ADVANCE Segment : Advance Date-key Advance Seq. Number-key Amount of advance PAYMENT Segment : Payment Date-key Payment Sequence Number-key Principal Repaid Interest Repaid RATE Segment : Rate Date -key Interest Rate Rate Basis Spread

17

2009 Wipro Ltd - Confidential

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.

18

2009 Wipro Ltd - Confidential

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.

19

2009 Wipro Ltd - Confidential

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.

20

2009 Wipro Ltd - Confidential

IMS/Program Communication
.

MVS MVS Access Modules Databases DBD PCB Mask PCB (in PSB) DBDLIB PSBLIB DL/I Modules

Application Program

ACB
21 2009 Wipro Ltd - Confidential

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

22

2009 Wipro Ltd - Confidential

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

Some common data dictionary products are CA10, IBMs Data Dictionary and Data Manager

23

2009 Wipro Ltd - Confidential

DBD Generation (DBDGEN)


.

Data Dict.

DBD SRCE

DBD GEN

DBD LIB
24 2009 Wipro Ltd - Confidential

Program Communication Block

The PCB is the programs view of database .It defines the database to be accessed and the scope of the programs 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 programs view of the database may be the same or different than the physical view of the database.

25

2009 Wipro Ltd - Confidential

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 segment R To change (replace) a segment D To delete a segment G To read a segment A All except load L To load a database LS 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 Ooption allows a program to read a segment,even if another program is updating it.

26

2009 Wipro Ltd - Confidential

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).

27

2009 Wipro Ltd - Confidential

IO-PCBs
There 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.

28

2009 Wipro Ltd - Confidential

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. PCB SENSEG SENSEG SENSEG SENSEG SENSEG SENSEG PSBGEN TEST PSB TYPE=DB,NAME=BMALOAN1,PROCOPT=A, KEYLEN16 NAME=ACCOUNT,PARENT=0 NAME=BILLING,PARENT=ACCOUNT NAME=FEES,PARENT=BILLING,PROCOPT=G NAME=ADVANCE,PARENT=ACCOUNT NAME=PAYMENT,PARENT=ACCOUNT NAME=RATE,PARENT=ACCOUNT PSBNAME=BMA001,CMPAT=YES X

Note: CMPAT = Y, To guarantee that the program using the PSB will always be

given an IO-PCB at run time.

29

2009 Wipro Ltd - Confidential

PSB-Database Views
Account PSB1 Rate Account PSB2 Billing Fees Account Payment
30 2009 Wipro Ltd - Confidential

PCB DBD=BMALOAN1 SENSEG=ACCOUNT SENSEG=RATE PCB DBD=BMALOAN1 SENSEG=ACCOUNT SENSEG=BILLING SENSEG=FEES

PSB3

PCB DBD=BMALOAN1 SENSEG=ACCOUNT SENSEG=PAYMENT

PSB Generation (PSBGEN)


.

DATA DICT.

PSB SRCE

PSB GEN

PSB LIB
31 2009 Wipro Ltd - Confidential

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 ACB GEN ACBLIB


32 2009 Wipro Ltd - Confidential

DBDLIB

IMS DB Coding
Program ENTRY statement Communication with IMS PCB Masks IO-AREAS SSA Some IMS database access commands GN, GHN GNP

33

2009 Wipro Ltd - Confidential

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.

34

2009 Wipro Ltd - Confidential

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) by Passing a PCB, or Passing an AIB By invoking the EXEC-DLI CICS interface by Passing a PCB, or Passing an AIB

35

2009 Wipro Ltd - Confidential

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 follow Function : What type of call to make PCB : Tells IMS what database to process and has return information from IO-AREA SSA : Tells IMS where to place the data(for retrieval) and where to find the : Segment Search Arguments steer IMS to correct segment by details such as segment name and key values

IMS data(for updates) supplying

36

2009 Wipro Ltd - Confidential

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.

37

2009 Wipro Ltd - Confidential

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.

38

2009 Wipro Ltd - Confidential

IMS PCB
.

DATA BASE

DBD

PSB PCB

APPLLICATION PROGRAM .. .. LINKAGE SECTION. 01 PCB-MASK.

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


39 2009 Wipro Ltd - Confidential

PCB Mask
.

Pos 1-8 9-10 11-12 13-16 17-20 21-28 29-32 33-36 37-xx

Description 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

40

2009 Wipro Ltd - Confidential

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.

41

2009 Wipro Ltd - Confidential

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 Ioarea in the program is too short, IMS will overlay the subsequent storage after Io-area, Its 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.

42

2009 Wipro Ltd - Confidential

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.

43

2009 Wipro Ltd - Confidential

Unqualified SSA
.

POS 1-8

DESCRIPTION

SEGMENT NAME BLANK

01 UNQUAL-SSA. 05 SEGMENT-NAME PIC X(9) VALUE ACCOUNT .


44 2009 Wipro Ltd - Confidential

Qualified SSA
.

POS 1-8 9-9 10-17 18-19 20-XX XX+1

DESCRIPTION SEGMENT NAME LEFT PARANTHESES KEY NAME FROM DBD RELATIONAL OPERATOR VALUE OF KEY FIELD MUST BE LENGTH OF KEY RIGHT PARANTHESES

45

2009 Wipro Ltd - Confidential

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

46

2009 Wipro Ltd - Confidential

Qualified SSA Example

01 ACCOUNT-SSA. 03 SEG-NAME 03 LEFT-PAREN 03 KEY-FIELD 03 FILLER PIC X(2) 03 KEY-VALUE 03 FILLER

PIC X(8) VALUE 'ACCOUNT'. PIC X ALUE '('. PIC X(8) VALUE 'ACCOUNT#'. VALUE 'EQ'. PIC X(6) VALUE '123456'. PIC X ALUE ')'.

NOTE: Field lengths must be exact. IMPORTANT : For better efficiency use Fully qualified calls, and Relational operator of equal.

47

2009 Wipro Ltd - Confidential

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-AREA ACCOUNT-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

48

2009 Wipro Ltd - Confidential

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.

49

2009 Wipro Ltd - Confidential

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.

50

2009 Wipro Ltd - Confidential

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

51

2009 Wipro Ltd - Confidential

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-GHN LOAN-PCB ACCOUNT-AREA ACCOUNT-UNQUAL-SSA. This call would read the next account segment on the database; the segment is held for possible update.

52

2009 Wipro Ltd - Confidential

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.

53

2009 Wipro Ltd - Confidential

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.

54

2009 Wipro Ltd - Confidential

Common Database Status Codes

Informational status codes: BLANKS - The call was successful GA - During unqualified sequential processing, IMS crossed to a higher level 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 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.

of the hierarchy

segment type at

55

2009 Wipro Ltd - Confidential

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

56

2009 Wipro Ltd - Confidential

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-GHNP LOAN-PCB ADVANCE-AREA ADVANCE-UNQUAL-SSA. This call would read and hold the next advance segment which is a child of the account segment.

57

2009 Wipro Ltd - Confidential

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 DLI SCHD PSB (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.

58

2009 Wipro Ltd - Confidential

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.

59

2009 Wipro Ltd - Confidential

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)

60

2009 Wipro Ltd - Confidential

Getting Started

Creating a database BMP vs DLI IMS JCL requirements.

61

2009 Wipro Ltd - Confidential

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

62

2009 Wipro Ltd - Confidential

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, ACCESS=(HDAM,VSAM), RMNAME=(DFSHDC40,001,00000135), 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 DISP=(NEW,CATLG)). IDCAMS or coding X X X

63

2009 Wipro Ltd - Confidential

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

64

2009 Wipro Ltd - Confidential

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.)

65

2009 Wipro Ltd - Confidential

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

66

2009 Wipro Ltd - Confidential

IMS Configurations IMS/DLI

JCL

APPLICATION PROGRAM IMS

DATABASES DB2 TABLES

PRINTOUT

DASD

LOG

67

2009 Wipro Ltd - Confidential

IMS TM

FP TRAN IMS TRAN

IMS CTRL
EMH MSGQ MSDB

DLI

DBRC

IFP

MPR BMP

MSQG DEDB

IMS DB

RECON

68

2009 Wipro Ltd - Confidential

IMS DBCTL

TERM IMS LOGS CICS/ESA TRANS TRANS DBCTL DLISAS (IMS)

ALL DATABASE UPDATES RECORDED ON THE IMS LOGS

DBRC

BMP

BMP

DEDB DATA + LOG


69

FULL FUNC DATABASES

2009 Wipro Ltd - Confidential

BMP VS. DLI

IMS programs can be run two ways: under IMSs 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.

70

2009 Wipro Ltd - Confidential

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

71

2009 Wipro Ltd - Confidential

IMS JCL Requirements


All 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 TYPE APPLICATION PROGRAM PSB TIMEOUT OPTION CONTROL REGION ID DBRC INDICATOR

72

2009 Wipro Ltd - Confidential

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.

73

2009 Wipro Ltd - Confidential

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.

74

2009 Wipro Ltd - Confidential

Samples
Sample DLI Execution JCL Sample BMP Execution JCL

75

2009 Wipro Ltd - Confidential

Additional Database Functions

GU, GHU ISRT REPL DLET

76

2009 Wipro Ltd - Confidential

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)

77

2009 Wipro Ltd - Confidential

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

78

2009 Wipro Ltd - Confidential

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-GHU LOAN-PCB ACCOUNT-AREA ACCOUNT-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)

79

2009 Wipro Ltd - Confidential

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

80

2009 Wipro Ltd - Confidential

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

81

2009 Wipro Ltd - Confidential

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

82

2009 Wipro Ltd - Confidential

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

83

2009 Wipro Ltd - Confidential

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.

84

2009 Wipro Ltd - Confidential

Additional Features Using Command Codes

Path calls Retrieving first and last dependent segments Setting parentage Null command codes.

85

2009 Wipro Ltd - Confidential

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.

86

2009 Wipro Ltd - Confidential

Unqualified SSA W/CC


POS 1-8 9 10 11 DESCRIPTION SEGMENT NAME * COMMAND CODE BLANK

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.

87

2009 Wipro Ltd - Confidential

Qualified SSA W/CC


POS 18 9 10 11 10 17 18 19 20 XX DESCRIPTION SEGMENT NAME * COMMAND CODE LEFT PARENTHESES KEY NAME FROM DBD RELATIONAL OPERATOR VALUE OF KEY FIELD MUST BE LENGTH OF LEY

XX + 1

RIGHT PARENTHESES

88

2009 Wipro Ltd - Confidential

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 -.

89

2009 Wipro Ltd - Confidential

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.

90

2009 Wipro Ltd - Confidential

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

91

2009 Wipro Ltd - Confidential

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

92

2009 Wipro Ltd - Confidential

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

93

2009 Wipro Ltd - Confidential

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

94

2009 Wipro Ltd - Confidential

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?

95

2009 Wipro Ltd - Confidential

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 nonkeyed 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

96

2009 Wipro Ltd - Confidential

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

97

2009 Wipro Ltd - Confidential

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 05 FILLER 05 CC-ACCOUNT 05 FILLER 05 ACCT-KEY 05 FILLER 01 ACCOUNT-IO-AREA 01 GU

VALUE ACCOUNT. PIC X VALUE *. PIC X VALUE C. PIC X VALUE ( . PIC X(6) VALUE 101205. PIC X VALUE ). PIC X (200). PIC X(4) VALUE GU. PIC X(8)

98

2009 Wipro Ltd - Confidential

Concatenated Key Command Code Contd..

LINKAGE-SECTION 01 01 IO-PCB LOAN-PCB. 05 FILLER 05 STATUS-CODE PROCEDURE DIVISION. ENTRY DLITCBL USING IO-PCB LOAN-PCB. CALL CBLTDLI USING GU LOAN-PCB ACCOUNT-IO-AREA ACCOUNT-SSA. PIC XX. PIC X(10). PIC X.

99

2009 Wipro Ltd - Confidential

Advanced Topics

Database Position

IMS Access Methods

Secondary Indexes

100

2009 Wipro Ltd - Confidential

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.

101

2009 Wipro Ltd - Confidential

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.

102

2009 Wipro Ltd - Confidential

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, KEYLEN = 16,POS = M X

103

2009 Wipro Ltd - Confidential

Multi-positioning PCB. Contd.

100056 123451 ACCOUNT

19910105 19901008 19900905 BILLING B 2


104

1990062301 1990042601 ADVANCE

1990052501 PAYMENT

19910103 19901227 19901101 19901031 RATE

FEES

2009 Wipro Ltd - Confidential

Multi-positioning PCB. Contd.

CALL

MULTI

SINGLE

GN ACCOUNT GN BILLING GN ADVANCE GN BILLING

123451 19900905 1990042601 19901008 19900905 1990042601

123451

--(Under next root)

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

105

2009 Wipro Ltd - Confidential

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.

106

2009 Wipro Ltd - Confidential

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. Its 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.

107

2009 Wipro Ltd - Confidential

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.

108

2009 Wipro Ltd - Confidential

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.

109

2009 Wipro Ltd - Confidential

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.

110

2009 Wipro Ltd - Confidential

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.

111

2009 Wipro Ltd - Confidential

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, variablelength or undefined. VSAM ESDS for DASD datasets. Record format can be blocked or unblocked fixed-length or variable-length.

112

2009 Wipro Ltd - Confidential

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 CLSE GSAM-PCB.

113

2009 Wipro Ltd - Confidential

Processing A GSAM Database Contd..

IF GSAM is an output database and the program doesnt 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 OPEN GSAM-PCB. The only function codes available for GSAM are GN for reading and ISRT for adding segments: CALL CBLTDLI USING WS-GN GSAM-PCB SEGMENT-AREA. CALL CBLTDLI USING WS-ISRT GSAM-PCB SEGMENT-AREA.

114

2009 Wipro Ltd - Confidential

GSAM DBD And PSB

An example of a GSAM DBD: DBD NAME=BMAGSAM,ACCESS=(GSAM,BSAM) DATASET DD1=BMAGS001,SIZE=00000,RECFM=FB DBDGEN FINISH END An example of PSB referencing the above GSAM database: PCB TYPE=DB,NAME=BMALOAN1. . PCB TYPE=GSAM,NAME=BMAGSAM,PROCCOPT=G PSSBGEN LANG=COBOL,PSBNAME=BMA001,COMPAT=YES

115

2009 Wipro Ltd - Confidential

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 to 127 segment types.

116

2009 Wipro Ltd - Confidential

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.

117

2009 Wipro Ltd - Confidential

ACCOUNT

DEDB DEDBAREAS AREAS


PAYMENT INTEREST RATE Accts 1-5 (Area 1)

BILLING

ADVANCE

FEES

ACCOUNT

BILLING

ADVANCE

PAYMENT

INTEREST RATE

FEES Accts 6- 10 (Area 2) ACCOUNT INTEREST RATE Accts 11-20 (Area 3)


2009 Wipro Ltd - Confidential

BILLING

ADVANCE

PAYMENT

FEES
118

Access Method Summary

ACCESS METHOD HDAM HIDAM

ORDER

HISAM GSAM DEDB


119

DATABASE STRUCTURE UNORDERED ONE ESDS/ DS GROUP ORDERED INDEX-KSDS PRIMEESDS/GP ORDERED KSDS/ESDS ORDER WRITTEN RANDOM MVS QSAM ONE ESDS/AREA
2009 Wipro Ltd - Confidential

DATA RELATIONSHIP POINTERS POINTERS

SEQUENTIAL SEQUENTIAL POINTERS

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.

120

2009 Wipro Ltd - Confidential

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.

ACCOUNT
TARGET SEGMENT

FEE SECONDARY INDEX


POINTER SEGMENT

BILLING

ADVANCE

PAYMENT

RATE

FEES SOURCE SEGMENT


121 2009 Wipro Ltd - Confidential

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.

122

2009 Wipro Ltd - Confidential

Loan Database With Secondary Index (Source = Target)


CUSTOMER NO SECONDARY INDEX
POINTER SEGMENT

ACCOUNT
TARGET SEGMENT SOURCE SEGMENT

BILLING

ADVANCE

PAYMENT

RATE

The Secondary index pointer segment is built from these fields on the source segment: Customer Number, Account Number. By accessing via the secondary the accounts will now be in order by customer number and account number. FEES index, SOURCE SEGMENT

123

2009 Wipro Ltd - Confidential

Normal Vs. Indexed Access


Normal Access Access thru Index

A=1,C=5 A=2,C=3 A=5,C=2 A=4,C=5 A=3,C=1

C=1,A=3 C=2,A=5 C=3,A=2 C=5,A=1 C=5,A=4

124

2009 Wipro Ltd - Confidential

Normal Vs. Indexed Access Contd..

Normal Access: Random read gets account only

Indexed Access: Random read gets index and account segment

Sequential Access: Segments are retrieved in unknown sequence

Segments are retrieved in customer, account sequence

125

2009 Wipro Ltd - Confidential

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

126

2009 Wipro Ltd - Confidential

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, X KEYLEN=21,PROCSEQ=BPLOAN1 SENSEG NAME=ACCOUNT,PARENT= 0 SENSEG NAME=BILLING,PARENT=ACCOUNT SENSEG NAME=FEES,PARENT=BILLING SENSEG NAME=ADVANCE,PARENT=ACCOUNT SENSEG NAME=PAYMENT,PARENT=ACCOUNT SENSEG NAME=RATE,PARENT=ACCOUNT PCB TYPE=DB,NAME=BMAGSAM,PRODUCT=G PSBGEN LANG=ASSEM,PSBNAME=BPG002,CMPT=YES

127

2009 Wipro Ltd - Confidential

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

128

2009 Wipro Ltd - Confidential

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, KEYLEN=11 SENSEG PSBGEN NAME= ACCTINDX,PARENT=0

LANG=ASSEM,PSBNAME=BPG22,CMPAT=YES

129

2009 Wipro Ltd - Confidential

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.

130

2009 Wipro Ltd - Confidential

ACCOUNT ACCOUNT

BILLING

ADVANCE INTEREST ADVANCE BILLING PAYMENT TARGET SEGMENT INTEREST RATE SOURCE SEGMENT PAYMENT TARGET SEGMENT RATE

SOURCE SEGMENT

FEES

FEES ADVANCE SECONDARY INDEX POINTER SEGMENT

ADVANCE SECONDARY

INDEX POINTER SEGMENT

ADVANCE ADVANCE ACCOUNT ACCOUNT ADVANCE


TARGET SEGMENT SOURCE SEGMENT

BILLING FEES
131

BILLING

ADVANCE

PAYMENT

INTEREST INTEREST PAYMENT RATE

TARGET SEGMENT SOURCE SEGMENT


FEES
2009 Wipro Ltd - Confidential

RATE

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

132

2009 Wipro Ltd - Confidential

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

133

2009 Wipro Ltd - Confidential

Secondary Index Options

SECONDARY RETRIEVE SEGMENTS IN SECONDARY INDEX SEQUENCE RETRIEVE TARGET BASED ON VALUE IN SECONDARY INDEX RETRIEVE SEGMENT BASED ON KEY VALUE PROCESS SECONDARY INDEX AS STANDALONE DATABASE PROCESS USING SECONDARY STRUCTURE

INDEX GN

PROCESSING PTIONS UNQUALIFIED (PROCESQ IN PSB) XDFLD (PROCSEQ IN PSB) SEQUENCE FIELD PCB = SECONDARY INDEX PCB = SECONDARY INDEX

GU

GU GN/GU

GN/GU

134

2009 Wipro Ltd - Confidential

Application Interface Block-AIB

Use of the AIB allows the application program to reference PCBs 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.
135 2009 Wipro Ltd - Confidential

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: DQUERY ENVIRON FIND INQY. 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.

136

2009 Wipro Ltd - Confidential

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 applications 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.

137

2009 Wipro Ltd - Confidential

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.

138

2009 Wipro Ltd - Confidential

AIB Definition

The layout for the AIB is as follows:

Field

Definition

Updated by?
Appl

Description

AIB-IDENTIFIER

PIC X(8) VALUE DFSAIB.

AIB eye-catcher

AIB-LENGTH

PIC S9(8) COMP VALUE 128.

Appl

AIB-SUBFUNCTION AIB-RESOURCE-NAME Filler


139

PIC X(8). PIC X(8). PIC X(16).

Appl Appl

Requested sub function. PCB name.

2009 Wipro Ltd - Confidential

AIB Definition Contd..

Field

Definition

Updated by?
Appl

Description

REQUESTED-OUTPUT-AREALENGTH

PIC S9(8) COMP.

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

ACTUAL-OUTPUT-AREA-LENGTH

PIC S9(8) COMP. PIC X(12). PIC S9(8) COMP. PIC S9(8) COMP.

IMS

The actual length of the data retrieved.

Filler AIB-RETURN-CODE

IMS IMS IMS return code.

AIB-REASON-CODE

IMS

IMS reason code.

140

2009 Wipro Ltd - Confidential

AIB Definition Contd..

Field

Definition

Updated by?

Description

Filler AIB-RESOURCE-ADDR

PIC X(4). PIC S9(8) IMS. Address of the PCB named in the call.

Filler

Example: PSB With Named PCBs

PIC X(48).

Example: Sample Program With AIB And DFSAIBLI

141

2009 Wipro Ltd - Confidential

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 alternate PCB DBQUERY ENVIRON FIND PROGRAM Information such as the status of the IO-PCB or a named Availability status of the database Information on the run-time environment Address of a specific PCB 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

142

2009 Wipro Ltd - Confidential

Recovery Functions

Checkpoint

Restart

143

2009 Wipro Ltd - Confidential

IMS Checkpoint

Appl. Program DL/I

Reads, Adds, Deletes, Updates

DEDB Updates Buffers

Enq Table

Updated Segment Info

Updated, FF Database Not Committed

144

2009 Wipro Ltd - Confidential

IMS Checkpoint Contd..


Checkpoint, Sync Point

App. Program

Buffers

Cleared

DL / I
Log File Enq Table

Before/After Images

Clears Segment Updates

Database

FF Updates Committed DEDB Updates Written

145

2009 Wipro Ltd - Confidential

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 checkpoint IMS sends a message to the operator containing the ID of the checkpoint IMS writes a log record containing checkpoint information, before and after the checkpoint id.

images of the updated segments and

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.

146

2009 Wipro Ltd - Confidential

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.

147

2009 Wipro Ltd - Confidential

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 all database position) Database position is not lost when an FR status code (NBA exhausted) is checkpoint causes the loss of returned.

148

2009 Wipro Ltd - Confidential

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.

149

2009 Wipro Ltd - Confidential

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.

150

2009 Wipro Ltd - Confidential

ABEND

Abend, Rollback

Appl. Program DL / I

Cleared
Buffers

Log File Abend info

Clears PI Enq Pool Segment Updates

Database Unchanged

151

2009 Wipro Ltd - Confidential

IMS Restart

Restart

Appl. Program DL / I

Checkpoint information
Log File

Databases and GSAM Files

IMS Repositions

152

2009 Wipro Ltd - Confidential

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.

153

2009 Wipro Ltd - Confidential

Checkpoint Call

CALL CBLTDLI USING WS-CHKP IO-PCB IO-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.

154

2009 Wipro Ltd - Confidential

Restart Call

CALL CBLTDLI USING WS-XRST IO-PCB IO-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.

155

2009 Wipro Ltd - Confidential

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.

Thats it!

156

2009 Wipro Ltd - Confidential

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.

157

2009 Wipro Ltd - Confidential

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.

158

2009 Wipro Ltd - Confidential

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.

159

2009 Wipro Ltd - Confidential

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.

160

2009 Wipro Ltd - Confidential

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 IMSs 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.

161

2009 Wipro Ltd - Confidential

Restart JCL Requirements

All output files must have an abnormal disposition of CATLG.

Thats 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.

162

2009 Wipro Ltd - Confidential

Restart JCL Requirements Contd..


Lets 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

163

2009 Wipro Ltd - Confidential

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.

164

2009 Wipro Ltd - Confidential

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.

165

2009 Wipro Ltd - Confidential

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 doesnt 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.

166

2009 Wipro Ltd - Confidential

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)

167

2009 Wipro Ltd - Confidential

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.

168

2009 Wipro Ltd - Confidential

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 reestablished after the last commit process.

169

2009 Wipro Ltd - Confidential

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.

170

2009 Wipro Ltd - Confidential

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.

171

2009 Wipro Ltd - Confidential

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.

172

2009 Wipro Ltd - Confidential

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).

173

2009 Wipro Ltd - Confidential

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 X SENSEG ... Or PCB1 PCB=BPGLOAN1,PROCOPT=A,KEYLEN=16 X SENSEG ... DEDB DBD DBD NAME=BPGLOAN1,ACCESS=DEDB, X RMNAME=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)

174

2009 Wipro Ltd - Confidential

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 AREA=(areaname1,areaname2,) Identifies the area(s) to be selected; range areaname3. Example : //DFSCTL DD * SETR DB=BPGLOAN1,PCB=PCB1,AREA=(A1-A3) /*

match the name in the PSB. may be specified as areaname1

175

2009 Wipro Ltd - Confidential

Вам также может понравиться