You are on page 1of 35

IMS-DB

Information Management System DB Concepts & Programming

HOME

Basic Topics

HOME

l Files Vs Databases l Networked,Hierarchical & Relational structure l Access types - HSAM, HISAM,HDAM,HIDAM,VSAM l IMS DB - an Hierarchical Structure l Database Definitions - DBD l Program Specification Block ,Program Control Block l DL/I Calls - Data Retrieval and Manipulation l DL/I Functions l Qualified/ Unqualified Calls, SSAs, Command Codes l DL/I Status codes

HOME

Advanced Topics
l Data Sensitivity - Segment Level & Field level l Checkpoint & Restart l IMS DB in CICS Environment l Secondary Indexing l Difference between MPP, BMP, DLI l Using HFCTDLI

HOME

File
Data more redundant Duplicate data Data insecure No control over data Threat to Integrity Lack of inbuilt recovery features l Lack of data Locks l l l l l l

Vs

Databases
Redundancy avoided Minimise Duplicates Security provided Field level sensitivity Consistency of data Data Logging, Commits & Rollbacks Automatic locks

HOME

Database Structures
Network Structures (e.g IDMS) l Many to Many relationships l Complex structure using Pointers l Best for Keeping storage Hierarchical Structures (e.g IMS DB) l One to Many Relationships l Inverted Tree like Structure l Best for storing parent and child type entities Relational Structures (e.g DB2) l One to Many, Many to One l Best for ease of data retrieval

HOME

Access Types
l HSAM/SHSAM (Simple /Hierarchic sequential Access Method)
The segments that make up the database record are related to one another by their physical locations (SHSAM has only root occurrences)

l HISAM/SHISAM (Simple / Hierarchic Indexed Sequential Access Method)


The data is stored with hierarchic sequential organization along with an index for random processing (SHISAM has only index of root occurrences)

l HDAM (Hierarchic Direct Access Method)


The segment occurrences include prefixes that contain the direct address pointers to related segment - stores root segment occurrences

l HIDAM (Hierarchic Indexed Direct Access Method)


Similar to HDAM but stores an index of the root segment occurrences

HOME
I M S R C S I n f o r m D a t a b C l i e n t a a IC n c t Si o R n s e lf i o e C S u p S D B H i e

r a B d

n S i t ts r a t e r g i c U n i t s i n f o l Eo r Ey D ym m e p p t a l o y e e e

n Et s m

r o

j e

t P I rn o f oj e S c at s l a

l o y e i l s

Basic IMS Terminologies


1 SRCS Units 2 3

HOME

SRCS Information Database Client Info

Clients

Employ

Project Info

Projects

Salary

Segment Occurrence Root Segment Parent Segment Child Segment Segment Level Path Database Record Twins Sequential Processing Random Processing

HOME

Definitions
l 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

l Occurrence
- Specific segment of a particular type of segment - Contains actual user data

l Root Segment
- Top of the hierarchy - All other segments are derived from the root

l Parent Segment
- Segment that has dependent segments

Definitions (contd)
l Child Segment
- A dependent segment

HOME

l Segment Level
- Depth of an IMS structure - Root is at Level 0, max 15 levels, max 255 segments

l Path
- Series of segments from Root to the child

l Database record
- Each occurrence of the Segment Plus all occurrence of the subordinate segments

l Twins
- Segment occurrences of same type with same parent segment occurrence

IMS Control Blocks


PSB
PCB for DB1 PCB for DB2 PCB for DB3 IMS PGM1

HOME
IMS PGM2

DBDs

DBD1

DBD2

DBD3

DL/I CONTROL UNIT

IMS DBs

DB1

DB2

DB3

DBD : Database Description, describes physical Database HOME DBDGEN : DBDGEN Utility, Describes the physical structure of the Database and creates DBD l DBD : Names the database and identifies the access method DBD Name = SRCS, ACCESS=(HIDAM,VSAM) l DATASET : Specifies DD Name used in the JCL and other parameters DATASET DD1=DDSAT,DEVICE=3380,SIZE=(4096),FRSPC=(0,15) l SEGM : Names the segment. Identifies the parent and establishes the length SEGM Name =SRU,PARENT=0,BYTES=40 l LCHILD : Names the logical segment used in secondary Indexing and Logical database LCHILD NAME=(SRUNAME,SRCS1),PTR=INDX l FIELD : Defines fields. And identifies search &key fields by SEQ parameter FIELD NAME=(SRUCODE,SEQ,U)BYTES=3,START=1,TYPE=C l DBDGEN: Indicates the end of the DBDGEN process DBDGEN l COMMENT: * IN 3rd COLUMN for writing user comments

