ims/db overview

53
1 IMS/DB Overview

Upload: vance-acosta

Post on 31-Dec-2015

264 views

Category:

Documents


19 download

DESCRIPTION

IMS/DB Overview. CONTENTS. Introduction 2 Hrs Hierarchical Database & Terms 2 Hrs IMS DB components 4 Hrs IMS DB program coding 4 Hrs IMS DB Functions 2 Hrs IMS Status codes 2 Hrs - PowerPoint PPT Presentation

TRANSCRIPT

Page 1: IMS/DB  Overview

1

IMS/DB Overview

Page 2: IMS/DB  Overview

2

CONTENTS• Introduction 2 Hrs

• Hierarchical Database & Terms 2 Hrs

• IMS DB components 4 Hrs

• IMS DB program coding 4 Hrs

• IMS DB Functions 2 Hrs

• IMS Status codes 2 Hrs

• IMS Processing Modes 2 Hrs

Page 3: IMS/DB  Overview

3

Introduction• IMS DBIMS DB

Information Management System - DataBase Used for creating and managing the physical storage and retrieval of data which is organized using the hierarchical data structure.

• IMS DB is the part of the IBM’s software product IMS/VS (Information Management System/ Virtual Storage).

• IMS/VS is having two components :

– IMS/DB : Used to create and manage the databases.– IMS/DC : Used to handle the online transaction

processing.

Page 4: IMS/DB  Overview

4

Hierarchical Database & TermsThe data relationship in IMS/DB is Hierarchical.• Hierarchical DatabaseHierarchical Database : It’s a Tree structure.

– Relationship of data is predefined by its structure.

– Program Traverses the structure to access the data.

– So all the access is through the predefined paths.

– Its major advantage is speed of access as path is predefined.

– Disadvantage is the reduced flexibility inherent in a pre-defined structure and its complexity of design.

Page 5: IMS/DB  Overview

5

Hierarchical Database

PAYCASH

ACCOUNT

PAYMENT

RATE

CASH

ADVANCE

CHEQUE

PAYCHEQ

BILLING

FEES

Page 6: IMS/DB  Overview

6

• TerminologyTerminology : :– Segment : Smallest unit of data an application can

retrieve from a database, contains one or more fields of data.

– Root : The entry point to the database. No parent.

– Parent : Segment with dependent segments.– Child : Dependent segment of parent

– Twin : Multiple occurrences of a dependent segment

– Key : Unique identifier of a segment

– Concatenated Key : The concatenation of all the keys of the parents with the key of the

segment.

– Database Record : One root with all of its children.– Search Field : Any field defined in the database

definition.

Page 7: IMS/DB  Overview

7

– Sequential processing sequence of an IMS database is Top-to-Bottom, Front-to-Back and Left-to-Right.

– An IMS database consists of some number of database records. The Size of the database is limited only by the constraints of VSAM and DASD.

– A maximum of 15 levels are allowed.

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

– IMS keeps track of its place in the database after every call. So it is important to keep database position in mind.

– IMS always moves forward, never backward.

Page 8: IMS/DB  Overview

8

IMS DB Components• Components of an IMS SystemComponents of an IMS System

– APPLICATION Program : The user modules written in Assembler, Cobol, PL/1

– DATABASE : The data accessed by one or more application.

– DL/I Modules : The modules which interface between the MVS access modules and the application program. All access to IMS databases is through this module. So every time a database is read or updated the DL/I interface must be called.

– DL/I Control Blocks : The executable modules which define the databases and the application program’s view.

Page 9: IMS/DB  Overview

9

MVS ACCESS MODULES

APPLICATION PROGRAM

DL/I MODULES

APPL. CONTROL BLOCKS

DBDLIB

PSBLIB

DATA BASES

MVS

DBD

PCB

(In

PSB)

PCB

MASK

Page 10: IMS/DB  Overview

10

• IMS Database TerminologyIMS Database Terminology : :

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

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

– PSB( Program Specification Block) Contains all the PCBs for a specific program.

– ACB( Application Control Block)An Internal Control Block containing DBD and PSB information.

Page 11: IMS/DB  Overview

11

• DATABASE DEFINITION (DBD)DATABASE DEFINITION (DBD)

