Ims DB2

Download as pdf or txt
Download as pdf or txt
You are on page 1of 226

IMS TRAINING

(INFORMATION MANAGEMENT SYSTEM)


by
M.SIRANJEEVI
WHAT IS A DATABASE???

• Database is a collection of
related datas.
• Storing and control of business
Data (or) Information (or)
Record
• The data independent from one
or more applications programs.
• The data can be centrally
controlled and managed.
DATABASE TYPES

There are 3 types of Databases,

1. Network Database
2. Relational Database
3. Hierarchical Database
NETWORK DATABASE
• In NDBMS, Entity is
said to be a SET.
• Collection of SET’s
forms a Network
Database.
• Interconnection of
each and every SET’s
produces NDBMS
Structure.
NETWORK STRUCTURE
In this structure,
A, B,C & D are SET’s.
Relationship is Many to
Many (M : N) A
Adv : Every Set is linked
together. So we can
B
easily Retrieve C
the Complete details.
D
RELATIONAL DATABASE
• In RDBMS, Entity is
said to be a TABLE.
• Collection of TABLE’s
forms a Relational
Database.
• Establish the
relationship between the
tables by using PK and
FK Concept.
RELATIONAL STRUCTURE
Attributes

Tuples

• In RDBMS, attributes &


tuples forms a TABLE.
• Collection of tables form
a RDBMS Database.
• Relationship is Optimal
(ie. 1 : M & M :1)
HIERARCHICAL DATABASE
• In HDBMS, Entity is
said to be a SEGMENT.
• Collection of
SEGMENT’s forms a
Hierarchical Database.
• It is the oldest
database among all of
the DB Types.
HIERARCHICAL STRUCTURE
A

B E F

C D G

• It is an inverted tree
structure.
• In the above structure,
A, B, C, D, E, F & G are
segments.
• Relationship is One to Many.
DBMS TYPES - OVERVIEW
TYPE ENTITY RELATIONSHIP EG. DB
NDBMS SET M : N IDMS
----------------------------------
RDBMS TABLE OPTIMAL DB2,
SYBEL,
ORACLE, etc
----------------------------------
HDBMS SEGMENT 1 : M IMS
EXAMPLE -
HOSPITAL DATABASE
PATIENT Level 1

Level 2
ILLNESS BILLING HOUSEHOLD

TREATMENT PAYMENT Level 3

Constraints,
• Maximum 255 Segments are allowed
per Database. Maximum upto 15 Levels.
DATABASE HIERARCHY CHART
• ROOT SEGMENT
• DEPENDENT SEGMENT
• SEGMENT TYPE
• SEGMENT OCCURRENCE
• SIBBLING SEGMENT
• TWIN SEGMENT
• DATABASE RECORD
• HIERARCHICAL PATH
• IMMEDIATE & NON-IMMEDIATE PARENTS
ROOT SEGMENT
A very first segment
or level-1 segment in an
IMS Database is said to
be a Root Segment. Only
one root segment is
allowed per hierarchical
database. In our Example
PATIENT segment is the
root segment.
DEPENDENT SEGMENT
Segments from Level-2
to Level-15 Segments are
said to be dependent
segments. In our example
ILLNESS, TREATMENT,
BILLING, PAYMENT &
HOUSEHOLD are dependent
segments.
SEGMENT TYPE
Every segment name is
said to be a segment
type. The segment type
should be unique in any
hierarchical database.
In our example, we have
six segment types.
SEGMENT OCCURRENCE
Every record in the
segment type is said to
be a segment occurrence.
Collection of segment
occurrences forms a
segment type.
SIBBLING SEGMENT
More than one
segments comes under a
same parent in the same
level is said to be a
sibbling segment. In our
example, ILLNESS,
BILLING & HOUSEHOLD are
sibblings.
TWIN SEGMENT
All occurrences of a
particular segment type
under a single parent
segment occurrence are
called TWINS.
PATIENT(P1)

ILL1 BILL1
ILL2 BILL2
Twins
ILL3 BILL3
ILL4 BILL4
DATABASE RECORD
Database record is
nothing but collection
of entire dependent
details about the root
key. In our example,
Collection of related
Illness, Treatment,
Billing, Payment &
Household details of a
particular patient.
HIERARCHICAL PATH
• Segments are always
accessed and retrieved
along the Hierarchical
Paths.
• A path is a route line that
Begins at the Root segment,
travels through the
segments at Intermediate
levels in the hierarchy and
Ends at a segment in the
Bottom of the hierarchy.
HIERARCHICAL PATH

In our example,
Hierarchical paths are,

PATIENT ILLNESS TREATMENT


PATIENT BILLING PAYMENT
PATIENT HOUSEHOLD
IMMEDIATE & NON-IMM’S
SEG. TYPE IMME NON-IMME
NON-
PATIENT NIL NIL
ILLNESS PATIENT NIL
TREATMENT ILLNESS PATIENT
BILLING PATIENT NIL
PAYMENT BILLING PATIENT
HOUSEHOLD PATIENT NIL
IMS ARCHITECTURE
IMS CONTROL BLOCKS

PSB DBD
APPLICATION
DL/I
PROGRAM

ACCESS METHODS
HDAM,HISAM
HIDAM,HSAM
GSAM . . . . .

DATA

ESDS
WHY ACCESS METHODS???
• Access methods are
like interfaces to help
us to communicate
between two subsystems
or systems. Based on the
access method type IMS
will organize and
retrieve the datas from
the back-end dataset.
WHY ACCESS METHODS???
• IMS provides number
of access methods to
communicate with back-
end datas. The basic
access methods are HDAM,
HIDAM, HISAM, HSAM,
GSAM. . .
HDAM OVERVIEW
HDAM Stands for
‘Hierarchical Direct
Access Method’. This
access method says we can
perform random operation
against backend ESDS file.
But! is it possible to do
random operation against
ESDS in Batch Environment?
HDAM OVERVIEW
Yes! It is possible
in this case because IMS
provides an inbuilt index
component called
‘Randomizer Module’. As a
user we can store our key
values in this RM Space
and actual values in Data
component called ESDS.
HDAM DATA FLOW
HDAM RANDOMIZER MODULE DATA
(INDEX)
ESDS

This is the flow of HDAM


Access method. We should
call this randomizer module
by using standard name
along with related
parameters.
HIDAM/HISAM DATA FLOW
HIDAM/HISAM
INDEX DATA

KSDS ESDS

If we use HIDAM/HISAM
as an Access method then
IMS Will not provide any
inbuilt index space. So
user has to create an
index component
explicitly.
HSAM/GSAM DATA FLOW
HSAM/GSAM DATA

ESDS

For HSAM & GSAM Access


methods no need of any
index components. Because
we cannot perform any
random operations by
using these access
methods. Only sequential
operations are possible.
DL/I CONTROL BLOCKS
IMS uses two kinds of control
blocks to enable application
programs to be independent of the
way in which you store the data
in the database. They are,
• Database Description (DBD)
• Program Communication Block
(PCB)
Database Description(DBD)
• DBD describes the physical
structure of a database as well
as the way in which it is stored
on the DASD and the way it is
accessed. The DBD also defines
the appearance and contents, or
fields, that make up each of the
segment types in the database.
Database Description(DBD)
• A physical database is limited
to 15 hierarchical levels and 255
segment types.
Up to 254 dependent segments
organized over 14 levels, plus
the root segment. There is no
limit to the number of segment
occurrences.
DBD FUNCTIONS
• Defines the physical storage
information
• Defines the hierarchical
structure
• Define the relationship between
the segments
• Defines the segment layouts
• Defines the key field with in
the segment
DBD FUNCTIONS
• Describe the information
necessary to create the database
• Defines any logical relationship
• Defines the secondary index
Steps to create DBD
Database Description(DBD) is
usually created by the DBA at an
installation. The steps are,
• The name of the DBD, which is
also used as a shorthand name for
the IMS-DLI Database. It should
not exceed 8 characters long.
• Type of the access method should
be specified for the database.
Steps to create DBD
• If we prefer access method as
HDAM then Randomizer module name
with parameters should be
specified. The randomizing method
to assign an address to each
record's key (HDAM only).
• DD Name for the database.
• Device type and Block size.
Steps to create DBD
• The name, parent, and length of
each segment type in the
database. The parent information
enables IMS-DL/I to determine the
segment's position in the
hierarchy.
• The name, length, starting
position, and type of data for
each field in each segment type.
Steps to create DBD
• DBD is then submitted to the
system with JCL that invokes a
procedure called DBDGEN. This
procedure produces an object
module which is in turn passed to
the linkage editor which produces
a load module. The load module
is stored in a library named
something like IMSVS.DBDLIB.
DBD Macros
• DBD
• DATASET
• SEGM
• FIELD
• LCHILD
• XDFLD
• DBDGEN
• FINISH
• END
DBD Macros
• DBD :
This is the very first
macro to define the database name
and the access method.
• DATASET :
Defines each file with
comprises the database. It
defines the DD name and the
dataset information.
DBD Macros
• SEGM :
Defines the name of the
segment type, its position in the
database and how it is related
with other segment.
• FIELD :
Defines the field within
a segment type. It identifies
field name, length, starting
position and data type of the
field.
DBD Macro
DBD Macro provides 3 different
parameters. The parameters are
• NAME
• ACCESS
• RMNAME
NAME and ACCESS parameters are
necessary. RMNAME parameter is
only required for HDAM Access
method.
DBD Macro
The NAME Parameter is for
specifying the database name and
ACCESS parameter is for
specifying the access method for
a database. Only one access
method is allowed per database.
DBD NAME=db_name(8 chars long),
ACCESS=(HSAM/HISAM/HIDAM/
HDAM…,backend_file_type),
RMNAME=(randomizer name
with parameters)
DBD Macro Example

DBD NAME=Hospital,
ACCESS=(HSAM,VSAM)