HOME

Sample DBD Listing for SRCS Info Database


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

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

HOME

PSB

Program Specification Block,describes Logical structure of the Database that a program will use.It contains one or more PCBs (Program Communication Block). PCB describes one Database. PSBGEN PSBGEN Produces a load module stored in the PSBLIB library and creates PSB

HOME

Major Macros Used


PCB PCB SENSEG SENSEG SENFLD SENFLD PSBGEN END : 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) TYPE=DB,DBDNAME=SRCS,KEYLEN=20,PROCOPT=LS : Define the name of the segments in the Database your program needs access to NAME=CLIENT,PARENT=SRU : Subordinate to the SENSEG macro, only fields that are defined by the SENFLD macro can be accessed from the I/O Area. NAME=PROJECT,PARENT=CLIENT PSBNAME=MYPSB,LANG=COBOL

SAMPLE PSB FOR SRCS INFO DB PROJECT REFERENCE PROGRAM HOME PCB SENSEG SENSEG SENSEG PSBGEN END TYPE=DB,DBDNAME=SRCS,KEYLEN=10,PROCOPT=LS NAME=SRU,PARENT=0 NAME=CLIENT,PARENT=SRU NAME=PROJECT,PARENT=CLIENT PSBNAME=MYPSB,LANG=COBOL

SAMPLE PSB FOR SRCS INFO DB PROJECT REFERENCE PROGRAM PCB SENSEG SENSEG SENSEG SENSEG SENSEG PSBGEN END TYPE=DB,DBDNAME=SRCS,KEYLEN=10,PROCOPT=LS NAME=SRU,PARENT=0 NAME=CLIENT,PARENT=SRU NAME=PROJECT,PARENT=CLIENT NAME=EMPLY,PARENT=SRU NAME=SALARY,PARENT=EMPLY PSBNAME=MYPSB,LANG=COBOL

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 ENTRY DLITCBL USING PCB-name1 PCB-name2

This DL/I tells entry of the program for Batch program & MPP program CALL CBLTDLI USING DLI-FUNCTION PCB-mask Segment-io-area [segment search arguments (s)]

This call is the name of the interface module that link edited with your programs object module.

CALL PARAMETERS
CALL CBLDTLI USING

HOME

DLI-FUNCTION PCB-mask Segment-io-area [segment search argument (s) ]

If we use PL/I language then CBLTDLI will be PLITDLI Parameter DL/I -Function PCB-mask IO-Area SSA Function A four byte code that tells DL/I what kind of call to make Arguments tells DL/I which PCB to use for the call Tells DL/I where to put the segment Gives DL/I additional criteria to use in finding a particular Segment, Can be upto 15 SSAs

DL/I FUNCTIONS

HOME

GU GN GNP GHU GHN GHNP ISRT REPL DLET CHKP XRST INIT SYNC

Get Unique Get Next Get Next within Parent Get Hold Unique Get Hold Next Get Hold Next within Parent To Insert To replace To Delete To take a Checkpoint at a particular point To Restart from Particular point previous Checkpoint To Initialize To commit

PCB MASK

HOME

Define in linkage Section and establishes correspondence between linkage Section PSB-mask and PSBs with in your program. SAMPLE PCB-MASK LAYOUT 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


SRUCODE SRUNAME SRULOC SRUHEAD 01 SRU-AREA. 03 SRU-CODE 03 SRU-NAME 03 SRU-LOC 03 SRU-HEAD CLTID PIC X(3). PIC X(5). PIC X(12) PIC X(20). EMPID

HOME

EMPNAME EMPPROJ EMPADR 01 EMP-AREA. 03 EMP-ID 03 EMP-NAME 03 EMP-PROJ 03 EMP-ADR BASIC HRA PIC X(5). PIC X(10). PIC X(5) PIC X(20). DA

CLTNAME CLTLOC CLT-HEAD PIC X(4). PIC X(10). PIC X(11) PIC X(20).

01 CLIENT-AREA. 03 CLT-CLTID 03 CLT-CLTNAME 03 CLT-CLTLOC 03 CLT-CLTHEAD PROJID

EMPID

PRJNAME TMSIZE PIC X(4). PIC X(5). PIC X(4) PIC X(20).

PRJADDR

01 PRJ-AREA. 03 PRJ-PROJID 03 PRJ-PRJNAME 03 PRJ-TMSIZE 03 PRJ-HEAD

01 SAL-AREA. 03 SAL-EMPID 03 SAL-BASIC 03 SAL-HRA 03 SAL-DA