– The DBD contains the database name and defines the actual tree structure.

– The Information given in the DBD includes :

• Database name• Segment name• Key field names, lengths and locations• Search field names, lengths and locations• IMS and MVS access methods• DD names (Logical name for datasets)

– DBDs are assembled and resides in DBDLIBs. The process of assembling is called DBDGEN.

Page 12: IMS/DB  Overview

12

Example of DBD source:

TITLE 'ASSEMBLE OF DBDNAME=OUTABLDB ' * DSNAME=CAPSMISC.TAMRA.DBDLIB * VOL=DMAS82 PRINT NOGEN DBD NAME=OUTABLDB, ACCESS=(HDAM,VSAM), RMNAME=(OUTB80RM,1,750), PASSWD=NO, ************************************************************* DATASET GROUP

NUMBER 1 ************************************************************ DSG001 DATASET

DD1=OUTABLD0,DEVICE=3380 SIZE=(4096),SCAN=3 ***************************************************** * SEGMENT NUMBER 1 *****************************************************

Page 13: IMS/DB  Overview

13

SEGM NAME=OWTB58RT,

PARENT=0, BYTES=5,

PTR=(TWIN,,,,) FIELD NAME=(OWTBROOT,SEQ,U), START=1, BYTES=5, TYPE=C ******************************************** SEGMENT NUMBER 10 * ******************************************* SEGM NAME=OWTMRSEG, PARENT=((OWTB58RT,SNGL)), BYTES=1250,

PTR=(NOTWIN,,,,) DBDGEN FINISH END

Page 14: IMS/DB  Overview

14

• PROGRAM COMMUNICATION BLOCK (PCB)PROGRAM COMMUNICATION BLOCK (PCB)

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

– It defines the segments which are available to the program. So if a PCB does not contain one or more of the segments in a database, it means the program is ‘not sensitive’ to these segments.

– So only the segments defined in PCB will be accessed and these are called as sensitive segments.

– The PCB also states what type of activities are allowed on respective segments : add, update, delete or read.

Page 15: IMS/DB  Overview

15

– The processing options allowed in a PCB are :

• I : To add/insert a segment.• R : To change/replace a segment.• D : To remove/delete a segment.• G : To read/get a segment.• A : All functions except load• L : To initialize(Load) database• LS : Load the database but database must be

in key seq..• GO : Read only. So to read a segment, even if

another program is updating it.

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

Page 16: IMS/DB  Overview

16

– The processing option can be coded at the database level so will be applicable for all the sensitive segments or it can be defined at the segment level.

– IO-PCBIO-PCB

It is also called as TP-PCB. It is used in online transactions to process messages to/from the terminal and in batch programs to take checkpoints.

Page 17: IMS/DB  Overview

17

• PROGRAM SPECIFICATION BLOCK (PSB)PROGRAM SPECIFICATION BLOCK (PSB)

– A PSB is the set of all PCBs that a program is going to use.

– The program can access only databases which are defined in the PSBs and can perform only those operations which are defined under Procopt.

– PSBs are assembled and resides in PSBLIBs. The process of assembling is called PSBGEN.

Page 18: IMS/DB  Overview

18

Example of PSB source:

TITLE 'ASSEMBLE OF PSBNAME=#FNT15 ' * DSNAME=CAPSMISC.TAMRA.PSBLIB * VOL=DMAS51 ************************************************************ * PCB NUMBER 1 TP NUMBER 1 ************************************************************ PCB TYPE=TP, LTERM=, ALTRESP=NO, SAMETRM=NO, MODIFY=YES,

EXPRESS=NO

Page 19: IMS/DB  Overview

19

*********************************************************** * PCB NUMBER 2 DB NUMBER 1 *********************************************************** PCB TYPE=DB,

DBDNAME=FKTSTMDB, PROCOPT=AP, KEYLEN=12, PCBNAME=PCB2, LIST=YES SENSEG NAME=FKSGROOT, PARENT=0 SENSEG NAME=FKSG02ND, PARENT=FKSGROOT SENSEG NAME=FKSG03RD, PARENT=FKSG02ND

Page 20: IMS/DB  Overview

20