DBD NAME=Hospital,
ACCESS=(HDAM,VSAM),
RMNAME=(DFSHDC40,010,00000120,
00004096)
DBD Macro Example
Where, DFSHDC40 is the name
of the IBM-supplied randomizing
module, DL/I will use when it
processes the database.
The other values specify
what the structure of the HDAM
will be. 010 tells DL/I to use 10
RAP’s per control interval in the
database root addressable area.
DBD Macro Example
The value 120 specifies the
root addressable area, should use
120 control intervals and 4096
specifies the size of the each
control interval in the root
addressable area.
DATASET Macro
DATASET Macro provides 3
different parameters. They are,
• DD1
• DEVICE
• SIZE
The parameter DD1 is for
specifying the dd name. The same
dd name should be declared in run
jcl to invoke the datas from
database.
DATASET Macro
The DEVICE parameter specifies
the physical storage device(DASD)
name and SIZE parameter specifies
the length of the control
interval in every control area.

DATASET DD1=hosdd,DEVICE=3390,
SIZE=4096
SEGM Macro
SEGM Macro provides 3
different parameters. They are,
• NAME
• BYTES
• PARENT
The NAME Parameter is
for specifying the segment name.
The name should be unique for
each and every segments. It
should not exceed 8 chars. Long.
SEGM Macro
The BYTES operand specifies
the segment length in terms of
bytes and PARENT operand names
the parent of each segment type
thereby defining the Hierarchical
Structure of a database. A root
segment is identified by the
absence of a Parent operand or
Parent=0.
FIELD Macro
The FIELD Macro provides
three different parameters,
• NAME
• BYTES
• START
• TYPE
FIELD Macro
We have 2 different types of
fields, Search field and Sequence
field based on the field type.
NAME parameter contains from
one to three positional sub-
parameters. The first sub-
parameter names the key or search
field. If it is the only sub-
parameter coded, the field will
be considered as a search field.
FIELD Macro
If SEQ is coded as the second
sub-parameter, the field will be
a key field, and the occurrences
will be sequenced in Ascending
order. This sub-parameter is
optional. If specified, only one
key field is allowed per SEGM
statement.
FIELD Macro
If U is coded as the third
sub-parameter, the field is a
UNIQUE sequence field unless M is
specified for Multiple value in
the field. If neither 'U' nor 'M'
is specified when SEQ is coded,
the sequence field is taken to be
unique. This sub-parameter is
optional.
FIELD Macro
The BYTES operand tells the
field length in bytes.
The START operand tells the
starting byte position of the key
or search field relative to the
beginning of the segment. The
starting position will be
initialized for each and every
segment.
FIELD Macro
The TYPE operand tells the
data type of field, accordingly C
specifies a character field of
alphanumeric type, P specifies a
packed Decimal numeric type. C is
the default data type. FIELD
statement for the sequence field,
if there is one, must be the
first such statement for the
segment.
FIELD Macro
Field macro
TYPE codes Data type
C Character
P Packed decimal
Z Zoned decimal
X Hexadecimal
H Halfword binary
F Fullword binary
DBDGEN FINISH END Macros
DBDGEN Macro ends the SEGM and
FIELD definitions in the DBD.
FINISH Macro causes the
assembler to set non-zero
condition code if errors are
encountered during assembly
process.
END Macro marks the end-of-
data to the assembler.
DBD Source for Hospital
Database
PRINT NOGEN
DBD NAME=Hospital,ACCESS=(HDAM,VSAM),
RMNAME=(DFSHDC40,010,00000120,00004096)
DATASET DD1=Hosdd,DEVICE=3390,SIZE=4096

******************PATIENT SEGMENT**********************
SEGM NAME=Patient,BYTES=45,PARENT=0
FIELD NAME=(Patno,seq,u),BYTES=5,START=1,TYPE=C
FIELD NAME=Pname,BYTES=10,START=6,TYPE=C
FIELD NAME=Paddr,BYTES=30,START=16,TYPE=C
DBD Source for Hospital
Database
******************ILLNESS SEGMENT**********************
SEGM NAME=Illness,BYTES=20,PARENT=Patient
FIELD NAME=(Illdate,seq,m),BYTES=10,START=1,TYPE=C
FIELD NAME=Illname,BYTES=10,START=11,TYPE=C

******************TRTMENT SEGMENT**********************
SEGM NAME=Treatmnt,BYTES=34,PARENT=Illness
FIELD NAME=(Trdate,seq,m),BYTES=10,START=1,TYPE=C
FIELD NAME=Medicine,BYTES=10,START=11,TYPE=C
FIELD NAME=Qnty,BYTES=4,START=21,TYPE=C
FIELD NAME=Doctor,BYTES=10,START=25,TYPE=C
DBD Source for Hospital
Database
******************BILLING SEGMENT**********************
SEGM NAME=Billing,BYTES=15,PARENT=Patient
FIELD NAME=(Billno,seq),BYTES=5,START=1,TYPE=C
FIELD NAME=Billdate,BYTES=10,START=6,TYPE=C

******************PAYMENT SEGMENT**********************
SEGM NAME=Payment,BYTES=20,PARENT=Billing
FIELD NAME=(Paydate,seq,m),BYTES=10,START=1,TYPE=C
FIELD NAME=Amount,BYTES=10,START=11,TYPE=C
DBD Source for Hospital
Database
******************HOUSEHLD SEGMENT**********************
SEGM NAME=Househld,BYTES=8,PARENT=Patient
FIELD NAME=(Wardno,seq,m),BYTES=3,START=1,TYPE=C
FIELD NAME=Wardtype,BYTES=5,START=4,TYPE=C

******************END OF STRUCTURE**********************

DBDGEN
FINISH
END
DBD Generation(DBDGEN)
To execute the DBD Source, we
have to call a procedure called
DBDGEN(DBD Generator). This will
assemble all the dbd source
statements before that it will
refer a built-in macro library
called MACLIB and it will
generate the load library called
DBDLIB(DBD Library).
DBD Generation(DBDGEN)

DBD
DBDGEN DBDLIB
Macro
Source code Assemble & Link edit

MACLIB
Program Specification
Block(PSB)
• The DBA defines the logical data
structure by creating a Control
Block called a Program
Specification Block or PSB.
• Logical Data Structure is a term
used to refer to a group of
segments that an application
program may access. To the
application program, the logical
data structure is the database.
Program Specification
Block(PSB)
• PSB is created with a process
called PSB generation or PSBGEN,
very similar to the DBDGEN
process, wherein DBA codes a
series of control statements.
• PSBGEN control statements are
Assembler Language Macros supplied
by IBM and submitted via JCL
invoking a procedure called PSBGEN
producing an OBJECT module.
Program Specification
Block(PSB)
• Macros are stored in Maclib and
Load modules are stored in PSBLIB,
which is the PSB itself and ready
for loading.
• Each PSB consists of one or more
control blocks called Program
Communication Blocks or PCB's.
Each PCB within a PSB defines
exactly one Logical Data
Structure.
Program Specification
Block(PSB)
• All the PCB's within a single PSB
are collectively known as an
Application Data Structure.
• It is possible that more than one
program may share a single PSB,
however, no program can use more
than one PSB in a single execution.
• The Logical Data Structures defines
all the segments that an appln.
program may access using that PSB.
PSB Macros
• PCB
• SENSEG
• PSBGEN
• END
PCB Macro
This is the very first macro
in the PSB. PCB is for creating
number of PCB’s in PSB. This PCB
macro is applicable to both batch
and online based on the operands
coded in the PCB Macro. PCB does
not has any name and accessed only
in sequential manner.
PCB Macro
PSB

PCB1

PCB2

PCB3

PCB4

PCB5
PCB Macro
This macro provides 4 types
of operands,
• TYPE
• NAME
• PROCOPT
• KEYLEN
PCB Macro
The TYPE operand specifies
whether PCB is for Database
processing(Batch) or for
Transaction processing(Online). If
TYPE=DB then its for accessing
database. If TYPE=TP then its for
accessing terminals. To perform
both then we require 2 different
PCB’s.
PCB Macro
The NAME operand tells the
database name which we have
specified in the DBD Macro(NAME
Parameter value). There is no
logical connection between PSB and
DBD in the IMS Architecture(Ref.
Diag.). This NAME parameter is for
automatically routing the control
from PCB to appropriate DBD which
belongs to.
PCB Macro
PROCOPT Stands for Processing
Options. It acts like gateway
between PCB and DBD. Because based
on the processing option values one
can perform the data oriented
operations. Its 4 bytes long.
PROCOPT=L/LS/G/R/I/D/A. . .
L-LOAD LS-LOAD SEQUENCE G-GET
R-REPLACE I-INSERT D-DELETE
A-ALL.
PCB Macro
KEYLEN Stands for Key Length.
It specifies the length of the
longest concatenated key or Key
Feedback Area(KFA) the program can
process in the database.
In our hospital database
KEYLENGTH=43.
Lengths of patno + illdate +
trdate + billno + paydate + wardno.
SENSEG Macro
SENSEG Macro is for creating
number of required logical paths
under PCB to access the database.
It provides 2 basic types of
operands,
• NAME
• PARENT
SENSEG NAME=Patient,PARENT=0
SENSEG NAME=Illness,PARENT=Patient
PSBGEN Macro
PSBGEN Stands for PSB
Generation. This is for specifying
the host language(appln. Program)
type and the PSB name. The operands
are,
• LANG
• PSBNAME
PSBGEN LANG=Cobol/PLI/ASM…,
PSBNAME=Hospsb
PSB Source for Hospital
Database
PCB TYPE=DB,NAME=Hospital,
PROCOPT=L,KEYLEN=43
SENSEG NAME=Patient,PARENT=0
SENSEG NAME=Illness,PARENT=Patient
SENSEG NAME=Treatmnt,PARENT=Illness
SENSEG NAME=Billing,PARENT=Patient
SENSEG NAME=Payment,PARENT=Billing
SENSEG NAME=Househld,PARENT=Patient
PSBGEN LANG=Cobol,PSBNAME=Hospsb
END
PSB Generation(PSBGEN)
To execute the PSB Source, we
have to call a procedure called
PSBGEN(PSB Generation). This will
assemble all the psb source
statements before that it will
refer a built-in macro library
called MACLIB and it will
generate the load library called
PSBLIB(PSB Library).
PSB Generation(PSBGEN)

PSB
PSBGEN PSBLIB
Macro
Source code Assemble & Link edit

