IMS DB CONCEPTS
TOPICS
• Introduction to IMS
• IMS Database Definition
• IMS Database programming
• Recovery & Restart
10/22/24 IMS DB Concepts 2
Introduction to IMS
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
10/22/24 IMS DB Concepts 4
IMS Software Development
IMS
Database
Operating
System
DL/I
IMS Control IMS DC
Blocks
Application Terminal
Program
Reports
10/22/24 IMS DB Concepts 5
IMS Terminology
• Segment : Smallest Unit of information that IMS transfers to
and from the database.
• Segment Types & Segment Occurrences
• Fields
• Path: An imaginary line that starts at the root segment type,
passes the segment types at intermediate levels in the hierarchy
and ends at a segment type at the bottom of the database
structure.
• Record: Consists of a single occurrence of the root segment
type and of its dependent segment occurrences
• Database: Collection of all the database records
10/22/24 IMS DB Concepts 6
IMS Terminology
• Parent : Any segment type having one or more segment
types below.
• Child : Any segment type having a segment type directly
above
• Twins : All occurrences of a particular segment type under a
single parent segment occurrence
• Twin Chain : The set of all twins dependent on a particular
parent
• Key or Sequence field : IMS uses to maintain segments in
ascending order
• Search Field : Additional field used for search for a segment
10/22/24 IMS DB Concepts 7
Hospital Database
10/22/24 IMS DB Concepts 8
IMS Database Definition
• Data Base Description (DBD)
- Physical Nature of a Database
• Program Specification Block
- Logical Data Structure
10/22/24 IMS DB Concepts 9
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.
10/22/24 IMS DB Concepts 10
Generation of DBD (DBDGEN)
DBD NAME = HOSPDBD,ACCESS=(HISAM,ISAM)
DATASET DD1=PRIME, OVFLW = OVERFLOW, DEVICE = 3380
SEGM NAME HOSPITAL, PARENT = 0, BYTES = 80
FIELD NAME = (HOSPNAME,SEQ,U),BYTES = 20,START = 1, TYPE = C
FIELD NAME = ADMIN,BYTES = 20,START =6 1, TYPE = C
SEGM NAME = WARD, PARENT = HOSPITAL, BYTES = 125
FIELD NAME = (WARDNO,SEQ,U),BYTES = 2,START = 1, TYPE = C
FIELD NAME = BEDAVAIL,BYTES = 3,START = 9, TYPE = C
FIELD NAME = WARDTYPE,BYTES = 20,START = 12, TYPE = C
:
DBDGEN
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.
10/22/24 IMS DB Concepts 12
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 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
10/22/24 IMS DB Concepts 13
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.
10/22/24 IMS DB Concepts 14
Generation of PSB (PSBGEN)
PCB TYPE = DB, NAME = HOSPDBD
SENSEG NAME = HOSPITAL, PARENT = 0, PROCOPT = K
SENSEG NAME = WARD, PARENT = HOSPITAL, PROCOPT = K
SENSEG NAME = PATIENT, PARENT = WARD, PROCOPT = G
PSBGEN LANG = COBOL, PSBNAME = PATGET
10/22/24 IMS DB Concepts 15
IMS Database programming
• Program Structure
• Random Retrieval
• Sequential Retrieval
• Loading and inserting Segments
• Deleting and Updating Segments
10/22/24 IMS DB Concepts 16
Program Structure
• Program Entry
• PCB mask
• I/O area
• DL/I calls
• Termination
10/22/24 IMS DB Concepts 17
IMS Application Program
Components
I/O AREA
WORKING
STORAGE
SEGMENTS TO/FROM DATABASE 3
PCB MASK
LINKAGE
RETURN INFO FROM DL/I SECTION
4
PROGRAM ENTRY 1 PROGRAM
LOGIC
CALLS TO DL./I
2
GET
INSERT
REPLACE
DELETE
PROCESSING
TERMINATON 5
DL/I
DL/I MODULES
10/22/24 IMS DB Concepts 18
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.
10/22/24 IMS DB Concepts 19
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
10/22/24 IMS DB Concepts 20
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
10/22/24 IMS DB Concepts 21
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 JCB-ADDRESS PIC S9(5) COMPUTATIONAL.
02 SEG-NAME PIC X(8).
02 KEY-LENGTH PIC S9(5) COMPUTATIONAL.
02 NUMBER-SEGS PIC S 9(5) COMPUTATIONAL.
02 KEY-FEEDBACK PIC X(n).
10/22/24 IMS DB Concepts 22
Format of an IMS CALL
COBOL:
CALL 'CBLTDLI' USING FUNCTION,
DBPCB,
I/O AREA,
[,SSA1,SSA2,SSA3...,SSAn].
10/22/24 IMS DB Concepts 23
Random Retrieval
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
10/22/24 IMS DB Concepts 25
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
10/22/24 IMS DB Concepts 26
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)
10/22/24 IMS DB Concepts 27
Random retrieval
Get Unique (GU) Call
Example 1: Fully Qualified SSAs in all
levels. SSA have values.
CALL ‘CBLTDLI’ USING GU
PCB-MASK
IO-AREA
HOSPITL-SSA
WARD-SSA
GU HOSPITAL (HOSPNAME = MAC NEAL)
WARD (WARDTYPE = INTENSIVE)
10/22/24 IMS DB Concepts 28
Random retrieval
Get Unique (GU) Call
Example 2: Unqualified SSAs in all
levels. SSA don’t have value.
CALL ‘CBLTDLI’ USING GU
PCB-MASK
IO-AREA
HOSPITL-SSA
WARD-SSA
PATIENT-SSA
GU HOSPITAL
WARD
PATIENT
10/22/24 IMS DB Concepts 29
Random retrieval
Get Unique (GU) Call
Example 3: Missing hierarchical levels:
CALL ‘CBLTDLI’ USING GU
PCB-MASK
IO-AREA
PATIENT-SSA
GU PATIENT (PATNAME= WHEELER)
10/22/24 IMS DB Concepts 30
Random retrieval
Get Unique (GU) Call
Example 4: Call with No SSAs.
CALL ‘CBLTDLI’ USING GU
PCB-MASK
IO-AREA
Retrieves the first occurrence of the root segment(Hospital segment)
10/22/24 IMS DB Concepts 31
Sequential retrieval
10/22/24 IMS DB Concepts 32
Get Next (GN) Call
• Usage
– when you want the next segment in the hierarchy
– when you want to sequentially browse the database in
the hierarchical order
– often issued after a GU call
• About
– DL/I uses the current position set by the previous call
as the search starting point
10/22/24 IMS DB Concepts 33
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.
10/22/24 IMS DB Concepts 34
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
10/22/24 IMS DB Concepts 35
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.
10/22/24 IMS DB Concepts 36
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
10/22/24 IMS DB Concepts 37
Sequential retrieval
Get Next (GN) Call
Example 1: Fully Qualified SSAs. SSA
have values
CALL ‘CBLTDLI’ USING GN
PCB-MASK
IO-AREA
HOSPITAL-SSA
WARD-SSA
PATIENT-SSA
GN HOSPITAL (HOSPNAME = RIVEREDGE)
WARD (WARDNO = 02)
PATIENT (BEDIDENT = 0003)
10/22/24 IMS DB Concepts 38
Sequential retrieval
Get Next (GN) Call
Example 1 (Contd..)
•Repeated use of this call retrieves all the Patient
segments, under the Ward segment, under the Hospital
segment with condition specified in SSA.
•After the last segment is retrieved, IMS returns ‘GE’
return code
10/22/24 IMS DB Concepts 39
Sequential retrieval
Get Next (GN) Call
Example 2: GN with Unqualified SSAs.
SSA dose not have value
CALL ‘CBLTDLI’ USING GU
PCB-MASK
IO-AREA
PATIENT-SSA
10/22/24 IMS DB Concepts 40
Sequential retrieval
Get Next (GN) Call
Example 2 (Contd..)
• Repeated use of this call retrieves all the Patient
segments
• After the last segment is retrieved, IMS returns ‘GE’
return code
10/22/24 IMS DB Concepts 41
Sequential retrieval
Get Next (GN) Call
Example 3: 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
10/22/24 IMS DB Concepts 42
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
10/22/24 IMS DB Concepts 43
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
10/22/24 IMS DB Concepts 44
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
– If a GNP call is issued without establishing prior
parentage, IMS returns a ‘GP’ status code.
10/22/24 IMS DB Concepts 45
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
10/22/24 IMS DB Concepts 46
IMS Calls: Loading and Inserting
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.
10/22/24 IMS DB Concepts 48
• 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
10/22/24 IMS DB Concepts 49
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.
10/22/24 IMS DB Concepts 50
Loading a database
•Insert Call for LOAD
CALL ‘CBLTDLI’ USING ISRT
HOSPITAL-PCB-MASK
IO-AREA
LOAD-SSA
where LOAD-SSA is
01 LOAD-SSA.
03 SEGNAME PIC X(08).
03 FILLERPIC X(01) VALUE SPACES.
10/22/24 IMS DB Concepts 51
Loading a Database
•Status Codes
LB - Segment already exists
LC - Key Values out of sequence
LD - No parent for segment being loaded
LE - Segment types out of sequence
10/22/24 IMS DB Concepts 52
Insert Call
Example : Insert with Qualified SSA
CALL ‘CBLTDLI’ USING ISRT
PCB-MASK
IO-AREA
HOSPITAL-SSA
WARD-SSA
PATIENT-SSA
ISRT HOSPITAL (HOSPNAME = XYZ)
WARD (WARDNO = X)
PATIENT
10/22/24 IMS DB Concepts 53
IMS Calls: Update Processing
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.
10/22/24 IMS DB Concepts 55
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.
10/22/24 IMS DB Concepts 56
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
10/22/24 IMS DB Concepts 57
Replace Call - REPL
Example
CALL ‘CBLTDLI’ USING GHU
PCB-MASK
IO-AREA
HOSPITAL-SSA
WARD-SSA
PATIENT-SSA
CALL ‘CBLTDLI’ USING REPL
10/22/24 IMS DB Concepts 58
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
10/22/24 IMS DB Concepts 59
Replace Call - REPL
• Restrictions
– Length of the segment can not be changed
– Key fields can not be changed
– Qualified SSA not allowed
10/22/24 IMS DB Concepts 60
Delete Call - DLET
• Usage
– Used to delete a segment
– DLET call must be preceded by one of the three
Get Hold calls
10/22/24 IMS DB Concepts 61
Delete Call - DLET
Example
CALL ‘CBLTDLI’ USING GHU
PCB-MASK
IO-AREA
HOSPITAL-SSA
WARD-SSA
PATIENT-SSA
CALL ‘CBLTDLI’ USING DLET
10/22/24 IMS DB Concepts 62
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
10/22/24 IMS DB Concepts 63
Delete Call - DLET
• Status Codes
– DJ - No previous Get Hold Call
– DA - Key field modified
– DX - Delete Rule Violation
10/22/24 IMS DB Concepts 64
IMS Environments and Regions
IMS Application Processing
Environments
• DB/DC Environment
– Message Processing Programs: MPPs
– Batch Message Processing Programs: BMPs
• DBCTL Environment
• Batch Environment
10/22/24 IMS DB Concepts 66
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
10/22/24 IMS DB Concepts 67
Types of Programs
• Batch programs
• Online message processing programs
(MPPs)
• Batch message processing programs
(BMPs)
10/22/24 IMS DB Concepts 68
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.
10/22/24 IMS DB Concepts 69
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.
10/22/24 IMS DB Concepts 70
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
10/22/24 IMS DB Concepts 71
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 transaction
• MPP’s cannot access MVS datasets.
10/22/24 IMS DB Concepts 72
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.
10/22/24 IMS DB Concepts 73
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.
10/22/24 IMS DB Concepts 74
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.
10/22/24 IMS DB Concepts 75
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.
10/22/24 IMS DB Concepts 76
IMS Recovery & Restart
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.
10/22/24 IMS DB Concepts 78
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.
10/22/24 IMS DB Concepts 79
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.
10/22/24 IMS DB Concepts 80
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.
10/22/24 IMS DB Concepts 81
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.
10/22/24 IMS DB Concepts 82
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
10/22/24 IMS DB Concepts 83
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.
10/22/24 IMS DB Concepts 84
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
10/22/24 IMS DB Concepts 85
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.
10/22/24 IMS DB Concepts 86
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
10/22/24 IMS DB Concepts 87
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)
10/22/24 IMS DB Concepts 88
I/O PCB Mask
• User Identification (8 bytes)
• Group name (8 bytes)
10/22/24 IMS DB Concepts 89
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.
10/22/24 IMS DB Concepts 90
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.
10/22/24 IMS DB Concepts 91
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.
10/22/24 IMS DB Concepts 92
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.
10/22/24 IMS DB Concepts 93
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
10/22/24 IMS DB Concepts 94
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.
10/22/24 IMS DB Concepts 95
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.
10/22/24 IMS DB Concepts 96
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]
10/22/24 IMS DB Concepts 97
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.
10/22/24 IMS DB Concepts 98
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]
10/22/24 IMS DB Concepts 99
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
10/22/24 IMS DB Concepts 100
Ways of Starting a Program
• Restart based on the PARM field of the
EXEC statement on the program’s JCL.
10/22/24 IMS DB Concepts 101
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.
10/22/24 IMS DB Concepts 102
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.
10/22/24 IMS DB Concepts 103
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.
10/22/24 IMS DB Concepts 104
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.
10/22/24 IMS DB Concepts 105
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
10/22/24 IMS DB Concepts 106
GSAM DBD & PCB
DBD
DBD NAME=GSAMDBD,ACCESS=(GSAM,VSAM)
DATASET DD1=INPUT,DD2=OUTPUT,RECFM=F,RECORD=80
DBDGEN
FINISH
END
PSB
PCB TYPE=GSAM,PROCOPT=G,DBDNAME=GSAMDBD
PCB TYPE=GSAM,PROCOPT=L,DBDNAME=GSAMDBD
PSBGEN LANG=COCOL,PSBNAME=<Name of the PSB>
10/22/24 IMS DB Concepts 107
GSAM IMS Calls
a) 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
10/22/24 IMS DB Concepts 108
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.
10/22/24 IMS DB Concepts 109
Coding GSAM DD names
To 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)
10/22/24 IMS DB Concepts 110
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.
10/22/24 IMS DB Concepts 111
IMS Advantages
• Performance
• Simplicity
• Maintenance
• Control
• Security
• Transaction Manager
10/22/24 IMS DB Concepts 112