860 likes | 1.75k Views
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
E N D
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
Introduction • IMS 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.
Hierarchical Database & Terms The data relationship in IMS/DB is Hierarchical. • Hierarchical 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.
Hierarchical Database ACCOUNT BILLING ADVANCE PAYMENT RATE PAYCASH FEES PAYCHEQ CHEQUE CASH
Terminology : • 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.
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.
IMS DB Components • Components 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.
MVS DL/I MODULES MVS ACCESS MODULES DATA BASES PCB MASK DBD DBDLIB PSBLIB PCB (In PSB) APPLICATION PROGRAM APPL. CONTROL BLOCKS
IMS 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.
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.
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 *****************************************************
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
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.
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.
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-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.
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.
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
*********************************************************** * 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
****************************************************************************************************************************** * 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
*********************************************************** * 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
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.
IMS DB Program Coding This 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
Program 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.
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.
Communication 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
PLITDLI 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..
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.
PCB & 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.
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
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
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).
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.
IO-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.
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.
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.
UNQUALIFIED SSA POS DESCRIPTION 1-8 SEGMENT NAME 9 BLANK Example 01 UNQUAL-SSA. 03 segment-name pic x(9) value ‘ACCOUNT’.
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
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 ‘)’.
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 GU LOAN-PCB BILLING-IO-AREA ACCOUNT-SSA BILLING-SSA.
Segment & 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..
IMS DB Functions IMS Databases can be processed one of two ways : • Sequential 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 Processing : The database is not retrieved in any order. The application program asks for a specific segment identified by some field in the segment.
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 : get next • GHN : get hold next • GNP : get next within parent • GHNP : get hold next within parent • GU : get unique • GHU : get hold unique • ISRT : insert a segment • DLET : delete a segment • REPL : replace a segment
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.
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.
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.
PARANTAGE : • 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.
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.
The most common Status 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..
‘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.