MACLIB
ACB Generation(ACBGEN)
ACBGEN Stands for Application
Control Block Generation. This
ACBGEN merges both DBDLIB and
PSBLIB, produces the final load
library called ACBLIB that
application program can access.
If this happens in batch then it
is said to be ‘DYNAMIC BUILD’. If
this happens in online then it is
said to be ‘STATIC BUILD’.
ACB Generation(ACBGEN)
To perform this build
operation, we have to invoke a
catalogue procedure called
DFSRC00. DFSRC00 is the DL/I load
module called Region Controller.
We have to define both PSBLIB
path and DBDLIB path in the
special DD name called ‘IMS’..
This step is said to be a Build
operation.
ACB Generation(ACBGEN)

DBDLIB

ACBGEN
(DFSRC00) ACBLIB
BUILD

PSBLIB
ACBGEN Sample jcl
• //RETRIEVE EXEC PGM=DFSRRC00, PARM=DLI, PATRETRV
• //STEPLIB DD DSN=IMSVS.RESLIB, DISP=SHR
• // DD DSN=IMSVS.PGMLIB, DISP=SHR
• //IMS DD DSN=IMSVS.PSBLIB, DISP=SHR
• // DD DSN=IMSVS.DBDLIB, DISP=SHR
• //SYSUDUMP DD SYSOUT=A
• //HOSDD DD DSN=IMS.VSAM.HOSDB, DISP=OLD
• //OUTPUT DD SYSOUT=A
• //INPUT DD A
• -------------------------------------
• -------------------------------------
• -------------------------------------
• (INPUT TRANSACTIONS)
• -------------------------------------
• -------------------------------------
DL/I (Data Language/I)
• It is a set of program modules
interfacing database and
application program.
• The modules use standard
operating system access methods
and a set of specialized access
methods to handle data transfers
to and from the database.
• This is an Interface Language
used by the Application Program.
DL/I (Data Language/I)
• We can invoke number of DL/I
subroutines through entry and
call statements.
ENTRY ‘DLITCBL’ USING
Parameters. . .
CALL ‘CBLTDLI’ USING
Parameters. . .
DL/I (Data Language/I)
• The ENTRY Statement is the very
first executable statement in the
program that establishes the
connection between the external
PCB with Internal PCB Mask.
• The CALL Statements are for
performing different data related
operations against the IMS
Database.
DL/I Data Processing

APPLICATION PROGRAM

Calls to DL/I

DL/I

IMS CONTROL BLOCKS


WITH ACCESS METHODS

DATABASE
DATASET
DL/I Programming
Considerations
• The application program is
treated as a subroutine of DL/I
and standard subroutine Linkages
and Parameter lists are used to
connect the application program to
the DL/I modules that passes
control to it.
• When DL/I links to the application
program, it passes to the program
a parameter list containing the
addresses of the PCB's in the PSB.
DL/I Programming
Considerations
Working-Storage section:
• The DL/I Function Code variables
are copied here.
• The SSA'S (Segment Search
Arguments) for segment retrievals
are defined here.
• The structure in COBOL for
various segments within the
database are declared here or
simply said to be an I-O Area.
DL/I Programming
Considerations
Function Code:
This is the first parameter
in the list. It names a four byte
function code for the service
requested from DL/I such as
Insert, Update, Delete, and
Browse of database. A function
table Copybook called DLI CALLS
is copied in the application
program using the command
COPY DLI CALLS.
DL/I Programming
Considerations
Function Code Abbreviation
For Write Operation:
ISRT Insert
For Rewrite Operation:
REPL Replace
For Delete Operation:
DLET Delete
DL/I Programming
Considerations
Function Code Abbreviation
For Read Operation:
GU Get Unique
GN Get Next
GHU Get Unique with Hold
GHN Get Next with Hold
GNP Get Next within a Parent
GHNP Get Next within a Parent
with Hold
DL/I Programming
Considerations
DL/I Programming
Considerations
DL/I Programming
Considerations
Working-storage section.
01 func-codes.
05 ins pic x(4) value ‘ISRT’.
05 rep pic x(4) value ‘REPL’.
05 del pic x(4) value ‘DLET’.
05 g1 pic x(4) value ‘GU’.
05 g2 pic x(4) value ‘GN’.
05 g3 pic x(4) value ‘GNP’.
05 g4 pic x(4) value ‘GHU’.
05 g5 pic x(4) value ‘GHN’.
05 g6 pic x(4) value ‘GHNP’.
DL/I Programming
Considerations
Segment Search Argument(SSA):
• This is the second parameter
in the list. This is optional.
Whenever specified, DL/I uses
it to narrow the field of
search to a particular segment
type or to a particular segment
occurrence to be manipulated at
each level of database.
DL/I Programming
Considerations
Segment Search Argument(SSA):
• There can be maximum of 1 SSA
per level upto 15 SSA's for
each database. If SSA is not
used for any level, DL/I will
follow the rules to calculate
the default SSA.
DL/I Programming
Considerations
SSA Types:
There are two types of
SSA’s,
• UNQUALIFIED SSA
• QUALIFIED SSA
DL/I Programming
Considerations
UNQUALIFIED SSA :-
This only specifies the
SEGMENT TYPE the program is
interested in. Here you don't
indicate a particular occurrence of
a segment because you don't care
which occurrence of a segment you
get. The segment name is first
eight characters padded by space.
For example - HOSPITAL. This will
retrieve the first occurrence of
HOSPITAL segment.
DL/I Programming
Considerations
UNQUALIFIED SSA:
DL/I provides the specific
structure for unqualified SSA.
It is said to be a Segment name
without any parameters.
Unqualified SSA Structure
Segment Name Blank

8 Bytes 1 Byte
DL/I Programming
Considerations
UNQUALIFIED SSA Declaration:
01 Unq-ssa.
05 seg-name pic x(8).
05 bla pic x.
(or)
01 unq-ssa pic x(9).
Example:
01 Unq-ssa-pat.
05 seg-name pic x(8) value ‘patient’.
05 bla pic x value SPACES.
DL/I Programming
Considerations
QUALIFIED SSA :
This is addition to the
SEGMENT TYPE, also contains one
or more qualification statements.
A qualified SSA describes the
segment occurrence a program
wants to access. This description
is called a qualification
statement having 3 parts.
DL/I Programming
Considerations
QUALIFIED SSA :
A qualified statement is
enclosed in parenthesis. The
part names the field that DL/I
will use for segment search. The
second part names the Relational
Operator of two bytes telling
DL/I what kind of comparison to
make during the search.
DL/I Programming
Considerations
QUALIFIED SSA :
The third part is a variable
length field that contains the
values for comparison during DL/I
search. Can code more than one
qualification statement.
Note:
In the ninth position of SSA,
A BLANK indicates unqualified SSA.
A LEFT PARENTHESIS indicates qualified SSA.
DL/I Programming
Considerations
QUALIFIED SSA:
DL/I provides the specific
structure for qualified SSA. It
is said to be a Segment name
with number of parameters.
Qualified SSA Structure
Relational
Segment Name ( Field Name Values )
Operator
8 Bytes 1 Byte 8 Bytes 2 Bytes 1 - 255 1 Byte
(EQ/NE/GT/ Bytes
LT/GE/LE)
DL/I Programming
Considerations
QUALIFIED SSA Declaration:
01 Qua-ssa.
05 seg-name pic x(8).
05 ob pic x.
05 fld-name pic x(8).
05 rel-oper pic x(2).
05 values pic x(n).
05 cb pic x.
DL/I Programming
Considerations
QUALIFIED SSA Example:

01 Qua-ssa-pat.
05 seg-name pic x(8) value ‘patient’.
05 ob pic x value ‘(‘.
05 fld-name pic x(8) value ‘patno’.
05 rel-oper pic x(2) value ‘EQ’.
05 values pic x(5) value ‘p1001’.
05 cb pic x value ‘)’.
DL/I Programming
Considerations
INPUT-OUTPUT AREA :
This is the third parameter
in the list. This area is used by
DL/I to put a retrieved segment
or by the application program to
store the data of a segment prior
to addition or updation. If a
single segment occurrence is
received, inserted or updated
this area should be the segment
layout area.
DL/I Programming
Considerations
INPUT-OUTPUT AREA :
The I-O area must be large
enough to contain the data of the
largest segment type. After
determining which segment is
retrieved move the segment
contents to an area describing it.
Another option is to use the
REDEFINES clause to describe each
segment type in the Hierarchy
path.
DL/I Programming
Considerations
INPUT-OUTPUT AREA FOR
PATIENT SEGMENT :