**************************************************************** PCB NUMBER 3 DB NUMBER 2 ***************************************************************PCB TYPE=DB, DBDNAME=FKTSTPDB, PROCOPT=AP, KEYLEN=12, PCBNAME=PCB3, LIST=YES SENSEG NAME=FKSGROOT, PARENT=0 SENSEG NAME=FKSG02ND, PARENT=FKSGROOT SENSEG NAME=FKSG14TH, PARENT=FKSG13TH, PROCOPT=A

Page 21: IMS/DB  Overview

21

*********************************************************** * PCB NUMBER 4 GSAM NUMBER 1 *********************************************************** PCB TYPE=GSAM,

NAME=CSIBCHIN, PROCOPT=G *********************************************************** * PCB NUMBER 5 GSAM NUMBER 2 *********************************************************** PCB TYPE=GSAM, NAME=CSIQLOAD, PROCOPT=L

PSBGEN PSBNAME=#FNT15, LANG=ASSEM, IOASIZE=512, CMPAT=YES END

Page 22: IMS/DB  Overview

22

• APPLICATION CONTROL BLOCK (ACB)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 the PSB and DBDs.

– For batch programs, IMS dynamically creates the ACB from the PSB and DBD.

– For online programs, an ACB gen is run which merges the DBD and PSB and creates the ACB.

Page 23: IMS/DB  Overview

23

IMS DB Program CodingThis section brief how to actually code application programs which access IMS databases. The following topics will be covered to have a better understanding of an IMS program:

– Program Entry Statement– Communication with IMS– PCB MASK– IO-AREA– SSA– Segment & SSA Copybooks

Page 24: IMS/DB  Overview

24

• Program Entry StatementProgram Entry Statement

– This is the starting point of your program. It should be the first executable statement in your IMS program. So in Cobol it follows the Procedure Division statement.

– IMS passes control to the application program at the ENTRY statement in the program; the application program returns control to IMS when finished by issuing a GOBACK.

ENTRY ‘DLITPLI’ USING IO-PCB

LOAN-PCB

PAY-PCB.

Page 25: IMS/DB  Overview

25

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

– For IMS programs that also uses DB2, the entry statement is not specified. Instead the PCBs are coded in the Procedure Division statement.

PROCEDURE DIVISION USING IO-PCB

LOAN-PCB

PAY-PCB.

Page 26: IMS/DB  Overview

26

• Communication with IMSCommunication with IMS

– Access to an IMS database is gained through the Data Language Interface, commonly known as DLI.

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

• By making a call to the IBM supplied program CBLTDLI & passing an PCB

• By invoking the EXEC-DLI CICS interface & passing a PCB

Page 27: IMS/DB  Overview

27

PLITDLI callPLITDLI call : :

CALL ‘PLITDLI’ USING PARM-COUNT

FUNCTION

PCB

IO-AREA

SSA.

– Parm-count tells how many parameter follow. This is a 4-byte binary field defined as S9(8) COMP.

– Function Tells DLI what type of call to make.

Contd..

Page 28: IMS/DB  Overview

28

– PCB tells IMS what database to process and has return information from IMS.

– IO-AREA tells IMS where to place the data (for retrievals) and where to find the data (for updates).

– SSA (Segment Search Argument) steer IMS to correct segment by supplying details such as segment name and key values.

Page 29: IMS/DB  Overview

29

• PCB & PCB-MASKPCB & PCB-MASK

– The PCB describes the results 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 in the form of PCB-MASK. One PCB-MASK for each PCB.

– Each PCB-MASK is an 01 level record 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 consequence.

Page 30: IMS/DB  Overview

30

– Thru PCB IMS communicates with the program. The application program must interrogate the PCB to determine the success or failure of the call.

– So the structure of IMS application program will be as follows:

::

01 PCB-MASK.:

PROCEDURE DIVISION.ENTRY ‘DLITCBL’ USING PCB-MASK

:DL/I CALLS

Page 31: IMS/DB  Overview

31

– PCB MASK structure:

POS DESCRIPTION

1-8 DATABASE NAME

9-10 SEGMENT LEVEL

11-12 STATUS CODE

13-16 PROCESSING OPTIONS

17-20 RESERVED FOR DL/I

21-28 SEGMENT NAME

29-32 KEY FEEDBACK LENGTH

