Download as ppt, pdf, or txt
Download as ppt, pdf, or txt
You are on page 1of 59

IMS DB

Objective:To provide an insight into the fundamentals of IMS DB

Course Details
No: Name C018 IMS DB Fundamentals

Introduction IMS is a hierarchical Database. This material provides an insight into the Fundamentals of IMS DB and DL/I calls.

Course Details
Pre-Requisite Knowledge of Databases
SRA videos-32804/32807

Target Audience Mode of Training Evaluation Criteria

To be decided by the CR and SWS Class Room Attendance > 80 % and/or (Case study Completion or Test score > 50 %)

Lesson Plan
M# Topic Time(hrs) 1 Introduction to IMS DB 1 2 Introduction to IMS DB 3 3 4 5 6 7 8 9

Module 1- Introduction
Topics Duration : 1 hour
Different type of Databases What is IMS DB ? Terminology :- Segments, PSBs, PCBs Main elements in an IMS application program

Module 2- Introduction
Topics DL/I calls Duration : 3 hours

Course Reference Material


DPEC/CBTS:

Web Sites: Names Of Books:

IMR standards to be followed for this topic are available in:

Faculty Who Can Handle this Module:

Peer Review
This material is made for EBSCO project training program. As it is project specific, it will not be peer reviewed.

Module 1- Introduction
Topics

Duration : 1 hour

Different type of Databases What is IMS DB ? Segments, PSB PCBs, DBD

Introduction
DBMS:-

Types of DBMS Hierarchical Network Relational

IMS /VS : Information Management System / Virtual Storage Hierarchical DBMS IMS DB is to DB2 as DL/I is to SQL. IMS DB is DBMS and DL/I is DML IMS DBs use VSAM data sets, either KSDS or RRDS to store data.

DEALER

Parent of Model segment

MODEL

Child(dependent of dealer Segment Parent of order,stock,and Sales Segments

ORDER

STOCK

SALES

Dependents of Model Segment

Segments
Unit of data that DL/I transfers to and from your program in an I/O operation. Segment Type: Category of data Segment Occurrence: One specific segment of a particular type of data. Unlimited occurrences of each segment type. Root Segment,Parent-child, Twin Segment

One Root Segment (with many instances) Each root segment - Unique Key Root Segment - Entry point to DB IMS the limit is 15 levels, from root to lowest child.

DBDs
DBDs defines the individual segment types to be contained in the data base and their relationship. What is DBDGEN? DBDLIB

PSBs
DBA designs a selected or logical view of the database for each program that will access it. Each programs view is then recorded in a control block called Program communication Block. PCB also indicates the access type the program has w.r.t segment, RD/UPD/WR/DEL

Example of DBD
Explain this with a DBD of the project, for which the training is being conducted.

Example of PSB

PCB TYPE=DB, DBDNAME=ANDODBP, PROCOPT=GO, KEYLEN=25 SENSEG NAME=OHSOMST, PARENT=0 SENSEG NAME=OHSOCTL,PARENT=OHSOMST SENSEG NAME=OHSOADJ,PARENT=OHSOCTL SENSEG NAME=OHSOAEX,PARENT=OHSOADJ SENSEG NAME=OHSOCLM,PARENT=OHSOCTL PSBGEN LANG=COBOL, PSBNAME=ANBFSTO END

PSBs
A DBD describes the content and hierarchical structure of the physical or logical database. DBDs also supply information to IMS in order to help in locating segments. A PSB specifies the database segments an application program can access and the functions it can perform on the data, such as read only, update,or delete. Because an application program can access multiple databases,PSBs are composed of one or more program control blocks (PCBs). The PSB describes the way a database is viewed by your application program

p
p

PSB

DBD1

DB1

PCB DBD2 p g PCB DB2

JCL - IMS DB Pgm


//OHDLYADJ PROC //STEP0015 EXEC PGM=DFSRRC00, // PARM=(DLI,OHADJR01,ANBFSTO,5) //STEPLIB DD DSN=IMS.RESLIB,DISP=SHR //DFSRESLB DD DSN=IMS.RESLIB,DISP=SHR //DPKTABLE DD DSN=BMC.DPK.DPKTABLE,DISP=SHR //IMS DD DSN=IMS.DBDLIB,DISP=SHR // DD DSN=IMS.PSBLIB,DISP=SHR //ANDODBD DD DSN=ANDODBD.MST.DB,DISP=SHR //ANDADBD DD DSN=VOH.ASAN.PROD.ESDS,DISP=SHR

Linkage Section
DL/I
passes control to your program, it also supplies the address of each PCB in PSB.

PCB Masks: Linkage section definition of a PCB is called a PCB

PCB Masks
01 PCB-AREA-1. 02 02 02 02 02 02 02 02 02 DBD-NAME-1 SEG-LEVEL-1 STATUS-CODE-1 PROCESS-OPTIONS-1 FILLER SEG-NAME-FDBK-1 LENGTH-FB-KEY-1 NUMB-SENS-SEGS-1 KEY-FB-AREA-1 PIC PIC PIC PIC PIC PIC PIC PIC X(8). XX. XX. X(4). S9(5) COMP. X(8). S9(5) COMP. S9(5) COMP.

PIC X(75).

Entry Stmt
Entry stmt provides a mechanism for DL/I to transfer control to your pgm. GOBACK: To be coded to pass control back to DL/I after pgm is completed. ENTRY DLITCBL USING pcb-name1, pcb-name2.

Module 2
Topics Duration : 3 hours DL/I - dB Call processing DL/I calls

DL/1 DB processing
Application pgm DL/1

OS access methods Data Base

Application Programming
Using a sample program and explain the links between Linkage Section, Entry Stmt & JCL.

DL/1
A DL/I call consists of a call statement and a list of parameters. The parameters provide information that IMS needs to execute the call. This information consists of the call function, the name of the data structure that IMS uses for the call, the data area in the program into which IMS returns data, and any condition that the retrieved data must meet.

Example of DL/1 Call


Call CBLTDLI Using DLI-GU, Inventory-PCB, inventory-seg, vendor-ssa, item-ssa, stock-location-ssa.

DL/1 Calls
CLSE DEQ DLET FLD GHN GHNP GHU GN GNP GU ISRT OPEN POS REPL GSAM Close Dequeue Delete Field Get Hold Next Get Hold Next in Parent Get Hold Unique Get Next Get Next in Parent Get Unique Insert GSAM Open Position Replace

Get Functions
Similar to Read stmt Two groups of Get Functions GU, GN, GNP GHU, GHN, GHNP Hold Functions: Specify an intent to update a segment after you retrieve it.

SSA
Segment Search Argument: Specifies info required by IMS to process a Dl/1 call.

DL/1 call : Qualified / Unqualified SSAs : Qualified SSA Unqualified SSA Unqaulified SSA: Contains only segment name Qualified SSA: Includes one or more more than one qualification to identify a segment occurrence.

Unqualified SSA
Unqualified SSA format
1

Segment Name 01 Unqualified-ssa. 03 unqual-ssa-segment name Pic x(8). 03 Filler Pic x value space.

Qualified SSA
18 19 20 n n+1

(
Segment name Field name Relational Operator Search value

COBOL code for a qualified SSA 01 VENDOR-SSA. 05 FILLER 05 FILLER 05 VENDOR-SSA-CODE 05 FIILER

PIC PIC PIC PIC

X(9) VALUE INVENSEG(. X(10) VALUE INVENCOD =. X(3). X VALUE ).

Relational Operators
Equal To Not Equal To Greater than Less than or equal to Greater than Or equal to Less than EQ NE GT LE GE LT <= => < <= =

Example Of Qualified SSA


Move Ws-vendor to Vendor-SSA-Code. Call CBLTDLI USING DLI-GU INVEN-PCB-MASK INVENTORY-VEN-SEG VENDOR-SSA.

Command Codes
Extend the functions of DL/1 calls. Using Command codes help in performance improvement Some command codes: D Path Call F First Occurrence L Last Occurrence N Path call ignore - Null Command Code

Qualified SSA
Qualified SSA format with a single command code
1

8 9 10 11 12

19 20 21 22

N+1

*Segment name

*-

...
Search Value

Field name Relational operator Command code

Status Code
GE : Segment Not Found GB: End of dB

Random Processing -GU


Used for Direct data retrieval or to establish position in a dB for subsequent sequential retrieval. GU call is independent of the position established by previous calls. Fully qualified Call:- Complete set of SSAs to retrieve a segment includes one for each segment level in hierarchy to the segment type you want to retrieve. The lowest SSA you specify is the one for the segment type you want to retrieve.

Random Processing -GU


Fully qualified Call:Call CBLTDLI using DLI-GU, inventory-pcb-mask inventory-stock-loc vendor-ssa Item-ssa stock-location-ssa. GU processing with fields other than sequence fields. (Possible. Depends on DBA settings. Usually, FIRST.)

GU without full set of SSAs


Example: Locate ITEM = 523 in Database. Issue a GU call with unqualified Vendor SSA, and a qualified ITEM SSA. What happens if you issue a GU call without any SSAs ? Expected Status Code: Blanks / GE

Sequential Retrieval:GN
Basic Sequential Processing: GN After a successful call, DB position is immediately before segment occurrence in the hierarchical sequence. GN call moves forward through the database from the position established by the previous call.

Example:
Discuss Program 45. (Page 52).

Status Codes: GA

Example: Retrieve all location segment occurrences that have a sequence field value NYC. Call CBLTDLI using GN IO-PCB SEGMENT-IO STOCK-LOCATION-SSA.

GNP
Sequential retrieval within established parentage. Similar to GN, except it retrieves segments that are subordinate to current established parent. Establish Parentage by successful GU or GN call. Segment returned by this call is parent. Discuss 5.1 (Page 77 & Page 88) Status Code: GP (If GNP is issued without establishing parentage).

Retrieval by Command Codes


F Command Code: When you issue a call with an SSA that includes the F command code, the call processes the first occurrence of the segment. L Command Code: When you issue a call with an SSA that includes the L command code, the call processes the Last occurrence of the segment. Discuss: F command Code with GN / GNP What about F command code with GU call? What about L command code with GU call?

D Command Code
DL/I operates on the lowest level segment you specify in an SSA. Ref Ex: Program 94 Path Call: A call with an SSA that includes the D command code Improves Performance of Pgms PROCOPT in PCB should have P How to exclude a segment from a path call.

C Command Code
If only the Lowest level segment is required to be retrieved. No need to code separate SSAS. Just one single SSA DL/I operates on the lowest level segment you specify in an SSA.

Example: C Command Code


01 location-ssa. 05 filler pic x(11) value INLOCSEG*C(. 05 location-ssa-vendor pic x(3). 05 location-ssa-item pic x(5). 05 location-ssa-location pic x(3). 05 filler pic x value ).
Call CBLTDLI USING GU INVENTORY-PCB-MASK INVENTORY-STOCK-LOC-SEGMENT LOCATION-SSA.

ISRT Call
CALL CBLTDLI USING DLI-ISRT INVENTORY-PCB LOCATION-SEGM UNQUAL-SSA. USING DLI-ISRT INVENTORY-PCB LOCATION-SEGM VENDOR-SSA ITEM-SSA UNQUAL-SSA.

CALL CBLTDLI

Status Codes - ISRT


Application Pgm: Blank GE II Load Processing LB LC LD LE

Get Hold Functions


3 GET HOLD Functions: GHU, GHN, GHNP Before Replace / Delete is done, the segment should be retrieved by one of these calls. The next Call should be to delete / replace. If you issue any intervening calls, the effect of get hold call is lost. Function Code for: Insert is ISRT Delete is DLET

REPL
CALL CBLTDLI USING GHU INVENTORY-PCB Location-SEGMENT VENDOR-SSA ITEM-SSA LOCATION-SSA. . . CALL CBLTDLI USING REPL INVENTORY-PCB LOCATION-SEGMENT.

Points to note with REPL


Restrictions:Cant change the length of the segment Cant change the value of the sequence field if the segment has one Never code a Qualified SSA on a REPL call. Status Codes: AJ: If qualified SSA is used with REPL DJ: If REPL Call without preceding GHU call DA: If segment key field is changed

Points to note with DLET


DLET works much like REPL. DLET call doesnt include any qualified SSAs. When you delete a segment, automatically deletes all segment occurrences subordinate to it.

Secondary Indexing
If an application has to access a segment using a field other than the sequence field a secondary index could be used. You can index any field in a segment by defining an XDFLD statement for the field in the DBD for the database. If the Get call is not qualified on the key but uses some other field, IMS must search all the database records to find the correct record.

Guidelines - S.Indexing
Define the indexed field in the DBD for the primary database in the XDFLD statement during DBD generation. Use the name that was given on the XDFLD statement as the field name in the qualification statement. Specify the secondary index as the processing sequence during PSB generation. Do this by specifying the name of the secondary index database on the PROCSEQ parameter on the PCB during PSB generation.

Guidelines to use Indexed fld


Speaker Notes

You might also like