01 PAT-REC.
05 PATNO PIC X(5).
05 PATNAME PIC X(10).
05 PATADDR PIC X(30).
DL/I Programming
Considerations
Linkage Section :
• PCB masks for the PCB's passed to
the program by DL/I is coded here.
• The data names describes the data
areas in the PCB mask for the
PCB's that DL/I loaded.
• Must for every DL/I program since
PCB is a DL/I control block that
is loaded into memory by DL/I
before the program is executed.
DL/I Programming
Considerations
Linkage Section :
• When a DL/I call is issued, the
PCB mask must be specified to
indicate which PCB (database) in
the PSB is to be used to process
the call.
• DL/I updates the PCB mask with
the execution results after every
DL/I call.
DL/I Programming
Considerations
Linkage Section :
DL/I provides an in-built
internal PCB Mask structure,
01 PCB-MASK.
05 DBDNAME PIC X(8).
05 LEVEL-NUMBER PIC X(2).
05 STATUS-CODE PIC X(2).
05 PROC-OPTIONS PIC X(4).
05 INTERNALS PIC X(4).
05 SEGMENT-NAME PIC X(8).
05 KEY-LENGTH PIC S9(5) COMP.
05 NUMBER-OF-SEGS PIC S9(5) COMP.
05 KEY-FEEDBACK-AREA PIC X(n).
DL/I Programming
Considerations
Procedure Division :
The entry code accomplishes three
things in a program written in COBOL.
They are,
• It gives a standard DL/I name to the
entry point of any COBOL - DL/I
program which must be ‘DLITCBL’.
• It hooks the program to the PCB
through the USING clause of the ENTRY
statement.
DL/I Programming
Considerations
Procedure Division :
• The sequence of PCB masks specified in the
ENTRY statement must be identical to the
sequence of their corresponding PCB's in the
PSB. Although the order of PCB masks in the
Linkage Section does not matter.
• The execution of a program terminates with a
GOBACK statement because all DL/I programs
are sub routines of DL/I. Therefore, do not
use STOP-RUN.
• The ENTRY statement provides a mechanism for
DL/I to transfer control to the application
program.
DL/I Programming
Considerations
DL/I Calls:
• Calls to DL/I are made using a DL/I
interface language.
• IMS services are requested via DL/I
calls having a standard format.
• The Language Components are,
* The call statement parameter list.
* The formats of the data items
specified in the list.
• DL/I calls can be imbed in COBOL,
DL/I or Assembler.
DL/I Programming
Considerations
DL/I Calls:
• The entry point name in the CALL
statement is 'CBLTDLI' the name used
whenever a DL/I service is requested
in a COBOL program.
The general command format is,
CALL 'CBLTDLI‘ USING Function code
PCB mask
I-O Area
SSA's.
INSERT Call
To insert occurrences into
segments, we require,
• ISRT as Function code.
• I-O area declaration as same as
physical segment(DBD) structure.
• Internal PCB Mask declaration.
• Entry Statement.
• Input values.
• Call Statements.
INSERT (into patient
segment)
IDENTIFICATION DIVISION.
PROGRAM-ID. PATISRT.
DATA DIVISION.
WORKING-STORAGE SECTION.
01 PATIENT-REC.
05 PAT-NO PIC X(5).
05 PAT-NAME PIC X(10).
05 PAT-ADDR PIC X(30).
01 UNQUAL-SSA.
05 SEG-NAME PIC X(8) VALUE 'PATIENT'.
05 FILLER PIC X VALUE SPACE.
01 FUN-CODE PIC X(4) VALUE 'ISRT'.
LINKAGE SECTION.
01 PCB-MASK.
05 DBD-NAME PIC X(8).
05 DBD-LEVEL-NO PIC X(2).
05 DBD-STATUS-CODE PIC XX.
05 DBD-PROC-OPT PIC X(4).
05 DBD-INTERNAL PIC X(04).
05 DBD-SEG-NAME PIC X(08).
05 DBD-KEY-LENGTH PIC S9(5) COMP.
05 DBD-NO-SENSEG PIC S9(5) COMP.
05 DBD-KEY-FEEDBACK PIC X(30).
INSERT (into patient
segment)
PROCEDURE DIVISION.
000-MAIN-PROCESS.
ENTRY 'DLITCBL' USING PCB-MASK.
PERFORM 100-ACCEPT-PARA.
PERFORM 100-ISRT-PARA.
GOBACK.
100-ACCEPT-PARA.
ACCEPT PAT-NO.
ACCEPT PAT-NAME.
ACCEPT PAT-ADDR.
100-ISRT-PARA.
CALL 'CBLTDLI' USING FUN-CODE, PCB-MASK, PATIENT-REC
UNQUAL-SSA.
IF DBD-STATUS-CODE = SPACES THEN
DISPLAY 'SUCESSFUL'
DISPLAY 'LEVEL ' DBD-LEVEL-NO
DISPLAY 'SCODE ' DBD-STATUS-CODE
DISPLAY 'SEGMENT NAME ' DBD-SEG-NAME
DISPLAY 'KEY FIELD ' DBD-KEY-FEEDBACK
DISPLAY 'NO OF SENSITIVE SEGMENT ' DBD-NO-SENSEG
INSERT (into patient
segment)
ELSE
DISPLAY 'UN SUCESSFUL'
DISPLAY 'LEVEL ' DBD-LEVEL-NO
DISPLAY 'SCODE ' DBD-STATUS-CODE
DISPLAY 'SEGMENT NAME ' DBD-SEG-NAME
DISPLAY 'KEY FIELD ' DBD-KEY-FEEDBACK
DISPLAY 'NO OF SENSITIVE SEGMENT ' DBD-NO-SENSEG
END-IF.
INSERT (into illness
segment)
IDENTIFICATION DIVISION.
PROGRAM-ID. QUALSSA.
ENVIRONMENT DIVISION.
DATA DIVISION.
WORKING-STORAGE SECTION.
01 ILL-REC.
05 ILL-DATE PIC X(8).
05 ILL-NAME PIC X(10).
01 QUAL-PATSSA.
05 SEG-NAME PIC X(8) VALUE 'PATIENT '.
05 FILLER PIC X VALUE '('.
05 FNAME PIC X(8) VALUE 'PATNO'.
05 OPER PIC X(2) VALUE 'EQ'.
05 PATNO PIC X(5).
05 FILLER PIC X VALUE ')'.
01 UNQUAL-ILL-SSA PIC X(9) VALUE 'ILLNESS'.
01 FUN-CODE PIC X(4) VALUE 'ISRT'.
INSERT (into illness
segment)
LINKAGE SECTION.
01 PCB-MASK.
05 DBD-NAME PIC X(8).
05 DBD-LEVEL-NO PIC X(2).
05 DBD-STATUS-CODE PIC XX.
05 DBD-PROC-OPT PIC X(4).
05 DBD-INTERNAL PIC X(04).
05 DBD-SEG-NAME PIC X(08).
05 DBD-KEY-LENGTH PIC S9(4) COMP.
05 DBD-NO-SENSEG PIC S9(4) COMP.
05 DBD-KEY-FEEDBACK PIC X(30).
PROCEDURE DIVISION.
000-MAIN-PROCESS.
ENTRY 'DLITCBL' USING PCB-MASK.
PERFORM 100-ACCEPT-PARA.
PERFORM 100-ISRT-PARA.
GOBACK.
INSERT (into illness
segment)
100-ACCEPT-PARA.
ACCEPT PATNO.
ACCEPT ILL-DATE.
ACCEPT ILL-NAME.
100-ISRT-PARA.
CALL 'CBLTDLI' USING FUN-CODE, PCB-MASK, ILL-REC
QUAL-PATSSA,UNQUAL-ILL-SSA.
IF DBD-STATUS-CODE = SPACES THEN
DISPLAY 'SUCESSFUL'
DISPLAY 'LEVEL ' DBD-LEVEL-NO
DISPLAY 'SCODE ' DBD-STATUS-CODE
DISPLAY 'SEGMENT NAME ' DBD-SEG-NAME
DISPLAY 'KEY FIELD ' DBD-KEY-FEEDBACK
DISPLAY 'NO OF SENSITIVE SEGMENT ' DBD-NO-SENSEG
ELSE
DISPLAY 'UN SUCESSFUL'
DISPLAY 'LEVEL ' DBD-LEVEL-NO
DISPLAY 'SCODE ' DBD-STATUS-CODE
DISPLAY 'SEGMENT NAME ' DBD-SEG-NAME
DISPLAY 'KEY FIELD ' DBD-KEY-FEEDBACK
DISPLAY 'NO OF SENSITIVE SEGMENT ' DBD-NO-SENSEG
END-IF.
GET Call
SEQUENTIAL RETRIEVAL USING GN CALL:
• This retrieves a series of
segments in Sequential order.
• GN call is issued to retrieve the
next segment occurrence from the
current database position
established by a GU or GN call.
DL/I will start the search from
current position forward to try
to satisfy the call.
GET Call
SEQUENTIAL RETRIEVAL USING GN CALL:
• Unqualified GN calls will
traverse through the entire
database.
• One or more GN calls can be
issued to retrieve the rest of
the occurrences with the
duplicate key.
GET Call
SEQUENTIAL RETRIEVAL USING GN CALL:
• After each call examine the PCB
mask fields for the status code,
segment name and level number to
determine the segment occurrence
retrieved. Also it is difficult
to figure out when you will go up
in level, go down in level, or
stay at the same level in
database.
GET Call
SEQUENTIAL RETRIEVAL USING GN CALL:
• DL/I Sequential Processing
sequence within a database is
always Top to Bottom, Left to
Right and Front to Back along
Twin occurrences.
• An important issue to be
considered in sequential calls is
the concept of position within
the database.
Call Types

Call statements are divided


into two types,
• Unqualified call
• Qualified Call
A call statement without SSA
is said to be an Unqualified call
and a call statement with SSA is
said to be a Qualified call.
Call Types
GN calls without SSA's
(unqualified GN calls):
• DL/I looks at the current position within
the database and retrieves the next
segment in hierarchical sequence.
• Issuing a GN call with SSA as the first
call in the program is equivalent to
issuing a GN call without SSA. Since both
retrieves the first segment in database,
the first occurrence of root segment.
• Segments are retrieved all the way to the
end of the database.
Call Types
GN calls with SSA's
(qualified GN calls):

• GN calls with unqualified SSAs lets