33-36 NO. OF SENSITIVE SEGMENT

37-XX KEY FEEDBACK AREA

Page 32: IMS/DB  Overview

32

– PCB MASK EXAMPLE:

01 LOAN-PCB.03 DBD-NAME PIC X(8).03 SEG-LEVEL PIC 99.03 STATUS-CODE PIC XX.03 PROC-OPT PIC X(4).03 FILLER PIC X(4).03 SEG-NAME PIC X(8).03 KEY-FEED-LEN PIC S9(8) COMP.03 SEN-SEG PIC S9(8) COMP.03 KEY-FEED PIC X(100).

Page 33: IMS/DB  Overview

33

– The status-code is most important and must be checked after every call made to the IMS.

– The segment-level and the segment-name contain the level and name of the last segment IMS processed.

– The key-feedback area contains the full key of the last segment processed.

– The IMS itself fills in the PCB with information;the application program never moves anything to it.

Page 34: IMS/DB  Overview

34

• IO-AREASIO-AREAS

– The IO-AREA passed to the IMS is the storage location for the segment to be processed. It’s a two-way communication.

– For retrieval calls, the IMS places the segment retrieved in the IO-AREA.

– For update calls, the program must place the update segment in the IO-AREA and IMS will use it to update the database.

– The IO-AREA length should be more enough to hold the longest segment used in the program, otherwise IMS will overlay the subsequent storage after the IO-AREA.

Page 35: IMS/DB  Overview

35

• SEGMENT SEARCH ARGUMENT (SSA)SEGMENT SEARCH ARGUMENT (SSA)

– SSA 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 pgm provides an

SSA telling IMS what segment to access

• UNQUALIFIED CALL : The application pgm does not

provide an SSA. IMS will determine

what segment to process.

Page 36: IMS/DB  Overview

36

– For Qualified calls, there are two types of SSAs :

• UNQUALIFIED SSA : Only the segment name is provided

• QUALIFIED SSA : The segment name, key value and other information is provided by the application.

Page 37: IMS/DB  Overview

37

– UNQUALIFIED SSA

POS DESCRIPTION

1-8 SEGMENT NAME

9 BLANK

Example

01 UNQUAL-SSA. 03 segment-name pic x(9) value ‘ACCOUNT’.

Page 38: IMS/DB  Overview

38

– QUALIFIED SSA

POS DESCRIPTION

1-8 SEGMENT NAME

9 LEFT PARENTHESIS

10-17 KEY NAME FROM DBD

18-19 RELATIONAL OPERATOR

20-XX VALUE OF KEY-FIELD

XX+1 RIGHT PARENTHESIS

Page 39: IMS/DB  Overview

39

Example

01 ACCOUNT-SSA.

03 seg-name pic x(8) value ‘ACCOUNT’.

03 left-paren pic x value ‘(’.

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 value ‘)’.

Page 40: IMS/DB  Overview

40

So now we are ready to see a full fledged DLI call. The example below will retrieve exactly one segment with a specific key value supplied by the call.

CALL ‘PLITDLI’ USING GULOAN-PCB

BILLING-IO-AREA

ACCOUNT-SSA

BILLING-SSA.

Page 41: IMS/DB  Overview

41

• Segment & SSA CopybooksSegment & SSA Copybooks

– The structure of segments are generally kept in copybook members and these copybook members are used in the IMS program by using COPY statement.

– Similarly it’s a good practice to code the SSAs in a separate copybook member (one for each segment) so there is no need to code them again and again inside the programs.

– In this case then you need to copy the SSA member by COPY statement and then just pass the values in key-value-field and use it in call..

Page 42: IMS/DB  Overview

42

IMS DB Functions

IMS Databases can be processed one of two ways :

• Sequential ProcessingSequential Processing : : The database 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 ProcessingRandom Processing : : The database is not retrieved in any order. The application program asks for a specific segment identified by some field in the segment.

Page 43: IMS/DB  Overview

43

These two processing methods can be used to retrieve, delete, add or to change the segments. Several Call functions are available in IMS to process the segments.

• GN GN : get next : get next• GHN GHN : get hold next : get hold next

• GNP GNP : get next within parent : get next within parent• GHNP GHNP : get hold next within parent: get hold next within parent

