ims training
TRANSCRIPT
04/09/23 IMS DB Concepts 1
IMS DB CONCEPTS
IMS
04/09/23 IMS DB Concepts 2
Course Plan Introduction to IMS Getting Started Application Programming IMS Calls - Retrieve Processing IMS Calls - Loading and Inserting IMS Calls - Update Processing IMS Environments & Regions Recovery & Restart GSAM Processing
04/09/23 IMS DB Concepts 3
Introduction to IMS
Session 1
04/09/23 IMS DB Concepts 4
Tree Structure
04/09/23 IMS DB Concepts 5
IMS Terminology
Segments Fields Path Parent Child Level Twins Twin Chain
Record Database Key Sequence field Search Field
04/09/23 IMS DB Concepts 6
Segment Types & Segment Occurrences
04/09/23 IMS DB Concepts 7
IMS Hierarchic Sequence
Top to Bottom Left to Right Front to Back
04/09/23 IMS DB Concepts 8
Data Manipulation
Locate a specific Segment Move to next Segment occurrence Move to next Segment type Browse a the whole database or a specific
tree in the Hierarchic Sequence Update a segment Delete a segment Insert a new segment
04/09/23 IMS DB Concepts 9
Components and Environments
IMS is a Database/Data Communication (DB/DC) System IMS has two components:
• IMS DB (Database Manager)
• IMS DC (Transaction Manager)
DB and DC components can be implemented independently
IMS DB is required for both Online and Batch. IMS DB is referred sometimes as DL/I or Data Language/I DL/I can interface with CICS/VS and IMS DC. IMS DC can interface with DB2
04/09/23 IMS DB Concepts 10
IMS Software Development
IMS DC
IMSDatabase
OperatingSystem
DL/I
ApplicationProgram
Terminal
Reports
IMS ControlBlocks
04/09/23 IMS DB Concepts 11
IMS Advantages
Performance
Simplicity Maintenance Control Security
Transaction Manager
04/09/23 IMS DB Concepts 12
Getting Started
Session 2
04/09/23 IMS DB Concepts 13
Database Definition (DBD)
Database Definition Block (DBD) Control Block that describes the physical structure of a database.
Defines the Database to IMS
One DBD is used to define one Database
DBD specifies the segment types for a database and the fields in each segment.
Created by a series of control statements.
The DBDGEN process compiles the DBD and the database is defined to IMS. The whole process is normally done by the DBA
The DBD definition is used by Dl/I whenever the database is used.
04/09/23 IMS DB Concepts 14
Database Definition (DBD)
Sample DBD1 DBD NAME=EDUCPDBD
2 SEGM NAME=COURSE, BYTES=36
3 FIELD NAME=(COURSE#,SEQ), BYTES=3, START=1
4 FIELD NAME=TITLE, BYTES=33, START=4
5 SEGM NAME=PREREQ, PARENT=COURSE, BYTES=3
6 FIELD NAME=(PREREQ#,SEQ), BYTES=3, START=1
7 SEGM NAME=OFFERING, PARENT=COURSE, BYTES=21
8 FIELD NAME=(OFF#,SEQ), BYTES=3, START=1
9 FIELD NAME=DATE, BYTES=6, START=4
One for each Segment Type
One for each Segment Type
04/09/23 IMS DB Concepts 15
Database Definition (DBD)
Sample DBD (Contd..)10 FIELD NAME=LOCATION, BYTES=12, START=10
11 SEGM NAME=TEACHER, PARENT=OFFERING, BYTES=24
12 FIELD NAME=(EMP#,SEQ), BYTES=6, START=1
13 FIELD NAME=NAME, BYTES=18, START=7
14 SEGM NAME=STUDENT, PARENT=OFFERING, BYTES=24
15 FIELD NAME=(EMP#,SEQ), BYTES=6, START=1
16 FIELD NAME=NAME, BYTES=18, START=7
17 FIELD NAME=GRADE, BYTES=1, START=25
04/09/23 IMS DB Concepts 16
Program Specification Block (PSB)
Defines a program’s view of the database Specifies the group of segments and fields that one or
more applications can access. Also specifies the level of access for such segments/fields. A PSB consists of one or more control blocks called
Program Communications Block (PCB) Each PCB in a PSB defines one logical data structure. All PCB’s in a PSB collectively is known as an
Application Data Structure.
04/09/23 IMS DB Concepts 17
Program Specification Block (PSB)
Sample PSB1 PCB DBDNAME = EDUCPDBD
2 SENSEG NAME = COURSE, PROCOPT = G
3 SENSEG NAME = OFFERING, PARENT = COURSE, PROCOPT = G
4 SENFLD NAME = OFF#, START = 1
5 SENFLD NAME = DATE, START = 4
6 SENSEG NAME = STUDENT, PARENT = OFFERING, PROCOPT = G
04/09/23 IMS DB Concepts 18
Program Specification Block (PSB)
Sensitive Segments– Segments in the database that a particular application is
sensitive to
– Key sensitive segments are those segments an application can use to gain access to gain access to segments below it in the hierarchy. Cannot access data.
– Data sensitive segments are those an application can use to retrieve data
– Sensitive segments are specified using SENSEG macro statement
04/09/23 IMS DB Concepts 19
Program Specification Block (PSB)
Sensitive Fields– Fields in a (Sensitive)segment that a particular
application is sensitive to
– Sensitive fields are specified by using the SENFLD macro statement.
04/09/23 IMS DB Concepts 20
Program Specification Block (PSB)The PROCOPT (Processing Options) entry Used for restricting the level of Segment access Specified as “PROCOPT=<Processing Options>”
04/09/23 IMS DB Concepts 21
Program Specification Block (PSB)
G – Get
I – Insert
R - Replace
D - Delete
P - Position
A - All the above previleges
L - Load
GO - Read Only access
K - Can only access the key
Valid PROCOPT entries
04/09/23 IMS DB Concepts 22
Program Specification Block (PSB)
Data independence: A new segment type can be added to the database without affecting existing users.
Data security: Users cannot access those segment types that they are not sensitive to.
04/09/23 IMS DB Concepts 23
Application Programming
Session 3
04/09/23 IMS DB Concepts 24
Features
Independent of Data Storage Method Common call structures Independent of Line Protocols Enhancements Maintain Data Integrity Programmer Aids Data Sharing Different Access Methods
04/09/23 IMS DB Concepts 25
IMS Application Program Components
I/O AREA
PCB MASK
SEGMENTS TO/FROM DATABASE
RETURN INFO FROM DL/I
3
4
PROGRAM ENTRY
CALLS TO DL./I
GETINSERTREPLACEDELETE
PROCESSING
TERMINATON
1
2
5
DL/I MODULES
PROGRAMLOGIC
DL/I
LINKAGESECTION
WORKINGSTORAGE
04/09/23 IMS DB Concepts 26
Program Structure
Program EntryPCB maskI/O areaDL/I callsTermination
04/09/23 IMS DB Concepts 27
Program Entry & Termination
Entry DLITCBL to be declared as entry point Example:
ENTRY ‘DLITCBL’ USING <PCB Name>
PCB resides outside the program (Linkage Section). IMS passes the address.
GOBACK to be used instead of STOP RUN.
04/09/23 IMS DB Concepts 28
Process
Program entry specifies PCB’s used by the program
Call statements are interpreted by Dl/I, the function performed and segments transferred between programs’ I/O area and database
Program terminates by returning control to DL/I
04/09/23 IMS DB Concepts 29
Format of an IMS CALL
COBOL:
CALL 'CBLTDLI' USING [PARMCOUNT,]
FUNCTION,
DBPCB,
I/O AREA,
[,SSA1,SSA2,SSA3...,SSAn].
04/09/23 IMS DB Concepts 30
Format of an IMS CALL
PL/1:
CALL PLITDLI (PARMCOUNT, FUNCTION, DBPCB, I/O AREA [,SSA1,SSA2,SSA3...,SSAn])
FUNCTION, DBPCB,I/O area are mandatory For the PLITDLI interface, all parameters except
PARMCOUNT are indirect pointers
04/09/23 IMS DB Concepts 31
CALL Functions Get Functions
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
Get Hold FunctionsGHU
GHN - Identical to GU, GN and GNP except that we use these calls for update intent.
GHNP
04/09/23 IMS DB Concepts 32
CALL Functions Update Functions
ISRT - Insert a new segment
DLET - Delete an existing segment along with its dependents
REPL - Replace an existing segment
Other FunctionsROLL - Roll Back and Exit
ROLB - Roll Back and Return
CHKP - Check Point
XRST - Check for Restart
04/09/23 IMS DB Concepts 33
PCB Mask
Defined in the LINKAGE SECTION Entry Statement to access PCB thru USING
clause Order of PCBs in the ENTRY statement
need not be the same as that in the LINKAGE SECTION
04/09/23 IMS DB Concepts 34
PCB Mask
Database Name Segment Level Status Code Processing Options Segment Name Feedback Area Key Length Feedback Area Number of Sensitive Segments Key Feedback Area
04/09/23 IMS DB Concepts 35
PCB Mask Example (COBOL)
01 PCBNAME.
02 DBD-NAME PIC X(8).
02 SEG-LEVEL PIC XX.
02 STATUS CODE PIC XX.
02 PROC-OPTIONS PIC XXXX.
02 RESERVE-DLI PIC S9(5) COMPUTATIONAL.
02 SEG-NAME-FB PIC X(8).
02 LENGTH-FB-KEY PIC S9(5) COMPUTATIONAL.
02 NUMB-SENS-SEGS PIC S 9(5) COMPUTATIONAL.
02 KEY-FB-AREA PIC X(n).
04/09/23 IMS DB Concepts 36
PCB Mask Example (PL/1)
DECLARE PCB_POINTER POINTER;
DECLARE 1 PCBNAME BASED (PCB_POINTER),
2 DBD_NAME CHAR(8),
2 SEG_LEVEL CHAR(2),
2 STATUS_CODE CHAR(2),
2 PROC_OPTIONS CHAR(4),
2 RESERVE_DLI FIXED BIN(31,0),
2 SEG_NAME_FB CHAR(8),
2 LENGTH_FB_KEY FIXED BIN(31,0),
2 NUMB_SENS_SEGS FIXED BIN(31,0),
2 KEY_FB_AREA CHAR(n);
04/09/23 IMS DB Concepts 37
Segment Search Arguments
Unqualified SSA Area of storage that contains data which identifies 9 bytes
in length first 8 bytes to contain segment name
8 chars 1
SEGMENT NAME b
04/09/23 IMS DB Concepts 38
Segment Search Arguments
Qualified SSA 8 character segment name 8 character field name 2 byte relational or logical operator variable field into which the search value is to be moved command code
8 chars 1 1 1 1 1 8 2 1 – 255 1
SEGMENTNAME
( FIELDNAME
OPR COMPARATIVEVALUE
)* CMD1
CMD2
CMD3
04/09/23 IMS DB Concepts 39
Segment Search Arguments
Command codes C Concatenated Key D Path Call F First Occurrence L Last Occurrence N Path Call Ignore P Set Parentage U Maintain Position at this level V Maintain Position at this & all superior levels - Null Command
04/09/23 IMS DB Concepts 40
SSA Definition (COBOL)
01 UNQUAL-SSA.
02 SEG-NAME PIC X(08) VALUE ’COURSEbb'.
02 FILLER PIC X(01) VALUE ' '.
01 QUAL-SSA-MAST.
02 SEG-NAME-M PIC X(08) VALUE 'ROOT '.
02 AST PIC X(01) VALUE '*'.
02 CMD1 PIC X(01) VALUE '-'.
02 CMD2 PIC X(01) VALUE '-'.
02 CMD3 PIC X(01) VALUE '-'.
02 BEGIN-PAREN-M PIC X(01) VALUE '('.
02 KEY-NAME-M PIC X(08) VALUE 'KEY '.
02 REL-OPER-M PIC X(02) VALUE ' ='.
02 KEY-VALUE-M PIC X(n) VALUE 'vv...v'.
02 END-PAREN-M PIC X(01) VALUE ')'.
04/09/23 IMS DB Concepts 41
IMS CALLS
Add Operation ISRTthe insert function
Retrieve Operation GU Get Unique function GN Get next function GNP Get next within parent function
04/09/23 IMS DB Concepts 42
Data Manipulation Functions
Update Operation GHUGet hold unique function GHNGet hold next function GHNP Get hold next within parent
function REPL Replace function DLET Delete function
04/09/23 IMS DB Concepts 43
IMS Calls: Retrieve Processing
Session 4
04/09/23 IMS DB Concepts 44
Retrieve Processing
Get Unique, or GUWe can use GU to retrieve a particular segment directly
Get Next, or GNWe can use GN to sequentially retrieve segments.
Get Next in Parent, or GNPWe can use GNP to retrieve dependents of a particular segment.
04/09/23 IMS DB Concepts 45
Random retrieval Get Unique (GU) Call
Usage– when there is a specific segment you want
– to establish your position in the database.
About– A GU with an unqualified SSA at the root level
attempts to satisfy the call by starting at the beginning of the database
04/09/23 IMS DB Concepts 46
Random retrieval Get Unique (GU) Call
– A GU with a qualified SSA can retrieve the segment described in the SSA regardless of that segment's location relative to current position.
– When a segment has non unique keys or no keys at all, a GU with qualified SSAs will return only the first occurrence of that segment
– When you issue a GU call that mixes qualified and unqualified SSAs, DL/I retrieves the first occurrence of the segment type that satisfies the call at each level
04/09/23 IMS DB Concepts 47
Random retrieval Get Unique (GU) Call
– When there are missing levels, DL/I assumes an unqualified SSA for those levels
Status Codes– Spaces: The call was successful
– GE: Segment not found (Invalid key)
04/09/23 IMS DB Concepts 48
Random retrieval Get Unique (GU) Call
Example 1: GU call with No SSAs
CALL ‘CBLTDLI’ USING GU PCB-MASK IO-AREA
This call retrieves the first ROOT segment in the database.
04/09/23 IMS DB Concepts 49
Random retrieval Get Unique (GU) Call
Example 2: Fully Qualified SSAs in all levels
CALL ‘CBLTDLI’ USING GU PCB-MASK
IO-AREA COURSE-SSA
OFFERING-SSA
where COURSE-SSA - COURSE (COURSE# =M23)bb bb
04/09/23 IMS DB Concepts 50
Random retrieval Get Unique (GU) Call
Example 2 (Contd..)
OFFERING-SSA - OFFERING(OFF# =M19)
This call retrieves the OFFERING segment M19 for the course M23.
bbbbb
04/09/23 IMS DB Concepts 51
Random retrieval Get Unique (GU) Call
Example 3: Unqualified SSAs in all levels
CALL ‘CBLTDLI’ USING GU PCB-MASK IO-AREA COURSE-SSA OFFERING-SSA
where COURSE-SSA - COURSEbb
04/09/23 IMS DB Concepts 52
Random retrieval Get Unique (GU) Call
Example 3: Unqualified SSAs in all levels
and OFFERING-SSA - OFFERING
This retrieves the first offering segment (OFF# = 1) under the Course M23.
b
04/09/23 IMS DB Concepts 53
Random retrieval Get Unique (GU) Call
Example 4: GU call with both Unqualified and Qualified SSAs
CALL ‘CBLTDLI’ USING GU PCB-MASK IO-AREA COURSE-SSA OFFERING-SSA STUDENT-SSA
04/09/23 IMS DB Concepts 54
Random retrieval Get Unique (GU) Call
Example 4 (Contd..)
where COURSE-SSA - COURSE (COURSE# =M23) OFFERING-SSA - OFFERING
STUDENT-SSA - STUDENT (EMP# =36162)
This retrieves the STUDENT segment with EMP# 36162, under first offering segment (OFF# = 1) under the Course M23.
b bbbbb
bb bbb
04/09/23 IMS DB Concepts 55
Random retrieval Get Unique (GU) Call
Example 5: GU call with Missing Levels
CALL ‘CBLTDLI’ USING GU PCB-MASK IO-AREA STUDENT-SSA
where
STUDENT-SSA - STUDENT (EMP# =36162)bbbbbb
04/09/23 IMS DB Concepts 56
Random retrieval Get Unique (GU) Call
Example 5 (Contd..)
This assumes the COURSE-SSA and the OFFERING-SSA as unqualified and retrieves the STUDENT segment with EMP# 36162, under first offering segment (OFF# = 1) under the first Course segment (M23).
04/09/23 IMS DB Concepts 57
Sequential retrieval Get Next (GN) Call
Usage– when you want the next segment in the hierarchy
– when you want to sequentially browse the database in the hierarchic order
– often issued after a GU call
About– DL/I uses the current position set by the previous call
as the search starting point
04/09/23 IMS DB Concepts 58
Sequential retrieval Get Next (GN) Call
– If no position is established in the hierarchy, GN retrieves the first segment in the database.
– The segment retrieved is determined by a combination of the current sequential position in the hierarchy and the SSAs included in the call.
– A GN call with an unqualified SSA retrieves the next occurrence of that segment type by going forward from the current position.
04/09/23 IMS DB Concepts 59
Sequential retrieval Get Next (GN) Call
– A GN call with qualified SSAs retrieves the next occurrence of the specified segment type that satisfies the SSAs.
– When a segment has non unique keys or no keys at all, a GN with qualified SSAs will return the next occurrence of that segment
– When you issue a GN call that mixes qualified and unqualified SSAs, DL/I retrieves the next occurrence of the segment type that satisfies the call at each level
04/09/23 IMS DB Concepts 60
Sequential retrieval Get Next (GN) Call
– When there are missing levels, DL/I assumes an unqualified SSA for those levels
– The above GN calls, when repeated, retrieve the next segment satisfying the call till no more segment found (‘GE’ status code) is reached
– Successive GN calls with ‘NO’ SSAs will result in the navigation in the database in the hierarchic sequence till the End of database is reached. The next GN call will retrieve the first Root segment in the database.
04/09/23 IMS DB Concepts 61
Sequential retrieval Get Next (GN) Call
Status Codes– Blank - The call was successful
– GE - Segment not found
– GB - End of Database reached
– GA - DL/I moved to a higher level
– GK - DL/I moved to the next segment type
04/09/23 IMS DB Concepts 62
Sequential retrieval Get Next (GN) Call
Example 1: GN call with No SSAs
CALL ‘CBLTDLI’ USING GN PCB-MASK IO-AREA
Repeated use of this call will get all the segments of the database in the hierarchical sequence
After the last segment is retrieved, IMS returns ‘GB’ return code
04/09/23 IMS DB Concepts 63
Sequential retrieval Get Next (GN) Call
Example 1 (Contd..)
Issuing one more GN call will get the first occurrence of the ROOT segment
The SEGMENT field of the PCB mask will tell us the segment type last retrieved
04/09/23 IMS DB Concepts 64
Sequential retrieval Get Next (GN) Call
Example 2: GN with Unqualified SSAs
CALL ‘CBLTDLI’ USING GU PCB-MASK IO-AREA COURSE-SSA
OFFERING-SSAwhere
COURSE-SSA - COURSEOFFERING-SSA - OFFERING
bbb
04/09/23 IMS DB Concepts 65
Sequential retrieval Get Next (GN) Call
Example 2 (Contd..) Repeated use of this call retrieves all the occurrences
of the OFFERING segment, no matter what at they are dependent on.
After the last segment is retrieved, IMS returns ‘GE’ return code
04/09/23 IMS DB Concepts 66
Sequential retrieval Get Next (GN) Call
Example 3: Fully Qualified SSAs
CALL ‘CBLTDLI’ USING GN PCB-MASK IO-AREA COURSE-SSA OFFERING-SSA
where COURSE-SSA - COURSE (COURSE# =M23) OFFERING-SSA - OFFERING(OFF# =1)
bb bbbbbbb
04/09/23 IMS DB Concepts 67
Sequential retrieval Get Next (GN) Call
Example 3 (Contd..)
Repeated use of this call retrieves all the OFFERING segments with key 1, under all the COURSE segments with key M23. After the last segment is retrieved, IMS returns ‘GE’ return code
04/09/23 IMS DB Concepts 68
Sequential retrieval Get Next (GN) Call
Example 4: Both Unqualified and Qualified SSAs
CALL ‘CBLTDLI’ USING GU PCB-MASK IO-AREA COURSE-SSA OFFERING-SSA STUDENT-SSA
04/09/23 IMS DB Concepts 69
Sequential retrieval Get Next (GN) Call
Example 4 (Contd..)
where COURSE-SSA - COURSE (COURSE# =M23) OFFERING-SSA - OFFERING STUDENT-SSA: STUDENT (EMP# =36162)
Repeated use of this call retrieves the STUDENT segments with EMP# 36162, under the all the offering segments present under all the COURSE segments with key value M23.
bb bbb
b bbbbb
04/09/23 IMS DB Concepts 70
Sequential retrieval Get Next (GN) Call
Example 5: GN call with Missing Levels
CALL ‘CBLTDLI’ USING GN PCB-MASK IO-AREA STUDENT-SSA
where STUDENT-SSA - STUDENT (EMP# =36162)bbbbbb
04/09/23 IMS DB Concepts 71
Sequential retrieval Get Next (GN) Call
Example 5: GN call with Missing Levels
Repeated use of this call retrieves all the STUDENT segments with EMP# 36162, no matter what they are dependent on.
After the last occurrence, ‘GE’ return code is returned
04/09/23 IMS DB Concepts 72
Sequential retrieval Get next within Parent (GNP)
Usage– when you want the next segment in the hierarchy
under an established parent
– when you want to sequentially browse the database in the hierarchic order, under given parent
– often issued after a GU or GN call
04/09/23 IMS DB Concepts 73
Sequential retrieval Get next within Parent (GNP)
About– DL/I uses the current position and parentage set by
the previous GU/GN call as the starting point.
– You can set parentage in two ways
• By issuing a successful GU or GN call
• By using the P command code with a GU, GN, or GNP call
04/09/23 IMS DB Concepts 74
Sequential retrieval Get next within Parent (GNP)
– GNP behaves exactly like the GN call but the in a GNP call, the search for the next segment occurs only under the established parent (Refer to the explanation for the GN call)
– If a GNP call is issued without establishing prior parentage, IMS returns a ‘GP’ status code.
04/09/23 IMS DB Concepts 75
Sequential retrieval Get next within Parent (GNP)
Status Codes– Blank - The call was successful
– GE - Segment not found
– GA - DL/I moved to a higher level
– GK - DL/I moved to the next segment type
– GP - Parentage not established
04/09/23 IMS DB Concepts 76
IMS Calls: Loading and Inserting
Session 5
04/09/23 IMS DB Concepts 77
Insert Call
Usage– Add new segments to an existing database
– Load records to a new database
– IMS knows whether the program is going to load a database from scratch or insert segments on to an existing database from the processing options in the PCB.
04/09/23 IMS DB Concepts 78
Insert Call Valid PROCOPT Values
– L - Load Mode
– LS - Load Mode ascending sequence (also allows insert calls)
– A - Get, Insert, Delete, Replace (not valid if loading from scratch)
– AS - Same as A, but in ascending sequence (not valid if loading from scratch)
– I - Insert mode
– IS - Insert mode ascending sequence
04/09/23 IMS DB Concepts 79
Loading a database A database is loaded from scratch usually using a load
program. The input records must be presented in hirearchical
sequence. The Load Program consists of a single ISRT call, which is
used to insert all segment types. Segment images are read from the input dataset and the
program determines the type segment that is to loaded The Unqualified SSA is formatted with the proper segment
name and the IOAREA populated. It is not correct to qualify the SSA for the segment to be
inserted.
04/09/23 IMS DB Concepts 80
Loading a database
Insert Call for LOAD
CALL ‘CBLTDLI’ USING ISRT COURSE-PCB-MASK IO-AREA LOAD-SSA
where LOAD-SSA is 01 LOAD-SSA. 03 SEGNAME PIC X(08). 03 FILLERPIC X(01) VALUE SPACES.
04/09/23 IMS DB Concepts 81
Loading a Database
Status CodesLB - Segment already exists
LC - Key Values out of sequence
LD - No parent for segment being loaded
LE - Segment types out of sequence
04/09/23 IMS DB Concepts 82
Insert Call
Example 1: Insert with unqualified SSA
CALL ‘CBLTDLI’ USING ISRT COURSE-PCB-MASK STUDENT-IO-AREA COURSE-SSA
STUDENT-SSA
where COURSE-SSA - COURSE (COURSE# =M23)
OFFERING-SSA - OFFERING bb bb
b
04/09/23 IMS DB Concepts 83
Insert Call
Example 2: (with qualified SSA)CALL ‘CBLTDLI’ USING DLI-ISRT
COURSE-PCB-MASK STUDENT-IO-AREA COURSE-SSA OFFERING-SSA
where COURSE-SSA - COURSE (COURSE# =M23)
OFFERING-SSA - OFFERING(OFF# =4)bb bb
bbbbb
04/09/23 IMS DB Concepts 84
Insert Call
Status Codes– GE : In a multiple SSA, at least one of the
segments is not present
– II: Duplicate Segment
– IX: Insert Rule Violation
04/09/23 IMS DB Concepts 85
Insert Call
Command Codes:– F & L
• Meaningful only for non-unique keys & segments without keys
– D
• For inserting more than one segment along the path
04/09/23 IMS DB Concepts 86
IMS Calls: Update Processing
Session 6
04/09/23 IMS DB Concepts 87
Get Hold Calls Usage
– The Get-Hold calls cause IMS to save information about the segment location, so that the segments can be later deleted (with a DLET) call or replaced (REPL) call.
04/09/23 IMS DB Concepts 88
Get Hold Calls Get Hold Functions
– "Get Hold Unique," or GHU, is the hold form for a GU call
– "Get Hold Next," or GHN, is the hold form for a GN call
– "Get Hold Next in Parent," or GHNP, is the hold form for a GNP call.
– No other call is allowed that reference the same PCB between the time the program issues a GH call and the REPL or DLET call.
04/09/23 IMS DB Concepts 89
Replace Call - REPL
Usage– Used to replace the original contents of a segment– Should always be preceded by a GHU, GHN or a GHNP call.– If the preceding Get Hold is a path call
• replace operates on the entire path• use N command with unqualified SSA if you don't want to
replace some of the segments in the path
04/09/23 IMS DB Concepts 90
Replace Call - REPL
Example
CALL ‘CBLTDLI’ USING GHU COURSE-PCB-MASK OFFERING-IO-AREA COURSE-SSA OFFERING-SSA
where COURSE-SSA - COURSE (COURSE# =M23) OFFERING-SSA - OFFERING
bbb
bb
04/09/23 IMS DB Concepts 91
Replace Call - REPL
Example (Contd..)
After retrieving the OFFERING Segment, with the GH call, its image in the I/O area is manipulated to effect the desired changes (except key field) and the REPL call is issued.
CALL ‘CBLTDLI’ USING REPL COURSE-PCB-MASK
OFFERING-IO-AREA
04/09/23 IMS DB Concepts 92
Replace Call - REPL
Status Codes– Blank - No error– AJ - Qualified SSA is used– DJ - No preceding Get Hold call– DA - Segment’s Key field is altered
04/09/23 IMS DB Concepts 93
Replace Call - REPL
Restrictions– Length of the segment can not be changed
– Key fields can not be changed
– Qualified SSA not allowed
04/09/23 IMS DB Concepts 94
Delete Call - DLET
Usage – Used to delete a segment
– DLET call must be preceded by one of the three Get Hold calls
04/09/23 IMS DB Concepts 95
Delete Call - DLET
Example
CALL ‘CBLTDLI’ USING GHU COURSE-PCB-MASK OFFERING-IO-AREA
COURSE-SSA OFFERING-SSA
04/09/23 IMS DB Concepts 96
Delete Call - DLET
Example (Contd..)
where COURSE-SSA - COURSE (COURSE# =M23) OFFERING-SSA - OFFERING
CALL ‘CBLTDLI’ USING DLET COURSE-PCB-MASK OFDERING-IO-AREA
bb bb
04/09/23 IMS DB Concepts 97
Delete Call - DLET
Restrictions– DLET call must be preceded by one of the three
Get Hold calls
– All of its physical dependents are also deleted from the database regardless of whether or not your program is sensitive to all of these segments
– Only one SSA is allowed in the DLET call
– No command codes apply to the DLET call
04/09/23 IMS DB Concepts 98
Delete Call - DLET
Status Codes– DJ - No previous Get Hold Call
– DA - Key field modified
– DX - Delete Rule Violation
04/09/23 IMS DB Concepts 99
IMS Environments and Regions
Session 7
04/09/23 IMS DB Concepts 100
IMS Application Processing Environments DB/DC Environment
– Message Processing Programs: MPPs– Batch Message Processing Programs: BMPs
DBCTL Environment Batch Environment
04/09/23 IMS DB Concepts 101
IMS Regions IMS control region
– Handles all the communication between remote terminals and IMS.
– Also controls the use of the various MP regions in the system
MP regions – Region where MP programs are executed
BMP regions. – Region where BMP programs are executed
04/09/23 IMS DB Concepts 102
Types of Programs
Batch programs Online message processing programs
(MPPs) Batch message processing programs
(BMPs)
04/09/23 IMS DB Concepts 103
Batch Programs
Also called DL/I Programs Typically produce a large amount of output Are not executed by another program or user Produce output that is not needed right away The databases and the online regions must be
down for Batch DL/I processing.
04/09/23 IMS DB Concepts 104
Batch Programs Users cannot use screens and other MP programs
that access these databases that are taken offline. DL/I programs are typically run from late
evening till midnight or till early morning to carry out daily (routine) processing, mass updates and/or to create daily reports.
Database datasets have to be defined in the batch JCL.
04/09/23 IMS DB Concepts 105
Online Message Processing Programs (MPP) Used for Screen Processing Steps to process a transaction
– Retrieve a message from IMS.
– Process the message and access the database as necessary.
– Respond to the message.
– Repeat the process until there are no more messages; terminate
04/09/23 IMS DB Concepts 106
Online Message Processing Programs (MPP) For each MPP, the following is to be
defined– The transaction's priority
– The number of messages for a particular transaction code that the MPP can process in a single scheduling
– The amount of time (in seconds) in which the MPP is allowed to process a single transactio
MPP’s cannot access MVS datasets.
04/09/23 IMS DB Concepts 107
Batch Message Processing Programs (BMP) Used when it is necessary to receive
substantial information from remote terminals and each message requires substantial processing and a response back to the terminal is generally not required.
BMPs can however send messages to other an MPP or another (transaction-oriented) BMP.
04/09/23 IMS DB Concepts 108
Batch Message Processing Programs (BMP) Also used for batch programs online,
without retrieving or sending messages from and to the terminals.
The databases need not be shut down and the online region can be up, so that users can use MP programs (screens).
Like the MPPs, The BMPs have to be defined to the IMS system.
04/09/23 IMS DB Concepts 109
Batch Message Processing Programs (BMP) BMPs can access MVS Datasets. There are two kinds of BMPs:
A transaction-oriented BMP accesses message queues for its input and output. It can also process input from MVS files, and it can create MVS files.
A batch-oriented BMP does not access the message queue for input; it is simply a batch program that runs online. It can send its output to an MVS output device.
04/09/23 IMS DB Concepts 110
Batch Message Processing Programs (BMP) Like Batch programs, BMP’s do have JCLs
defined to specify the MVS datasets to be used, PSB, Recovery options IMS log datasets etc.
The BMP’s can be scheduled to run every hour or every couple of hours, depending on the need.
04/09/23 IMS DB Concepts 111
IMS Recovery & Restart
Session 8
04/09/23 IMS DB Concepts 112
Recovery and Restart– Needed when a DL/I or BMP program abends.
– Helps in maintaining the integrity of the databases
– Once database is recovered to the last stable state, program(s) can be conveniently restarted.
– When a job which normally runs for 5 hrs crashes after 4 hrs, recovery and restart procedures help in restarting the job from the point it abended, so that it is not run from scratch.
04/09/23 IMS DB Concepts 113
Recovery and Restart DL/I abends
– A DL/I program does not abend the way a non-DL/I program abends, because DL/I programs are executed under the control if DL/I rather than the operating system
– DL/I intervenes to contain the damage to the databases by invoking an abnormal termination routine.
– DL/I however, does not correct the damage.
04/09/23 IMS DB Concepts 114
Recovery and Restart Abnormal Termination Routine
– Make sure that the database data sets are properly closed.
– Catalog entries are properly updated.
– The DL/I log used is closed
– Cancels the job
– If requested, puts out a storage dump, which can be manually analyzed to find what caused abend.
04/09/23 IMS DB Concepts 115
Recovery and Restart Logging
– When logging is used, DL/I records all the changes a program makes to its databases in a special file called IMS LOG file.
– The log is updated prior to the database update (Write-Ahead Logging.
– Can reside in Tape or Disk
– Records the before and after image of a segment, when changes are made to it.
04/09/23 IMS DB Concepts 116
Forward Recovery– Change data in the DL/I logs accumulated for a
period of time is applied to a image copy of the database as it existed before the changes began.
– Used only when a database is physically damaged in some way and may be a device error makes it inaccessible
– An old image copy of database (in stable state) and a log dataset containing the accumulated changes must be available.
04/09/23 IMS DB Concepts 117
Forward Recovery– The Database Image Copy Utility is used for
making image copies of the database
– The Database Change Accumulation Utility is used for consolidating the change logs.
– The Dataset recovery utility is used for recovering the database to a stable state
04/09/23 IMS DB Concepts 118
Backward Recovery– Also called Database Backout
– Used for reversing all the changes to the database till the last Stable State (Checkpoint), in case of an abend.
– The IMS log records are read backwards and their effects are reversed in the database.
– When the backout is complete, the databases are in the same state they were before the failure.
04/09/23 IMS DB Concepts 119
Backward Recovery– Database backout Utility can be used for the
purposes of performing a Backout.
– Backward Recovery is appropriate when program ends in a controlled fashion- that is, an abnormal termination routine is called by the application program, that records and reports the problem
04/09/23 IMS DB Concepts 120
Backward Recovery Note:
– An application program can also chose to invoke dymanic backout, by issuing a ROLLBACK call (ROLB).
– Generally speaking, ROLB calls are avoided in pure DL/I programs and Batch-Oriented BMPs. However, they will normally be used in MPPs and Transaction-oriented BMPs.
04/09/23 IMS DB Concepts 121
I/O PCB Mask
An IO-PCB is a special PCB used to request system related requests like:– Checkpoint
– Restart
– Receiving messages from the message queue into an application program
– Sending messages from an application program to the same logical terminal or application program
04/09/23 IMS DB Concepts 122
I/O PCB Mask
Logical Terminal Name (8 bytes) Reserved for IMS (2 bytes) Status Code (2 bytes) Current Date (4 bytes) Current Time ( 4 bytes) Input Message Sequence Number (4 bytes) Message Output Descriptor Name (8 bytes)
04/09/23 IMS DB Concepts 123
I/O PCB Mask
User Identification (8 bytes) Group name (8 bytes)
04/09/23 IMS DB Concepts 124
Checkpoint Synonymous to Sync point, commit point or
point of integrity. Database changes are committed during Checkpoint.
Point of execution in a the program where the database changes are considered complete and accurate.
Database changes before the most recent checkpoint are not reversed by backward recovery.
04/09/23 IMS DB Concepts 125
Checkpoint Database changes logged after the most recent
checkpoint are not applied to an image copy of the database during forward recovery.
Establishing Checkpoint
– A Checkpoint is established using a CHKP call
– A checkpoint record is written on to the IMS log file, which tells the DL/I recovery utilities that recovery should stop here.
04/09/23 IMS DB Concepts 126
Checkpoint Frequency Generally, Checkpoints are taken at regular
intervals (example every 10 minutes or 15 minutes) or after a specified number of transactions (say for every 1000 transactions)
The Checkpoint frequency may vary depending on the complexity and average execution time of the application and on the volume of data updated.
04/09/23 IMS DB Concepts 127
Basic Checkpoint The format of a Basic Checkpoint call is
CALL ‘CBLTDLI’ USING CHKP IO-PCB-MASK
CHECKPOINT-ID The IO-PCB format is as follows:
01 IO-PCB-MASK 05 FILLER PIC X(10). 05 IO-PCB-STATUS-CODE PIC X(02).
The IO-PCB has to be the first PCB in the ENTRY statement in the Procedure Division.
04/09/23 IMS DB Concepts 128
Basic Checkpoint Checkpoint-id Field:
– Contains Eight-bytes – Takes the place of a segment I/O area for an IMS
call. – Program places a value that identifies the
checkpoint record on the IMS log file The checkpoint-id can then be used to restart the
program
04/09/23 IMS DB Concepts 129
Basic Checkpoint Disadvantages
– Program has to provide a facility to accept the checkpoint-id, then decide what to do with it.
– May have to read transaction files to skip transactions that were posted before the last checkpoint.
– This means the resetting of working storage fields to the values they had when the checkpoint was taken.
04/09/23 IMS DB Concepts 130
Symbolic Checkpoint Similar to Basic Checkpoint but:
– Works with Extended Restart (XRST) call to restart the program which was terminated abnormally.
– Can save as many as 7 data areas in the program, which are restored when the program is restarted.
– Note: • In each Data area, the first item is the name of a full-word
field [PIC S9(5) COMP], that contains the name of length of the data area to be saved. The second is the name of the data area itself.
04/09/23 IMS DB Concepts 131
Symbolic Checkpoint The format of a Symbolic Checkpoint call
is CALL ‘CBLTDLI’ USING CHKP IO-PCB-MASK
CHECKPOINT-ID [DATA-AREA-1] [DATA-AREA-2] [DATA-AREA-3]
….. ….. ….. [DATA-AREA-7]
04/09/23 IMS DB Concepts 132
Extended Restart - XRST Call Causes restart to be performed. Must be used in a program if Symbolic Checkpoint
is used Issued only once - at the beginning of the program. If the program is not restarted, it indicates that
subsequent CHKP calls will be Symbolic Checkpoints rather than basic checkpoints.
Establishes the maximum number of areas within the program that can be Checkpointed on subsequent CHKP calls.
04/09/23 IMS DB Concepts 133
XRST Call The format of an XRST call is
CALL ‘CBLTDLI’ USING XRST IO-PCB-MASK
RESTART-IO-AREA [DATA-AREA-1]
[DATA-AREA-2] [DATA-AREA-3]
….. ….. ….. [DATA-AREA-7]
04/09/23 IMS DB Concepts 134
Ways of Starting a Program Normal start
– The IO-AREA pointed to in the XRST call must contain blanks. If IMS does not change the area after issuing the XRST call, then the program is being started normally.
Restart based on the I/O area provided by the XRST call– The first 8 bytes of the I/O area will be populated
with the Checkpoint ID and the remaining 4 bytes will be blank
04/09/23 IMS DB Concepts 135
Ways of Starting a Program Restart based on the PARM field of the
EXEC statement on the program’s JCL.
04/09/23 IMS DB Concepts 136
What happens during XRST IMS reads the system log defined in the //IMSLOGR
DD statement and searches for the checkpoint records with the Checkpoint ID supplied.
When this ID is found, IMS restores the areas that we identified in the Symbolic CHKP Call.
For restarting a BMP, instead of supplying the whole Checkpoint ID, we can just specify ‘LAST’ in the I/O area pointed to by the XRST call and leaving the remaining 8 bytes blank. This instructs IMS to use the last checkpoint issued by the BMP.
04/09/23 IMS DB Concepts 137
Repositioning after XRST The XRST call attempts to reposition all the databases
to the position held when the checkpoint was taken. This is done by including each PCB and PCB key
feedback area in the checkpoint record. Issuing XRST causes the key feedback area from the
PCB in the checkpoint record to be moved to the corresponding PCB in the PSB being restarted.
Then IMS issues a GU call qualified with the concatenated key for each PCB that held a position when the checkpoint was taken.
04/09/23 IMS DB Concepts 138
Restrictions After issuing a Checkpoint call, IMS loses the positions
held in all the databases. It is our responsibility to reposition our databases in the application program, after a CHKP call.
Do not take a checkpoint call after a DLET. If we do so, the next time we try to reposition `issue a XRST call to restart, IMS will issue a GU call with the relevant concatenated keys to find the segment. Since it is already deleted, IMS will return a ‘GE status code.
XRST cannot reposition to the right segment if a segment or any of its parents have a non-unique key.
04/09/23 IMS DB Concepts 139
GSAM Processing Generalized Sequential Access Method Allows an application program to access either a
standard dataset or a VSAM ESDS through IMS calls. GSAM datasets allow Symbolic Checkpoint and Restart. GSAM is non-hierarchical. GSAM does not have any
segments, segment type, key fields, search fields. The unit of data that is retrieved is merely a record. GSAM datasets are commonly used when the business
requires that the programs are re-startable. GSAM allows files with record formats F, FB, V,VB
and U.
04/09/23 IMS DB Concepts 140
GSAM Processing GSAM supports only GU, GN and ISRT, OPEN,
CLSE calls. GSAM files can be easily restarted Only sequential processing is allowed. Records can be added only at the end of the database It is not possible to delete records
04/09/23 IMS DB Concepts 141
GSAM DBD & PCBDBD
DBD NAME=GSAMDBD,ACCESS=(GSAM,VSAM)DATASET DD1=INPUT,DD2=OUTPUT,RECFM=F,RECORD=80DBDGENFINISHEND
PSB
PCB TYPE=GSAM,PROCOPT=G,DBDNAME=GSAMDBDPCB TYPE=GSAM,PROCOPT=L,DBDNAME=GSAMDBDPSBGEN LANG=COCOL,PSBNAME=<Name of the PSB>
04/09/23 IMS DB Concepts 142
GSAM IMS Callsa) CALL ‘CBLTDLI’ USING GU
GSAM-PCB IO-AREA
b) CALL ‘CBLTDLI’ USING GN GSAM-PCB
IO-AREA
c) CALL ‘CBLTDLI’ USING ISRT GSAM-PCB
IO-AREA
04/09/23 IMS DB Concepts 143
GSAM IMS Calls Note:
– GSAM automatically opens the database upon the first GU or GN call.
– GSAM automatically closes the database upon reaching the end of the database or when the program terminates
– The OPEN and CLSE call are used to explicitly open and close the database, in cases where the same GSAM file is created and read in a single job step.
04/09/23 IMS DB Concepts 144
Coding GSAM DD namesTo use Input GSAM files//INPUT DD DSN=FILE1,DISP=SHR
To use Output GSAM files
//OUTPUT DD DSN=FILE2,DISP=(,CATLG,CATLG), DCB=(LRECL=80,REFCM=FB,BLKSIZE=8000)
04/09/23 IMS DB Concepts 145
Checkpoint and Restart To Checkpoint GSAM databases, we must use Symbolic
CHKP and XRST calls. When we use XRST, IMS automatically repositions
GSAM for processing. Do not use Temporary datasets with Symbolic CHKP and
XRST SYSOUT used at restart time can give duplicate output
data After taking a checkpoint, IMS cancels all the positions
held normal IMS databases, but in GSAM, positions are maintained.