the sequential retrieval restricted to
only a particular segment type, no
matter what segments they are
dependent upon.
Call Types
Unqualified call statement:
Call ‘CBLTDLI’ using Function-code
PCB-Mask
IO-Area.
Qualified call statement:
Call ‘CBLTDLI’ using Function-code
PCB-Mask
IO-Area
SSA.
GET Call (for reading the
patient occurrences)
IDENTIFICATION DIVISION.
PROGRAM-ID. GETPAT.
ENVIRONMENT DIVISION.
DATA DIVISION.
WORKING-STORAGE SECTION.
01 PATIENT-REC.
05 PAT-NO PIC X(5).
05 PAT-NAME PIC X(10).
05 PAT-ADDR PIC X(30).
01 UNQUAL-PAT-SSA.
05 SEG-NAME PIC X(8) VALUE 'PATIENT '.
05 FILLER PIC X VALUE SPACES.
01 FUN-CODE PIC X(4) VALUE 'GN'.
LINKAGE SECTION.
01 PCB-MASK.
05 DBD-NAME PIC X(8).
05 DBD-LEVEL-NO PIC X(2).
05 DBD-STATUS-CODE PIC XX.
05 DBD-PROC-OPT PIC X(4).
05 DBD-INTERNAL PIC X(04).
05 DBD-SEG-NAME PIC X(08).
05 DBD-KEY-LENGTH PIC S9(5) COMP.
05 DBD-NO-SENSEG PIC S9(5) COMP.
05 DBD-KEY-FEEDBACK PIC X(30).
GET Call (for reading the
patient occurrences)
PROCEDURE DIVISION.
000-MAIN-PROCESS.
ENTRY 'DLITCBL' USING PCB-MASK.
PERFORM 100-GET-PARA UNTIL DBD-STATUS-CODE ='GB'.
GOBACK.
100-GET-PARA.
CALL 'CBLTDLI' USING FUN-CODE, PCB-MASK, PATIENT-REC, UNQUAL-PAT-SSA.
IF DBD-STATUS-CODE = SPACES THEN
DISPLAY 'PATIENT NO ' PAT-NO
DISPLAY 'PATIENT NAME ' PAT-NAME
DISPLAY 'PATIENT ADDRESS ' PAT-ADDR
DISPLAY 'SUCESSFUL'
DISPLAY 'LEVEL ' DBD-LEVEL-NO
DISPLAY 'SCODE ' DBD-STATUS-CODE
DISPLAY 'SEGMENT NAME ' DBD-SEG-NAME
DISPLAY 'KEY FIELD ' DBD-KEY-FEEDBACK
DISPLAY 'NO OF SENSITIVE SEGMENT ' DBD-NO-SENSEG
ELSE
DISPLAY 'UN SUCESSFUL'
DISPLAY 'LEVEL ' DBD-LEVEL-NO
DISPLAY 'SCODE ' DBD-STATUS-CODE
DISPLAY 'SEGMENT NAME ' DBD-SEG-NAME
DISPLAY 'KEY FIELD ' DBD-KEY-FEEDBACK
DISPLAY 'NO OF SENSITIVE SEGMENT ' DBD-NO-SENSEG END-IF.
GET Call (for reading the
entire database)
IDENTIFICATION DIVISION.
PROGRAM-ID. GETALL.
ENVIRONMENT DIVISION.
DATA DIVISION.
WORKING-STORAGE SECTION.
01 COMMON-AREA.
05 CA1 PIC X(100).
01 FUN-CODE PIC X(4) VALUE 'GN'.
LINKAGE SECTION.
01 PCB-MASK.
05 DBD-NAME PIC X(8).
05 DBD-LEVEL-NO PIC X(2).
05 DBD-STATUS-CODE PIC XX.
05 DBD-PROC-OPT PIC X(4).
05 DBD-INTERNAL PIC X(04).
05 DBD-SEG-NAME PIC X(08).
05 DBD-KEY-LENGTH PIC S9(5) COMP.
05 DBD-NO-SENSEG PIC S9(5) COMP.
05 DBD-KEY-FEEDBACK PIC X(30).
GET Call (for reading the
entire database)
PROCEDURE DIVISION.
000-MAIN-PROCESS.
ENTRY 'DLITCBL' USING PCB-MASK.
PERFORM 100-GET-PARA UNTIL DBD-STATUS-CODE ='GB'.
GOBACK.
100-GET-PARA.
CALL 'CBLTDLI' USING FUN-CODE, PCB-MASK, COMMON-AREA.

IF DBD-STATUS-CODE = SPACES THEN


DISPLAY COMMON-AREA.
DISPLAY 'SUCESSFUL'
DISPLAY 'LEVEL ' DBD-LEVEL-NO
DISPLAY 'SCODE ' DBD-STATUS-CODE
DISPLAY 'SEGMENT NAME ' DBD-SEG-NAME
DISPLAY 'KEY FIELD ' DBD-KEY-FEEDBACK
DISPLAY 'NO OF SENSITIVE SEGMENT ' DBD-NO-SENSEG
ELSE
DISPLAY 'UN SUCESSFUL'
DISPLAY 'LEVEL ' DBD-LEVEL-NO
DISPLAY 'SCODE ' DBD-STATUS-CODE
DISPLAY 'SEGMENT NAME ' DBD-SEG-NAME
DISPLAY 'KEY FIELD ' DBD-KEY-FEEDBACK
DISPLAY 'NO OF SENSITIVE SEGMENT ' DBD-NO-SENSEG
END-IF.
GN Calls - STATUS CODES
When issued without SSA's
(unqualified GN call) three
values are returned,
• GA - Moved up in level to
retrieve the segment.
• GK - New segment type at the same
level is retrieved.
• GB - End of database is reached.
GN Calls - STATUS CODES
When issued with Unqualified SSA's
(Qualified GN call) one value is
returned,
• GB - End of database is reached.
When issued with qualified SSA's
(Qualified GN call) two values are
returned.
• BLANK - Segment successfully
retrieved.
• GE - Segments not found following the
current position.
GET Call
RANDOM RETRIEVAL USING GU CALL:
• This retrieves a unique segment
occurrence randomly.
• This is a fully qualified call
wherein the program supplies a
fully qualified SSA for each
level in the hierarchy down to
the segment being retrieved.
GET Call
RANDOM RETRIEVAL USING GU CALL:
• This retrieves a unique segment
occurrence randomly.
• This is a fully qualified call
wherein the program supplies a
fully qualified SSA for each
level in the hierarchy down to
the segment being retrieved.
GET Call (Random
retrieval)
IDENTIFICATION DIVISION.
PROGRAM-ID. PATGET.
ENVIRONMENT DIVISION.
DATA DIVISION.
WORKING-STORAGE SECTION.
01 PATIENT-REC.
05 PAT-NO PIC X(5).
05 PAT-NAME PIC X(10).
05 PAT-ADDR PIC X(30).
01 QUAL-PAT-SSA.
05 SEG-NAME PIC X(8) VALUE 'PATIENT '.
05 FILLER PIC X VALUE '('.
05 FNAME PIC X(8) VALUE 'PATNO'.
05 OPER PIC X(2) VALUE 'EQ'.
05 PATNO PIC X(5).
05 FILLER PIC X VALUE ')'.
01 FUN-CODE PIC X(4) VALUE 'GU'.
GET Call (Random
retrieval)
LINKAGE SECTION.
01 PCB-MASK.
05 DBD-NAME PIC X(8).
05 DBD-LEVEL-NO PIC X(2).
05 DBD-STATUS-CODE PIC XX.
05 DBD-PROC-OPT PIC X(4).
05 DBD-INTERNAL PIC X(04).
05 DBD-SEG-NAME PIC X(08).
05 DBD-KEY-LENGTH PIC S9(4) COMP.
05 DBD-NO-SENSEG PIC S9(4) COMP.
05 DBD-KEY-FEEDBACK PIC X(30).
PROCEDURE DIVISION.
000-MAIN-PROCESS.
ENTRY 'DLITCBL' USING PCB-MASK.
PERFORM 100-ACCEPT-PARA.
PERFORM 100-GET-PARA.
GOBACK.
100-ACCEPT-PARA.
ACCEPT PATNO.
GET Call (Random
retrieval)
100-GET-PARA.
CALL 'CBLTDLI' USING FUN-CODE, PCB-MASK, PATIENT-REC
QUAL-PAT-SSA.
IF DBD-STATUS-CODE = SPACES THEN
DISPLAY 'PATIENT NO ' PAT-NO
DISPLAY 'PATIENT NAME ' PAT-NAME
DISPLAY 'PATIENT ADDRESS ' PAT-ADDR
DISPLAY 'SUCESSFUL'
DISPLAY 'LEVEL ' DBD-LEVEL-NO
DISPLAY 'SCODE ' DBD-STATUS-CODE
DISPLAY 'SEGMENT NAME ' DBD-SEG-NAME
DISPLAY 'KEY FIELD ' DBD-KEY-FEEDBACK
DISPLAY 'NO OF SENSITIVE SEGMENT ' DBD-NO-SENSEG
ELSE
DISPLAY 'UN SUCESSFUL'
DISPLAY 'LEVEL ' DBD-LEVEL-NO
DISPLAY 'SCODE ' DBD-STATUS-CODE
DISPLAY 'SEGMENT NAME ' DBD-SEG-NAME
DISPLAY 'KEY FIELD ' DBD-KEY-FEEDBACK
DISPLAY 'NO OF SENSITIVE SEGMENT ' DBD-NO-SENSEG
END-IF.
GET Call
SEQUENTIAL RETRIEVAL USING GNP CALL:
• Performs sequential retrieval very
similar to the GN function, except that
it retrieves only segments that are
subordinate to the currently established
parent.
• Parentage must be established by issuing
either a GU or GN call, in which case
DL/I not only establishes a position on
same segment occurrence, but it also,
establishes parentage on that occurrence.
GET Call
SEQUENTIAL RETRIEVAL USING GNP CALL:
• The segment retrieved by the GN or GU
call is treated as the parent segment
for any subsequent GNP calls issued in
the program.
• The GNP calls return only those
dependent segment occurrences.
REPL & DLET Call
• Updating and Deleting segments
always requires the program to
perform a sequence of two calls.
• The first call being a GET HOLD
function to retrieve the segment
that the program intends to Update
or Delete.
• The second call being a REPL or
DLET function to perform the
replacement or deletion of the
segment eventually.
REPL & DLET Call
• Any intervening calls between the first
and the second call will nullify the
effect of the GET HOLD call. The
practical implication of this is that
the program can proceed with the other
processing if it is decided not to go
ahead with the replacement or the
deletion of the segment. Hence any
explicit action to cancel the effect of
a get hold call is not required in the
program.
REPL & DLET Call
GET HOLD CALLS:
• Are GHU, GHN, GHNP
Perform similar functions of GU, GN
and GNP apart from certain additional
functions such as,
• DL/I saves information about the
segments location.
• DL/I writes information in system log
data sets, which are used to restore a
database should recovery is ever
necessary.
REPL & DLET Call
GET HOLD CALLS:
• Same kind of SSA's used with normal
calls can be used with Get Hold calls
to bring a particular segment into the
I-O area.
• Status codes returned by DL/I are also
identical, given the similar
circumstances.
REPL & DLET Rules
Rule No.1 - Must issue a Get-Hold call
prior to issuing a REPL or DLET
function call.

Rule No.2 - Should not issue any other


call using the same PCB, between the
time a Get Hold call is issued and the
time a Replace or Delete call is
issued, unless that other call is also
a Get Hold call.
REPL & DLET Rules
• Rule No.3 - Should not normally code
SSA's in the Replace or Delete calls
except when the Get Hold call is with
one or more SSA's using the D command
code.

• Rule No.4 - The KEY field in the