• GU GU : get unique : get unique• GHUGHU : get hold unique : get hold unique

• ISRTISRT : insert a segment : insert a segment• DLETDLET : delete a segment : delete a segment• REPLREPL : replace a segment : replace a segment

Page 44: IMS/DB  Overview

44

– Hold means to hold the segment in exclusive mode for a possible update.

– Within parent means to retrieve the next dependent segment of this parent.

– Unique asks IMS to retrieve a specific ( Unique) segment in the database.

– An unqualified get next retrieves the next sensitive segment in the hierarchy.

– An qualified get next retrieves the next sensitive segment matching the search criterian.

Page 45: IMS/DB  Overview

45

– When inserting, or adding, a root segment, 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 the key of the parent may 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. MS takes the key-info fron io-area.

Page 46: IMS/DB  Overview

46

– When replacing a segemnt the application must have first read and held the segment for update (GHU, GHN, GHNP).

– So no qualification is allowed on replace.

– The key-field on a segment can never be changed.

– When deleting a segemnt again the application must have first read and held the segment for update (GHU, GHN, GHNP).

– When a parent segment is deleted all dependent segments are always deleted automatically.This is true even if the application pgm is not sensitive to the dependent segments in the PCB of the PSB.

Page 47: IMS/DB  Overview

47

PARANTAGEPARANTAGE : :– Parantage is set by the GNP or GHNP functions.

– These commands sequentially process the database but limit the segments to dependent segments of the established parent.

– The Seq. Search starts at the current position and stops at the last dependent segment of the parent.

– Parentage must have been set prior to issuing GNP/GHNP request. This can be done by two ways :

• By retrieving a parent segment with the help of GN, GU etc. Command. Parentage will be set at the last segment read.

• By using Command codes.

Page 48: IMS/DB  Overview

48

IMS Status Codes• After every call IMS returns a status code in the PCB. The status

code describes the success or failure of the call.

• The status code should be checked after every call to IMS.

• If an unexpected status code is encountered, the program should abend.

• IMS Status code can be divided into three categories :

Informational, Program error, IO Error.

• For calls using XXXTDLI all status codes are returned to the application program.

Page 49: IMS/DB  Overview

49

The most common Status CodesStatus Codes are as follows:

BLANK - The call was successful.

‘GB’ - End of database reached.

‘GE’ - Segment not found.

‘GK’ - During unqualified call IMS crossed to a next segment type at the same level.

‘GA’ - During unqualified call IMS crossed to higher level of hierarchy.

‘AD’ - Function code is invalid .

‘AK’ - Field name does not match the name in DBD.

Cont..

Page 50: IMS/DB  Overview

50

‘AI’ - Open error; probably a missing DD statement.

‘DA’ - Pgm tried to change the key value on a replace or delete call.

‘DJ’ - Pgm tried to replace/delete a segment that had not been held.

‘II’ - Pgm tried to insert a segment that is already exist.

‘AJ’ - The SSA is coded incorrectly.

Page 51: IMS/DB  Overview

51

IMS Processing ModesIMS Processing can be done thru three different modes :

DL/I - It’s a pure batch processing and database will be mentioned in the form of DD statement. i.e. The databases will be used in when they are not up.

BMP - ‘Batch Message Processing’. In BMP mode the application run in conjunction with an IMS control region. An MVS started task controls all online and BMP programs. Although these jobs are run thru batch mode but they use to run on database directly. i.e. BMP jobs uses online databases. BMP jobs can be hourly, daily, weekly, monthly etc.

Page 52: IMS/DB  Overview

52

MPP - ‘Message Processing Program ’ In MPP mode the application run is a online

application which updates/enquire database in pure online mode. All the transactions made by various terminals accumulated in the form of messages in a message queue and then the IMS schedular process all those messages against online databases thru online programs. All MPP request are handled thru the IMS online region.

Page 53: IMS/DB  Overview

53

SUMMARY

The course is starting with the introduction of IMS terminology and covering all areas essential to start writing a IMS DB program.

The topics covered in the course are Intro to IMS DB components, Programming techniques, Various functions and status codes in IMS and finally a brief about the processing mode available in the IMS world.

This course is definitely a good start to sail through the IMS ocean and to explore its power and complexities.