Upload
kumar-abhinav
View
215
Download
0
Embed Size (px)
Citation preview
7/31/2019 Concepts of IMS Database
1/6
Concepts of IMS Database
table of contents
OBJECTIVE 2
INTRODUCTION 2
HOW DOES AN APPLICATION PROGRAM ACCESS IMS 2
PARAMETERS 3
POSSIBLE FUNCTIONS IN IMS 3
FORMAT OF A PCB MASK TO BE SPECIFIED IN THE LINKAGE SECTION 4
IO AREA 5
SSA 5
IMS CONTROL BLOCKS 6
FORMAT OF A DBD 6
FORMAT OF A PSBCOMMAND CODES 7 7
SECONDARY INDEXING 8
OBJECTIVE
This document aims to introduce the concepts of IMS database from application programmers' and
designers' perspective. There are live examples of data model taken from our client. This is part of
work aimed at introducing the client to alternate database options. It provides, as does the option to
port the database to relational DB, a perspective to look away from proprietary technologies and go
in for standard technologies and the superior features and support it offers.
INTRODUCTION
IMS is a Hierarchical database and it consists of data contained in segments. Data represented by
tree structure. The database manager is referred to as DLI and it can interface with IMS-DC and CICS-
VS. Application programs Use standard CALL statements and parameter lists to communicate with
IMS.
A segment may contain one or more fields. Maximum number of segment types is 255.A Segment
can be both a PARENT & CHILD with the exception of the ROOT segment and the lowest level
segments. No child segment can exist without its parent.
model
article
custom
barcodes
color
7/31/2019 Concepts of IMS Database
2/6
HOW DOES AN APPLICATION PROGRAM ACCESS IMS
This entry statement makes the database connection. IMS is given control first by invoking the batch
initialization module DFSRRC00.DLI first loads the relevant control blocks and modules, then loads
the application program and passes control to it by supplying the addresses of PCBs.
PROCEDURE DIVISION.
ENTRY DLITCBL USING PCB1-MASK PCB2-MASK
Finally, the GOBACK statement transfers control back to DLI. DLI deallocates its resources and closes
the database data sets.
Application programs request IMS services by issuing Calls to IMS. Parameters coded on the Call
Statement specify the details of the operation that the program wants DLI to perform.
E.g. CALL 'CBLTDLI' USING GU
Model-pcb
Ws-article-ioarea
Model-ssa
Article-ssa
PARAMETERS
Function (GU)
PCB mask (Model-pcb)
IO area (Ws-article-ioarea)
Segment search area (SSA) { Model-ssa Article-ssa }
POSSIBLE FUNCTIONS IN IMS
GU Retrieve a segment occurrence randomly
GN Retrieve next segment occurrence from the current position.
GNP Retrieve next segment occurrence under the current parent from The current position.
GHU }
GHN } Identical to GU, GN & GNP respectively, except with Update intent
GHNP }ISRT Add a new segment occurrence
7/31/2019 Concepts of IMS Database
3/6
REPL Update on existing segment occurrence
DLET Delete a segment occurrence along with all its dependents
ROLL Roll back and exit
ROLB Roll back and continue
FORMAT OF A PCB MASK TO BE SPECIFIED IN THE LINKAGE SECTION
LINKAGE SECTION.
01 PCB1-MASK.
05 PCB1-DBDNAME PIC X(8).
05 PCB1-LEVEL-NUMBER PIC X(2).
05 PCB1-STATUS-CODE PIC X(2).
05 PCB1-PROC-OPTIONS PIC X(4).
05 PCB1-JCB-ADDRESS PIC X(4).
05 PCB1-SEGMENT-NAME PIC X(8).05 PCB1-KEY-LENGTH PIC S9(5) COMP.
05 PCB1-NUMBER-SEGS PIC S9(5) COMP.
05 PCB1-KEY-FEEDBACK PIC X(26)
DBDNAME : name of database manipulated by the last DLI call. (MODEL)
LEVEL NUMBER : the level number of last segment which satisfied the CALL.(2)
STATUS CODE : a 2 character code indicating result of the last DLI execution.(GE)
PROC OPTIONS : the processing options which describe what types of calls are valid against the
database. (G)
JCB ADDRESS : used by DLI for its own internal linkage to an operating system control block.
SEGMENT NAME : the name of the last segment which satisfied the call. (ARTICLE)
KEY LENGTH : length of the concatenated key.(27)
NO. OF SEGMENTS : the number of key fields that are stored in the key feedback area.(3)
KEY FEEDBACK AREA : the concatenated key values of all the segments along the retrieval
path.(W1234 216789 ABCD)
IO AREA
To be defined in the working storage. This is the copybook structure used to retrieve data into or to
send data from into the database.
01 WS-MODEL_IOAREA.
05 MODEL-NO PIC X(15).
7/31/2019 Concepts of IMS Database
4/6
01 WS-ARTICLE-IOAREA.
05 ARTICLE-NO PIC X(08).
05 STATUS PIC X(02).
05 ORDERLOCK PIC X(01).
01 WS-COLOR_IOAREA.
05 COLOR-CODE PIC X(04).
05 DESCRIPTION PIC X(20).
SSA
unqualified SSA contains only the segment name
qualified SSA ( )
e.g.
01 SSA-ART.
03 SSA-ART-SEGNAME PIC X(08) VALUE 'DSGART '.
03 SSA-ART-COMMAND PIC X(04) VALUE '*---'.
03 SSA-ART-QUALIFY PIC X(01) VALUE '('.
03 SSA-ART-KEY-FLD PIC X(08) VALUE 'ARTNO'.
03 SSA-ART-OPERATOR PIC X(02) VALUE 'EQ'.
03 SSA-ART-KEY-VAL PIC X(16) VALUE '216789'.
03 FILLER PIC X(01) VALUE ')'.
IMS CONTROL BLOCKS
But as explained earlier, DLI first needs to load the relevant control blocks and modules, then only
can it load the application program.
DBD (Data Base Definition) is used to define the physical nature of an IMS database. It describes the
way in which data is stored on the storage device and the way in which it can be accessed.
PSB (Program Specification Block) describes the database as a particular application program views
it. It identifies which pieces of data a program is allowed to access and the types of functions it can
perform on it. Group of segments that one or more applications can access. Each PCB in a PSB
identifies the database that the application program can access and defines its logical data structure.
FORMAT OF A DBD
PRINT NOGEN
DBD NAME=MODDB,ACCESS=(HISAM,VSAM)
DATASET DD1=PRIME,OVFLW=OVERFLOW,DEVICE=3380*
7/31/2019 Concepts of IMS Database
5/6
SEGM NAME=MODEL,PARENT=0,BYTES=280
FIELD NAME=(MODEL-NO,SEQ,U),BYTES=20,START=1
FIELD NAME=MODADMN,BYTES=20,START=61
*
SEGM NAME=ARTICLE,PARENT=MODEL,BYTES=140
FIELD NAME=(ARTICLE-NO,SEQ,U),BYTES=8,START=1
FIELD NAME=STATUS,BYTES=02,START=9
FIELD NAME=ORDERLOCK,BYTES=01,START=11
*
SEGM NAME=COLOR,PARENT=ARTICLE,BYTES=70
FIELD NAME=(COLOR-CODE,SEQ,U),BYTES=4,START=1
FIELD NAME=DESCRIPTION,BYTES=20,START=5
*
DBDGEN
FINISH
END
FORMAT OF A PSB
PCB TYPE=DB, NAME=MODDB,KEYLEN=27
SENSEG NAME=MODEL,PARENT=0,PROCOPT=K
SENSEG NAME=ARTICLE,PARENT=MODEL,PROCOPT=K
SENSEG NAME=COLOR,PARENT=ARTICLE,PROCOPT=G
PSBGEN LANG=COBOL,PSBNAME=PATGET
END
COMMAND CODES
Command Codes are an efficient way to code. It allows programs to request useful IMS functions to
save programming & processing time.
Some of the frequently used command codes are:
D - Put this segment into the IO-AREA (path call)
N - Do not replace this segment
C - Concatenated key in this SSA
F - Locate first occurrence
L - Locate last occurrence
P - Establish parentage at this level
U - Maintain current position at this levelV - Maintain current position here & higher
7/31/2019 Concepts of IMS Database
6/6
- - Null Command code.
The asterisk (*) in the 9th position of the SSA tells IMS that one or more command codes follow until
the left parentheses.
e.g. .articlebbbb* P(ARTICLENOb=04)
SECONDARY INDEXING
Programs use secondary indexing to search for segments in a sequence other than key sequence. For
e.g. In finding the models for given articles
A secondary index is a database containing pointers which point to segments in the data base being
indexed.
Using secondary indexes is advantageous in sequential processing of data in non key field sequence,
for producing reports in different sequences and for accessing a segment without having to navigatethe full hierarchical path.
The disadvantages are Performance overheads in updating the secondary index database,
Administrative overheads in setting up, monitoring, backing up and tuning the secondary index
database.
-*-