segment cannot be modified before the
REPL or DLET calls.
REPL Steps
• Must issue a Get Hold call to
retrieve the segment data into I-O
area.
• Changes can be made to the data in
I-O area except the KEY field.
• Issuing a REPL call will cause
changes to the segment to be
rewritten to the database.
REPL Call (replacing
patient details)
IDENTIFICATION DIVISION.
PROGRAM-ID. PATREPL.
ENVIRONMENT DIVISION.
DATA DIVISION.
WORKING-STORAGE SECTION.
01 PATIENT-REC.
05 PAT-NO PIC X(5).
05 PAT-NAME PIC X(10).
05 PAT-ADDR PIC X(30).
01 QUAL-PAT-SSA.
05 SEG-NAME PIC X(8) VALUE 'PATIENT '.
05 FILLER PIC X VALUE '('.
05 FNAME PIC X(8) VALUE 'PATNO'.
05 OPER PIC X(2) VALUE 'EQ'.
05 PATNO PIC X(5).
05 FILLER PIC X VALUE ')'.
01 UNQUAL-PAT-SSA.
05 SEG-NAME PIC X(8) VALUE 'PATIENT '.
05 FILLER PIC X VALUE SPACES.
01 FUN-CODE PIC X(4).
REPL Call (replacing
patient details)
LINKAGE SECTION.
01 PCB-MASK.
05 DBD-NAME PIC X(8).
05 DBD-LEVEL-NO PIC X(2).
05 DBD-STATUS-CODE PIC XX.
05 DBD-PROC-OPT PIC X(4).
05 DBD-INTERNAL PIC X(04).
05 DBD-SEG-NAME PIC X(08).
05 DBD-KEY-LENGTH PIC S9(4) COMP.
05 DBD-NO-SENSEG PIC S9(4) COMP.
05 DBD-KEY-FEEDBACK PIC X(30).
PROCEDURE DIVISION.
000-MAIN-PROCESS.
ENTRY 'DLITCBL' USING PCB-MASK.
PERFORM 100-ACCEPT-PARA.
PERFORM 100-GET-PARA.
PERFORM 100-REPL-PARA.
GOBACK.
REPL Call (replacing
patient details)
100-ACCEPT-PARA.
MOVE 'P1001' TO PATNO.
MOVE 'GHU' TO FUN-CODE.
100-GET-PARA.
CALL 'CBLTDLI' USING FUN-CODE, PCB-MASK, PATIENT-REC QUAL-PAT-SSA.
IF DBD-STATUS-CODE = SPACES THEN
DISPLAY '*****************READ*******************'
DISPLAY 'PATIENT NO ' PAT-NO
DISPLAY 'PATIENT NAME ' PAT-NAME
DISPLAY 'PATIENT ADDRESS ' PAT-ADDR
DISPLAY 'SUCESSFUL'
DISPLAY 'LEVEL ' DBD-LEVEL-NO
DISPLAY 'SCODE ' DBD-STATUS-CODE
DISPLAY 'SEGMENT NAME ' DBD-SEG-NAME
DISPLAY 'KEY FIELD ' DBD-KEY-FEEDBACK
DISPLAY 'NO OF SENSITIVE SEGMENT ' DBD-NO-SENSEG
ELSE
DISPLAY 'UN SUCESSFUL'
DISPLAY 'LEVEL ' DBD-LEVEL-NO
DISPLAY 'SCODE ' DBD-STATUS-CODE
DISPLAY 'SEGMENT NAME ' DBD-SEG-NAME
DISPLAY 'KEY FIELD ' DBD-KEY-FEEDBACK
DISPLAY 'NO OF SENSITIVE SEGMENT ' DBD-NO-SENSEG END-IF.
REPL Call (replacing
patient details)
100-REPL-PARA.
MOVE 'REPL' TO FUN-CODE.
MOVE 'RAJA' TO PAT-NAME.
MOVE 'BLR ' TO PAT-ADDR.
CALL 'CBLTDLI' USING FUN-CODE, PCB-MASK, PATIENT-REC.
IF DBD-STATUS-CODE = SPACES THEN
DISPLAY '************REPLACE*********************'
DISPLAY 'PATIENT NO ' PAT-NO
DISPLAY 'PATIENT NAME ' PAT-NAME
DISPLAY 'PATIENT ADDRESS ' PAT-ADDR
DISPLAY 'SUCESSFUL'
DISPLAY 'LEVEL ' DBD-LEVEL-NO
DISPLAY 'SCODE ' DBD-STATUS-CODE
DISPLAY 'SEGMENT NAME ' DBD-SEG-NAME
DISPLAY 'KEY FIELD ' DBD-KEY-FEEDBACK
DISPLAY 'NO OF SENSITIVE SEGMENT ' DBD-NO-SENSEG
ELSE
DISPLAY 'UN SUCESSFUL'
DISPLAY 'LEVEL ' DBD-LEVEL-NO
DISPLAY 'SCODE ' DBD-STATUS-CODE
DISPLAY 'SEGMENT NAME ' DBD-SEG-NAME
DISPLAY 'KEY FIELD ' DBD-KEY-FEEDBACK
DISPLAY 'NO OF SENSITIVE SEGMENT ' DBD-NO-SENSEG END-IF.
REPL Call - STATUS CODES
• DJ - Replace call issued
without an immediately preceding
GETHOLD call.
• DA - Program has changed the
segment's key field
• RX - Encountered a Replace Rule
Violation
• AJ - Used an SSA without command
code in the REPL call
DLET Steps
• Must issue a Get Hold call to
retrieve the segment data into the
I-O area.
• Issuing a DLET call will cause the
segment to be deleted, and
automatically deletes all its
subordinate occurrences from the
database.
DLET (deleting a patient
occurrence)
IDENTIFICATION DIVISION.
PROGRAM-ID. PATREPL.
ENVIRONMENT DIVISION.
DATA DIVISION.
WORKING-STORAGE SECTION.
01 PATIENT-REC.
05 PAT-NO PIC X(5).
05 PAT-NAME PIC X(10).
05 PAT-ADDR PIC X(30).
01 QUAL-PAT-SSA.
05 SEG-NAME PIC X(8) VALUE 'PATIENT '.
05 FILLER PIC X VALUE '('.
05 FNAME PIC X(8) VALUE 'PATNO'.
05 OPER PIC X(2) VALUE 'EQ'.
05 PATNO PIC X(5).
05 FILLER PIC X VALUE ')'.
01 UNQUAL-PAT-SSA.
05 SEG-NAME PIC X(8) VALUE 'PATIENT '.
05 FILLER PIC X VALUE SPACES.
01 FUN-CODE PIC X(4).
DLET (deleting a patient
occurrence)
LINKAGE SECTION.
01 PCB-MASK.
05 DBD-NAME PIC X(8).
05 DBD-LEVEL-NO PIC X(2).
05 DBD-STATUS-CODE PIC XX.
05 DBD-PROC-OPT PIC X(4).
05 DBD-INTERNAL PIC X(04).
05 DBD-SEG-NAME PIC X(08).
05 DBD-KEY-LENGTH PIC S9(4) COMP.
05 DBD-NO-SENSEG PIC S9(4) COMP.
05 DBD-KEY-FEEDBACK PIC X(30).
PROCEDURE DIVISION.
000-MAIN-PROCESS.
ENTRY 'DLITCBL' USING PCB-MASK.
PERFORM 100-ACCEPT-PARA.
PERFORM 100-GET-PARA.
PERFORM 100-DLET-PARA.
GOBACK.
DLET (deleting a patient
occurrence)
100-ACCEPT-PARA.
MOVE 'P1001' TO PATNO.
MOVE 'GHU' TO FUN-CODE.
100-GET-PARA.
CALL 'CBLTDLI' USING FUN-CODE, PCB-MASK, PATIENT-REC QUAL-PAT-SSA.
IF DBD-STATUS-CODE = SPACES THEN
DISPLAY '*****************READ*******************'
DISPLAY 'PATIENT NO ' PAT-NO
DISPLAY 'PATIENT NAME ' PAT-NAME
DISPLAY 'PATIENT ADDRESS ' PAT-ADDR
DISPLAY 'SUCESSFUL'
DISPLAY 'LEVEL ' DBD-LEVEL-NO
DISPLAY 'SCODE ' DBD-STATUS-CODE
DISPLAY 'SEGMENT NAME ' DBD-SEG-NAME
DISPLAY 'KEY FIELD ' DBD-KEY-FEEDBACK
DISPLAY 'NO OF SENSITIVE SEGMENT ' DBD-NO-SENSEG
ELSE
DISPLAY 'UN SUCESSFUL'
DISPLAY 'LEVEL ' DBD-LEVEL-NO
DISPLAY 'SCODE ' DBD-STATUS-CODE
DISPLAY 'SEGMENT NAME ' DBD-SEG-NAME
DISPLAY 'KEY FIELD ' DBD-KEY-FEEDBACK
DISPLAY 'NO OF SENSITIVE SEGMENT ' DBD-NO-SENSEG END-IF.
DLET (deleting a patient
occurrence)
100-DLET-PARA.
MOVE ‘DLET' TO FUN-CODE.
CALL 'CBLTDLI' USING FUN-CODE, PCB-MASK, PATIENT-REC.
IF DBD-STATUS-CODE = SPACES THEN
DISPLAY '************DELETE*********************'
DISPLAY 'PATIENT NO ' PAT-NO
DISPLAY 'PATIENT NAME ' PAT-NAME
DISPLAY 'PATIENT ADDRESS ' PAT-ADDR
DISPLAY 'SUCESSFUL'
DISPLAY 'LEVEL ' DBD-LEVEL-NO
DISPLAY 'SCODE ' DBD-STATUS-CODE
DISPLAY 'SEGMENT NAME ' DBD-SEG-NAME
DISPLAY 'KEY FIELD ' DBD-KEY-FEEDBACK
DISPLAY 'NO OF SENSITIVE SEGMENT ' DBD-NO-SENSEG
ELSE
DISPLAY 'UN SUCESSFUL'
DISPLAY 'LEVEL ' DBD-LEVEL-NO
DISPLAY 'SCODE ' DBD-STATUS-CODE
DISPLAY 'SEGMENT NAME ' DBD-SEG-NAME
DISPLAY 'KEY FIELD ' DBD-KEY-FEEDBACK
DISPLAY 'NO OF SENSITIVE SEGMENT ' DBD-NO-SENSEG
END-IF.
DLET Call - STATUS CODES
• DJ - Delete call issued without
an immediately preceding Get Hold
call
• DA - Program has changed the
segment's KEY FIELD
• DX - Encountered a Delete Rule
Violation
• AJ - Used an SSA which is
Qualified
Multiple Qualifications
• Sometimes an SSA needs more than
one qualification statement when
there are more than one condition
to be tested to qualify at that
segment.
• The conditions are tested on more
than one field in a segment
Boolean Operators are needed to
connect these qualification
statements.
Multiple Qualifications
The valid Boolean Operators are,