PIC X(5). PIC X(10). PIC X(5). PIC X(5).

SEGMENT SEARCH ARGUMENT


Identifies Segment Occurrence You want to access You may have to code several SSAs in a single DL/I CALL There are two types of SSAs Unqualified SSA & Qualified SSA
UNQUALIFIED QUALIFIED

HOME

Search for a Specific Segment type Access the database Sequentially Identify by segment name and space Example

Searches for a specific occurrence of a specific segment type Access the database Randomly Identify by segment name and Seg-key

01 UNSRU-SSA. 01 QUALKBU-SSA. 03 SRU-UNSSA-NM PIC X(8) Value SRU . 03 SEG-NAME PIC X(8) VALUE SRU 03 FILLER PIC X Value Space.

03 COM-CODE PIC X(2) VALUE *-. 03 BEGIN-QUAL PIC X VALUE (. 03 KEY-NAME PIC X(8) VALUE SRUKEY. 03 REL-OPR PIC X(2) VALUE = . 03 KEY-VALUE PIC X(20). 03 END-QUAL PIC X VALUE ).

HOME
COMMAND CODES Command Code
D F L U V levels Q N C P Enqueue Segment Do Not replace this Segment Use a Concatenated Key Establish Percentage at this level Null command code / ignore

Description
Retrieve Path Access First Segment occurrence Access Last Segment occurrence Maintain current position at this level Maintain current position at this level and higher

DL/I STATUS CODES

HOME

List of Codes Common Status Codes AB GK GB AC GP End of Database during Sequential retrieval using GN AD II AH IX GE AI LB Segment Occurrence as defined in a qualified SSA not AJ LC found or not added in a ISRT due to error in Specified path AK LD AM LE AI AO NO Error in opening the database dataset AT RX AU V1 Spaces DA SPACES Call ended normally DJ DX GA GB GD GE

Data Sensitivity
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 Processing Options : G, I, R, D, A, P, O, N, T, E, L, GS, LS, H At a PSB level for fields Done by DBA by use of SENFLD macro , specifying those fields that can be changed.

HOME

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 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.

HOME

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


Scheduling Call CICS Region / Partition

HOME

User Interface Block (UIB)

User Task Program Communication Block (PCB)

A DL/I task must establish addressability to UIB and one or more PCB

IMS & CICS Continued


CALL CBLTDLI USING FUNC-INIT PSB-NAME ADDRESS OF DLIUIB SET ADDRESS OF PCB-ADDR-LIST TO UIBPCBAL SET ADDRESS OF PCB-1 TO PCB-1-ADR SET ADDRESS OF PCB-2 TO PCB-2-ADR ...

HOME
User Interface Block
Address of PCB List

Address of PCB 1

PCB Address list


Address of PCB 2

PCB1

PCB2

Secondary Indexing

HOME
Employee Index Database Employee ID

EMP..Seg Addr SRU Index Target Segment

Index Pointer Segment

Index Source Segment CLIENTS EMPLOYEE

PROJECTS

Same index Source segment and index target segment

Secondary Indexing Continued

HOME
Employee ID

Employee Index Database SRU..Seg Addr SRU Index Target Segment

Index Pointer Segment

Index Source Segment CLIENTS EMPLOYEE

PROJECTS

Different index Source segment and index target segment

Secondary Indexing Continued

HOME

Alternate sequencing is provided by storing pointers to Segments of the indexed Database in a separate secondary index data base Secondary index data base has only one segment type - the Index pointer segment which in turn contains a prefix element and a data element Prefix element points to the index target segment Secondary indexing is useful for accessing segments were both Index source segment and index target segment are same Index source segment and index target segment are different 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


DBDGEN - The Secondary Index code for SRCS DB

HOME

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 PSB Requirements for Secondary Indexing. PCB TYPE=DB,DBDNAME=SRCS,KEYLEN=10,PROCOPT=LS, PROCSEQ=MYIDBD SENSEG NAME=EMPLY SENSEG NAME=SRU,PARENT=EMPLY PSBGEN PSBNAME=MYSBX,LANG=COBOL END

Difference Between MPP , BMP & DLI

HOME

MPP (Message Processing Program) For Online programs( IMSDC) only. PSB used by a MPP program cannot be used by another programs simultaneously. Cannot run on Individual partitions. BMP (Batch message processing) For batch programs only PSB used by a BMP program cannot be used by another programs simultaneously. All partitions specified in PSB will be allocated whether used by program or not. Cannot run on Individual partitions. 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

You might also like