Ims-Db: Information Management System DB Concepts & Programming
Ims-Db: Information Management System DB Concepts & Programming
Ims-Db: Information Management System DB Concepts & Programming
IMS-DB
Files Vs Databases
Networked,Hierarchical & Relational structure
Access types - HSAM, HISAM,HDAM,HIDAM,VSAM
IMS DB - an Hierarchical Structure
Database Definitions - DBD
Program Specification Block ,Program Control Block
DL/I Calls - Data Retrieval and Manipulation
DL/I Functions
Qualified/ Unqualified Calls, SSAs, Command Codes
DL/I Status codes
HOME
Advanced Topics
Data Sensitivity - Segment Level & Field level
Checkpoint & Restart
IMS DB in CICS Environment
Secondary Indexing
Difference between MPP, BMP, DLI
Using ‘HFCTDLI’
HOME
File Vs Databases
I M S D B H ie r a r c h ic a l S t ru c t u re
SR C S
I n f o r m a t io n S R C S u n its S t r a t e rg ic B u s in e s s
D a ta b a s e U n it s in fo
C lie n t I n fo C lie n t s E m p lo y E m p lo y e e d a ta
P r o je c t I n fo P r o je c ts S a la r y E m p lo y e e S a la ry
D e t a ils
Basic IMS Terminologies HOME
3
2
1
SRCS SRCS Units
Information Segment
Occurrence
Database Root Segment
Parent Segment
Child Segment
Client Info Clients Employ Segment Level
Path
Database Record
Twins
Project Info Projects Salary Sequential Processing
Random Processing
HOME
Definitions
Segment
- Unit of Information handled in IMS
- Unit of data transferred from DL/I in an IO operation
- Consists of fields, key fields & Search fields
Occurrence
- Specific segment of a particular type of segment
- Contains actual user data
Root Segment
- Top of the hierarchy
- All other segments are derived from the root
Parent Segment
- Segment that has dependent segments
HOME
Definitions (contd)
Child Segment
- A dependent segment
Segment Level
- Depth of an IMS structure
- Root is at Level 0, max 15 levels, max 255 segments
Path
- Series of segments from Root to the child
Database record
- Each occurrence of the Segment Plus all
occurrence of the subordinate segments
Twins
- Segment occurrences of same type with same parent
segment occurrence
HOME
IMS Control Blocks
PCB for DB1
IMS IMS
PSB PCB for DB2 PGM1 PGM2
PCB for DB3
DBD NAME=SRCS,ACCESS=(HIDAM,VSAM)
DSG1 DATASET DD1=DDSAT,DEVICE=3380,SIZE=4096,FRSPC=0,15)
SEGM NAME=SRU,PARENT=0,BYTES=40
FIELD NAME=(SRUCODE,SEQ,U),BYTES=3,START=1,TYPE=P
FIELD NAME=SRUNAME,BYTES=5,START=4,TYPE=C
FIELD NAME=SRULOC,BYTES=12,START=9,TYPE=C
FIELD NAME=SRUHEAD,BYTES=20,START=21,TYPE=C
SEGM NAME=CLIENT,PARENT=SRU,BYTES=45
FIELD NAME=(CLTID,SEQ,U),BYTES=4,START=1,TYPE=P
FIELD NAME=CLTNAME,BYTES=10,START=5,TYPE=C
FIELD NAME=CLTLOC,BYTES=11,START=15,TYPE=C
FIELD NAME=CLTHEAD,BYTES=20,START=26,TYPE=C
HOME
SEGM NAME=PROJECT,PARENT=CLIENT,BYTES=35
FIELD NAME=(PRJID,SEQ,U),BYTES=4,START=1,TYPE=P
FIELD NAME=PRJNAME,BYTES=5,START=5,TYPE=C
FIELD NAME=PRJTMSIZE,BYTES=4,START=10,TYPE=C
FIELD NAME=PRJHEAD,BYTES=22,START=14,TYPE=C
SEGM NAME=EMPLY,PARENT=SRU,BYTES=40
FIELD NAME=(EMPID,SEQ,U),BYTES=5,START=1,TYPE=P
FIELD NAME=EMPNAME,BYTES=10,START=6,TYPE=C
FIELD NAME=EMPPROJ,BYTES=5,START=16,TYPE=C
FIELD NAME=EMPADDR,BYTES=20,START=21,TYPE=C
SEGM NAME=SALARY,PARENT=EMPLY,BYTES=35
FIELD NAME=(SALEMPID,SEQ,U),BYTES=5,START=1,TYPE=P
FIELD NAME=SALBASIC,BYTES=10,START=6,TYPE=C
FIELD NAME=SALHRA,BYTES=5,START=16,TYPE=C
FIELD NAME=SALDA,BYTES=5,START=21,TYPE=C
DBDGEN
FINISH
END
PSB HOME
Program Specification Block,describes Logical structure of the Database that a
program will use.It contains one or more PCB’s (Program Communication Block).
PCB describes one Database.
PSBGEN
PSBGEN Produces a load module stored in the PSBLIB library and creates PSB
Major Macros Used
PCB : Describes type (DB or DC), name of the DBD, Key length(length of
the longest concatenated key the program can process) and
processing Option (Defines how the segment may be accessed)
PCB TYPE=DB,DBDNAME=SRCS,KEYLEN=20,PROCOPT=LS
SENSEG : Define the name of the segments in the Database your program
needs access to
SENSEG NAME=CLIENT,PARENT=SRU
SENFLD : Subordinate to the SENSEG macro, only fields that are defined by
the SENFLD macro can be accessed from the I/O Area.
SENFLD NAME=PROJECT,PARENT=CLIENT
PSBGEN PSBNAME=MYPSB,LANG=COBOL
END
SAMPLE PSB FOR SRCS INFO DB PROJECT REFERENCE PROGRAM
HOME
PCB TYPE=DB,DBDNAME=SRCS,KEYLEN=10,PROCOPT=LS
SENSEG NAME=SRU,PARENT=0
SENSEG NAME=CLIENT,PARENT=SRU
SENSEG NAME=PROJECT,PARENT=CLIENT
PSBGEN PSBNAME=MYPSB,LANG=COBOL
END
PCB TYPE=DB,DBDNAME=SRCS,KEYLEN=10,PROCOPT=LS
SENSEG NAME=SRU,PARENT=0
SENSEG NAME=CLIENT,PARENT=SRU
SENSEG NAME=PROJECT,PARENT=CLIENT
SENSEG NAME=EMPLY,PARENT=SRU
SENSEG NAME=SALARY,PARENT=EMPLY
PSBGEN PSBNAME=MYPSB,LANG=COBOL
END
DL/I INTERFACE HOME
• DL/I passes control to your program
• Uses ENRTY and CALL statement to code DL/I call in the Procedure Division
This DL/I tells entry of the program for Batch program & MPP program
This call is the name of the interface module that link edited with your
program’s object module.
CALL PARAMETERS HOME
CALL ‘CBLDTLI’ USING DLI-FUNCTION
PCB-mask
Segment-io-area
[segment search argument (s) ]
Parameter Function
DL/I -Function A four byte code that tells DL/I what kind of call to make
PCB-mask Arguments tells DL/I which PCB to use for the call
IO-Area Tells DL/I where to put the segment
SSA Gives DL/I additional criteria to use in finding a particular
Segment, Can be upto 15 SSA’s
DL/I FUNCTIONS HOME
GU - Get Unique
GN - Get Next
GNP - Get Next within Parent
GHU - Get Hold Unique
GHN - Get Hold Next
GHNP - Get Hold Next within Parent
ISRT - To Insert
REPL - To replace
DLET - To Delete
CHKP - To take a Checkpoint at a particular point
XRST - To Restart from Particular point previous Checkpoint
INIT - To Initialize
SYNC - To commit
PCB MASK HOME
Define in linkage Section and establishes correspondence between linkage Section
PSB-mask and PSB’s with in your program.
VARIABLE DESCRIPTION
01 SRCS-PCB-MASK.
03 SR-DBD-NAME PIC X(8). Name of the Database being processed
03 SR-SEG-LEVEL PIC XX. Specifies current segment level in the DB
03 SR-STATUS-CODE PIC XX. Contains data yr program will evaluate after call
03 SR-PROC-OPT PIC X(4). Type of processing the program authorized to do
03 SR-SEG-NAME PIC X(8). Stores name of the segment just proceeded
03 SR-KEY-LENGTH PIC S9(5). Length of the concatenated key
03 SR-NUM-SENSEGS PIC S9(5). No of SENSEG macros subordinate to the PCB
03 SR-KEY-VALUE PIC X(20). Key value retrieved
I-O AREA LAYOUT FOR SEGMENTS
HOME
SRUCODE SRUNAME SRULOC SRUHEAD
01 SRU-AREA.
03 SRU-CODE PIC X(3). EMPID EMPNAME EMPPROJ EMPADR
03 SRU-NAME PIC X(5).
03 SRU-LOC PIC X(12) 01 EMP-AREA.
03 SRU-HEAD PIC X(20). 03 EMP-ID PIC X(5).
03 EMP-NAME PIC X(10).
CLTID CLTNAME CLTLOC CLT-HEAD 03 EMP-PROJ PIC X(5)
03 EMP-ADR PIC X(20).
01 CLIENT-AREA.
03 CLT-CLTID PIC X(4).
EMPID BASIC HRA DA
03 CLT-CLTNAME PIC X(10).
03 CLT-CLTLOC PIC X(11)
03 CLT-CLTHEAD PIC X(20). 01 SAL-AREA.
03 SAL-EMPID PIC X(5).
PROJID PRJNAME TMSIZE PRJADDR 03 SAL-BASIC PIC X(10).
01 PRJ-AREA. 03 SAL-HRA PIC X(5).
03 PRJ-PROJID PIC X(4). 03 SAL-DA PIC X(5).
03 PRJ-PRJNAME PIC X(5).
03 PRJ-TMSIZE PIC X(4)
03 PRJ-HEAD PIC X(20).
SEGMENT SEARCH ARGUMENT HOME
• Identifies Segment Occurrence You want to access
• You may have to code several SSA’s in a single DL/I CALL
• There are two types of SSA’s Unqualified SSA & Qualified SSA
UNQUALIFIED QUALIFIED
• Search for a Specific Segment type Searches for a specific occurrence of a
specific segment type
• Access the database Sequentially Access the database Randomly
• Identify by segment name and space Identify by segment name and Seg-key
• Example
01 UNSRU-SSA. 01 QUALKBU-SSA.
03 SRU-UNSSA-NM PIC X(8) Value ‘SRU ‘. 03 SEG-NAME PIC X(8) VALUE ‘SRU ‘.
D Retrieve Path
F Access First Segment occurrence
L Access Last Segment occurrence
U Maintain current position at this level
V Maintain current position at this level and higher
levels
Q Enqueue Segment
N Do Not replace this Segment
C Use a Concatenated Key
P Establish Percentage at this level
- Null command code / ignore
Data Sensitivity HOME
•DBA
At a PSB level for SEGMENTS PROCOPT
PCB TYPE=DB,DBDNAME-SRCS,,KEYLEN=11,PROCOPT
SENSEG NAME =SRU,PARENT=0
SENSEG NAME =CLIENT,PARENT=SRU
•Programmer
At PROGRAM Level
- Qualified SSA call with Command code N (No Replacement)
Checkpointing & Restart
• A point in the program where the database changes the program made are
HOME
Considered complete and accurate -written to a DL/I log
• Used for Recovery Process
• Are of two types - Basic Checkpointing and Symbolic Checkpointing
• Basic Checkpointing
CALL ‘CBLTDLI’ USING DLI-CHKP,
I-O-PCB-MASK,
CHECKPOINT-ID.
• Symbolic Checkpointing
Stores program data along with checkpoint records and retrieves that data
when program restarts after failure.
For extended Restart , an XRST call to be issued with the same fields as in
CHKP call. It allows DL/I to retrieve the value in checkpoint record and
restores the specified fields.
Explosive Mix - IMS DB with CICS HOME
• Scheduling Call
User Task
Program Communication
Block
(PCB)
PCB1
PCB2
Secondary Indexing
HOME
Employee Index Database
EMP..Seg Employee ID
Addr
Index Target
SRU Index Pointer
Segment
Segment
CLIENTS EMPLOYEE
SRU..Seg Employee ID
Addr
Index Target
SRU Index Pointer
Segment
Segment
CLIENTS EMPLOYEE
• Secondary index data base has only one segment type - the Index pointer segment
which in turn contains a prefix element and a data element
• Two DBDGENS are required as a secondary database involves two database: one
for indexed database , the other for the secondary index database
Secondary Indexing Continued HOME
DBDGEN - The Secondary Index code for SRCS DB
DBD NAME=SRCS,ACCESS=(HIDAM,VSAM)
DSG1 DATASET DD1=DDSAT,DEVICE=3380,SIZE=4096,FRSPC=0,15)
SEGM NAME=SRU,PARENT=0,BYTES=40
FIELD NAME=(SRUCD,SEQ,U),BYTES=2,START=1,TYPE=P
……
SEGM NAME=EMPLY,PARENT=SRU,BYTES=80
LCHILD NAME= (MYPNTR,MYDBD),POINTER=INDX
FIELD NAME=(EMPID,SEQ,U),BYTES=5,START=1,TYPE=P
XDFLD NAME=MYINDX,SRCH=EMPID
FIELD NAME=EMPNAME,BYTES=25,START=6,TYPE=C
FIELD NAME=EMPPROJ,BYTES=15,START=31,TYPE=C
FIELD NAME=EMPADDR,BYTES=35,START=46,TYPE=C
…….
Secondary Indexing Continued HOME
DBDGEN - The Secondary Index code for Secondary Index DB
DBD NAME=MYIDBD,ACCESS=(INDEX)
DSG1 DATASET DD1=DDKAY,DEVICE=3380,SIZE=4096,FRSPC=0,15)
SEGM NAME=MYPNTR,PARENT=0,BYTES=6
LCHILD NAME= (EMPID,SRCS), INDX=MYINDX
FIELD NAME=(MYEMPID,SEQ,U),BYTES=6,START=1,TYPE=C
DBDGEN
FINISH
END
• DL/I
It can be used as Interface between MPP and Database OR BMP and Database
For batch DL/I job it can access database directly
PSB of DL/I job can be used by another jobs simultaneously
It can run on Individual partitions.
HOME