Logical AND:
* (Asterisk) or the & (Ampersand)

Logical OR:
+ (Plus) or the | (Vertical Bar)
Multiple Qualifications
Structure
1 - 255
8 Bytes 1 Byte 8 Bytes 2 Bytes Bytes
Relational
Segment Name1 ( Field Name1 Values
Operator1

1 Byte
Logical Relational
Field Name2 Values
Operator Operator2

………………………………
………………………………
…………………………… )
Multiple Qualifications
QUALIFIED SSA Declaration with
multiple qualifications:
01 Qua-ssa-mul.
05 segname pic x(8) value ‘patient’.
05 ob pic x value ‘(‘.
05 fld-name1 pic x(8) value ‘patno’.
05 rel-oper1 pic x(2) value ‘eq’.
05 value1 pic x(5) value ‘p1001’.
05 lo1 pic x value ‘&’
05 fld-name2 pic x(8) value ‘patname’.
05 rel-oper2 pic x(2) value ‘eq’.
05 value2 pic x(5) value ‘john’.
05 cb pic x value ‘)‘.
Command Codes
• The command code is not an
independent concept. It always
depends on SSA’s.
• Command codes can simplify the
IMS Application programs.
• Command codes in a SSA makes the
call powerful since DL/I treats
such SSA'S differently from those
without the command codes while
performing some special functions.
Command Codes
• Command codes are specified in an
SSA following the segment name and
an Asterisk '*‘.
• An Asterisk '*' in the ninth
position in a SSA indicates that one
or more command codes follow the
asterisk.
• A Blank or Left Parenthesis marks
the end of command codes.
• ONE or MORE command codes can be
used in any combination.
Command Codes

F - Locate First Occurrence


L - Locate Last Occurrence
D - Retrieve this segment data into the
I-O Area (Path Call)
N - Do not replace this segment
C - Concatenated key in this SSA
Q - Enqueue this segment
P - Establish Parentage at this level
- - Null command code
Command Codes Structure
Command codes can be embedded in
both Unqualified and Qualified
SSA’s.
Command codes in UNQ-SSA:

8 Bytes 1 Byte 1-10 Bytes 1 Byte


Command
Segment Name * Blank
Codes

Command code
identifier
Command Codes Structure

Command codes in QUA-SSA:

8 Bytes 1 Byte 1-10 Bytes


Relational
Segment * Command ( Field Name Values )
Operator
Name Codes
1 Byte 8 Bytes 2 Bytes 1 - 255 1
Bytes By
Command code te
identifier
F Command Code
• Tells DL/I to begin the search
with the first occurrence of this
segment type in a twin chain under
its parent.
• It can be used only with GN, GNP,
GHN and GHNP calls.
L Command Code
• Tells DL/I to retrieve the last
occurrence of this segment type in a
twin chain under its parent.
• In an insert call this command code
insert the segment occurrence as the
last occurrence in the segment type
which has non-unique or no key field.
• L command code can be used only in
the dependent segment types. It is
ignored, if used in the root segment.
L Command Code
Suppose you want to retrieve the last
twin occurrence of the Treatment
Segment type for a particular patient
segment.
WITHOUT COMMAND CODE
1. GU PATIENT(PATNO=P1001)
ILLNESS(ILLDATE=08/02/2010)
TREATMNT(TRDATE=09/02/2010)
2. GNP TREATMNT
3. Loop back to step 2 until status code is GE.
When GE, the I-O area will contain the last
twin occurrence of treatment.
L Command Code

WITH COMMAND CODE


1. GU PATIENT(PATNO=P1001)
ILLNESS(ILLDATE=08/02/2010)
TREATMENT * L
D & N Command Code
• D & N command codes work together to
process multiple segments in a single call.
• D command code performs a PATH call,
wherein, DL/I retrieves multiple segments
along the retrieval path in the I-O area.
Thus the I-O area must be defined large
enough to accommodate all the segments
being retrieved in the path. DL/I will
place the segment at the higher level in
front of the segment at the lower levels.
The segment layouts within the I-O area
must be defined in the hierarchical
structure.
D & N Command Code
• If D command code is not coded, only the
segment identified by the last SSA is
placed in the I-O area by default.
Necessary to retrieve all the segments in
the hierarchical path. Therefore, you can
code D command code in the higher level
SSA's only for those segments you want DL/I
to place in the I-O area.
• A processing option of P must be coded in
the PROCOPT operand of the PCB in your PSB
for the segment, if D command code is to be
used in an SSA for that segment.PROCOPT = P
D & N Command Code
• DL/I remember how many segments are
stored in the I-O area by the Get Hold
path call. So a subsequent replace call
without SSA's will replace all the
segments in the I-O area along the path.
• N command code is coded in the SSA'S
for those segments used in the Replace
call that you don't want to Replace.
• SSA'S with the N command code is an
exception to the rule that qualified
SSA'S cannot be coded in a Replace call.
D & N Command Code
Without D Command code:
1. GU
PATIENT (PATNO=p1001)
2. GU
PATIENT (PATNO=p1001)
ILLNESS (ILLDATE=01/03/2010)
3. GU
PATIENT (PATNO=p1001)
ILLNESS (ILLDATE=01/03/2010)
TREATMNT (TRDATE=03/03/2010)
D & N Command Code
With D Command code:
1. GU
PATIENT *D(PATNO=p1001)
ILLNESS *D(ILLDATE=01/03/2010)
TREATMNT (TRDATE=03/03/2010)
2. GU
PATIENT *D(PATNO=p1001)
ILLNESS *DN(ILLDATE=01/03/2010)
TREATMNT (TRDATE=03/03/2010)
C Command Code
• C command code is used in
situations where you would
normally use fully qualified
calls.
• It allows you to use a
concatenated key value in a single
SSA rather than using a set of
fully qualified SSA'S.
C Command Code
• The concatenated key must be
enclosed in Parenthesis and no key
in the path can be omitted from
the concatenated key.
• Only a single SSA naming the
segment to be retrieved can be
used in the call with C command
code.
C Command Code structure

Target C
Segment * Command ( Key Key Key . . . . . Key )
Name code 1 2 3 15
C Command Code
Without C Command code:

GU
PATIENT (PATNO=p1001)
ILLNESS (ILLDATE=01/03/2010)
TREATMNT (TRDATE=03/03/2010)
C Command Code
With C Command code:

TREATMNT * C (
p1001
01/03/2010
02/03/2010 )
Q Command Code
• Q command code is only used when
multiple applications will be
accessing the same database at the
same time. Normally used in the
O/L MPP where the O/L programs are
running under multitasking
environment and more than one task
can update the same database at
the same time.
Q Command Code
• If you do not want this to happen,
issue DL/I calls with Q command
code to ENQUEUE the particular
segment occurrence for exclusive
use by your task, preventing other
online transactions from updating
the segment until your task is
completed.
Q Command Code
• Other users cannot make a Get Hold
type call for that segment, only
get calls can access that segment.
Get Hold type calls must wait
until the Enqueued segment has
been Dequeued through the DEQ
call, CHKP call, or the program
termination.
Q Command Code
• Q command code set at the root
segment level will not allow any
other user to gain access to any
segment in that database record.
• A one-byte class identifier in the
range of 'A 'through' J follows Q
command code. This class
identifier must be specified in
the DEQ call to dequeue the
segments
P Command Code
• P command code allows the parentage
to be set at any levels in the
database other than the one
identified by the last SSA.
• Code the P command code in the SSA
for the segment at which you would
like the parentage established and
DL/I will still retrieve the segment
identified by the last SSA, but sets
parentage where you set the P command
code.
P Command Code
• The parentage will be destroyed
when another GU or GN call is
executed.
With P Command Code:
GU PATIENT(PATNO=p1001)
ILLNESS * P (ILLDATE=01/03/2010)
TREATMNT(TRDATE=03/03/2010)
By using a P command code, you saved one
call by retrieving the first Treatmnt segment
in the Get Unique call itself and setting the
parentage at the illness level.
NULL Command Code
• The NULL command code '__’ is used
in the SSA to simplify the
construction of SSA within the
program and does not perform any
function at all.
• The SSA is treated as if no
command code were coded.
NULL Command Code
• The null command code '__'
reserves one or more positions in
a SSA into which you can store
command codes during the program
execution. This way making it
possible to use the same set of
SSA'S for more than one purpose.
• PATIENT *------- (PATNO = P1001)
Multiple Positioning
within the PCB
• With Multiple Positioning DL/I
maintains a unique position within
a Database Record for each
dependent segment type at each
level in each Hierarchical path in
the database.
• Multiple Positioning is normally
used to access segments of two or
more types dependent on a specific
parent.
Multiple Positioning
within the PCB
• The segments are processed
sequentially at the same time,
enabling parallel processing
within the database.
• Multiple Positioning lets a
program maintain more than one
position within a database using a
single PCB.
Multiple Positioning
within the PCB
• Multiple Positioning for a
database is specified in the PCB
statement in the PSB for POS
operand. For example
PCB TYPE=DB, NAME=HOSPITAL,
POS=M or S
M stands for Multiple, S stands
for Single Positioning.
If POS operand is not coded,
the default is single positioning.
Multiple PCB’s in a PSB
• When a program needs access to more
than one database, it has a PCB for
each.
• A single PCB can refer to only one DBD
• Multiple PCB's can also be defined for
a single database in which case the
program has two or more views of the
same database and DL/I will maintain a
unique position in that database for
each PCB you define on it.
Multiple PCB’s in a PSB
• Multiple PCB's on the same database is
defined when the program require access
to two completely different logical
data structures, each describing
different segments in different
hierarchical paths from the same
database.
• Each PCB in PSB has its own PCB mask in
the Linkage Section and is specified in
the ENTRY statement for addressing that
block in the order in which PCB's
appear in the PSB.
Multiple PCB’s in a PSB
PSB

PCB1 PATIENT  ILLNESS  TREATMENT

PCB2 PATIENT  BILLING  PAYMENT

PCB3 PATIENT  HOUSEHOLD

PCB4 PATIENT  WARD

PCB5 PATIENT  HISTORY


