ims db-apr2002
TRANSCRIPT
8/6/2019 IMS DB-Apr2002
http://slidepdf.com/reader/full/ims-db-apr2002 1/132
Apr 3, 2002 IMS DB Page : 1/132
IMS DBIMS DBCourse Code:
Version No: 1.1
Date of Release: April 3, 2002
Authors:
Deepak Madhusoodanan
Prasad Krishna Murthy Rajagopa Balakrishnan
Tinu J Punnoor
8/6/2019 IMS DB-Apr2002
http://slidepdf.com/reader/full/ims-db-apr2002 2/132
Apr 3, 2002 IMS DB Page : 2/132
ObjectivesObjectives
To create awareness among trainees about the IMS DBtechnology and how it is used to perform data base
operations.
The target audience consists of people who are new or
relatively new to the IMS DB Technology.
8/6/2019 IMS DB-Apr2002
http://slidepdf.com/reader/full/ims-db-apr2002 3/132
8/6/2019 IMS DB-Apr2002
http://slidepdf.com/reader/full/ims-db-apr2002 4/132
Apr 3, 2002 IMS DB Page : 4/132
Course OutlineCourse Outline
1. An Introduction to DL/I Data Bases
2. An Introduction to DL/I Programs and Control Blocks
3. COBOL Basics for Processing a DL/I Data Base
4. Using Segment Search Arguments
5. Retrieving Data from a Data Base
6. Adding and Updating Data in a Data Base7. Secondary Indexing
8/6/2019 IMS DB-Apr2002
http://slidepdf.com/reader/full/ims-db-apr2002 5/132
Apr 3, 2002 IMS DB Page : 5/132
ReferencesReferences
IMS for the COBOL Programmer Part 1: Data base processing with IMS/VS and DL/I DOS/VS
By Steve Eckols
IBM IMS Primer
By Rick Long, Mark Harrington, Robert Hain, Geoff Nicholls
8/6/2019 IMS DB-Apr2002
http://slidepdf.com/reader/full/ims-db-apr2002 6/132
Apr 3, 2002 IMS DB Page : 6/132
Module 1Module 1An Introduction to DL/I Data BasesAn Introduction to DL/I Data Bases
Hierarchical Structures
Why a Data Base Management System
Basic DL/I Terminology
Basic DL/I Data Base Processing
8/6/2019 IMS DB-Apr2002
http://slidepdf.com/reader/full/ims-db-apr2002 7/132
Apr 3, 2002 IMS DB Page : 7/132
Hierarchical StructuresHierarchical Structures
In a DL/I data base, data elements are organized in ahierarchical structure.
Some data elements are dependent on others.
Fig 1.1 A hierarchical structure
DL/I supports hierarchies that are difficult to
implement with standard files.
8/6/2019 IMS DB-Apr2002
http://slidepdf.com/reader/full/ims-db-apr2002 8/132
Apr 3, 2002 IMS DB Page : 8/132
W hy a data base manag ement system? W hy a data base manag ement system?
01 VENDOR-RECORD.05 VR-VENDOR-CODE PIC X(3).
05 VR-VENDOR-NAME PIC X(30).
05 VR-VENDOR-ADDRESS PIC X(30).
05 VR-VENDOR-CITY PIC X(17).
05 VR-VENDOR-STATE PIC XX.
05 VR-VENDOR-ZIP-CODE PIC X(9).
05 VR-VENDOR-TELEPHONE PIC X(10).
05 VR-VENDOR-CONTACT PIC X(30).
Fig 1.2.a Record layout for the VENDORS data set
01 INVENTORY-RECORD.
05 IR-ITEM-KEY.
10 IR-VENDOR-CODE PIC X(3).
10 IR-NUMBER PIC X(5).
05 IR-DESCRIPTION PIC X(35).
05 IR-UNIT-PRICE PIC S9(5)V99 COMP-3.
05 IR-AVG-UNIT-COST PIC S9(5)V99 COMP-3.
05 IR-LOCATION-QUANTITY-DATA OCCURS 20 TIMES.
10 IR-LOCATION PIC X(3).
10 IR-QUANTITY-ON-HAND PIC S9(7) COMP-3.
10 IR-REORDER-POINT PIC S9(7) COMP-3.10 IR-QUANTITY-ON-ORDER PIC S9(7) COMP-3.
10 IR-LAST-REORDER-DATE PIC X(6).
Fig 1.2.b Record layout for the Inventory Master data set
Fig 1.2 Record layouts that illustrate a hierarchical structure
8/6/2019 IMS DB-Apr2002
http://slidepdf.com/reader/full/ims-db-apr2002 9/132
Apr 3, 2002 IMS DB Page : 9/132
Basic DL/I Terminolog yBasic DL/I Terminolog y
Segment A grouping of data
The unit of data that DL/I transfers to and from your
program in an I/O operation.
Consists of one or more fields
ADDRESS
HouseNumber
Street
Name
City State Country ZipCode
Fig 1.3 The ADDRESS segment with six fields
Segment Type
A category of data
There can be a maximum of 255 segment types and 15
levels in one data base
Segment Occurrence
One specific segment of a particular type containing user
data
Note:-
Within a data base there is only one of each segment type- it¶s part of
the data base¶s definition- but there can be an unlimited number of
occurrences of each segment type.
The word µsegment¶ is used to mean either µsegment type¶ or µsegment
occurrence¶ and usually the meaning is clear from the context
8/6/2019 IMS DB-Apr2002
http://slidepdf.com/reader/full/ims-db-apr2002 10/132
Apr 3, 2002 IMS DB Page : 10/132
Basic DL/I Terminolog y (contd.)Basic DL/I Terminolog y (contd.)
*
01 INVENTORY-VENDOR-SEGMENT.
05 IVS-VENDOR-CODE PIC X(3).
05 IVS-VENDOR-NAME PIC X(30).
05 IVS-VENDOR-ADDRESS PIC X(30).
05 IVS-VENDOR-CITY PIC X (17).
05 IVS-VENDOR-STATE PIC XX.
05 IVS-VENDOR-ZIP-CODE PIC X(9).
05 IVS-VENDOR-TELEPHONE PIC X(10).
05 IVS-VENDOR-CONTACT PIC X(30).
*
01 INVENTORY-ITEM-SEGMENT.
05 IIS-NUMBER PIC X(5).
05 IIS-DESCRIPTION PIC X(35).
05 IIS-UNIT-PRICE PIC S9(5)V99 COMP-3.
05 IIS-AVG-UNIT-COST PIC S9(5)V99 COMP-3.
*
01 INVENTORY-STOCK-LOC-SEGMENT.
05 ISLS-LOCATION PIC X(3).
05 ISLS-QUANTITY-ON-HAND PIC S9(7) COMP-3.
05 ISLS-REORDER-POINT PIC S9(7) COMP-3.
05 ISLS-QUANTITY-ON-ORDER PIC S9(7) COMP-3.
05 ISLS-LAST-REORDER-DAT PIC X(6).
*
Fig 1.5 Segment layouts for the Inventory data base
Vendor
Item
Stock Location
Fig 1.4 The hierarchical structure of the Inventory data base with three segment types
8/6/2019 IMS DB-Apr2002
http://slidepdf.com/reader/full/ims-db-apr2002 11/132
Apr 3, 2002 IMS DB Page : 11/132
Basic DL/I Terminolog y (contd.)Basic DL/I Terminolog y (contd.)
R oot Segment The segment type at the top of a hierarchy
Data base record
Each occurrence of the root segment plus all the
segment occurrences that are subordinate to it make up
one data base record
Every data base record has one and only one root segment, although it may have any number of
subordinate segment occurrences
Data baseR ecord 1
Data baseR ecord 2
Vendor 1
Item 1
Item 2
Loc 5
Loc 4
Loc 3
Loc 2
Loc 1
Loc 2
Loc 1
Vendor 2
Item 1
Loc 2
Loc 1
Fig 1.6 Two data base records from the Inventory data base
8/6/2019 IMS DB-Apr2002
http://slidepdf.com/reader/full/ims-db-apr2002 12/132
8/6/2019 IMS DB-Apr2002
http://slidepdf.com/reader/full/ims-db-apr2002 13/132
8/6/2019 IMS DB-Apr2002
http://slidepdf.com/reader/full/ims-db-apr2002 14/132
Apr 3, 2002 IMS DB Page : 14/132
Basic DL/I Data Base Processing Basic DL/I Data Base Processing
Sequential Processing When you retrieve segments from a data basesequentially, DL/I follows a predictable pattern: down thehierarchy, then right.
Position
At any point, a program has a position in the data base.
Position can affect not only how segments are retrieved, but
how new segments are inserted as well
Data baseR ecord 1
Data base
R ecord 2
Vendor 1
Item 1
Item 2
Loc 5
Loc 4
Loc 3
Loc 2
Loc 1
Loc 2
Loc 1
Vendor 2
Item 1
Loc 2
Loc 1
Fig 1.8 Sequential processing
8/6/2019 IMS DB-Apr2002
http://slidepdf.com/reader/full/ims-db-apr2002 15/132
Apr 3, 2002 IMS DB Page : 15/132
Basic DL/I Data Base Processing (contd.)Basic DL/I Data Base Processing (contd.)
R andom (Direct) Processing Many applications require that a data base be processed
randomly rather than sequentially
Segments that you need to access randomly normally
contain a key field (or sequence field)
Concatenated Key
Completely identifies the path from the root segment to thesegment you want to retrieve.
Concatenated Key:
Vendor 2 Item 1
Location 1
Fig 1.9 R andom Processing
Data baseR ecord 1
Data baseR ecord 2
Vendor 1
Item 1
Item 2
Loc 5
Loc 4
Loc 3
Loc 2
Loc 1
Loc 2
Loc 1
Vendor 2
Item 1
Loc 2
Loc 1
8/6/2019 IMS DB-Apr2002
http://slidepdf.com/reader/full/ims-db-apr2002 16/132
Apr 3, 2002 IMS DB Page : 16/132
Module 2Module 2An Introduction to DL/I Prog rams and An Introduction to DL/I Prog rams and
Control BlocksControl Blocks
The IMS Software Environment
How DL/I relates to your application programs
Control Blocks
DBDGEN
PSBGEN
How to run an application program that uses DL/I
8/6/2019 IMS DB-Apr2002
http://slidepdf.com/reader/full/ims-db-apr2002 17/132
Apr 3, 2002 IMS DB Page : 17/132
The IMS Software EnvironmentThe IMS Software Environment
Application
Programs
IMS Control
Blocks
DL/I
OS
Data
Base
IMS DC Remote
Terminal
Fig 2.1 The IMS Software Environment
8/6/2019 IMS DB-Apr2002
http://slidepdf.com/reader/full/ims-db-apr2002 18/132
8/6/2019 IMS DB-Apr2002
http://slidepdf.com/reader/full/ims-db-apr2002 19/132
Apr 3, 2002 IMS DB Page : 19/132
How DL/I relatesHow DL/I relatesto your application prog rams (contd.)to your application prog rams (contd.)
Standard file processing Application programs issue standard COBOL statementslike R EAD and W R ITE
These statements invoke the appropriate access method,like VSAM to transfer data between records if necessary
The format of the record that is processed by your program is the same as the format of the record on disk
DL/I data base processing DL/I acts as an interface between an application programand the access method
To perform an operation on a DL/I data base, a programdoesn¶t issue a standard COBOL file I/O statement
Instead it executes a CALL statement to invoke DL/I
The parameters passed by the call tell DL/I what operation to perform
Then, DL/I, not the application program, invokes theaccess method
DL/I uses a standard access method- usually VSAM- tostore data base data on disk
In fact, the access method doesn¶t know that a particular data set contains a data base instead of a standard file
Format of records in a data base data set probably doesn¶t match the layouts of the segments that make upthe data base
As a result, the way the program sees the data basediffers from the way the access method sees it.
8/6/2019 IMS DB-Apr2002
http://slidepdf.com/reader/full/ims-db-apr2002 20/132
Apr 3, 2002 IMS DB Page : 20/132
Control BlocksControl Blocks
The physical structure of a DL/I data base isn¶t specified in application programs
Instead, DL/I uses a set of control blocks to define adata base¶s structure
In particular, DL/I uses two types of control blocks:DBDs and PSBs
Data Base Description (DBD)Describes the complete structure of a data base
An installation must create one DBD for each DL/I database
Program Specification Block (PSB)
Although each data base has a single physical structurethat is defined by a DBD, the application programs that
process it can have different views of it These views, also called application data structures,specify
The data bases (one or more) a program can access,
The data elements the program can ³see´ in those databases, and,
The processing the program can do.
This information is specified in a PSB Although each application program can have its ownPSB, it is not uncommon for application programs that have similar data base processing requirements to sharea PSB
Creating DL/I control blocks is the responsibility of aData Base Administrator (DBA)
8/6/2019 IMS DB-Apr2002
http://slidepdf.com/reader/full/ims-db-apr2002 21/132
Apr 3, 2002 IMS DB Page : 21/132
DBDGENDBDGENSTMT SOURCE STATEMENT
1 PRINT NOGEN
2 DBD NAME=INDBD,ACCESS=HIDAM
3 DATASET DD1=IN,DEVICE=3380
4 **/ 3380 DISK STORAGE
5 *
6 SEGM NAME=INVENSEG, PARENT=0,POINTER=TB,BYTES=131
7 LCHILD NAME=(INPXPNTR,INPXDBD),POINTER=INDX
8 FIELD NAME=(INVENCOD,SEQ),BYTES=3,START=1,TYPE=C
9 FIELD NAME=INVENNAM,BYTES=30,START=4,TYPE=C
10 FIELD NAME=INVENADR,BYTES=30,START=34,TYPE=C
11 FIELD NAME=INVENCIT,BYTES=17,START=64,TYPE=C
12 FIELD NAME=INVENSTA,BYTES=2,START=81,TYPE=C
13 FIELD NAME=INVENZIP,BYTES=9,START=83,TYPE=C
14 FIELD NAME=INVENTEL,BYTES=10,START=92,TYPE=C
15 FIELD NAME=INVENCON,BYTES=30,START=102,TYPE=C
16 *
17 SEGM NAME=INITMSEG,PARENT=INVENSEG,BYTES=48
18 FIELD NAME=(INITMNUM,SEQ),BYTES=5,START=1,TYPE=C
19 FIELD NAME=INITMDES,BYTES=35,START=6,TYPE=C
20 FIELD NAME=INITMPRC,BYTES=4,START=41,TYPE=P
21 FIELD NAME=INITMCST,BYTES=4,START=45,TYPE=P
22 *
23 SEGM NAME=INLOCSEG, PARENT=INITMSEG,BYTES=21
24 FIELD NAME=(INLOCLOC,SEQ),BYTES=3,START=1,TYPE=C
25 FIELD NAME=INLOCONH,BYTES=4,START=4,TYPE=P
26 FIELD NAME=INLOCROP,BYTES=4,START=8,TYPE=P
27 FIELD NAME=INLOCONO,BYTES=4,START=12,TYPE=P
28 FIELD NAME=INLOCDAT,BYTES=6,START=16,TYPE=C
29 *
30 DBDGEN
72 **/**************************************************************************
73 **/ RECOMMENDED VSAM DEFINE CLUSTER PARAMETERS
74 **/**************************************************************************
75 **/* * NOTE2
76 **/* DEFINE CLUSTER (NAME(IN) NONINDEXED -
77 **/* RECORDSIZE (2041,2041) -
78 **/* COUNTERINTERVALSIZE (2048))
79 **/* * NOTE2 - SHOULD SPECIFY DSNNAME FOR DD IN
80 **/**************************************************************************
162 **/***********SEQUENCE FIELD*************
211 **/***********SEQUENCE FIELD*************
236 **/***********SEQUENCE FIELD*************
325 FINISH
326 END Fig 2.3 Assembler source listing for the Inventory data base DBDGEN
8/6/2019 IMS DB-Apr2002
http://slidepdf.com/reader/full/ims-db-apr2002 22/132
Apr 3, 2002 IMS DB Page : 22/132
DBDGEN (contd.)DBDGEN (contd.)
Explanation of Fig 2.3The first macro± DBD± identifies the data base
The DBD macro names the data base (NAME=INDBD) and specifies the DL/I access method that will be used for it (ACCESS=HIDAM)
The second macro, DATASET, identifies the file that will contain the data base
In this case, its symbolic name will be IN (DD1=IN), and it will reside on a 3380 disk unit (DEVICE=3380)
The symbolic name is used in the JCL to identify the dataset at execution time
Lines 72 through 80 are produced at assembly time and give recommendations for the VSAM file that will containthe inventory data base
The segment types are defined using the SEGM macroThe hierarchical relationships among the segments arespecified by coding the PAR ENT parameter on eachSEGM macro
PAR ENT= 0 or absence of PAR ENT parameter specifies root segment
The POINTE R parameter in the first SEGM macro and the
LCHILD macro that follows are required because the DBAspecified HIDAM in the DBD macro
DBA does not have to define each field in the segment,because application programs identify fields within it in asegment layout.
Only search fields need to be specified
8/6/2019 IMS DB-Apr2002
http://slidepdf.com/reader/full/ims-db-apr2002 23/132
Apr 3, 2002 IMS DB Page : 23/132
DBDGEN (contd.)DBDGEN (contd.)
To define a field in the DBD, the DBA codes a FIELDmacro, which can contain the following parameters
NAME name of the field (1 to 8 characters long)
START position of field within segment
LENGTH length of the field
TYPE data type of the field
FIELD Macro TYPE Codes
Data Type
C Character
P Packed decimal
Z Zoned decimal
X Hexadecimal
H Half word Binary
F Full word Binary
The SEQ parameter is used to specify a sequence field
When occurrences of these segments are added to the data
base, they are added in sequence by values in these fields
Fig 2.4 FIELD macro TYPE parameter codes
8/6/2019 IMS DB-Apr2002
http://slidepdf.com/reader/full/ims-db-apr2002 24/132
Apr 3, 2002 IMS DB Page : 24/132
PSBGENPSBGEN
STMT SOURCE STATEMENT
1 PRINT NOGEN
2 PCB TYPE=DB,DBDNAME=INDBD,PROCOPT=LS
3 SENSEG NAME=INVENSEG
4 SENSEG NAME=INITMSEG,PARENT=INVENSEG
5 SENSEG NAME=INLOCSEG,PARENT=INITMSEG
6 PSBGEN PSBNAME=INLOAD,LANG=COBOL
87 END
Fig 2.5 Assembler source listing for the Inventory data base load program¶s PSBGEN
Explanation of Fig 2.5
The first macro in the PSBGEN job stream is PCB
PCB (Program Communication Block) describes one database.
A PSBGEN job contains one PCB macro for each data
base the application program can access.The PSB in the figure is one for a program that accessesa single data base with segment level sensitivity
Segment Level Sensitivity
The program¶s access to parts of the data base is identified at the segment level
Within the segments to which it is sensitive, the program has
access to all fields A program can also have field level sensitivity
Within sensitive segments, only specific fields are identified as sensitive fields
When the program accesses that segment, only sensitivefields are presented
8/6/2019 IMS DB-Apr2002
http://slidepdf.com/reader/full/ims-db-apr2002 25/132
Apr 3, 2002 IMS DB Page : 25/132
PSBGEN (contd.)PSBGEN (contd.)
The DBDNAME parameter on the PCB macro specifiesthe name of the DBD for the data base to which the PCB
corresponds
The KEYLEN parameter specifies the length of the
longest concatenated key the program can process in the
data base
The P R OCOPT parameter specifies the program¶s
processing optionsIndicate what processing the program is allowed to perform
on the data base
LS The program can perform only load operations
Other values can authorize programs to retrieve, insert,
replace, and delete segments
This parameter can be used by the DBA to control access to
the database more selectively than is possible at the database level
For each PCB macro, subordinate SENSEG macros
identify the segments in the data base to which the
application program is sensitive
The names specified in the SENSEG macros must be
segment names from the DBDGEN for the data base named
in the DBDNAME parameter of the PCB macro
8/6/2019 IMS DB-Apr2002
http://slidepdf.com/reader/full/ims-db-apr2002 26/132
How to run anHow to run an
8/6/2019 IMS DB-Apr2002
http://slidepdf.com/reader/full/ims-db-apr2002 27/132
Apr 3, 2002 IMS DB Page : 27/132
How to run an How to run an application prog ram that uses DL/Iapplication prog ram that uses DL/I
A batch program that processes a DL/I data base is not run directly
Instead, the programmer supplies JCL to invoke the
DL/I µbatch initialization module¶, which in turn loads
the application program and the DL/I modules required
to service it.
Under IMS, the batch initialization module isDFS RR C00
The program and DL/I modules execute together
8/6/2019 IMS DB-Apr2002
http://slidepdf.com/reader/full/ims-db-apr2002 28/132
The ENTRY andThe ENTRY and
8/6/2019 IMS DB-Apr2002
http://slidepdf.com/reader/full/ims-db-apr2002 29/132
Apr 3, 2002 IMS DB Page : 29/132
The ENTRY andThe ENTRY andGO BACK StatementsGO BACK Statements
ENTRY µDLITCBL¶ USING PCB-name1
[PCB-name2...]
Fig 3.1 Format of the DL/I ENT R Y Statement
The application program is invoked under the control of the
batch initialization module
DL/I first loads the appropriate control blocks and modules,
then loads the application program and passes control to it
DLITCBL, which stands for µDL/I to COBOL¶ is declared as the
entry point to the program by coding the ENT R Y statement
When DL/I passes control to the program, it also supplies the
address of each PCB defined in the program¶s PSB, in much
the same way as parameters are passed to a called subprogram
Since these PCBs reside outside the program they must be
defined in the Linkage Section, just like passed parameters
would be defined in a subprogram
The Linkage Section definition of a PCB is called a µPCB
Mask¶
Addressability to PCBs- that is, the way the programmer
relates PCB masks in your program¶s Linkage Section to
actual PCBs in storage- is established by listing the PCB
Masks on the ENT R Y statement
8/6/2019 IMS DB-Apr2002
http://slidepdf.com/reader/full/ims-db-apr2002 30/132
8/6/2019 IMS DB-Apr2002
http://slidepdf.com/reader/full/ims-db-apr2002 31/132
Apr 3, 2002 IMS DB Page : 31/132
The DL/I CallThe DL/I Call
CALL statements are used to request DL/I servicesThe parameters you code on the CALL statement
specify, among other things, the operation you want
DL/I to perform
CALL µCBLTDLI¶ USING DLI-function
PCB-mask
segment-io-area
[segment-search-argument(s)]
Fig 3.2 Format of the DL/I call
CBLTDLI, which stands for µCOBOL to DL/I¶, is thename of an interface module that is link edited with
your program¶s object module.
If you work on PL/I, you would specify PLITDLI and for
assembler language, you would specify ASMTDLI
Th DL/I C ll ( d )Th DL/I C ll ( d )
8/6/2019 IMS DB-Apr2002
http://slidepdf.com/reader/full/ims-db-apr2002 32/132
Apr 3, 2002 IMS DB Page : 32/132
The DL/I Call (contd.)The DL/I Call (contd.)
The DL/I FunctionThe first parameter coded on any DL/I call
For this parameter, you supply the name of a four character working storage field that contains the code for the function you want
01 DLI-FUNCTIONS.
05 DLI-GU PIC X(4) VALUE µGU ¶.05 DLI-GHU PIC X(4) VALUE µGHU ¶.
05 DLI-GN PIC X(4) VALUE µGN ¶.
05 DLI-GHN PIC X(4) VALUE µGHN ¶.
05 DLI-GNP PIC X(4) VALUE µGNP ¶.
05 DLI-GHNP PIC X(4) VALUE µGHNP¶.
05 DLI-ISRT PIC X(4) VALUE µISRT¶.
05 DLI-DLET PIC X(4) VALUE µDLET¶.
05 DLI-REPL PIC X(4) VALUE µREPL¶.
05 DLI-CHKP PIC X(4) VALUE µCHKP¶.
05 DLI-XRST PIC X(4) VALUE µXRST¶.
05 DLI-PCB PIC X(4) VALUE µPCB ¶.
Fig 3.3 DL/I function codes
For specifying the DL/I function, the programmer would code one of the 05 level data names (like DLI-GN) in aDL/I call, since COBOL doesn¶t let you code literals on aCALL statement
Th DL/I C ll ( td )Th DL/I C ll ( td )
8/6/2019 IMS DB-Apr2002
http://slidepdf.com/reader/full/ims-db-apr2002 33/132
Apr 3, 2002 IMS DB Page : 33/132
The DL/I Call (contd.)The DL/I Call (contd.)
Get functionsThe first six 05-level items in Fig 3.3 are get functions
They are used to retrieve segments from a DL/I data base
GU µget unique¶ function causes DL/I to retrieve a specific
segment occurrence based on field values that you specify.
GN µget next¶ function used to retrieve segment
occurrences in sequence
GNP
µget next within parent¶ function lets you retrievesegment occurrences in sequence, but only subordinate to
an established parent segment
The three get function codes that contain an H are µget hold
functions¶ and are used to specify an intent to update a
segment after you retrieve it
GHU or the µget hold unique¶ function corresponds to GU
GHN or the µget hold next¶ function corresponds to GN
GHNP or the µget hold next within parent¶ function
corresponds to GNP
Update functions
Used to change data in the data base
IS R T or the µinsert¶ function is used to add a new segment
occurrence to a data base± whether it be change an existing
data base or to load a new one
DLET or the µdelete¶ function is used to remove a segment
from a data base
R EPL or the µreplace¶ function is used to replace a segment
occurrence
Th DL/I C ll ( td )Th DL/I C ll ( td )
8/6/2019 IMS DB-Apr2002
http://slidepdf.com/reader/full/ims-db-apr2002 34/132
Apr 3, 2002 IMS DB Page : 34/132
The DL/I Call (contd.)The DL/I Call (contd.)
Other functionsFunctions CHKP (the µcheckpoint¶ function) and X R ST (the
µrestart¶ function) are used in programs to take advantage of
IMS¶s recovery and restart features
The last function code PCB is used in CICS programs
The DL/I Call (contd )The DL/I Call (contd )
8/6/2019 IMS DB-Apr2002
http://slidepdf.com/reader/full/ims-db-apr2002 35/132
Apr 3, 2002 IMS DB Page : 35/132
The DL/I Call (contd.)The DL/I Call (contd.)
The PCB mask The second parameter on the DL/I call
The name of the PCB mask defined in the program¶s
Linkage Section
The ENT R Y statement establishes a correspondence
between PCB masks in the Linkage Section and the PCBs
within the program¶s PSB
So, when you code a particular PCB mask on a DL/I call,
you tell DL/I which data base to use for the operation you
are requesting
After each DL/I call, DL/I stores a status code in the PCB
mask, which the programmer can use to determine
whether the call succeeded or failed
Segment I/O AreaThe third parameter on the DL/I call
The name of the working storage field into which DL/I will
return retrieved data or from which it will get data for an
update operation
The DL/I Call (contd )The DL/I Call (contd )
8/6/2019 IMS DB-Apr2002
http://slidepdf.com/reader/full/ims-db-apr2002 36/132
Apr 3, 2002 IMS DB Page : 36/132
The DL/I Call (contd.)The DL/I Call (contd.)
Segment search argumentsOptional parameter on the DL/I call
An SSA identifies the segment occurrence you want to
access
Depending on the call you are issuing and the structure
of the data base, you may have to code several SSAs on
a single DL/I call
The structure of the SSAs can vary from simple to
complex
You can code as many SSAs as required
There are two kinds of SSAs± unqualified and qualified
An unqualified SSA
Supplies the name of the next segment type that you want to
operate on
For instance, if you issue a GN call with an unqualified SSA,
DL/I will return the next occurrence of the segment type you
specify
A qualified SSA
Combines a segment name with additional information that
specifies the segment occurrence to be processed
For example, a GU call with a qualified SSA might request a
particular occurrence of a named segment type by providing
a key value
The PCB MaskThe PCB Mask
8/6/2019 IMS DB-Apr2002
http://slidepdf.com/reader/full/ims-db-apr2002 37/132
Apr 3, 2002 IMS DB Page : 37/132
The PCB MaskThe PCB Mask
For each data base your program accesses, DL/I maintains an area of storage called the program
communication block (PCB)
You define masks for those areas of storage in the
Linkage Section of your program
Then, after establishing the proper linkage to them at
the start of your program, you can evaluate data DL/I stores there for information about the data bases your
program can process
01 INVENTORY-PCB-MASK.
05 IPCB-DBD-NAME PIC X(8).
05 IPCB-SEGMENT-LEVEL PIC XX.
05 IPCB-STATUS-CODE PIC XX.
05 IPCB-PROC-OPTIONS PIC X(4).
05 FILLER PIC S9(5) COMP.
05 IPCB-SEGMENT-NAME PIC X(8).
05 IPCB-KEY-LENGTH PIC S9(5) COMP.
05 IPCB-NUMB-SENS-SEGS PIC S9(5) COMP.
05 IPCB-KEY PIC X(11).
Fig 3.4 PCB mask for the Inventory data base
The PCB Mask (contd )The PCB Mask (contd )
8/6/2019 IMS DB-Apr2002
http://slidepdf.com/reader/full/ims-db-apr2002 38/132
Apr 3, 2002 IMS DB Page : 38/132
The PCB Mask (contd.)The PCB Mask (contd.)
Data base nameThe name of the data base being processed
Segment level
Specifies the current segment level in the data base
After a successful call, DL/I stores the level of the
segment just processed in this field
Status codeContains the DL/I status code
When DL/I successfully completes the processing you
request in a call, it indicates that to your program by
moving spaces to the status code field in the PCB
On the other hand, if a call is unsuccessful or raises
some condition that isn¶t normal, DL/I moves some non- blank value to the status code field
It is good programming practice to evaluate the status
code after you issue a DL/I call
Processing options
Indicates the processing a program is allowed to do on
the data baseSegment name feedback area
The name of the segment is stored by DL/I in this field
after each DL/I call.
8/6/2019 IMS DB-Apr2002
http://slidepdf.com/reader/full/ims-db-apr2002 39/132
8/6/2019 IMS DB-Apr2002
http://slidepdf.com/reader/full/ims-db-apr2002 40/132
Types of SSAsTypes of SSAs
8/6/2019 IMS DB-Apr2002
http://slidepdf.com/reader/full/ims-db-apr2002 41/132
Apr 3, 2002 IMS DB Page : 41/132
ypyp
An SSA identifies the segment occurrence you want toaccess
It can be either
Qualified, or,
Unqualified
An unqualified SSA simply names the type of segment
you want to use A qualified SSA, on the other hand, specifies not only
the segment type, but also a specific occurrence of it.
Includes a field value DL/I uses to search for the segment
you request
Any field to which the program is sensitive to can be
used in an SSA
Because of the hierarchical structure DL/I uses, you
often have to specify several levels of SSAs to access
a segment at a low level in a data base
You can code as many SSAs on a single call as you
need
You can combine qualified and unqualified SSAs on a
single call
Basic Unqualified SSABasic Unqualified SSA
8/6/2019 IMS DB-Apr2002
http://slidepdf.com/reader/full/ims-db-apr2002 42/132
Apr 3, 2002 IMS DB Page : 42/132
01 UNQUALIFIED-SSA.
*
05 UNQUAL-SSA-SEGMENT-NAME PIC X(8).
05 FILLER PIC X VALUE SPACE.
*
Fig 4.1 A basic unqualified SSA
A basic unqualified SSA is 9 bytes long
The first eight bytes contain the name of the segment
you want to process
If the segment name is less than eight characters long,
you must pad it on the right with blanksThe ninth position of a basic unqualified SSA always
contains a blank
The DL/I uses the value in position 9 to decide what kind
of SSA you are providing
Basic Unqualified SSA (contd.)Basic Unqualified SSA (contd.)
8/6/2019 IMS DB-Apr2002
http://slidepdf.com/reader/full/ims-db-apr2002 43/132
Apr 3, 2002 IMS DB Page : 43/132
q ( )q ( )
Unqualified SSA shown in Fig 4.1 was generalized
To access a particular segment type, you must modify
the segment name during program execution, by moving
an appropriate eight-character segment name to the field
UNQUAL-SSA-SEGMENT-NAME
For example,
MOVE µINVENSEG¶ TO UNQUAL-SSA-SEGMENT-NAME
MOVE µINITMSEG¶ TO UNQUAL-SSA-SEGMENT-NAME
Alternatively, you can code the segment name as a
literal when you define a qualified SSA
For example,
01 UNQUAL-VENDOR-SSA PIC X(9) VALUE µINVENSEG ¶.
*
01 UNQUAL-ITEM-SSA PIC X(9) VALUE µINITMSEG ¶.
*
01 UNQUAL-STOCK-LOC-SSA PIC X(9) VALUE µINVENSEG ¶.
8/6/2019 IMS DB-Apr2002
http://slidepdf.com/reader/full/ims-db-apr2002 44/132
8/6/2019 IMS DB-Apr2002
http://slidepdf.com/reader/full/ims-db-apr2002 45/132
Command CodesCommand Codes
8/6/2019 IMS DB-Apr2002
http://slidepdf.com/reader/full/ims-db-apr2002 46/132
Apr 3, 2002 IMS DB Page : 46/132
Fig 4.4 Qualified SSA format with a single command code
Command are used in SSAs for three purposesTo extend DL/I functionality
To simplify programs by reducing the number of DL/I
calls
For performance improvement resulting from the reduced
number of DL/I calls
Fig 4.3 Unqualified SSA format with a single command code
Command Codes (contd.)Command Codes (contd.)
8/6/2019 IMS DB-Apr2002
http://slidepdf.com/reader/full/ims-db-apr2002 47/132
Apr 3, 2002 IMS DB Page : 47/132
To use command codes, code an asterisk in position 9
of the SSA
Then code your command codes starting from
position 10.
When DL/I finds an asterisk in position 9, it knows
command codes will follow
From position 10 onwards, DL/I considers all characters to be command codes until it encounters a
space (for an unqualified SSA) or a left parenthesis
(for a qualified SSA)
It is unusual to use more than one command code in a
single SSA
A basic unqualified SSA with a single variablecommand code is shown below
01 UNQUALIFIED-SSA.
*
05 UNQUAL-SSA-SEGMENT-NAME PIC X(8).
05 FILLER PIC X VALUE ³*´
.05 UNQUAL-SSA-COMMAND-CODE PIC X.
05 FILLER PIC X VALUE SPACE.
*
Command Codes (contd.)Command Codes (contd.)
8/6/2019 IMS DB-Apr2002
http://slidepdf.com/reader/full/ims-db-apr2002 48/132
Apr 3, 2002 IMS DB Page : 48/132
Command Code Meaning
C Concatenated Key
D Path Call
F First Occurrence
L Last OccurrenceN Path Call Ignore
P Set Parentage
Q Enqueue Segment
U Maintain position at
this level
V Maintain position at
this and all superior
levels
± Null command codes
Fig 4.5 SSA Command Codes
The Null Command CodeThe Null Command Code
8/6/2019 IMS DB-Apr2002
http://slidepdf.com/reader/full/ims-db-apr2002 49/132
Apr 3, 2002 IMS DB Page : 49/132
Value is a hyphen (±)
Although command code position is present, DL/I
ignores it
Particularly useful if you would like to use the same
SSA with and without command codes
An SSA with the null command code is shown below
01 UNQUALIFIED-SSA.
*
05 UNQUAL-SSA-SEGMENT-NAME PIC X(8).
05 FILLER PIC X VALUE ³*´.
05 UNQUAL-SSA-COMMAND-CODE PIC X VALUE ³-´.
05 FILLER PIC X VALUE SPACE.
*
Multiple QualificationsMultiple Qualifications
8/6/2019 IMS DB-Apr2002
http://slidepdf.com/reader/full/ims-db-apr2002 50/132
Apr 3, 2002 IMS DB Page : 50/132
There are two cases in which you would use multiple
qualificationWhen you want to process a segment based on thecontents of two or more fields within it
When you want to process a segment based on a rangeof possible values for a single field
To use multiple qualification, you connect two or more
qualification statements (a field name, a relational operator, and a comparison value) within the parentheses of the SSA.
To connect them, you use the Boolean operators ANDand O R
Either of the two symbols shown in the table below may be used for AND or O R
The independent AND operator is used for special operations with secondary indexes and will bediscussed later
Multiple Qualifications (contd.)Multiple Qualifications (contd.)
8/6/2019 IMS DB-Apr2002
http://slidepdf.com/reader/full/ims-db-apr2002 51/132
Apr 3, 2002 IMS DB Page : 51/132
01 VENDOR-SSA.
*
05 FILLER PIC X(9) VALUE µINVENSEG(¶.
05 FILLER PIC X(10) VALUE µINVENCOD>=¶.
05 VENDOR-SSA-LOW-CODE PIC X(3).
05 FILLER PIC X VALUE µ&¶.
05 FILLER PIC X(10) VALUE µINVENCOD<=¶.
05 VENDOR-SSA-HIGH-CODE PIC X(3).
05 FILLER PIC X VALUE µ)¶.
The above SSA, which uses multiple qualifications can
be used to retrieve vendor segments whose vendor
codes fall within a certain range
The first qualification statement specifies that the vendor code field must be greater than or equal to a particular
value; that is the low end of the range
The second qualification statement specifies that the
vendor code field must be less than or equal to a
particular value; that is the high end of the range
To retrieve segments that fall within this range, you
would first move values for low and high ends of therange to VENDOR-SSA-LOW-CODE and VENDOR-SSA-HIGH-CODE
Then you would execute GN calls that include VENDOR-SSA
8/6/2019 IMS DB-Apr2002
http://slidepdf.com/reader/full/ims-db-apr2002 52/132
The GU CallThe GU Call
8/6/2019 IMS DB-Apr2002
http://slidepdf.com/reader/full/ims-db-apr2002 53/132
Apr 3, 2002 IMS DB Page : 53/132
Used for random processing
Applications of random processing
When a relatively small number of updates are posted to
a large data base
To establish position in a data base for subsequent
sequential retrieval
You know what data you want to retrieve and you want to get to it directly
Independent of the position established by the
previous calls
CALL µCBLTDLI¶ USING DLI-GU
INVENTORY-PCB-MASK
INVENTORY-STOCK-LOC-SEGMENT
VENDOR-SSA
ITEM-SSA
STOCK-LOCATION-SSA.
A typical GU call like the one above, wherein a
complete set of qualified SSAs to retrieve a segment,includes one for each level in the hierarchical path to
the segment you want to retrieve is called a µfully
qualified call¶
8/6/2019 IMS DB-Apr2002
http://slidepdf.com/reader/full/ims-db-apr2002 54/132
The GU Call (contd.)The GU Call (contd.)
8/6/2019 IMS DB-Apr2002
http://slidepdf.com/reader/full/ims-db-apr2002 55/132
Apr 3, 2002 IMS DB Page : 55/132
Status codes you can expect during random
processing with GU calls
Only two status code values need to be considered±
spaces and GE
Spaces means the call was successful and the requested
segment was returned in your program¶s segment I/O
area
A GE status code indicates that DL/I couldn¶t find asegment that met the criteria you specified in the call
8/6/2019 IMS DB-Apr2002
http://slidepdf.com/reader/full/ims-db-apr2002 56/132
The GNP CallThe GNP Call
8/6/2019 IMS DB-Apr2002
http://slidepdf.com/reader/full/ims-db-apr2002 57/132
Apr 3, 2002 IMS DB Page : 57/132
CALL µCBLTDLI¶ USING DLI-GNP
INVENTORY-PCB-MASK
INVENTORY-STOCK-LOC-SEGMENT
UNQUALIFIED-SSA.
Used for sequential processing within parentage
Works like the GN call, except it retrieves only
segments that are subordinate to the currently established parent
To establish parentage, your program MUST issue
either a GU call or a GN call, and the call must be
successful
Parentage is never automatically established, in spite of
the hierarchical structure of the data base
The segment returned by the call becomes the
established parent
Subsequent GNP calls return only segment
occurrences that are dependent on that parent
When there are no more segments within theestablished parentage DL/I returns GE as the status
code
8/6/2019 IMS DB-Apr2002
http://slidepdf.com/reader/full/ims-db-apr2002 58/132
Status Codes you can expect during Status Codes you can expect during Sequential Processing Sequential Processing
8/6/2019 IMS DB-Apr2002
http://slidepdf.com/reader/full/ims-db-apr2002 59/132
Apr 3, 2002 IMS DB Page : 59/132
Using Command Codes with Retrieval CallsUsing Command Codes with Retrieval Calls
8/6/2019 IMS DB-Apr2002
http://slidepdf.com/reader/full/ims-db-apr2002 60/132
Apr 3, 2002 IMS DB Page : 60/132
The F command code
When you issue a call with an SSA that includes the F command code, the call processes the first occurrence of the segment named by the SSA, subject to the call¶sother qualifications
Can be used when you are doing sequential processing and you need to back up in the data base, or in other words, the F command code can be used for sequential
retrieval using GN and GNP callsMeaningless with GU calls, because GU normally retrieves the first segment occurrence that meets thecriteria you specify
The L command code
When you issue a call with an SSA that includes the Lcommand code, the call processes the last occurrence of
the segment named by the SSA, subject to the call¶sother qualifications
The D command code
Used to retrieve more than one segment occurrenceusing just one call
Normally DL/I operates on the lowest level segment you specify in an SSA, but in many cases, you want data not
just from the lowest level in the call, but from other levelsas well
Makes it easy to retrieve an entire path of segments
8/6/2019 IMS DB-Apr2002
http://slidepdf.com/reader/full/ims-db-apr2002 61/132
Using Command Codes with Retrieval CallsUsing Command Codes with Retrieval Calls(contd.)(contd.)
8/6/2019 IMS DB-Apr2002
http://slidepdf.com/reader/full/ims-db-apr2002 62/132
Apr 3, 2002 IMS DB Page : 62/132
The C command code
If you are developing a program that retrieves just lower- level segment occurrences from a data base, you don¶t have to code separate SSAs for each level in thehierarchical path
Instead you can use a single SSA with the C command code
Then, rather than coding a field name, relational operator,
and search value, you specify the concatenated key for the segment you are interested in
An illustration of the use of the C command code isshown below
*
01 LOCATION-SSA.
*
05 FILLER PIC X(11) VALUE µINLOCSEG*C(µ.
05 LOCATION-SSA-VENDOR PIC X(3).
05 LOCATION-SSA-ITEM PIC X(5).
05 LOCATION-SSA-LOCATION PIC X(3).
05 FILLER PIC X VALUE µ)¶.
*
.
.
.CALL µCBLTDLI¶ USING DLI-GU
INVENTORY-PCB-MASK
INVENTORY-STOCK-LOC-SEGMENT
LOCATION-SSA.
Using Command Codes with Retrieval CallsUsing Command Codes with Retrieval Calls(contd.)(contd.)
8/6/2019 IMS DB-Apr2002
http://slidepdf.com/reader/full/ims-db-apr2002 63/132
Apr 3, 2002 IMS DB Page : 63/132
The P command code
When you issue a GU or GN call, DL/I normally
establishes parentage at the lowest level segment that is
retrieved
However, if you want to override that and cause
parentage to be established at a higher-level segment in
the hierarchical path, you can use the P command code
in its SSAThe U command code
When you use an unqualified SSA that specifies the U
command code in a GN call, DL/I restricts the search for
the segment you request to dependents of the segments
with the U command code
Has the same effect as a call which contains a qualified
SSA for the current position
Is ignored if used with a qualified SSA
The V command code
Effect is same as coding the U command code at that
level and all levels above it in the hierarchy
Is ignored if used with a qualified SSA
8/6/2019 IMS DB-Apr2002
http://slidepdf.com/reader/full/ims-db-apr2002 64/132
Multiple Processing Multiple Processing
8/6/2019 IMS DB-Apr2002
http://slidepdf.com/reader/full/ims-db-apr2002 65/132
Apr 3, 2002 IMS DB Page : 65/132
Multiple processing is a general term that means a
program can have more than one position in a single physical data base at the same time
DL/I lets the programmer implement multiple
processing in two ways
1. Through multiple PCBs
2. Through multiple positioning
Multiple PCBs
The DBA can define multiple PCBs for a single data base
Then, the program has two (or more) views of the data
base
As with PCBs for different data bases, each has its own
mask in the Linkage Section and is specified in the
ENT R Y statement
It is up to the program¶s logic to decide when to use a
particular PCB to access the data base
This method for implementing multiple processing,
though flexible, is inefficient because of the overhead
imposed by the extra PCBs
Multiple Processing (contd.)Multiple Processing (contd.)
M lti l iti i
8/6/2019 IMS DB-Apr2002
http://slidepdf.com/reader/full/ims-db-apr2002 66/132
Apr 3, 2002 IMS DB Page : 66/132
Multiple positioning
Lets a program maintain more than one position within adata base using a single PCB
To do that, DL/I maintains a distinct position for each
hierarchical path the program processes
Most of the time, multiple positioning is used to access
segments of two or more types sequentially at the same
time
Fig 5.2 Two data base records to illustrate multiple positioning
A1
B13
B12
B11
Data base
Record 1
C13
C12
C11
A2
B22
B21
Data base
Record 2
C22
C21
8/6/2019 IMS DB-Apr2002
http://slidepdf.com/reader/full/ims-db-apr2002 67/132
8/6/2019 IMS DB-Apr2002
http://slidepdf.com/reader/full/ims-db-apr2002 68/132
Apr 3, 2002 IMS DB Page : 68/132
Module 6Module 6Adding and Updating DataAdding and Updating Data
in a Data Basein a Data Base
The IS R T Call
The Get Hold Calls
The R EPL Call
The DLET Call
8/6/2019 IMS DB-Apr2002
http://slidepdf.com/reader/full/ims-db-apr2002 69/132
The ISRT Call (contd.)The ISRT Call (contd.)
A f t h i i t if lifi d SSA f h
8/6/2019 IMS DB-Apr2002
http://slidepdf.com/reader/full/ims-db-apr2002 70/132
Apr 3, 2002 IMS DB Page : 70/132
A safer technique is to specify a qualified SSA for each
hierarchical level above the one where you want toinsert the segment, as illustrated below
CALL µCBLTDLI¶ USING DLI-ISRT
INVENTORY-PCB-MASK
INVENTORY-STOCK-LOC-SEGMENT
VENDOR-SSA ITEM-SSA
UNQUALIFIED-SSA.
If SSAs for vendor and item are initialized with the
proper key values, DL/I inserts the new segment
occurrence in the correct position in the data base
When you issue a fully qualified IS R T call like this, DL/I
returns a status code of GE if any segment occurrence
you specify in an SSA isn¶t present in the data base
As a result, you can issue an IS R T call with qualified
SSAs instead of first issuing GU calls to find out if
higher-level segments in the path are present By issuing one call instead of two (or more), you can
save system resources
The ISRT Call (contd.)The ISRT Call (contd.)
Wh i t d t t d
8/6/2019 IMS DB-Apr2002
http://slidepdf.com/reader/full/ims-db-apr2002 71/132
Apr 3, 2002 IMS DB Page : 71/132
Where inserted segments are stored
If the new segment has a unique sequence field, as most segment types do, it is added in its proper sequential
position
However, some lower-level segment types in some data
bases have non-unique sequence fields or don¶t have
sequence fields at all
When that¶s the case, where the segment occurrence isadded depends on the rules the DBA specifies for the
data base
For a segment without a sequence field, the insert rule
determines how the new segment is positioned relative to
existing twin segments
If the rule is ³first´, the new segment is added before any
existing twinsIf the rule is ³last´, the new segment is added after all
existing twins
If the rule is ³here´, it is added at the current position relative
to existing twins, which may be first, last, or anywhere in the
middle
For a segment with non-unique sequence fields, the rules
are similar, but they determine where the new segment is positioned relative to existing twin segments that have
the same key value
8/6/2019 IMS DB-Apr2002
http://slidepdf.com/reader/full/ims-db-apr2002 72/132
The Get Hold CallsThe Get Hold Calls
There are three get hold functions you can specify in a
8/6/2019 IMS DB-Apr2002
http://slidepdf.com/reader/full/ims-db-apr2002 73/132
Apr 3, 2002 IMS DB Page : 73/132
There are three get hold functions you can specify in a
DL/I call:1. GHU (Get hold unique)
2. GHN (Get hold next), and,
3. GHNP (Get hold next within parent)
These calls parallel the three retrieval calls earlier
discussed
Before you can replace or delete a segment, you must
declare your intent to do so, by retrieving the segment
with one of these three calls
Then you must issue the replace or delete call before
you do another DL/I processing in your program
The REPL CallThe REPL Call
After you have retrieved a segment with one of the get
8/6/2019 IMS DB-Apr2002
http://slidepdf.com/reader/full/ims-db-apr2002 74/132
Apr 3, 2002 IMS DB Page : 74/132
After you have retrieved a segment with one of the get
hold calls, you can make changes to the data in that segment, then issue an R EPL call to replace the
original segment with the new data
There are two restrictions on the changes you can
make:
1. You can¶t change the length of the segment
2. You can¶t change the value of the sequence field (if the
segment has one)
Never code a qualified SSA on an R EPL call: if you do,
the call will fail
An example of a typical replace operation is shown
below CALL µCBLTDLI¶ USING DLI-GHU
INVENTORY-PCB-MASK
INVENTORY-STOCK-LOC-SEGMENT
VENDOR-SSA
ITEM-SSA
LOCATION-SSA.
ADD TRANS-RECEIPT-QTY TO ISLS-QUANTITY-ON-HAND.
SUBTRACT TRANS-RECEIPT-QTY FROM ISLS-QUANTITY-ON-ORDER.CALL µCBLTDLI¶ USING DLI-REPL
INVENTORY-PCB-MASK
INVENTORY-STOCK-LOC-SEGMENT.
The REPL Call (contd.)The REPL Call (contd.)
Status codes you can expect during replace
8/6/2019 IMS DB-Apr2002
http://slidepdf.com/reader/full/ims-db-apr2002 75/132
Apr 3, 2002 IMS DB Page : 75/132
Status codes you can expect during replace
processing If you try to use a qualified SSA on an R EPL call, you will
get an AJ status code
If your program issues a replace call without an
immediately preceding get hold call, DL/I returns a DJ
status code
If your program makes a change to the segment¶s key field before issuing the R EPL call, DL/I returns a DA
status code
The DLET CallThe DLET Call
The DLET call works much like R EPL
8/6/2019 IMS DB-Apr2002
http://slidepdf.com/reader/full/ims-db-apr2002 76/132
Apr 3, 2002 IMS DB Page : 76/132
You must first issue a get hold call to indicate that you intend to make a change to the segment you areretrieving
Then you issue a DLET call to delete the segment occurrence from the data base
For example, to delete a stock location that is no
longer active, you¶d code a series of statements likethe ones below CALL µCBLTDLI¶ USING DLI-GHU
INVENTORY-PCB-MASK
INVENTORY-STOCK-LOC-SEGMENT
VENDOR-SSA
ITEM-SSA
LOCATION-SSA.CALL µCBLTDLI¶ USING DLI-DLET
INVENTORY-PCB-MASK
INVENTORY-STOCK-LOC-SEGMENT.
Notice that the DLET call does not include any SSAs
There is one important point you must keep in mind whenever you use the DLET call± when you delete a
segment, you automatically delete all segment occurrences subordinate to it
The status codes you might get after a DLET call arethe same as those you can get after an R EPL call
8/6/2019 IMS DB-Apr2002
http://slidepdf.com/reader/full/ims-db-apr2002 77/132
Apr 3, 2002 IMS DB Page : 77/132
Module 7Module 7Secondary Indexing Secondary Indexing
The Need for Secondary Indexing
A Customer Data Base
Secondary Indexes
Secondary Keys
Secondary Data Structures
DBDGEN R equirements for Secondary Indexes
PSBGEN R equirements for Secondary Indexing
Indexing a Segment based on a Dependent Segment
The Independent AND Operator
Sparse Sequencing
Duplicate Data Fields
The Need for Secondary Indexing The Need for Secondary Indexing
Often you need to be able to access a data base in an
8/6/2019 IMS DB-Apr2002
http://slidepdf.com/reader/full/ims-db-apr2002 78/132
Apr 3, 2002 IMS DB Page : 78/132
y
order other than its primary hierarchical sequenceOr, you may need to access a segment in a data base
directly, without supplying its complete concatenated
key
With secondary indexing both are possible
8/6/2019 IMS DB-Apr2002
http://slidepdf.com/reader/full/ims-db-apr2002 79/132
The Customer Data Base (contd.)The Customer Data Base (contd.)
01 CUSTOMER-SEGMENT.
05 CS-CUSTOMER-NUMBER PIC X(6).
8/6/2019 IMS DB-Apr2002
http://slidepdf.com/reader/full/ims-db-apr2002 80/132
Apr 3, 2002 IMS DB Page : 80/132
( )
05 CS-CUSTOMER-NAME PIC X(31).
05 CS-ADDRESS-LINE-1 PIC X(31).
05 CS-ADDRESS-LINE-2 PIC X(31).
05 CS-CITY PIC X(18).
05 CS-STATE PIC XX.
05 CS-ZIP-CODE PIC X(9).
*
01 SHIP-TO-SEGMENT.
05 STS-SHIP-TO-SEQUENCE PIC XX.
05 STS-SHIP-TO-NAME PIC X(31).05 STS-ADDRESS-LINE-1 PIC X(31).
05 STS-ADDRESS-LINE-2 PIC X(31).
05 STS-CITY PIC X(18).
05 STS-STATE PIC XX.
05 STS-ZIP-CODE PIC X(9).
*
01 BUYER-SEGMENT.
05 BS-BUYER-NAME PIC X(31).
05 BS-TITLE PIC X(31).05 BS-TELEPHONE PIC X(10).
*
01 RECEIVABLE-SEGMENT.
05 RS-INVOICE-NUMBER PIC X(6).
05 RS-INVOICE-DATE PIC X(6).
05 RS-PO-NUMBER PIC X(25).
05 RS-PRODUCT-TOTAL PIC S9(5)V99 COMP-3.
05 RS-CASH-DISCOUNT PIC S9(5)V99 COMP-3.
05 RS-SALES-TAX PIC S9(5)V99 COMP-3.
05 RS-FREIGHT PIC S9(5)V99 COMP-3.
05 RS-BALANCE-DUE PIC S9(5)V99 COMP-3.
*
Fig 7.2 Segment Layouts for the Customer Data Base (Part 1 of 2)
The Customer Data Base (contd.)The Customer Data Base (contd.)
01 PAYMENT-SEGMENT.
05 PS-CHECK-NUMBER PIC X(16).
8/6/2019 IMS DB-Apr2002
http://slidepdf.com/reader/full/ims-db-apr2002 81/132
Apr 3, 2002 IMS DB Page : 81/132
05 PS-BANK-NUMBER PIC X(25).05 PS-PAYMENT-DATE PIC X(6).
05 PS-PAYMENT-AMOUNT PIC S9(5)V99 COMP-3.
*
01 ADJUSTMENT-SEGMENT.
05 AS-REFERENCE-NUMBER PIC X(16).
05 AS-ADJUSTMENT-DATE PIC X(6).
05 AS-ADJUSTMENT-TYPE PIC X.
05 AS-ADJUSTMENT-AMOUNT PIC S9(5)V99 COMP-3.
*01 LINE-ITEM-SEGMENT.
05 LIS-ITEM-KEY.
10 LIS-ITEM-KEY-VENDOR PIC X(3).
10 LIS-ITEM-KEY-NUMBER PIC X(3).
05 LIS-UNIT-PRICE PIC S9(5)V99 COMP-3.
05 LIS-QUANTITY PIC S9(7) COMP-3.
*
Fig 7.2 Segment Layouts for the Customer Data Base (Part 2 of 2)
Secondary IndexesSecondary Indexes
Invoice number index data base
Secondary Index
Data BaseCustomer Data Base
8/6/2019 IMS DB-Apr2002
http://slidepdf.com/reader/full/ims-db-apr2002 82/132
Apr 3, 2002 IMS DB Page : 82/132
Customer
Ship-to
Buyer Receivable
Payment Adjustment Line Item
Prefix DataRec. Seg.
Addr.
Invoice
No.Index
Pointer
Segment
Indexed Data
Base
Index Target
SegmentIndex Source
Segment
Fig 7.3 Secondary Indexing Example in which the Index Source Segment and the Index Target Segment are the same
Secondary Indexes (contd.)Secondary Indexes (contd.)
DL/I maintains the alternate sequence by storing
8/6/2019 IMS DB-Apr2002
http://slidepdf.com/reader/full/ims-db-apr2002 83/132
Apr 3, 2002 IMS DB Page : 83/132
pointers to segments of the indexed data base in aseparate index data base
A secondary index data base has just one segment
type, called the index pointer segment
The index pointer segment contains two main
elements± a prefix element and a data element
The data element contains the key value from the
segment in the indexed data base over which the index
is built, called the index source segment
The prefix part of the index pointer segment contains a
pointer to the index target segment± the segment that
is accessible via the secondary index
The index source and target segments need not be the
same
After a secondary index has been set up, DL/I
maintains it automatically as changes are made to the
indexed data base± though the index is transparent to
application programs that use it So, even if a program that is not sensitive to a secondary
index updates a data base record in a way that would
affect the index, DL/I automatically updates the index
That can also result in performance degradation
Secondary Indexes (contd.)Secondary Indexes (contd.)
If multiple access paths are required into the same
8/6/2019 IMS DB-Apr2002
http://slidepdf.com/reader/full/ims-db-apr2002 84/132
Apr 3, 2002 IMS DB Page : 84/132
data base, the DBA can define as many different secondary indexes as necessary± each stored in a
separate index data base
In practice, the number of secondary indexes for a given
data base is kept low because each imposes additional
processing overhead on DL/I
Secondary KeysSecondary Keys
The field in the index source segment over which the
8/6/2019 IMS DB-Apr2002
http://slidepdf.com/reader/full/ims-db-apr2002 85/132
Apr 3, 2002 IMS DB Page : 85/132
secondary index is built is called the secondary key The secondary key need not be the segment¶s
sequence field± any field can be used as a secondary
key
Though usually, a single field within the index source
segment is designated as the secondary key for a
secondary index, the DBA can combine as many asfive fields in the source segment to form the complete
secondary key
These fields need not even lie adjacent to each other
Secondary key values do not have to be unique
Secondary Data StructuresSecondary Data Structures
A secondary index changes the apparent hierarchical
8/6/2019 IMS DB-Apr2002
http://slidepdf.com/reader/full/ims-db-apr2002 86/132
Apr 3, 2002 IMS DB Page : 86/132
structure of the data baseThe index target segment is presented to your
program as if it were a root segment, even if it isn¶t
actually the root segment
As a result, the hierarchical sequence of the segments
in the path from the index target segment to the root
segment is inverted: those segments appear to besubordinate to the index target segment, even though
they are actually superior to it
The resulting rearrangement of the data base structure
is called a secondary data structure
Customer
Receivable
Ship-to Payment Adjustment Line Item
Buyer
Fig 7.4 Secondary Data Structure for the Secondary Index
Secondary Data Structures (contd.)Secondary Data Structures (contd.)
Secondary data structures don¶t change the way the
d t b t t d di k
8/6/2019 IMS DB-Apr2002
http://slidepdf.com/reader/full/ims-db-apr2002 87/132
Apr 3, 2002 IMS DB Page : 87/132
data base segments are stored on disk They just alter the way DL/I presents those segments to
application programs
When you code an application program that processes
a data base via a secondary index, you must consider
how the secondary data structure affects your
program¶s logic
DBDGEN Requirements forDBDGEN Requirements forSecondary IndexesSecondary Indexes
Because a secondary index relationship involves two
d t b t DBDGEN i d f th
8/6/2019 IMS DB-Apr2002
http://slidepdf.com/reader/full/ims-db-apr2002 88/132
Apr 3, 2002 IMS DB Page : 88/132
data bases, two DBDGENs are required± one for theindexed data base and the other for the secondary
index data base
Fig 7.5 Partial DBDGEN output for the customer data base showing the code toimplement the secondary index
8/6/2019 IMS DB-Apr2002
http://slidepdf.com/reader/full/ims-db-apr2002 89/132
DBDGEN Requirements forDBDGEN Requirements forSecondary Indexes (contd.)Secondary Indexes (contd.)
ACCESS=INDEX in the DBD macro in Fig 7.6 tells DL/I
that an index data base is being defined
8/6/2019 IMS DB-Apr2002
http://slidepdf.com/reader/full/ims-db-apr2002 90/132
Apr 3, 2002 IMS DB Page : 90/132
that an index data base is being defined The INDEX parameter of the LCHILD macro in Fig 7.6
specifies the name of the secondary key field±
C RR ECXNO
The XDFLD macro in Fig 7.5 supplies a field name
(C RR ECXNO) that is used to access the data base via
the secondary key This key field does not become a part of the segment
Instead, its value is derived from up to five fields defined
within the segment with FIELD macros
The S R CH parameter defines the field(s) that
constitute the secondary index
PSBGEN Requirements forPSBGEN Requirements forSecondary Indexing Secondary Indexing
Just because a secondary index exists for a data base
doesn¶t mean DL/I will automatically use it when one of
8/6/2019 IMS DB-Apr2002
http://slidepdf.com/reader/full/ims-db-apr2002 91/132
Apr 3, 2002 IMS DB Page : 91/132
doesn t mean DL/I will automatically use it when one of your programs issues calls for that data base
You need to be sure that the PSBGEN for the program
specifies the proper processing sequence for the data
base on the P R OCSEQ parameter of the PSB macro
If it doesn¶t, processing is done using the normal
hierarchical sequence for the data baseFor the P R OCSEQ parameter, the DBA codes the DBD
name for the secondary index data base that will be
used
Fig 7.7 PSBGEN Output
PSBGEN Requirements forPSBGEN Requirements forSecondary Indexing (contd.)Secondary Indexing (contd.)
The SENSEG macros in Fig 7.7 reflect the secondary
data structure imposed by the secondary index
8/6/2019 IMS DB-Apr2002
http://slidepdf.com/reader/full/ims-db-apr2002 92/132
Apr 3, 2002 IMS DB Page : 92/132
data structure imposed by the secondary index When the P R OCSEQ parameter is present, processing
is done based on the secondary index sequence
If a program needs to access the same indexed data
base using different processing sequences, the
program¶s PSBGEN will contain more than one PCB
macro, each specifying a different value for theP R OCSEQ parameter
Indexing a SegmentIndexing a Segmentbased on a Dependent Segmentbased on a Dependent Segment
C tInvoice number index data base
Secondary Index Data Base
Customer Data Base
8/6/2019 IMS DB-Apr2002
http://slidepdf.com/reader/full/ims-db-apr2002 93/132
Apr 3, 2002 IMS DB Page : 93/132
Customer
Ship-to
Buyer Receivable
Payment Adjustment Line Item
Prefix Data
Cust. Seg.Addr.
ItemNo.
IndexPointer
Segment
Indexed Data Base
Index TargetSegment
Index SourceSegment
Fig 7.8 Secondary Indexing Example in which the Index SourceSegment and the Index Target Segment are different
Indexing a SegmentIndexing a Segmentbased on a Dependent Segment (contd.)based on a Dependent Segment (contd.)
The Index Source Segment and the Index Target
Segment need not be the same
8/6/2019 IMS DB-Apr2002
http://slidepdf.com/reader/full/ims-db-apr2002 94/132
Apr 3, 2002 IMS DB Page : 94/132
Segment need not be the sameSome applications require that a particular segment be
indexed by a value that is derived from a dependent
segment
In such a case, the Index Target Segment and the Index
Source Segment are different
For example, in Fig 7.8, you can retrieve customersbased on items they have purchased
In other words, the SSA for a get call would specify an
item number, but the call would retrieve a customer
segment
The only restriction you need to be aware of here is
that the Index Source Segment must be a dependent of the Index Target Segment
Thus, in the example shown in Fig 7.8, it wouldn¶t be
possible to index the buyer segment based on values in
the line item segment, because the line item segment
isn¶t dependent on the buyer segment
Similarly , you couldn¶t index the line item segment
based in the customer segment, because the customer segment is superior to the line item segment
The Independent AND OperatorThe Independent AND Operator
When used with secondary indexes, AND ( * or & ) is called
the dependent AND operator
The independent AND (#) lets you specify qualifications that
8/6/2019 IMS DB-Apr2002
http://slidepdf.com/reader/full/ims-db-apr2002 95/132
Apr 3, 2002 IMS DB Page : 95/132
The independent AND (#) lets you specify qualifications that
would be impossible with the dependent AND
This operator can be used only for secondary indexes where
the index source segment is a dependent of the index target
segment
Then, you can code an SSA with the independent AND to
specify that an occurrence of the target segment be processed based on fields in two or more dependent source
segments
In contrast, a dependent AND requires that all fields you
specify in the SSA be in the same segment occurrence
An SSA that uses the independent AND operator is shown
below
01 ITEM-SELECTION-SSA.
*
05 FILLER PIC X(9) VALUE µCRCUSSEG(¶.
05 FILLER PIC X(10) VALUE µCRLINXNO =¶.
05 SSA-ITEM-KEY-1 PIC X(8).
05 FILLER PIC X VALUE µ#¶.
05 FILLER PIC X(10) VALUE µCRLINXNO =¶.
05 SSA-ITEM-KEY-2 PIC X(8).
05 FILLER PIC X VALUE µ)¶.
Sparse Sequencing Sparse Sequencing
When the DBA implements a secondary index database with sparse sequencing (also called sparseindexing), it is possible to omit some index source
8/6/2019 IMS DB-Apr2002
http://slidepdf.com/reader/full/ims-db-apr2002 96/132
Apr 3, 2002 IMS DB Page : 96/132
g), psegments from the index
Sparse sequencing can improve performance whensome occurrences of the index source segment must be indexed but others need not be
DL/I uses a suppression value, a suppression routine,
or both to determine whether a segment should beindexed (either when inserting a new segment or processing an existing one)
If the value of the sequence field(s) in the index sourcesegment matches a suppression value specified by theDBA, no index relationship is established (for an
insert) or expected (for any other call)The DBA can also specify a suppression routine that DL/I invokes to determine the index status for thesegment
The suppression routine is a user-written program that evaluates the segment and determines whether or not it should be indexed
Note:
When sparse indexing is used, its functions are handled by DL/I
You don¶t need to make special provisions for it in your application program
8/6/2019 IMS DB-Apr2002
http://slidepdf.com/reader/full/ims-db-apr2002 97/132
8/6/2019 IMS DB-Apr2002
http://slidepdf.com/reader/full/ims-db-apr2002 98/132
Apr 3, 2002 IMS DB Page : 98/132
Module 8Module 8Log ical Data BasesLog ical Data Bases
Introduction to Logical Data Bases
Logical Data Base Terminology
DBDGENs for Logical Data Bases
An Introduction to Log ical Data BasesAn Introduction to Log ical Data Bases
Inter related databases.
A logical child segment having 2 parent segments.One physical parent and one logical parent
8/6/2019 IMS DB-Apr2002
http://slidepdf.com/reader/full/ims-db-apr2002 99/132
Apr 3, 2002 IMS DB Page : 99/132
One physical parent and one logical parent.
SEG-a SEG-b RLC
PP
C2
SEG-1
LP
VLC
Virtual Logical Child
R eal Logical Child
DB1
DB2
Logical Parent
Physical Parent
Log ical Data Base Terminolog yLog ical Data Base Terminolog y
R eal Logical Child
The child under consideration
8/6/2019 IMS DB-Apr2002
http://slidepdf.com/reader/full/ims-db-apr2002 100/132
Apr 3, 2002 IMS DB Page : 100/132
Physical Parent
Original parent of the child
Logical Parent
The parent in the other data base
Virtual Logical Child
The child as seen from the other data base
Three types of Logical data bases
Unidirectional.The child accesses logical parent¶s data but the reverse isnot allowed.
Bi-directional virtual. Accesses in both the directions, but the child exists only inthe physical DB.
Bi-directional physical.
Accesses in both the directions, but the child exists both inthe physical DB as well as the logical DB.
DBDGENs for a Log ical Data BaseDBDGENs for a Log ical Data Base
******DBD1******
.
.
.
8/6/2019 IMS DB-Apr2002
http://slidepdf.com/reader/full/ims-db-apr2002 101/132
Apr 3, 2002 IMS DB Page : 101/132
6 SEGM NAME=RLC,
7 PARENT=(PP,PTR), (LP,DBD2),
8 POINTER=(TWIN,LTWIN), RULES=(LLV,LAST),BYTES=16
9 FIELD NAME=********************************
10 FIELD NAME=********************************
.
.
.
******DBD2*******
.
.
.6 SEGM NAME=LP, PARENT=SEG-1, BYTES=48
7 LCHILD NAME= (RLC,DBD1), POINTER=PTR, PAIR=VLC
8 FIELD NAME=********************************
9 FIELD NAME=********************************
10 FIELD NAME=********************************
.
.
.
8/6/2019 IMS DB-Apr2002
http://slidepdf.com/reader/full/ims-db-apr2002 102/132
Apr 3, 2002 IMS DB Page : 102/132
Module 9Module 9Recovery and RestartRecovery and Restart
Introduction to Data Base R ecovery
Introduction to Checkpointing
Types of Checkpointing
Extended R estart
Introduction to Data Base RecoveryIntroduction to Data Base Recovery
The process of recovering the data base in case of
application program failureBack out changes made by the abended program,
8/6/2019 IMS DB-Apr2002
http://slidepdf.com/reader/full/ims-db-apr2002 103/132
Apr 3, 2002 IMS DB Page : 103/132
g y p g
correct the error and rerun the program.
Types of recoveries
Forward recovery
Backward recovery
Forward R ecovery Data base changes for a time period is accumulated
A copy of the data base is created
The changes are applied to this data base copy
DL/I uses change data stored in DL/I logs for forward
recovery
Used when a data base is physically damaged
Backward R ecovery
Data base changes due to the failed program is reverted
directly in the data base
Program log records are read backwards and their effects
are reversed in the data base
When backout is complete data base is in the former
state that was before the failure
Normally applied when the program ends in a controlled
fashion and no data base damage
Introduction to Checkpointing Introduction to Checkpointing
Synonyms: synchronization point, sync point, commit
point and point of integrity Program execution point at which the DB changes are
8/6/2019 IMS DB-Apr2002
http://slidepdf.com/reader/full/ims-db-apr2002 104/132
Apr 3, 2002 IMS DB Page : 104/132
complete and accurate
DB changes made before the most recent checkpoint
are not reversed by recovery
Normally the start of the pgm is considered as a
default checkpoint In case of a number of DB updates, explicit
checkpoints can be specified
Explicit checkpoints can be established using
checkpoint call(CHKP) inside the program
CHKP creates a checkpoint record on DL/I log which
prevents recovery before that point
Types of Checkpointing Types of Checkpointing
Types of checkpointing
Basic checkpointing Symbolic checkpointing
8/6/2019 IMS DB-Apr2002
http://slidepdf.com/reader/full/ims-db-apr2002 105/132
Apr 3, 2002 IMS DB Page : 105/132
Basic checkpointing
Simple form of checkpointing.
Issues checkpoint calls that the DL/I recovery utilities use
during recovery processing
Symbolic checkpointing More advanced type of checkpointing
Used in combination with extended restart
Programs resume from the point following the
checkpoint, in case of a failure
Store program data and CHKP records and retrieve them
at the time of restart Along with symbolic CHKP call you must use the X R ST
(Extended R estart) call too.
Extended Restart (XRST)Extended Restart (XRST)
The X R ST call is used in connection with the symbolic
checkpoint call It is used to restart your program
8/6/2019 IMS DB-Apr2002
http://slidepdf.com/reader/full/ims-db-apr2002 106/132
Apr 3, 2002 IMS DB Page : 106/132
The X R ST call precedes a symbolic checkpoint call
The X R ST call must be issued only once
It should be issued early in the execution of the
program
It must precede any CHKP call
The program is restarted from a symbolic CHKP taken
during a previous execution of the program
The CHKP used to perform the restart can be identified
by entering the checkpoint ID
CHKP ID can be specified in 2 waysIn the I/O area pointed to by the X R ST call
Specifying ID in the CKPTID= field of EXEC statement in
the program's JCL
8/6/2019 IMS DB-Apr2002
http://slidepdf.com/reader/full/ims-db-apr2002 107/132
Apr 3, 2002 IMS DB Page : 107/132
Module 10Module 10Advanced DL/I featuresAdvanced DL/I features
Variable Length Segments
DBD for GSAMs
PCB for GSAMs
Variable Leng th SegmentsVariable Leng th Segments
When a field length that is stored in a segment type
varies, for example Description or Explanatory text,
then we define those fields as variable length fields
The segment with such a field defined in it is called
8/6/2019 IMS DB-Apr2002
http://slidepdf.com/reader/full/ims-db-apr2002 108/132
Apr 3, 2002 IMS DB Page : 108/132
The segment with such a field defined in it is called
Variable Length Segment
For description and explanatory fields if we define
them long enough to accommodate longest possible
text then lot of space is wasted in cases where it contains shorter strings.
The SEGM macro in DBD is defined asSEGM NAME=INVENSEG,PARENT=0,POINTER=TR,BYTES=m,n
m=maximum length of the segment + 2 bytes
n=minimum length of the segment + 2 bytes
The extra two bytes is used to store the length field of the occurrence of the variable length segment
In Application Program :
The length field has to be included in the I-O Area for the
segment. Length PIC S 9(4)
The I-O area should be large enough to accommodate the
Maximum variable length segment + Length field Before an IS R T / R EPLACE / DELETE call is issued we
have to move the actual length to the length field in the
I/O area
Variable Leng th Segments (contd.)Variable Leng th Segments (contd.)
Variable Length Segments are appropriate when
segment occurrence length vary but once created and
made stabilized.
8/6/2019 IMS DB-Apr2002
http://slidepdf.com/reader/full/ims-db-apr2002 109/132
Apr 3, 2002 IMS DB Page : 109/132
Disadvantage:
If the occurrence of the segment type grows in length
then Variable length segment will drop performance
When segment type occurrences grow in size then it
split's into 2 parts which are not stored in the same
physical record, so we require two I/O operations to fetch
the segment therefore the performance drops
DBD for GSAMsDBD for GSAMs
During DBD generation for a GSAM database we
should specify one dataset group
The DD name of the input dataset that is used when
the application retrieves data from the database
8/6/2019 IMS DB-Apr2002
http://slidepdf.com/reader/full/ims-db-apr2002 110/132
Apr 3, 2002 IMS DB Page : 110/132
the application retrieves data from the database
The DD name of the output dataset used when loading
the database.
The DBD for a GSAM is shown below DBD NAME=CARDS,ACCESS=(GSAM,BSAM)
DATASET D1=ICARDS,DD2=OCARDS,RECFM=F,RECORD=80
DBDGEN
FINISH
END
In GSAM DBD's you can't specify SEGM and FIELD statements
The use of logical or index relationships between
segments
IMS adds 2 bytes to the record length value specified
in the DBD in order to accommodate the ZZ field that is
needed to make up the BSAM R DW.
DBD for GSAMs (contd.)DBD for GSAMs (contd.)
Whenever the database is GSAM/BSAM and the
records are variable (V or VB), IMS adds 2 bytes.
The record size of the GSAM database is 2 bytes
8/6/2019 IMS DB-Apr2002
http://slidepdf.com/reader/full/ims-db-apr2002 111/132
Apr 3, 2002 IMS DB Page : 111/132
The record size of the GSAM database is 2 bytes
greater than the longest segment that is passed to IMS
by the application program.
A database if defined as GSAM has the advantage of the usage of CHECKPOINT and R ESTAR T
Disadvantage of GSAM database : Only inserts can be
done to the DB which is defined as GSAM, no delete
operation can be performed on GSAM Database.
PCB for GSAMsPCB for GSAMs
The PCB for a GSAM database is coded as shown
below PCB TYPE=GSAM,DBDNAME=REPORT,PROCOPT=LS
The GSAM PCB statement must follow the PCB
8/6/2019 IMS DB-Apr2002
http://slidepdf.com/reader/full/ims-db-apr2002 112/132
Apr 3, 2002 IMS DB Page : 112/132
The GSAM PCB statement must follow the PCB
statements with TYPE=TP or DB if any exist in the PSB
generation, the rule is:
TP PCBs First
DB PCBs Second GSAM PCBs Last
A sample PSB is shown below PCB TYPE=TP,NAME=OUTPUT1
PCB TYPE=DB,DBDNAME=PARTMSTR,PROCOPT=A,KEYLEN=100
SENSEG NAME=PARTMAST,PARENT=0,PROCOPT=A
SENSEG NAME=CPWS,PARENT=PARTMAST,PROCOPT=A
PCB TYPE=GSAM,DBDNAME=REPORT,PROCOPT=LS
PSBGEN LANG=COBOL,PSBNAME=APPLPGM3
END
8/6/2019 IMS DB-Apr2002
http://slidepdf.com/reader/full/ims-db-apr2002 113/132
Apr 3, 2002 IMS DB Page : 113/132
Module 11Module 11DL/I Data Base OrganizationsDL/I Data Base Organizations
DL/I Organizations & Access Methods
Hierarchical Sequential Organization
Hierarchical Direct Organization
Additional IMS Access Methods
DL/I Organization & Access MethodsDL/I Organization & Access Methods
File Organization is a description of how a file is
processed & access method is the software used to
implement that processing.
DL/I provides two basic data base organizations :
8/6/2019 IMS DB-Apr2002
http://slidepdf.com/reader/full/ims-db-apr2002 114/132
Apr 3, 2002 IMS DB Page : 114/132
p g
Hierarchic Sequential: In this the segments that make up
the database record are related to one another by their
physical locations.
Hierarchic Direct : In this the segment occurrences
include prefixes that contain direct pointers to related
segments.
8/6/2019 IMS DB-Apr2002
http://slidepdf.com/reader/full/ims-db-apr2002 115/132
Hierarchic Direct OrganizationHierarchic Direct OrganizationAccess MethodAccess Method
HDAM ( Hierarchic Direct Access Method ):
HDAM stores root segment occurrences based on a
randomizing routine.
Occurrences of dependent segments are related to root
d th b t f i t th HD
8/6/2019 IMS DB-Apr2002
http://slidepdf.com/reader/full/ims-db-apr2002 116/132
Apr 3, 2002 IMS DB Page : 116/132
and one another by a system of pointers the HD
Organization is based upon.
HDAM databases are not appropriate for sequential
processing.
HIDAM (Hierarchic Indexed Direct Access Method) :Segment data in HIDAM is stored in the same way like
that in HDAM.
In HIDAM, unlike HDAM root segment is located through
an index.
R oot segments can be retrieved in sequence.
Additional IMS Access MethodsAdditional IMS Access Methods
GSAM( Generalized Sequential Access Methods):
GSAM lets application files to be treat OS sequential files
as databases.
Data is processed on a record to record to basis but
through DL/I calls
8/6/2019 IMS DB-Apr2002
http://slidepdf.com/reader/full/ims-db-apr2002 117/132
Apr 3, 2002 IMS DB Page : 117/132
through DL/I calls.
Processing of database is sequential , IS R T add data only
at the end of database & R EPL and DLET calls are not
supported.
They are typically used during conversion from a systemthat uses standard files to one that uses data bases.
Since files are considered by IMS to be databases, IMS
recovery facilities can be used.
Fast Path data bases:
Fast Path data bases provides fast processing of simple
data structures.Two types of Fast Path databases : MSDB(Main Storage
Data Base ) & DEDB( Data Entry Data Base ).
MSDB(Main Storage Data Base) :
It is used to store an application¶s most intensively used
data and resides in virtual storage.
It provides fast access to data and it contains only asmall amount of data.
These are root-segment-only data bases.
Additional IMS Access Methods (contd.)Additional IMS Access Methods (contd.)
DEDB( Data Entry Data Base ) :
DEBD is stored in a disk and has a hierarchical structure
They are organized in typical DL/I fashion, as direct
dependent segments types.
DEBD li t d t h th t i l
8/6/2019 IMS DB-Apr2002
http://slidepdf.com/reader/full/ims-db-apr2002 118/132
Apr 3, 2002 IMS DB Page : 118/132
DEBDs use a complicated storage scheme that involves
separating the data base into as many as 240 areas and
this allows very large data bases
ACB & ACBGENACB & ACBGEN
ACB(Application Control Blocks) : It is created by
merging and expanding PSBs and DBDs into an IMS
internal format when an application program is
scheduled for execution.
ACBGEN The process of b ilding ACB is called Block
8/6/2019 IMS DB-Apr2002
http://slidepdf.com/reader/full/ims-db-apr2002 119/132
Apr 3, 2002 IMS DB Page : 119/132
ACBGEN : The process of building ACB is called Block
Building and is done by means of ACBGEN.
IMS can build ACBs either dynamically or it can
prebuild them using ACB maintenance utility. ACBs cannot be prebuilt for GSAM DBDs.
ACBs can be prebuild for PSBs that reference GSAM
databases.
ACBs save instruction, execution and direct-access
wait time and improves performance in application
scheduling. ACBs are maintained in IMS.ACBLIB library.
Sample JCLSample JCL
//JOBNAME JOB (ACCT),'PGMR NAME',
// CLASS=J,
//MSGCLASS=Z,
// NOTIFY=&SYSUID
//JOBLIB DD DSN=YOUR.PROGRAM.LOAD.LIBRARY,
// DISP=SHR
8/6/2019 IMS DB-Apr2002
http://slidepdf.com/reader/full/ims-db-apr2002 120/132
Apr 3, 2002 IMS DB Page : 120/132
// DD DSN=YOUR.SYSTEM.RESLIB.LIBRARY,
// DISP=SHR
//PROC EXEC PROCNAME, SYMBOLIC PARAMETERS
//****************************************************************
//PROCNAME PROC//****************************************************************
//* THIS STEP LOADS INTO AN IMS VSAM DATABASE
//* A COBOL PROGRAM 'LOAD' IS USED FOR THIS
//*PURPOSE
//* THE PSB USED FOR LOADING IS LOADPSB
//****************************************************************
//LOAD EXEC PGM=DFSRRC00,
// PARM='DLI,LOAD,LOADPSB'
//*
//DFSRESLB DD DSN=YOUR.DFRESLIB.LIBRARY,
// DISP=SHR
//IMS DD DSN=YOUR.DBD.LIBRARY,
// DISP=SHR
// DD DSN=YOUR.PSB.LIBRARY,
//DISP=SHR
//*
Sample JCL (contd.)Sample JCL (contd.)
//IMSLOGR DD DSN=YOUR.IMSRLOG.DATASET,
// DISP=SHR
//*
//IEFRDER DD DSN=YOUR.IEFRDER.DATASET,
// DISP=(,DELETE,DELETE),UNIT=&UNITDA,
// CB=(RECFM=&RECFM,LRECL=&LRECL,
8/6/2019 IMS DB-Apr2002
http://slidepdf.com/reader/full/ims-db-apr2002 121/132
Apr 3, 2002 IMS DB Page : 121/132
// BLKSIZE=&BLKSIZE), SPACE=&SPACE
//*
//* DD NAMES ARE AS SPECIFIED IN THE DATABASE
//* DBD
//DATA DD DSN=VSAMDB.DATA.PART,DISP=SHR //INDEX DD DSN=VSAMDB.INDEX.PART,DISP=SHR
//*
//INPUT DD DSN=FILE.USED.FOR.LOADING,
// DISP=SHR
//DFSVSAMP DD DSN=IMSVS.PROCLIB(DFSVSAMP),
// DISP=SHR
//CPXMOPTS DD DSN=PARMLIB.LIBRARY(LOAD),
// DISP=SHR
//CPXMRPTS DD SYSOUT=*
//SYSOUT DD SYSOUT=*
//SYSPRINT DD SYSOUT=*
//SYSUDUMP DD SYSOUT=*
//IMSERR DD SYSOUT=*
//IMSPRINT DD SYSOUT=*
8/6/2019 IMS DB-Apr2002
http://slidepdf.com/reader/full/ims-db-apr2002 122/132
Apr 3, 2002 IMS DB Page : 122/132
Module 12Module 12Miscellaneous TopicsMiscellaneous Topics
Data base image copy
Path Call
IMS Processing Options
IMS Status Codes
IMS Abends
Key, search and concatenated key fields
Data Base Imag e CopyData Base Imag e Copy
Job which is run to take backup copies of IMS
database datasets at periodic intervals
Traditionally, batch cycle starts at 7 pm and ends at 7 am
Image Copy jobs are usually run before and after a batch
cycle
8/6/2019 IMS DB-Apr2002
http://slidepdf.com/reader/full/ims-db-apr2002 123/132
Apr 3, 2002 IMS DB Page : 123/132
y
If abend occurs, revert to the DB generated by image
copy job and rerun
Commonly used image copy utility is BMC Software¶s
ICPUMAIN
Database and Image copy DD names specified in the
ICPSYSIN card
Advantage : Simple, Fast, Automated procedure
Path CallPath Call
A DB call with an SSA that includes the 'D' Command code is a "PATH CALL³ . It¶s a facility where in we can
retrieve an entire path of the segment Consider a sample GU call
CALL 'CBLTDLI' USING DLI-GU
8/6/2019 IMS DB-Apr2002
http://slidepdf.com/reader/full/ims-db-apr2002 124/132
Apr 3, 2002 IMS DB Page : 124/132
INVEN-PCB-MASK
INVEN-STOCK-LOC-SEG
VENDO R -SSA
ITEM-SSA
STOCK-LOC-SSA
Normally, DL/I operates on the lowest level segment that is specified in an SSA(STOCK-LOC-SSA in theabove E.g.)
In case if we need data from not just from the lowest level but from other levels as well we normally have to
give 3 separate GU calls.This will reduce the efficiency of the program
Such a call operates on two or more segments rather than just one segment.
If a program has to use "Path call" then "P" should beone of the values specified in the P R OCOPT
parameter of the PCB in the programs PSBGEN.If path call is not explicitly enabled in the PSBGEN jobthere will be an 'AM' status code.
Sample Prog ramSample Prog ram
IDENTIFICATION DIVISION.
PROGRAM-ID. PATGET2.
ENVIRONMENT DIVISION.
CONFIGURATION SECTION.
SOURCE-COMPUTER. IBM-370.
OBJECT-COMPUTER. IBM-370.
INPUT-OUTPUT SECTION.
FILE-CONTROL.
DATA DIVISION.
8/6/2019 IMS DB-Apr2002
http://slidepdf.com/reader/full/ims-db-apr2002 125/132
Apr 3, 2002 IMS DB Page : 125/132
FILE SECTION.
WORKING-STORAGE SECTION.
77 TOP-PAGE PIC X VALUE '1'.
77 GET-UNIQUE PIC X(4) VALUE 'GU'.
01 HOSPITAL-SSA.
05 FILLER PIC X(19) VALUE 'HOSPITAL(HOSPNAME ='.
05 HOSPNAME-SSA PIC X(20).
05 FILLER PIC X VALUE ')'.
01 WARD-SSA.
05 FILLER PIC X(19) VALUE 'WARD (WARDNO ='.
05 WARDNO-SSA PIC X(04).
05 FILLER PIC X VALUE ')'.
01 PATIENT-SSA.
05 FILLER PIC X(19) VALUE 'PATIENT (PATNAME ='.
05 PATNAME-SS PIC X(20).
05 FILLER PIC X VALUE ')'.
01 UNQUAL-HOSPITAL-SSA PIC X(9) VALUE 'HOSPITAL '.
01 UNQUAL-WARD-SSA PIC X(9) VALUE 'WARD '.
01 UNQUAL-PATIENT-SSA PIC X(9) VALUE 'PATIENT '.
01 WS-ISRT PIC X(4) VALUE 'ISRT'.
01 WS-GHU PIC X(4) VALUE 'GHU '.
01 HOSP-I-O-AREA.
05 HOSP-NAME PIC X(20).
05 HOSP-ADDRESS PIC X(30).
05 HOSP-PHONE PIC X(10).
01 Ward-I-O-AREA.
03 WARD-NO PIC X(04).
03 TOT-ROOMS PIC 9(03).
03 TOT-BEDS PIC XXX.
03 BEDAVAIL PIC X(3).
03 WARD-TYPE PIC X(20).
8/6/2019 IMS DB-Apr2002
http://slidepdf.com/reader/full/ims-db-apr2002 126/132
Sample Prog ram (contd.)Sample Prog ram (contd.)
IF STATUS-CODE-1 NOT EQUAL SPACES
EXIT.
INSERT-HOSP-EXIT.
EXIT.
INSERT-WARD-01-PARA.
MOVE '01' TO WARD-NO.
MOVE 10 TO TOT-ROOMS.
MOVE 20 TO TOT-BEDS.
MOVE '03' TO BEDAVAIL
MOVE 'INTENSIVE' TO WARD-TYPE
8/6/2019 IMS DB-Apr2002
http://slidepdf.com/reader/full/ims-db-apr2002 127/132
Apr 3, 2002 IMS DB Page : 127/132
MOVE INTENSIVE TO WARD-TYPE.
CALL 'CBLTDLI' USING WS-ISRT
PCB-MASK
WARD-I-O-AREA
UNQUAL-HOSPITAL-SSA
UNQUAL-WARD-SSA.
IF STATUS-CODE-1 NOT EQUAL SPACES
EXIT.
INSERT-WARD-01-EXIT.
EXIT.
INSERT-PATIENTS-PARA.
MOVE 'MACNEAL' TO WARDNO-SSA.
MOVE 'JOHN SMITH' TO PATIENT-NAME.
MOVE '123 HAMILTON STR' TO PATIENT-ADDRESS.
MOVE '12345 ' TO PATIENT-PHONE.
MOVE '1111' TO BEDINDENT.
MOVE '02021999' TO DATEADMT.
MOVE 'N' TO PREV-STAY-FLAG.
CALL 'CBLTDLI' USING WS-ISRT
PCB-MASK
PATIENT-I-O-AREA
HOSPITAL-SSA
WARD-SSA
UNQUAL-PATIENT-SSA.
IF STATUS-CODE-1 NOT EQUAL SPACES
EXIT.
INSERT-PATIENTS-EXIT.EXIT.
IMS Processing OptionsIMS Processing Options
Indicates to IMS the type of access allowed for a
sensitive segment (SENSEG)
Commonly used Processing Options
P R OCOPT=G means only read only access
P R OCOPT=R means read/replace access
8/6/2019 IMS DB-Apr2002
http://slidepdf.com/reader/full/ims-db-apr2002 128/132
Apr 3, 2002 IMS DB Page : 128/132
P R OCOPT=I means insert access allowed
P R OCOPT=D means R ead/Delete access
P R
OCOPT=A means all the above options present For GSAM DBs P R OCOPT=LS for output and GS (Get
Sequential) for input
P R OCOPT=L allows a 'load' into the DB. If VSAM DB, it
should be empty prior to the load
The P R OCOPT given for a Sensitive segment would
override the one given for the DB
Example : -
PCB
TYPE=DB,NAME=LDB42F,P R OCOPT=G,KEYLEN=200
SENSEG NAME=SEGL4201,PAR ENT=0,P R OCOPT=A
WAR NING : Indiscriminate use of P R OCOPTS might lead
to inexplicable results !
IMS Status CodesIMS Status Codes
R eturned by IMS after each DB call Field STATUS-CODE X(02) in the PCB-MASK definition
Acceptable and unacceptable status codesµGE¶ ± record occurrence not found
µGB¶ ± End of DB reached
8/6/2019 IMS DB-Apr2002
http://slidepdf.com/reader/full/ims-db-apr2002 129/132
Apr 3, 2002 IMS DB Page : 129/132
Status codes relate to the type of IMS call
DLET ± AB, AJ, DJ AB ± I/O area not specified in the call
AJ ± Invalid SSA format (invalid command code etc)
DJ ± Segment not in µHOLD¶ status
GHN, GHNP, GHU, GU ± AB, AK, GE, GB
AK ± Invalid field name in SSA
IS R T ± AB, AC, AD, AJ, AK, II
AC ± Segment not found
AD ± Wrong PCB used
II -- Segment occurrence already exists in the DB
R EPL -- AB, AC, AD, DJ
IMS AbendsIMS Abends
U0456 -- PSB stopped
U0456 -- IMS Compile option µDLITCBL¶ not set to µY¶
U0458 -- DB Stopped
U0844 -- DB being updated is full
S013 -- Error opening the DB
8/6/2019 IMS DB-Apr2002
http://slidepdf.com/reader/full/ims-db-apr2002 130/132
Apr 3, 2002 IMS DB Page : 130/132
S013 Error opening the DB
A few tips on resolving IMS abends:
Confirm that the Abend is caused by IMS ± check the
joblog for IMS return code
Check the JCL ± if modified from another JCL, verify
that changes are correct
Check the SYSOUT dump for IMS diagnostic
messagesUse MVS/QW to get further information on the abend
Key, Search and Concatenated Key FieldsKey, Search and Concatenated Key Fields
Key or Sequence Field
The field DLI uses to maintain segments in ascending
sequence
Only a single field within a segment
Segments need not necessarily require a key field
If in a root segment key field uniquely identifies the
8/6/2019 IMS DB-Apr2002
http://slidepdf.com/reader/full/ims-db-apr2002 131/132
Apr 3, 2002 IMS DB Page : 131/132
If in a root segment, key field uniquely identifies the
record
Additional Search fields
Used to search through the DB for particular values
Max 255 search fields in a segment
Concatenated field
Key formed to access a particular segment Concatenation of keys of root segment and all
successive children down to the accessed segment
Undefined fields
Fields not defined to IMS
Format determined by the program loading the DB
8/6/2019 IMS DB-Apr2002
http://slidepdf.com/reader/full/ims-db-apr2002 132/132
Apr 3, 2002 IMS DB Page : 132/132
Thank YouThank You