Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
14 views

IMS Programming2

Copyright
© © All Rights Reserved
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
14 views

IMS Programming2

Copyright
© © All Rights Reserved
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
You are on page 1/ 115

IMS

Training
Objectives

To create awareness about the IMS DB technology and how it is used to perform data base
operations.

Target audience - people who are relatively new to IMS DB

Member firms and DTTL: Insert appropriate copyright Presentation title 2


[To edit, click View > Slide Master > Slide Master] [To edit, click View > Slide Master > Slide Master]
Course Outline

1. An Introduction to DL/I Data Bases

2. DL/I Programs and Control Blocks

3. COBOL Basics for Processing a DL/I Data Base

4. Segment Search Arguments : How to use them

5. Data retrieval from an IMS Data Base

6. Adding and Updating Data to a Data Base

Member firms and DTTL: Insert appropriate copyright Presentation title 3


[To edit, click View > Slide Master > Slide Master] [To edit, click View > Slide Master > Slide Master]
Module 1
An Introduction to DL/I Data
Bases

Hierarchical Structures
Why a Data Base Management System
Basic DL/I Terminology
Basic DL/I Data Base Processing

Member firms and DTTL: Insert appropriate copyright Presentation title 4


[To edit, click View > Slide Master > Slide Master] [To edit, click View > Slide Master > Slide Master]
Hierarchical Structures

A data base is a group of data elements organized to meet the requirements of one or more applications.

In a DL/I data base, data elements are organized in a hierarchical structure.

Some data elements are dependent on others.

Vendor

Item

Stock Location

Fig 1.1 A hierarchical structure

DL/I supports hierarchies that are difficult to implement with


standard files.

Member firms and DTTL: Insert appropriate copyright Presentation title 5


[To edit, click View > Slide Master > Slide Master] [To edit, click View > Slide Master > Slide Master]
Why a data base management 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
hierarchical structure Fig 1.2 Record layouts that illustrate a
Member firms and DTTL: Insert appropriate copyright Presentation title 6
[To edit, click View > Slide Master > Slide Master] [To edit, click View > Slide Master > Slide Master]
Basic DL/I Terminology

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
House Street City State Country Zip Code
Number Name

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
In the previous example there are three segment types,
Vendor, Item and Stock Location

Member firms and DTTL: Insert appropriate copyright Presentation title 7


[To edit, click View > Slide Master > Slide Master] [To edit, click View > Slide Master > Slide Master]
Basic DL/I Terminology (Contd.)

Segment Occurrence
One specific segment of a particular type containing user
data
Root Segment
The segment type at the top of a hierarchy

Member firms and DTTL: Insert appropriate copyright Presentation title 8


[To edit, click View > Slide Master > Slide Master] [To edit, click View > Slide Master > Slide Master]
Basic DL/I Terminology (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).
*
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.
*
Fig 1.5 Segment layouts for the Inventory data base
Member firms and DTTL: Insert appropriate copyright Presentation title 9
[To edit, click View > Slide Master > Slide Master] [To edit, click View > Slide Master > Slide Master]
Basic DL/I Terminology (contd.)

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

Vendor 1 Vendor 2

Item 1
Item 2
Data base Record 2
Item 1

Loc 2 Loc 2
Data base Record 1
Loc 1 Loc 1

Loc 5
Loc 4
Loc 3
Loc 2
Loc 1

Fig 1.6 Two data base records from the Inventory data base

Member firms and DTTL: Insert appropriate copyright Presentation title 10


[To edit, click View > Slide Master > Slide Master] [To edit, click View > Slide Master > Slide Master]
Basic DL/I Terminology (contd.)

Dependent Segment

A segment other than the root segment in a data base record

Accessible only through one or more “parent” segments

Parent Segment

A segment that has one or more dependent segments

Child Segment

Every dependent segment in a hierarchy

Twin Segment

Two or more segment occurrences of the same type and with the same segment occurrence as
their parent

Path

Series of segments leading from the root segment occurrence down to any specific segment
occurrence

Must be continuous- intermediate levels can’t be skipped

Member firms and DTTL: Insert appropriate copyright Presentation title 11


[To edit, click View > Slide Master > Slide Master] [To edit, click View > Slide Master > Slide Master]
Basic DL/I Terminology (contd.)

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

Member firms and DTTL: Insert appropriate copyright Presentation title 12


[To edit, click View > Slide Master > Slide Master] [To edit, click View > Slide Master > Slide Master]
Basic DL/I Terminology (contd.)

Logical data bases

DL/I does not support multiple parent relationships in physical data bases. However, it allows you to define
logical data bases that combine two physical data bases

Customer

Ship-to
Vendor

Buyer Receivable Item

Stock Location
Payment Adjustment Line Item

Fig 1.7 A logical relationship can connect two data bases

In Fig 1.7, the line item segment is the logical child segment (or just logical child) of the item
segment.

Likewise, the item segment is the logical parent segment (or just logical parent) of the line item
segment

Member firms and DTTL: Insert appropriate copyright Presentation title 13


[To edit, click View > Slide Master > Slide Master] [To edit, click View > Slide Master > Slide Master]
Basic DL/I Data Base Processing

Sequential Processing

Top –> Down, Left -> Right

The first segment retrieved in a database record is the root segment.

Position

• At any point, a program has a position in the data base.

• Position reflects not only on retrieved segments, but on new segments inserted as well

Vendor 1 Vendor 2

Item 1
Item 2
Data base Record 2
Item 1

Loc 2 Loc 2
Data base Record 1
Loc 1 Loc 1

Loc 5
Loc 4
Loc 3
Loc 2
Loc 1

Fig 1.8 Sequential processing


Member firms and DTTL: Insert appropriate copyright Presentation title 14
[To edit, click View > Slide Master > Slide Master] [To edit, click View > Slide Master > Slide Master]
Basic DL/I Data Base Processing (contd.)
Random (Direct) Processing

Key (sequence) field required

Concatenated Key

• Completely identifies the path from the root segment to the segment you want to retrieve.

Vendor 1 Vendor 2

Item 1
Item 2
Data base Record 2
ItemKey:
Concatenated 1

Vendor 2
Loc 2 Loc 2
Item 1
Data base Record 1 Loc 1
Loc 1
Location 1

Loc 5
Loc 4
Loc 3
Loc 2
Loc 1

Fig 1.9 Random Processing


Member firms and DTTL: Insert appropriate copyright Presentation title 15
[To edit, click View > Slide Master > Slide Master] [To edit, click View > Slide Master > Slide Master]
Module 2
DL/I Programs and Control
Blocks
The IMS Software Environment
How DL/I relates to your application programs
Control Blocks
DBDGEN
PSBGEN
IMS Processing Options
ACB & ACBGEN
Running an application program under DL/I

Member firms and DTTL: Insert appropriate copyright Presentation title 16


[To edit, click View > Slide Master > Slide Master] [To edit, click View > Slide Master > Slide Master]
How DL/I relates
to your application programs (contd.)
Standard file processing

Standard COBOL statements (like READ / WRITE) invoke the appropriate access method (like
VSAM)

Format of the record as processed by the program should be the same as the format of the
record in the file

DL/I data base processing

DLI - Interface between application program and the access method

CALL statement to invoke DL/I

Parameters passed by the CALL tell DL/I what operation to perform

DL/I invokes a standard access method- usually VSAM- to store data base data on disk

Format of records in a data base data set need not match the layouts of the segments that
make up the data base

The way the program sees the data base is different from the way the access method sees it.

Member firms and DTTL: Insert appropriate copyright Presentation title 17


[To edit, click View > Slide Master > Slide Master] [To edit, click View > Slide Master > Slide Master]
Control Blocks

Physical structure of a DL/I data base isn’t specified in an application program

DL/I uses a set of control blocks(DBDs and PSBs) to define a data base’s structure

Data Base Descriptor (DBD)

Describes the complete structure of a data base

A unique DBD for each DL/I data base

Program Specification Block (PSB)

Application program’s view of the Database

PSB Specifies

• Data bases (one or more) a program can access,

• Data elements a program can “see” in those data bases

• The processing a program can do with the data elements

Application programs that have similar data base processing requirements can share a PSB

Data Base Administrator (DBA) has to create DL/I control blocks

DBDGEN and PSBGEN Control Statements

Member firms and DTTL: Insert appropriate copyright Presentation title 18


[To edit, click View > Slide Master > Slide Master] [To edit, click View > Slide Master > Slide Master]
SAMPLE DBDGEN (Explained in next slide)

STMT 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

Member firms and DTTL: Insert appropriate copyright Presentation title 19


[To edit, click View > Slide Master > Slide Master] [To edit, click View > Slide Master > Slide Master]
SAMPLE DBDGEN
(Contd..)
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 PARAMETER
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*************
325 FINISH
END Member firms and DTTL: Insert appropriate copyright
[To edit, click View > Slide Master > Slide Master]
Presentation title
[To edit, click View > Slide Master > Slide Master]
20

Fig 2.3 Assembler source listing for the Inventory data base DBDGEN
DBDGEN (contd.)

FIELD macro defines a field in the DB

• START  position of field within segment

• NAME  name of the field

• 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
Fig 2.4 FIELD macro TYPE parameter codes

SEQ parameter specifies a sequence field


segment occurrences are added in sequence by values in these fields

Member firms and DTTL: Insert appropriate copyright Presentation title 21


[To edit, click View > Slide Master > Slide Master] [To edit, click View > Slide Master > Slide Master]
PSBGEN
PSB is the application program’s view of one or more data bases.

The following is a PSB which access only the vendor segment.

SAMPLE PSBGEN

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

7 END

Fig 2.5 Assembler source listing for the Inventory data base load program’s PSBGEN

Member firms and DTTL: Insert appropriate copyright Presentation title 22


[To edit, click View > Slide Master > Slide Master] [To edit, click View > Slide Master > Slide Master]
PSBGEN (contd.)

DBDNAME parameter on the PCB macro specifies the name of the DBD

KEYLEN parameter specifies the length of the longest concatenated key the program can
process in the data base

PROCOPT parameter specifies the program’s processing options

For each PCB macro, subordinate SENSEG macros identify the sensitive segments in the data
base

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

PSBGEN macro

• Indicates that there are no more statements in the PSBGEN job

• PSBNAME parameter specifies the name to be given to the output PSB module

• LANG parameter specifies the language in which the related application program will be written.

Member firms and DTTL: Insert appropriate copyright Presentation title 23


[To edit, click View > Slide Master > Slide Master] [To edit, click View > Slide Master > Slide Master]
IMS Processing Options

Indicates to IMS the type of access allowed for a sensitive segment (SENSEG)

Commonly used Processing Options

PROCOPT=G means only read-only access

PROCOPT=R means read/replace access

PROCOPT=I means insert access allowed

PROCOPT=D means Read/Delete access

PROCOPT=A means all the above options present

For GSAM DBs PROCOPT=LS for output and GS (Get Sequential) for input

PROCOPT=L allows a 'load' into the DB. If VSAM DB, it should be empty prior to the load

The PROCOPT given for a Sensitive segment would override the one given for the DB

Example : -

PCB TYPE=DB,NAME=LDB42F,PROCOPT=G,

KEYLEN=200 SENSEG NAME=SEGL4201,

PARENT=0,PROCOPT=A

Member firms and DTTL: Insert appropriate copyright Presentation title 24


[To edit, click View > Slide Master > Slide Master] [To edit, click View > Slide Master > Slide Master]
ACB & ACBGEN

ACB(Application Control Blocks)

It is created by merging and expanding PSB’s and DBD’s into an IMS internal format when an application
program is scheduled for execution.

ACBGEN

The process of building ACB is called Block Building and is done by means of ACBGEN.

IMS can build ACB’s either dynamically or it can prebuild them using ACB maintenance utility.

ACB’s cannot be prebuilt for GSAM DBD’s.

ACB’s can be prebuild for PSB’s that reference GSAM databases.

ACB’s save instruction, execution and direct-access wait time and improves performance in application
scheduling.

ACB’s are maintained in IMS.ACBLIB library.

Member firms and DTTL: Insert appropriate copyright Presentation title 25


[To edit, click View > Slide Master > Slide Master] [To edit, click View > Slide Master > Slide Master]
Module 3
COBOL Basics for Processing a
DL/I Data Base

The ENTRY and GO BACK Statements


The DL/I Call
The PCB Mask
DL/I Status codes

Member firms and DTTL: Insert appropriate copyright Presentation title 26


[To edit, click View > Slide Master > Slide Master] [To edit, click View > Slide Master > Slide Master]
ENTRY and
GO BACK Statements
ENTRY ‘DLITCBL’ USING PCB-name1
[PCB-name2...]
Fig 3.1 Format of the DL/I ENTRY Statement

Application program is invoked under the control of the batch initialization module

DLITCBL => ‘DL/I to COBOL’ is the entry point to the program

DL/I supplies the address of each PCB defined in the program’s PSB

PCBs must be defined in the Linkage Section

Linkage Section definition of a PCB is called a ‘PCB Mask’

Addressability to PCBs established by listing the PCB Masks on the ENTRY statement

PCB masks should be listed on the ENTRY statement in the same sequence as
they appear in your program’s PSBGEN
GO BACK Statement
When a program ends, it passes control back to the DL/I

DL/I reallocates resources and closes the data base data sets

Use GO BACK and not a STOP RUN statement


Member firms and DTTL: Insert appropriate copyright Presentation title 27
[To edit, click View > Slide Master > Slide Master] [To edit, click View > Slide Master > Slide Master]
The DL/I Call

CALL statements are used to request DL/I services

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 => ‘COBOL to DL/I’, is an interface module that is link edited with your program’s object module

PLITDLI, ASMTDLI are other options

Member firms and DTTL: Insert appropriate copyright Presentation title 28


[To edit, click View > Slide Master > Slide Master] [To edit, click View > Slide Master > Slide Master]
The DL/I Call (contd.)

The DL/I Function


First parameter coded on any DL/I call

Four character working storage field containing the function code

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

COBOL doesn’t allow coding literals in a CALL statement

To specify a DL/I function, one of the 05-level item is specified in a DL/I call.

Member firms and DTTL: Insert appropriate copyright Presentation title 29


[To edit, click View > Slide Master > Slide Master] [To edit, click View > Slide Master > Slide Master]
The DL/I Call (contd.)

Get functions

• First six 05-level items in Fig 3.3

• 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 retrieve segment 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

Member firms and DTTL: Insert appropriate copyright Presentation title 30


[To edit, click View > Slide Master > Slide Master] [To edit, click View > Slide Master > Slide Master]
The DL/I Call (contd.)

Update functions

• Used to change data in the data base

• ISRT 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

• REPL or the ‘replace’ function is used to replace a segment occurrence

Member firms and DTTL: Insert appropriate copyright Presentation title 31


[To edit, click View > Slide Master > Slide Master] [To edit, click View > Slide Master > Slide Master]
The DL/I Call (contd.)

Other functions

• Functions CHKP (the ‘checkpoint’ function) and XRST (the ‘restart’ function) are used in programs to
take advantage of IMS’s recovery and restart features

• Function PCB is used in CICS programs

• Function SYNC is used for releasing resources that IMS has locked for the program (applicable only in a
BMP)

• Function INIT allows an application to receive status codes

regarding deadlock and data availability (from DB PCBs)

Member firms and DTTL: Insert appropriate copyright Presentation title 32


[To edit, click View > Slide Master > Slide Master] [To edit, click View > Slide Master > Slide Master]
The DL/I Call (contd.)

PCB mask

Second parameter on the DL/I call

The name of the PCB mask defined in the program’s Linkage Section

ENTRY statement establishes a correspondence between PCB masks in the Linkage Section and
the PCBs within the program’s PSB

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 Area

Third parameter on the DL/I call

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

Member firms and DTTL: Insert appropriate copyright Presentation title 33


[To edit, click View > Slide Master > Slide Master] [To edit, click View > Slide Master > Slide Master]
The DL/I Call (contd.)

Segment search argument

Optional parameter on the DL/I call

Identifies the segment occurrence you wish to access

Multiple SSAs on a single DL/I call

Two kinds of SSAs– unqualified and qualified

An unqualified SSA

• Supplies the name of the next segment type that you want to operate on

• 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

• A GU call with a qualified SSA might request a particular occurrence of a named segment type by
providing a key value

Member firms and DTTL: Insert appropriate copyright Presentation title 34


[To edit, click View > Slide Master > Slide Master] [To edit, click View > Slide Master > Slide Master]
The PCB Mask

For each data base your program accesses, DL/I maintains an area of storage called the program communication block (PCB)

Masks are defined for those areas of storage in the Linkage Section of your program

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 an Inventory data base

Member firms and DTTL: Insert appropriate copyright Presentation title 35


[To edit, click View > Slide Master > Slide Master] [To edit, click View > Slide Master > Slide Master]
The PCB Mask (contd.)

Data base name

The 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 code

Contains 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

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 (would be elaborated later)

Indicates the processing a program is allowed to do on the data base

Member firms and DTTL: Insert appropriate copyright Presentation title 36


[To edit, click View > Slide Master > Slide Master] [To edit, click View > Slide Master > Slide Master]
The PCB Mask (contd.)

Segment name feedback area

The name of the segment is stored by DL/I in this field after each DL/I call.

Key length feedback area

The field DL/I uses to report the length of the concatenated key of the lowest level segment
processed during the previous call

Used with the key feedback area

Number of sensitive segments

Contains the number of SENSEG macros subordinate to the PCB macro for this data base

Key feedback area

Varies in length from one PCB to another

As long as the longest possible concatenated key that can be used with the program’s view of
the data base

After a data base operation, DL/I returns the concatenated key of he lowest level segment
processed in this field, and it returns the key’s length in the key length feedback area

Member firms and DTTL: Insert appropriate copyright Presentation title 37


[To edit, click View > Slide Master > Slide Master] [To edit, click View > Slide Master > Slide Master]
Report Preparation Program

An inventory availability report

One report line will be printed for each item segment occurrence in the data base

Each report line contains five items.

Prepare inventory 000


availability report

Process inventory 100


segment

Get inventory segment Print report line 120


110
150
130
Print report heading Write report line
140
Write page-top line Write report line 150

Member firms and DTTL: Insert appropriate copyright Presentation title 38


[To edit, click View > Slide Master > Slide Master] [To edit, click View > Slide Master > Slide Master]
Report Program

Member firms and DTTL: Insert appropriate copyright Presentation title 39


[To edit, click View > Slide Master > Slide Master] [To edit, click View > Slide Master > Slide Master]
Report Pgm (Contd.)

Member firms and DTTL: Insert appropriate copyright Presentation title 40


[To edit, click View > Slide Master > Slide Master] [To edit, click View > Slide Master > Slide Master]
Report Pgm (Contd.)

Member firms and DTTL: Insert appropriate copyright Presentation title 41


[To edit, click View > Slide Master > Slide Master] [To edit, click View > Slide Master > Slide Master]
Report Pgm (Contd.)

Member firms and DTTL: Insert appropriate copyright Presentation title 42


[To edit, click View > Slide Master > Slide Master] [To edit, click View > Slide Master > Slide Master]
Report Pgm (Contd.)

Member firms and DTTL: Insert appropriate copyright Presentation title 43


[To edit, click View > Slide Master > Slide Master] [To edit, click View > Slide Master > Slide Master]
Report Pgm (Contd.)

Member firms and DTTL: Insert appropriate copyright Presentation title 44


[To edit, click View > Slide Master > Slide Master] [To edit, click View > Slide Master > Slide Master]
Report Pgm (Contd.)

Member firms and DTTL: Insert appropriate copyright Presentation title 45


[To edit, click View > Slide Master > Slide Master] [To edit, click View > Slide Master > Slide Master]
Module 4
Segment Search Arguments
Types of SSAs
Basic Unqualified SSA
Basic Qualified SSA
Command Codes
The Null Command Code
Path Call
Multiple Qualifications

Member firms and DTTL: Insert appropriate copyright Presentation title 46


[To edit, click View > Slide Master > Slide Master] [To edit, click View > Slide Master > Slide Master]
Types of SSAs

SSA identifies the segment occurrence you want to access

It can be either

Qualified

Unqualified

An unqualified SSA simply names the type of segment you want to use

A qualified SSA 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

Member firms and DTTL: Insert appropriate copyright Presentation title 47


[To edit, click View > Slide Master > Slide Master] [To edit, click View > Slide Master > Slide Master]
Basic Unqualified SSA

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 blanks

The 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

Member firms and DTTL: Insert appropriate copyright Presentation title 48


[To edit, click View > Slide Master > Slide Master] [To edit, click View > Slide Master > Slide Master]
Basic Unqualified SSA (contd.)

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

Member firms and DTTL: Insert appropriate copyright Presentation title 49


[To edit, click View > Slide Master > Slide Master] [To edit, click View > Slide Master > Slide Master]
Program using Unqualified SSA

Member firms and DTTL: Insert appropriate copyright Presentation title 50


[To edit, click View > Slide Master > Slide Master] [To edit, click View > Slide Master > Slide Master]
Program (contd.)

Member firms and DTTL: Insert appropriate copyright Presentation title 51


[To edit, click View > Slide Master > Slide Master] [To edit, click View > Slide Master > Slide Master]
Program (contd.)

Member firms and DTTL: Insert appropriate copyright Presentation title 52


[To edit, click View > Slide Master > Slide Master] [To edit, click View > Slide Master > Slide Master]
Program (contd.)

Member firms and DTTL: Insert appropriate copyright Presentation title 53


[To edit, click View > Slide Master > Slide Master] [To edit, click View > Slide Master > Slide Master]
Program (contd.)

MOVE REPORT-LINE TO PRTOUT-RECORD.


PERFORM 150-WRITE-REPOR-LINE.
ADD 1 TO LINE-COUNT.
MOVE 1 TO SPACE-CONTROL.

130-PRINT-REPORT-HEADING.
ADD 1 TO PAGE-COUNT.
MOVE PAGE-COUNT TO HL1-PAGE.
MOVE HEADING-LINE-1 TO PRTOUT-RECORD.
PERFORM 140-WRITE-PAGE-TOP-LINE.
MOVE 2 TO SPACE-CONTROL.

140-WRITE-PAGE-TOP-LINE.
WRITE PRTOUT-RECORD AFTER ADVANCING PAGE.
150-WRITE-REPORT-LINE.
WRITE PRTOUT-RECORD AFTER SPACE-CONTROL LINES.

Member firms and DTTL: Insert appropriate copyright Presentation title 54


[To edit, click View > Slide Master > Slide Master] [To edit, click View > Slide Master > Slide Master]
Basic Qualified SSA

Fig 4.2 A basic qualified SSA

A qualified SSA lets you specify a particular segment occurrence based on a


condition that a field within the segment must meet

The first eight characters of a basic qualified SSA is the eight character segment
name

The ninth byte is a left parenthesis

Immediately following the left parenthesis in positions 10 through 17 is an eight


character field name
Member firms and DTTL: Insert appropriate copyright Presentation title 55
[To edit, click View > Slide Master > Slide Master] [To edit, click View > Slide Master > Slide Master]
Basic Qualified SSA (contd.)

After the field name, in positions 18 and 19, you code a two-character relational operator to indicate the
kind of checking DL/I should do on the field in the segment

The qualified SSA relational operators are shown below

(  stands for a single blank space)

Equal to EQ = =

Not equal to NE <>

Greater Than GT > >

Greater than or Equal to GE >= =>

Less Than LT < <

Less than or Equal to LE <= =<

After the relational operator, you code a variable field into which you move the search value you want to
use for the call

The length of the search value field can vary depending on the size of the field in the segment– it is the
only part of a basic qualified SSA that doesn’t have a fixed length

The last character in the qualified SSA is a right parenthesis


Member firms and DTTL: Insert appropriate copyright Presentation title 56
[To edit, click View > Slide Master > Slide Master] [To edit, click View > Slide Master > Slide Master]
Command Codes

Fig 4.3 Unqualified SSA format with a single command code

Fig 4.4 Qualified SSA format with a single command code

Command are used in SSAs for three purposes

To 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
Member firms and DTTL: Insert appropriate copyright Presentation title 57
[To edit, click View > Slide Master > Slide Master] [To edit, click View > Slide Master > Slide Master]
Command Codes (contd.)

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 variable 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.
05 FILLER PIC X VALUE SPACE.
*

Member firms and DTTL: Insert appropriate copyright Presentation title 58


[To edit, click View > Slide Master > Slide Master] [To edit, click View > Slide Master > Slide Master]
Command Codes (contd.)

Command Code Meaning


C Concatenated Key
D Path Call
F First Occurrence
L Last Occurrence
N 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 code

Fig 4.5 SSA Command Codes

Member firms and DTTL: Insert appropriate copyright Presentation title 59


[To edit, click View > Slide Master > Slide Master] [To edit, click View > Slide Master > Slide Master]
The Null Command Code

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.

Member firms and DTTL: Insert appropriate copyright Presentation title 60


[To edit, click View > Slide Master > Slide Master] [To edit, click View > Slide Master > Slide Master]
Path 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
INVEN-PCB-MASK
INVEN-STOCK-LOC-SEG
VENDOR-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 the above 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 be one of the values specified in the
PROCOPT parameter of the PCB in the programs PSBGEN.

If path call isMember


not explicitly
firms and enabled
DTTL: Insert appropriate copyright in the PSBGEN job there will be an 'AM' status code . title
Presentation 61
[To edit, click View > Slide Master > Slide Master] [To edit, click View > Slide Master > Slide Master]
Multiple Qualifications

There are two cases in which you would use multiple qualification
When you want to process a segment based on the contents of two or more fields within it

When you want to process a segment based on a range of 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 AND and OR

Either of the two symbols shown in the table below may be used for AND or OR

The independent AND operator is used for special operations with secondary indexes and will be
discussed later

Member firms and DTTL: Insert appropriate copyright Presentation title 62


[To edit, click View > Slide Master > Slide Master] [To edit, click View > Slide Master > Slide Master]
Multiple Qualifications (contd.)

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 the range to VENDOR-SSA-LOW-CODE
and VENDOR-SSA-HIGH-CODE

Then you would execute GN calls that include VENDOR-SSA


Member firms and DTTL: Insert appropriate copyright Presentation title 63
[To edit, click View > Slide Master > Slide Master] [To edit, click View > Slide Master > Slide Master]
Module 5
Retrieving Data from a Data
Base

The GU Call
The GN Call
The GNP Call
Status Codes Expected during Sequential Processing
Using Command Codes with Retrieval Calls
Multiple Processing

Member firms and DTTL: Insert appropriate copyright Presentation title 64


[To edit, click View > Slide Master > Slide Master] [To edit, click View > Slide Master > Slide Master]
The GU Call
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

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’

Member firms and DTTL: Insert appropriate copyright Presentation title 65


[To edit, click View > Slide Master > Slide Master] [To edit, click View > Slide Master > Slide Master]
The GU Call (contd.)
Usually, GU processing is based on sequence (key) fields with unique values

However, for some applications you may find it necessary to either

Access a segment whose sequence field allows non-unique values

Access a segment based on a field that is not the segment’s key field

In the above cases, DL/I returns the first segment occurrence with the specified search value

Special considerations for GU calls without a full set of qualified SSAs

1. When you use an unqualified SSA in a GU call, DL/I accesses the first segment occurrence in
the data base that meets the criteria you specify

2. If you issue a GU call without any SSAs, DL/I returns the first occurrence of the root segment
in the data base

3. If you omit some SSAs for intermediate levels in a hierarchical path, the action DL/I takes
depends on your current position and on the SSAs that are missing

• DL/I either uses the established position or defaults to an unqualified SSA for the segment

Member firms and DTTL: Insert appropriate copyright Presentation title 66


[To edit, click View > Slide Master > Slide Master] [To edit, click View > Slide Master > Slide Master]
The GU Call (contd.)

Recommended style of coding

Code a qualified or unqualified SSA for each level in the path from the
root segment to the segment you want to retrieve

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 a segment that met
the criteria you specified in the call

Member firms and DTTL: Insert appropriate copyright Presentation title 67


[To edit, click View > Slide Master > Slide Master] [To edit, click View > Slide Master > Slide Master]
The GN Call
CALL ‘CBLTDLI’ USING DLI-GN

INVENTORY-PCB-MASK

INVENTORY-STOCK-LOC-SEGMENT

STOCK-LOCATION-SSA.

Used for basic sequential processing

After any successful data base call, your data base position is immediately before the next segment occurrence in
the normal hierarchical sequence

Before your program issues any calls, position is before the root segment of the first data base record

The GN call moves forward through the data base from the position established by the previous call

If a GN call is unqualified (that is, if it does not employ an SSA), it returns the next segment occurrence in the
data base regardless of type, in hierarchical sequence

If a GN call includes SSAs– qualified or unqualified– DL/I retrieves only segments that meet requirements of all
SSAs you specify

If you include an unqualified SSA or omit an SSA altogether for a segment type, DL/I allows any occurrence of
that segment type to satisfy the call

But when you specify a qualified SSA, DL/I selects only those segment occurrences that meet the criteria you
specify

Member firms and DTTL: Insert appropriate copyright Presentation title 68


[To edit, click View > Slide Master > Slide Master] [To edit, click View > Slide Master > Slide Master]
The GNP Call
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 the established parentage DL/I returns GE as the status code

Member firms and DTTL: Insert appropriate copyright Presentation title 69


[To edit, click View > Slide Master > Slide Master] [To edit, click View > Slide Master > Slide Master]
The GNP Call (contd.)

Vendor 1

Item 2

Established  Item 1
Parent

Loc 2
Loc 1
Established
 Parent
Loc 5 Vendor 1
Loc 4
Loc 3
Loc 2 Item 2

Loc 1
Item 1

Loc 2
Loc 1
Fig 5.1 Sequential retrieval with GNP call
Loc 5
Loc 4
Loc 3
Loc 2
Loc 1
Member firms and DTTL: Insert appropriate copyright Presentation title 70
[To edit, click View > Slide Master > Slide Master] [To edit, click View > Slide Master > Slide Master]
Status Codes you can expect during
Sequential Processing

Member firms and DTTL: Insert appropriate copyright Presentation title 71


[To edit, click View > Slide Master > Slide Master] [To edit, click View > Slide Master > Slide Master]
Reporting Program

A complex reporting program:

Report specifications:

For each selected item segment occurrence in the inventory database

•Print a group of report lines that contain one line for each subordinate location segment
occurrence and a total line for all locations. Use a single report line for both.

•An item should be selected for the report only if one or more of its subordinate locations’
available stock is less than the reorder point.

•Each report line for a location should show the location’s code, quantity on hand, quantity on
order, available stock (the sum of the quantity on hand and quantity on order) and reorder
point.

•For each location, if the available stock is less than or equal to the reorder point, the program
should print an asterisk in column 109; otherwise, column 109 is left as space.

•The first report line in each group should contain the item number and the description,
subsequent lines should not.

•The total lines for each item should specify the total available stock and the total reorder point
for stock at all locations.

Member firms and DTTL: Insert appropriate copyright Presentation title 72


[To edit, click View > Slide Master > Slide Master] [To edit, click View > Slide Master > Slide Master]
Program

Member firms and DTTL: Insert appropriate copyright Presentation title 73


[To edit, click View > Slide Master > Slide Master] [To edit, click View > Slide Master > Slide Master]
Program (Contd.)

Member firms and DTTL: Insert appropriate copyright Presentation title 74


[To edit, click View > Slide Master > Slide Master] [To edit, click View > Slide Master > Slide Master]
Program (Contd.)

Member firms and DTTL: Insert appropriate copyright Presentation title 75


[To edit, click View > Slide Master > Slide Master] [To edit, click View > Slide Master > Slide Master]
Program (Contd.)

Member firms and DTTL: Insert appropriate copyright Presentation title 76


[To edit, click View > Slide Master > Slide Master] [To edit, click View > Slide Master > Slide Master]
Program (Contd.)

Member firms and DTTL: Insert appropriate copyright Presentation title 77


[To edit, click View > Slide Master > Slide Master] [To edit, click View > Slide Master > Slide Master]
Program (Contd.)

Member firms and DTTL: Insert appropriate copyright Presentation title 78


[To edit, click View > Slide Master > Slide Master] [To edit, click View > Slide Master > Slide Master]
Program (Contd.)

Member firms and DTTL: Insert appropriate copyright Presentation title 79


[To edit, click View > Slide Master > Slide Master] [To edit, click View > Slide Master > Slide Master]
Program (Contd.)

Member firms and DTTL: Insert appropriate copyright Presentation title 80


[To edit, click View > Slide Master > Slide Master] [To edit, click View > Slide Master > Slide Master]
Program (Contd.)

Member firms and DTTL: Insert appropriate copyright Presentation title 81


[To edit, click View > Slide Master > Slide Master] [To edit, click View > Slide Master > Slide Master]
Using Command Codes with Retrieval Calls

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’s other 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 calls

Meaningless with GU calls, because GU normally retrieves the first segment occurrence that
meets the criteria you specify

The L command code

When you issue a call with an SSA that includes the L command code, the call processes the
last occurrence of the segment named by the SSA, subject to the call’s other qualifications

Unlike the F command code, you can use the L command code with a GU call.

This can be used to access the last occurrence of a segment with a specific key value and the
segment’s key field can have non-unique values. The L command code overrides DL/I ‘s
normal function of returning the first occurrence that fully satisfies the call’s SSA’s.

Member firms and DTTL: Insert appropriate copyright Presentation title 82


[To edit, click View > Slide Master > Slide Master] [To edit, click View > Slide Master > Slide Master]
Using Command Codes with Retrieval Calls (Contd.)

The D command code

Used to retrieve more than one segment occurrence using 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 levels as well

Makes it easy to retrieve an entire path of segments

Member firms and DTTL: Insert appropriate copyright Presentation title 83


[To edit, click View > Slide Master > Slide Master] [To edit, click View > Slide Master > Slide Master]
Using Command Codes with Retrieval Calls(contd.)

Member firms and DTTL: Insert appropriate copyright Presentation title 84


[To edit, click View > Slide Master > Slide Master] [To edit, click View > Slide Master > Slide Master]
Using Command Codes with Retrieval Calls(contd.)
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 the hierarchical 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 is shown below

Member firms and DTTL: Insert appropriate copyright Presentation title 85


[To edit, click View > Slide Master > Slide Master] [To edit, click View > Slide Master > Slide Master]
Using Command Codes with Retrieval Calls(contd.)

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 SSA

For example, a GN call without the P command code for an item segment from the inventory
data base would establish parentage at the item segment.

We can retrieve the same item segment, but establish parentage at the vendor segment by
using the P command code on the vendor segment’s SSA.

We can also use the P command code in a GNP call. Before we can issue a GNP successfully,
parentage must have successfully been established.. The parentage that you specify with the P
command code in an SSA used in a GNP call does not go into effect until after the segment is
retrieved.

Also you should specify the P command code at just one hierarchical level. If you issue a call
with two or more SSA’s that contain the P command code, DL/I ignores all except the one at
the lowest level in the hierarchical path.

Member firms and DTTL: Insert appropriate copyright Presentation title 86


[To edit, click View > Slide Master > Slide Master] [To edit, click View > Slide Master > Slide Master]
P Command Code
Example
The example below shows a segment of code to retrieve the appropriate location segment occurrences using SSA’s
without command codes. A GU call establishes parentage a the right item segment occurrence, then GNP calls are
executed repeatedly to return all location segments subordinate to the item.

Code to establish parentage without the P command code

Member firms and DTTL: Insert appropriate copyright Presentation title 87


[To edit, click View > Slide Master > Slide Master] [To edit, click View > Slide Master > Slide Master]
Example contd.

Member firms and DTTL: Insert appropriate copyright Presentation title 88


[To edit, click View > Slide Master > Slide Master] [To edit, click View > Slide Master > Slide Master]
Example contd.

Member firms and DTTL: Insert appropriate copyright Presentation title 89


[To edit, click View > Slide Master > Slide Master] [To edit, click View > Slide Master > Slide Master]
Using Command Codes with Retrieval
Calls(contd.)
The 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

The Q command code

This command code is used to enqueue, or reserve for exclusive use, a segment or path of
segments

You only need to use the Q command code in an interactive environment where there is a
chance that another program might make a change to a segment between the time you first
access it and the time you are finished with it

Member firms and DTTL: Insert appropriate copyright Presentation title 90


[To edit, click View > Slide Master > Slide Master] [To edit, click View > Slide Master > Slide Master]
Multiple Processing

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

Member firms and DTTL: Insert appropriate copyright Presentation title 91


[To edit, click View > Slide Master > Slide Master] [To edit, click View > Slide Master > Slide Master]
Multiple Processing (contd.)

Multiple positioning

Lets a program maintain more than one position within a data 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

A1

Data base Record 1

C13
C12 A2

B13 C11
B12
Data base Record 2
B11
C22

B22 C21

B21

Fig 5.2 Two data base records to illustrate multiple positioning

Member firms and DTTL: Insert appropriate copyright Presentation title 92


[To edit, click View > Slide Master > Slide Master] [To edit, click View > Slide Master > Slide Master]
Multiple Processing (contd.)

When you use multiple positioning, DL/I maintains its separate positions based on segment type

As a result you include an unqualified SSA in the call that names the segment type whose position
you want to use

It is the DBA who decides whether single or multiple positioning will be in effect in the program’s
PSB

As a result multiple positioning is not the characteristic of the data base but instead, it’s how DL/I
allows a program to view a data base

The same program can be processed with either single or multiple positioning by different programs

The technique a program uses is determined by the program’s PSB

Member firms and DTTL: Insert appropriate copyright Presentation title 93


[To edit, click View > Slide Master > Slide Master] [To edit, click View > Slide Master > Slide Master]
Module 6
Adding and Updating Data
to a Data Base
The ISRT Call
The Get Hold Calls
The REPL Call
The DLET Call
Common IMS Status Codes
IMS Abends
Sample IMS Program

Member firms and DTTL: Insert appropriate copyright Presentation title 94


[To edit, click View > Slide Master > Slide Master] [To edit, click View > Slide Master > Slide Master]
The ISRT Call

The ISRT call is used to add a segment occurrence to a data base, either during update processing of an
existing data base or during load processing of a new data base

Before an ISRT call is issued, you should first build the segment occurrence by moving data to the fields of
the segment description

After formatting the segment, you issue the ISRT call with at least one SSA: an unqualified SSA for the
segment type you want to add

Consider the example below

CALL ‘CBLTDLI’ USING DLI-ISRT

INVENTORY-PCB-MASK

INVENTORY-STOCK-LOC-SEGMENT

UNQUALIFIED-SSA.
Here UNQUALIFIED-SSA specifies the segment name

Because the SSA is unqualified, DL/I tries to satisfy the call based on the current position in the data base

As a result, you need to be careful about position when you issue an ISRT call that specifies only a single
unqualified SSA

Member firms and DTTL: Insert appropriate copyright Presentation title 95


[To edit, click View > Slide Master > Slide Master] [To edit, click View > Slide Master > Slide Master]
The ISRT Call (contd.)

A safer technique is to specify a qualified SSA for each hierarchical level above the one where you want to
insert 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 ISRT 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 ISRT 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

Member firms and DTTL: Insert appropriate copyright Presentation title 96


[To edit, click View > Slide Master > Slide Master] [To edit, click View > Slide Master > Slide Master]
The ISRT Call (contd.)

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 is added 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 twins

• If 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

Member firms and DTTL: Insert appropriate copyright Presentation title 97


[To edit, click View > Slide Master > Slide Master] [To edit, click View > Slide Master > Slide Master]
The ISRT Call (contd.)

Status codes you can expect during insert processing

GE  When you use multiple SSAs and DL/I cannot satisfy the call with the specified path

I I  When you try to add a segment occurrence that is already present in the data base

For load processing you might get status codes LB, LC, LD or LE.

• In most cases they indicate that you are not inserting segments in exact hierarchical sequence

• That means there is an error in your program or the files from which you are loading the data base
contain incorrect data

Member firms and DTTL: Insert appropriate copyright Presentation title 98


[To edit, click View > Slide Master > Slide Master] [To edit, click View > Slide Master > Slide Master]
The Get Hold Calls

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

Member firms and DTTL: Insert appropriate copyright Presentation title 99


[To edit, click View > Slide Master > Slide Master] [To edit, click View > Slide Master > Slide Master]
The REPL Call
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 REPL 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 REPL 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.

Member firms and DTTL: Insert appropriate copyright Presentation title 100
[To edit, click View > Slide Master > Slide Master] [To edit, click View > Slide Master > Slide Master]
The REPL Call (contd.)

Status codes you can expect during replace processing

If you try to use a qualified SSA on an REPL 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 REPL call, DL/I
returns a DA status code

Member firms and DTTL: Insert appropriate copyright Presentation title 101
[To edit, click View > Slide Master > Slide Master] [To edit, click View > Slide Master > Slide Master]
The DLET Call

The DLET call works much like REPL

You must first issue a get hold call to indicate that you intend to make a change to the segment you are
retrieving

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 like the
ones below

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 are the same as those you can get after an REPL call

Member firms and DTTL: Insert appropriate copyright Presentation title 102
[To edit, click View > Slide Master > Slide Master] [To edit, click View > Slide Master > Slide Master]
Sample IMS Program

Member firms and DTTL: Insert appropriate copyright Presentation title 103
[To edit, click View > Slide Master > Slide Master] [To edit, click View > Slide Master > Slide Master]
Sample Program (contd.)

Member firms and DTTL: Insert appropriate copyright Presentation title 104
[To edit, click View > Slide Master > Slide Master] [To edit, click View > Slide Master > Slide Master]
Sample Program (contd.)

Member firms and DTTL: Insert appropriate copyright Presentation title 105
[To edit, click View > Slide Master > Slide Master] [To edit, click View > Slide Master > Slide Master]
Sample Program (contd.)

Member firms and DTTL: Insert appropriate copyright Presentation title 106
[To edit, click View > Slide Master > Slide Master] [To edit, click View > Slide Master > Slide Master]
Sample IMS Update Program

Member firms and DTTL: Insert appropriate copyright Presentation title 107
[To edit, click View > Slide Master > Slide Master] [To edit, click View > Slide Master > Slide Master]
Program contd.

Member firms and DTTL: Insert appropriate copyright Presentation title 108
[To edit, click View > Slide Master > Slide Master] [To edit, click View > Slide Master > Slide Master]
Program contd.

Member firms and DTTL: Insert appropriate copyright Presentation title 109
[To edit, click View > Slide Master > Slide Master] [To edit, click View > Slide Master > Slide Master]
Program contd.

Member firms and DTTL: Insert appropriate copyright Presentation title 110
[To edit, click View > Slide Master > Slide Master] [To edit, click View > Slide Master > Slide Master]
Program contd.

Member firms and DTTL: Insert appropriate copyright Presentation title 111
[To edit, click View > Slide Master > Slide Master] [To edit, click View > Slide Master > Slide Master]
Program contd.

Member firms and DTTL: Insert appropriate copyright Presentation title 112
[To edit, click View > Slide Master > Slide Master] [To edit, click View > Slide Master > Slide Master]
Program contd.

Member firms and DTTL: Insert appropriate copyright Presentation title 113
[To edit, click View > Slide Master > Slide Master] [To edit, click View > Slide Master > Slide Master]
Program contd.

Member firms and DTTL: Insert appropriate copyright Presentation title 114
[To edit, click View > Slide Master > Slide Master] [To edit, click View > Slide Master > Slide Master]
Thank
you

You might also like