Multiple PCB’s in a PSB
LINKAGE SECTION. PSB
01 PCB-MASK1.
05 . . . . . PCB1
05 . . . .
01 PCB-MASK2.
05 . . . . . PCB2
05 . . . .
01 PCB-MASK3.
05 . . . . . PCB3
05 . . . .
01 PCB-MASK4.
05 . . . . . PCB4
05 . . . .

01 PCB-MASK5.
PCB5
05 . . . . .
05 . . . .
Multiple PCB’s in a PSB
LINKAGE SECTION. PSB
CALL ‘CBLTDLI’ USING ISRT
PCB-MASK1, PAT-IO-AREA, PCB1
UNQ-SSA-PAT.
CALL ‘CBLTDLI’ USING GN, PCB-MASK2,
PAY-IO-AREA, QUA-SSA-PAT, PCB2
QUA-SSA-BILL, UNQ-SSA-PAY.
CALL ‘CBLTDLI’ USING GU
PCB-MASK3, HLD-IO-AREA, PCB3
QUA-SSA-PAT, QUA-SSA-HLD.
CALL ‘CBLTDLI’ USING GU
PCB-MASK4, WARD-IO-AREA, PCB4
QUA-SSA-PAT, QUA-SSA-WARD.

CALL ‘CBLTDLI’ USING GN


PCB5
PCB-MASK5, HIS-IO-AREA,
QUA-SSA-PAT, UNQ-SSA-WARD.
HIDAM Access Method
(Primary Indexing)
• HIDAM database is made up of two
databases: a main database and
index database.
• One is used to store the data, and
the other is used as an index to
root segments in the primary data
base. The index data base will
always be a VSAM KSDS file. The
primary data base can be a VSAM
ESDS file or an OSAM file.
HIDAM Access Method
(Primary Indexing)
• Space is immediately reusable after
DELETE operations, and segment
relationships are maintained by
pointers, not physical adjacency.
• Root segments in a HIDAM data base
must have a unique key field
defined so that it can be used to
construct the index, thereby
providing efficient direct access
to data base records.
HIDAM Access Method
(Primary Indexing)
HIDAM data bases are typically
used when the following conditions
exist:
• A combination of random and
sequential processing is required.
• There is a large number of segments
within a data base record.
• There is a large amount of insert
and delete activity.
HIDAM Organization
Index Data Base (After Insert)
KSDS

A1 A2 A3

Primary Data Base

ESDS OSAM

A1 B1 C1 D1 B2 Free Space

C2 C3 C4 B3 D2 Free Space

C5 A3 B4 D3 D4 A2 Free Sp

D6 Free Space
HIDAM Primary
Database(ESDS)
PRINT NOGEN
DBD NAME=Hospital,ACCESS=(HIDAM,VSAM),
DATASET DD1=Hosdd,DEVICE=3390,SIZE=4096

******************PATIENT SEGMENT**********************
SEGM NAME=Patient,BYTES=45,PARENT=0
LCHILD NAME=(IDXSEG,IDXDBD),PTR=INDEX
FIELD NAME=(Patno,seq,u),BYTES=5,START=1,TYPE=C
FIELD NAME=Pname,BYTES=10,START=6,TYPE=C
FIELD NAME=Paddr,BYTES=30,START=16,TYPE=C
HIDAM Primary
Database(ESDS)
******************ILLNESS SEGMENT**********************
SEGM NAME=Illness,BYTES=18,PARENT=Patient
FIELD NAME=(Illdate,seq,m),BYTES=10,START=1,TYPE=C
FIELD NAME=Illname,BYTES=10,START=11,TYPE=C

******************TRTMENT SEGMENT**********************
SEGM NAME=Treatmnt,BYTES=32,PARENT=Illness
FIELD NAME=(Trdate,seq,m),BYTES=10,START=1,TYPE=C
FIELD NAME=Medicine,BYTES=10,START=11,TYPE=C
FIELD NAME=Qnty,BYTES=4,START=21,TYPE=C
FIELD NAME=Doctor,BYTES=10,START=25,TYPE=C
HIDAM Primary
Database(ESDS)
******************BILLING SEGMENT**********************
SEGM NAME=Billing,BYTES=15,PARENT=Patient
FIELD NAME=(Billno,seq),BYTES=5,START=1,TYPE=C
FIELD NAME=Billdate,BYTES=10,START=6,TYPE=C

******************PAYMENT SEGMENT**********************
SEGM NAME=Payment,BYTES=20,PARENT=Billing
FIELD NAME=(Paydate,seq,m),BYTES=10,START=1,TYPE=C
FIELD NAME=Amount,BYTES=10,START=11,TYPE=C
HIDAM Primary
Database(ESDS)
******************HOUSEHLD SEGMENT**********************
SEGM NAME=Househld,BYTES=8,PARENT=Patient
FIELD NAME=(Wardno,seq,m),BYTES=3,START=1,TYPE=C
FIELD NAME=Wardtype,BYTES=5,START=4,TYPE=C

******************END OF STRUCTURE**********************

DBDGEN
FINISH
END
HIDAM Primary Index(KSDS)
PRINT NOGEN
DBD NAME=IDXDBD,ACCESS=INDEX
DATASET DD1=idxdd1

******************INDEX SEGMENT**********************
SEGM NAME=IDXSEG,BYTES=5,PARENT=0
LCHILD NAME=(PATIENT,HOSPITAL),INDEX=PATNO
FIELD NAME=(Fld1,seq,u),BYTES=5,START=1,TYPE=C

DBDGEN
FINISH
END
HIDAM Access Method
(Secondary Indexing)
• Secondary indexes provide
alternate entry points when
processing HISAM, HIDAM, or HDAM
data bases.
• Segments can be accessed in a
sequence other than that specified
by the root key.
HIDAM Access Method
(Secondary Indexing)
For example, If you want to access
the Treatment(Intermediate or
Target) segment directly, you can
access it directly without
accessing the immediate and non-
immediate parents through
secondary indexing concept. The
number of call statements to the
database is reduced. Overall
processing is simplified and
efficient.
HIDAM Access Method
(Secondary Indexing)
REGULAR DATABASE SECONDARY INDEX DATABASE

SECONDARY INDEX

(KSDS)
TREATMENT KEY VALUES
HIDAM Primary
Database(ESDS)
PRINT NOGEN
DBD NAME=Hospital,ACCESS=(HIDAM,VSAM),
DATASET DD1=Hosdd,DEVICE=3390,SIZE=4096

******************PATIENT SEGMENT**********************
SEGM NAME=Patient,BYTES=45,PARENT=0
LCHILD NAME=(IDXSEG,IDXDBD),PTR=INDEX
FIELD NAME=(Patno,seq,u),BYTES=5,START=1,TYPE=C
FIELD NAME=Pname,BYTES=10,START=6,TYPE=C
FIELD NAME=Paddr,BYTES=30,START=16,TYPE=C
HIDAM Primary
Database(ESDS)
******************ILLNESS SEGMENT**********************
SEGM NAME=Illness,BYTES=18,PARENT=Patient
FIELD NAME=(Illdate,seq,m),BYTES=10,START=1,TYPE=C
FIELD NAME=Illname,BYTES=10,START=11,TYPE=C

******************TRTMENT SEGMENT**********************
SEGM NAME=Treatmnt,BYTES=32,PARENT=Illness
LCHILD NAME=(SIDXSEG,SIDXDBD),PTR=INDEX
FIELD NAME=(Trdate,seq,m),BYTES=10,START=1,TYPE=C
XDFLD NAME=LOGNAME,SRCH=TRDATE
FIELD NAME=Medicine,BYTES=10,START=11,TYPE=C
FIELD NAME=Qnty,BYTES=4,START=21,TYPE=C
FIELD NAME=Doctor,BYTES=10,START=25,TYPE=C
HIDAM Primary
Database(ESDS)
******************BILLING SEGMENT**********************
SEGM NAME=Billing,BYTES=15,PARENT=Patient
FIELD NAME=(Billno,seq),BYTES=5,START=1,TYPE=C
FIELD NAME=Billdate,BYTES=10,START=6,TYPE=C

******************PAYMENT SEGMENT**********************
SEGM NAME=Payment,BYTES=20,PARENT=Billing
FIELD NAME=(Paydate,seq,m),BYTES=10,START=1,TYPE=C
FIELD NAME=Amount,BYTES=10,START=11,TYPE=C
HIDAM Primary
Database(ESDS)
******************HOUSEHLD SEGMENT**********************
SEGM NAME=Househld,BYTES=8,PARENT=Patient
FIELD NAME=(Wardno,seq,m),BYTES=3,START=1,TYPE=C
FIELD NAME=Wardtype,BYTES=5,START=4,TYPE=C

******************END OF STRUCTURE**********************

DBDGEN
FINISH
END
HIDAM Secondary
Index(KSDS)
PRINT NOGEN
DBD NAME=SIDXDBD,ACCESS=INDEX
DATASET DD1=idxdd2,OVFLW=idxdd3

******************INDEX SEGMENT**********************
SEGM NAME=SIDXSEG,BYTES=5,PARENT=0
LCHILD NAME=(TREATMNT,HOSPITAL),INDEX=LOGNAME
FIELD NAME=(Fld1,seq,m),BYTES=5,START=1,TYPE=C

DBDGEN
FINISH
END
HIDAM Primary & Secondary
Index Flow
OVFLW :
idxdd3
PRIMARY INDEX SECONDARY INDEX
(KSDS) (KSDS)
DD NAME : idxdd1 DD NAME : idxdd2

PCB STRUCTURE PCB STRUCTURE ???

DATABASE
(ESDS)
DD NAME : hosdd
PCB Structure for
Secondary Index
TREATMENT

ILLNESS

PATIENT

BILLING HOUSEHLD

PAYMENT
PCB Coding for Secondary
Index
PCB TYPE=DB,NAME=Hospital,
PROCOPT=A,KEYLEN=43,PROCSEQ=SIDXDBD
SENSEG NAME=Treatmnt,PARENT=0
SENSEG NAME=Illness,PARENT=Treatmnt
SENSEG NAME=Patient,PARENT=Illness
SENSEG NAME=Billing,PARENT=Patient
SENSEG NAME=Payment,PARENT=Billing
SENSEG NAME=Househld,PARENT=Patient
PSBGEN LANG=Cobol,NAME=Spsb
END

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy