Вы находитесь на странице: 1из 60

Mainframe VSAM

CHAPTER - 1: Introduction to VSAM

Virtual Storage Access Method - VSAM - is a data management system


introduced by IBM in the 1970s as part of the OS/VS1 and OS/VS2 operating
systems. Although there are still datasets that are best managed with the several
other (non-VSAM) data management methods, VSAM is a major component of
modern IBM operating systems. VSAM is a high performance access method used to
organize data and to maintain information about that data in an index or library
called a catalog.
VSAM acts as interface between Operating System and Application Program.
VSAM is an access method used to organize data and maintain information about the
data in a catalog.
All VSAM data sets reside on DASD Devices and must be defined in a catalog.
There are two major parts to VSAM:
• Catalog management
• Record management

Catalog Management

• The catalog contains information about the VSAM data sets. The catalog can
be an ICF Catalog or a VSAM catalog (older versions of the operating
system). DFSMS/MVS deals only with ICF catalogs.
• All VSAM data set information is maintained in the ICF catalog and it can be
easily retrieved using AMS commands (Access Method Services).
Record management

The purpose of record management is to maintain records in a VSAM data set


for an application or a system program. VSAM supports five data set organizations:
• Key-sequenced data set (KSDS)
• Entry-sequenced data set (ESDS)
• Fixed-length relative record data set (RRDS)
• Variable-length relative record data set (VRRDS)
• Linear data set (LDS)
The primary difference between the VSAM data set organizations is in the way
the records are stored and accessed.

VSAM HISTORY

In the year 1973 VSAM was introduced with ESDS & KSDS only and in the
year 1975 the concept of Alternate Index, RRDS, and Catalog Recovery features
were introduced. VSAM was re-introduced with a facility called as Integrated Catalog
Facility (ICF). In the year 1983 VSAM was introduced with DFP/VSAM (Data Facility
Product) which can run under MCS/XA. Later in the year 1987 the DFP/VSAM 2.3
with LDS facility was introduced and another VSAM 3.1 under MVS/ESA with DFSMS
(Data Facility Storage Management System). In the year 1991, VSAM 3.3 was
introduced with variable length records for RRDS

iFrames Technologies 1
Mainframe VSAM

STRUCTURE OF VSAM

VSAM provides a comprehensive catalog facility that stores information about


VSAM data sets and other files.
There are two types of catalogs:
• Master Catalogs
• User Catalogs

Master Catalog

Every system that uses VSAM has one, and only one, master catalog. The
master catalog contains entries about system datasets and VSAM structures used to
manage the operation of VSAM. The master catalog is created during the System
Generation process and usually resides on the System Residence volume. The
master catalog "owns" all other VSAM resources in a computer system, and this is
denoted by the position of the master catalog.

User Catalogs

A user catalog is a catalog created to contain entries about application specific


datasets. The information defining a user catalog is stored into a catalog entry in the
master catalog. A production system might have any number of user catalogs, with
the datasets cataloged in a specific user catalog related by application type.

ADVANTAGES & DISADVANTAGES OF VSAM

Advantages:
• The retrieval of records is faster because of an efficiently organized index. The
index is small because of a key compression algorithm used to store and
retrieve its records.
• Imbedded free space makes the insertion of records easy, and data sets
therefore require less reorganization.
• The deletion of records in VSAM, unlike that in ISAM, means that they are
physically deleted, thus allowing the reclaiming of free space within the data
set.
• VSAM data sets are device-independent.
• VSAM catalogs and data sets are portable between operating systems.
• Records can be accessed randomly by key or by address and can also be
accessed sequentially at the same time.
Disadvantages:
• To take advantage of the partial self-reorganization capabilities of VSAM data
sets, free space must deliberately be left. For data sets that are used for read
only purposes, no free space is required.
• Except for read-only data sets, the integrity of VSAM data sets in cross-
system and cross –region sharing must be controlled by the user. Data
integrity must be a prime consideration in the initial design of applications
that will be shared across systems.

iFrames Technologies 2
Mainframe VSAM

MAJOR AREAS WHERE VSAM IS USED


• It can be used as a stand-alone product. VSAM data sets can be created and
processed by a powerful software product called IDCAMS.
• Batch application programs in COBOL, PL/I, Assembler, etc. can access VSAM
data sets.
• In data set management, PDS directories, catalogs, and generation data
groups can be manipulated through specific IDCAMS commands. GDGs and
catalogs are themselves VSAM data sets, Also, the IDCAMS utility can be used
to process older, non-VSAM data set organizations.
• Many major IBM software products, such as CICS, IMS, DB2 and TSO, use
VSAM data sets in a majority of applications. In some of them, VSAM data
sets are the only ones that are compatible.
VSAM is available under all IBM’s Mainframe operating systems; MVS, VM,
and VSE. The MVS implementation of VSAM is the most comprehensive. Also, VSAM
data sets can be stored on almost all standard disk drives, such as 3390, 3380,
3350, 3370, etc. Present and future mainframe software released by IBM will be
designed to process records storage in VSAM data sets. VSAM is going to be around
for a long time to come.

VSAM TERMINOLOGY

Before we discuss VSAM data set organizations in detail, we need to review


some terms that will be used throughout the book.
• Logical record
• Control interval
• Control area
Logical record (LR)
A logical record is a unit of information used to store data in a VSAM data set.
Logical records in VSAM data sets are stored differently than logical records in non-
VSAM data sets.

LR

A LR is comparable to the logical-record –length (lrecl) for a Non-Vsam dataset, as in


the DCB Parameter of JCL.

Control Interval (CI)


Logical records are contained in a control interval (CI). A group of LRs will
make one CI.

LR LR LR LR

The fundamental building block of every component of a VSAM data set is the
control interval. A control interval is the unit of information that VSAM transfers
between the storage device and the virtual storage. One CI can be made of one or
more physical blocks of DASD.

iFrames Technologies 3
Mainframe VSAM

Control Interval Format for a Non- LDS Cluster.

Control
Logical Record Interval
Area Record
definition Definition
field field
Free space Area

R R
D D
RECORD 1 RECORD 2 F F
1 2

A CI consists
• Logical records stored from beginning to end
• Unused space, referred to as free space, for data records to be inserted into
or lengthened
• The maximum size of a CI is 32k and the minimum size is 512 bytes.
• Control information, which is made up of two types of fields; one Control
Interval Definition Field (CIDF) per CI, and one or more Record Definition
Fields (RDF) per logical record.
1. CIDF is a 4-byte field. It contains information about the length of data
in the CI and the amount and location of free space.
2. RDF is a 3-byte field. It describes the length of records and how many
adjacent records are of the same length.

Control area (CA)


• A control area (CA) is one or more CIs put together into fixed-length
contiguous areas of DASD. A VSAM data set is composed of one or more CAs.
• The number of CIs in a CA is fixed by VSAM. The CA size is implicitly defined
when you specify the size of a data set at data set definition.
• The maximum size of a CA is one cylinder and the minimum size is one track.

iFrames Technologies 4
Mainframe VSAM

Figure 1-2 shows the structure of a CA.

CA1
LR1 LR2 FREE SPACE RDF2 RDF1 CIDF

CA2 LR3 LR4 FREE SPACE RDF4 RDF1 CIDF

CA3 LR5 LR6 FREE SPACE CIDF


RDF RDF
CA 1

REVIEW QUESTIONS

1. What is VSAM?

2. What are the major parts in VSAM?

3. What are the two Catalogs available in VSAM?

4. What is Control Interval?

5. What is Control Area?

6. How many Bytes occupied for RDF and CIDF?

7. The Maximum and minimum size of a Control Area is __________,


_________.

8. What are the advantages and disadvantages of VSAM?

9. What are the different datasets supported by VSAM?

10. What is a logical record?

11. What's the biggest disadvantage of using a VSAM dataset?

iFrames Technologies 5
Mainframe VSAM

CHAPTER --- 2 : Dataset Organization

VSAM DATASET ORGANIZATION

LR1 LR2 LR3

CI

LR2

WORK AREA

Whenever a record is retrieved from DASD, the entire CI containing the


record is read into a VSAM I/O buffer in virtual storage. From the VSAM buffer, the
desired record is transferred to a user defined buffer or work area.
The physical organization of VSAM data sets differs considerably from those
used by other access methods. VSAM data sets are held in control intervals and
control areas; the size of these is normally determined by the access method, and
the way in which they are used is not visible to you.

TYPES OF DATASET ORGANISATION

VSAM supports 5 different organizations. They are as follows:


• Linear Data Set – LDS – with no record organization
• Entry-Sequenced Data Set – ESDS - is like a standard sequential data set.
• Fixed-length Relative-Record Data Set - FRRDS - Fixed length RRDS
• Variable-length Relative Record Data Set - VRRDS - Variable length RRDS
• Key-Sequenced Data Set – KSDS- is like an indexed sequential access
method file.

The VSAM data set organizations are superior to the native access methods.
VSAM provides for alternate indexes, a feature not available in native access
methods. It has an admirable catalog facility that stores more information about
VSAM and other data sets. The powerful AMS utility in VSAM provides a variety of
services dealing with catalogs, files, security, file management, etc. It provides

iFrames Technologies 6
Mainframe VSAM

comprehensive support for application development in many environments such as


COBOL, PL/I, FORTRAN, Assembler and CICS.
LINEAR DATA SET (LDS)

A linear data set (LDS) contains data that can be accessed as byte-addressable
strings in virtual storage. It is a VSAM data set with a control interval size of 4096
bytes.

DATA CA
DATA
DATA
DATA

DATA CA DATA

DATA

DATA

An LDS has no imbedded control information in its CI, which is, no RDFs and
CIDFs. All LDS bytes are data bytes. Logical records must be blocked and de blocked
by the application program, but records do not exist from the point of view of VSAM.
An LDS contains a data component only.
LDS are generally used for fast random access to data that has no
hierarchical structure - i.e., for data, that is a large flat file, such as a table or array.
A relational database is just this. You specify the LDS organization with the IDCAMS
DEFINE command specifying the LINEAR parameter.

ENTRY SEQUENCED DATA SET (ESDS)

An ESDS is a sequential file, in which records are typically retrieved in the


order in which they were written to the data set and additions are always made at
the end of the file. Each record can be identified by a relative byte address or RBA.
Records cannot be physically deleted. Since records in an ESDS are not sequenced
on any key field, there is no primary key index component. Imbedded free space is
not allocated at the time of allocation of an ESDS, since records are not added to the
middle of the file. Records in an ESDS may be of variable length.

iFrames Technologies 7
Mainframe VSAM

CI 1

RECORD1 RECORD2 RECORD3 RECORD4


RBA
0
CI 2
RECORD7 RECORD8
RECORD5 RECORD6
RBA
4096
CI 3

UNUSED SPACE

RBA 8192

Records can be updated, but without length change. To change the length of
a record, you must either store it at the end of the data set as a new record, or
override an existing record of the same length that you have flagged as inactive.

A record can be accessed sequentially or directly by its RBA:


Relative Byte Address (RBA) is the address of a record in a dataset. Records
can be accessed sequentially or by relative byte address (RBA).The RBA of the first
logical record is 0. The second record has an RBA equal to the length of the first
record and so on.

TYPICAL ESDS PROCESSING

Sequential processing:
VSAM automatically retrieves records in stored sequence. Sequential
processing can be started from the beginning or somewhere in the middle of a data
set. If processing is to begin in the middle of a data set, positioning is necessary
before sequential processing can be performed.

Direct processing:
When a record is loaded or added, VSAM indicates its RBA. To retrieve records
directly, you must supply the RBA for the record as a search argument. Although an
ESDS does not contain an index component, you can build an alternate index to keep
track of these RBAs.

Empty spaces in the CI are referred to as unused space because they can
never be used.

You specify ESDS organization using the IDCAMS DEFINE command and
specifying the NONINDEXED parameter.

iFrames Technologies 8
Mainframe VSAM

RELATIVE RECORD DATASET (RRDS)

1) FIXED LENGTH RECORDS


In an RRDS the entire data set is a string of fixed length slots. Each slot occupies a
fixed position and is identified by its position relative to the first slot of the data set.

RECORD1 RECORD2 RECORD3 RECORD4

DATA RECORD5 RECORD6 RECORD7 RECORD8


CA
RECORD9 RECORD10 RECORD11 RECORD12

RECORD13 RECORD14 RECORD15 RECORD16

DATA RECORD17 RECORD18 RECORD19 RECORD20


CA
RECORD21 RECORD22 RECORD23 RECORD24

The relative position of each slot is called relative record number (RRN). An
RRN is an integer that identifies the position of the slot no the value of a particular
field within the slot. Each slot of an RRDS may or may not contain a record. Records
in an RRDS may be inserted, retrieved, updated, and deleted both sequentially and
randomly. Records in an RRDS are always fixed in the length. RRDS has only data
component. When a record is deleted from a particular slot, the slot remains in the
same physical location although a record does not exist in that slot anymore
You specify the RRDS organization using the IDCAMS DEFINE command with
the NUMBERED option.
TYPICAL RRDS PROCESSING
CONTROL AREA 2 CI

APPLICATION 29 30 31 32
PROGRAM
CI
GET RECORD 25 25 26 27 28

CI
CI
13 14 15 16 21 22 23 24
CI CI
9 10 11 12 17 18 19 20
CI
SLOT 8
5 6 7 8
CONTROL AREA 1
Slot8
CI
1 2 3 4
iFrames Technologies 9
Mainframe VSAM

The relative record number can be used as a search argument. The


application program inputs the relative record number of the target record and VSAM
is able to find its location quickly using an internal algorithm. An RRDS can be
processed sequentially, directly or skip-sequentially.
• RRDS sequential processing is treated the same way as ESDS sequential
processing. Empty slots are automatically skipped by VSAM.
• An RRDS can be processed directly by supplying the relative record number
as a key. VSAM accesses the appropriate slot and returns the record to the
user’s buffer. RRDS direct address processing by supplying the RBA is not
supported.
• Skip-sequential processing is treated like an RRDS direct processing request,
but the position is maintained. Records must be in ascending sequence.

2. VARIABLE RELATIVE RECORD DATA SET (VRRDS)


A VRRDS is similar to a fixed-length RRDS, except that it contains variable-
length records. Each record has a unique relative record number, and is placed in
ascending relative record number order. Each record is stored and retrieved using its
relative record number. VRRDS has no preformatted slots.
The relative record number of a record cannot change. When that record is
erased, the relative record number can be reused for a new record.
You can specify free space for inserting records and increasing the length of a
record. VRRDS is a KSDS processed as an RRDS, so an index will be created.
You specify the VRRDS organization with the IDCAMS DEFINE command with
the NUMBERED option and variable length record.

REVIEW QUESTIONS.

1. Which VSAM cluster support only fixed length records?

a) LDS

b) RRDS

c) ESDS

d) KSDS

2. FREESPACE can be specified for which type of cluster?

a) LDS

b) B. RRDS

c) C. ESDS

d) D. KSDS

3. For a KSDS, the larger the data CA size, the smaller the number of index CIs.

A. TRUE

B. FALSE.

iFrames Technologies 10
Mainframe VSAM

4. VSAM control intervals containing data records have at least one RDF and one
CIDF.

A. TRUE

B. FALSE

5. In which cluster type are records always added at the end of the data set?

a) LDS

b) RRDS

c) ESDS

d) KSDS

6. Which VSAM clusters support only fixed length records?

a) LDS

b) RRDS

c) ESDS

d) KSDS

7. The types of processing supported by RRDS are

a) sequential

b) skip-sequential

c) direct

d) a and b

e) a, b and c

8. The types of processing supported by ESDS are

a) Sequential

b) skip-sequential

c) Direct

d) a and b

e) a and c

9. What is the Difference between LDS & ESDS?

10. How Many Times Secondary Space Allocated?

11. What is the RRN for the first record in RRDS?

iFrames Technologies 11
Mainframe VSAM

CHAPTER - 3: KSDS

KEY SEQUENCED DATASET (KSDS)

In a KSDS, records are placed in the data set in ascending collating sequence
by key. The records for KSDS can be fixed-length or variable-length records. The key
of the record contains a unique value that determines the record's collating position
in the data set. The key must be in the same position in each record.

INDEX COMPONENT

DATA COMPONENT

The key data must be contiguous and each record's key must be unique. After
it is specified, the value of the key cannot be altered, but the entire record can be
deleted. When a new record is added to the data set, it is inserted in its collating
sequence by key.
A KSDS has a data and an Index Component. The Index Component keeps
track of the used keys and is used by VSAM to retrieve quickly a record from the
data component, when a request is made for a record with a certain key. A KSDS
can have fixed or variable length records. A KSDS can be accessed either
sequentially or directly or skip-sequentially.
You specify the KSDS organization using the IDCAMS DEFINE command with the
INDEXED parameter.

DATA / INDEX RELATIONSHIP

A KSDS has an index that relates key values to the relative locations of the
logical records in a data set. This index is called the Prime Index. It has two uses:
• Locate the collating position when inserting records.
• Locate records for retrieval.
When initially loading a data set, records must be presented to VSAM in key
sequence. The Index is built automatically by VSAM as the data set is loaded with
records. When a data CI is loaded with records, VSAM makes an entry in the index.
The entry consists of the highest possible key in the data CI and a pointer to the
beginning of that CI.
VSAM index can consists of more than one index level. Each level contains a
set of records with entries giving The location of the records in the next lower level.

iFrames Technologies 12
Mainframe VSAM

• Sequence Set: contains the index CI’s at the lowest level.


There is one CI in the sequence set for each data CA. It contains pointers and high
key information for each CI within the data CA. It contains also horizontal pointers
from one sequence set CI to the next sequence set CI.
• Index Set: remainder of the index component.
If there is more than one sequence set level record, VSAM automatically builds
another index level. Each CI in the index set contains pointers and high key
information for CI’s in the next lower level of the index.

IS1 Index set


IS2IS3
Index
Component
SS1 SS2 SS3 SS4 SS5 Sequence set

CA1 CA2 CA3 CA4 CA5

CI1 CI1 CI1 CI1 CI1


CI2 CI2 CI2 CI2 CI2
Data
Component CI3 CI3 CI3 CI3 CI3

TYPICAL KSDS PROCESSING:

INDEX COMPONENT
079 236

007 021 079 FS 099 124 236 FS


001 002 004 007

DATA COMPONENT

008 012 018 021

0
67 079
iFrames Technologies 13
Mainframe VSAM

084 087 099


CONTROL AREAS

There are three


methods by which to 111 124
access a KSDS. These are
sequential, direct, or skip-
sequential. 2
38
Sequential access
is used to load a KSDS,
and to retrieve, update,
add and delete records in
an existing data set.
Sequential access means that records are retrieved one-by-one, starting from the
first record, in the order that they are placed in the dataset.. When retrieving
records, you do not need to specify key values because VSAM automatically obtains
the next logical record in sequence. The sequence set is used to find the next logical
CI. Sequential access allows you to avoid searching the index more than once.
Sequential is faster than direct for accessing multiple data records in ascending key
order.
Direct access is used to retrieve, update, add and delete records in an
existing data set. You need to supply a key value for each record to be processed.
You can supply the full key or a generic key. The generic key is the high order
portion of a full key. For example, you might want to retrieve all records whose keys
begin with XY (where XY is the generic key), regardless of the full key value. VSAM
searches the index from the highest-level index set CI to the sequence set for a
record to be accessed. Vertical pointers in the sequence set CI are used to access the
data CA containing the record. Direct access saves you a lot of overhead by not
retrieving the entire data set sequentially to process a small percentage of the total
number of records.
Skip-sequential access is used to retrieve, update, add and delete records in
an existing data set. In skip-sequential method of access, the record pointer can be
placed anywhere within the dataset (by giving the key) and records can then be
retrieved sequentially from that point.

LOADING A KSDS:
When loading a KSDS, logical records are stored in ascending key sequence
within a data CI. The data component for a KSDS can contain user specified
FREESPACE. This free space is used later, when records are inserted or expanded.
• CI Free Space: Percentage of CI left empty / unused at load time.
• CA Free Space: Percentage of CIs in eachFSdata CA empty / unused at load
time.
SEQUENCE SET CI

4037 4065 4077

iFrames Technologies 14
Mainframe VSAM

CI 0 4012 4023 4034 4037 FREE SPACE

CI 1 4041 4050 4052 4085 FREE SPACE

CI 2 4072 4073 4075 4077 FREE SPACE

FREESPACE
CI 3

UPDATING A KSDS CLUSTER:


Insertion:
While Inserting a Record in the KSDS Cluster, the records are placed in logical
sequence. The CI free space is used. The Index Component is not altered.
Deletion:
While deleting a record from the KSDS Cluster, the records are physically removed
from CI. The records in CI with higher keys are shifted left and the available free
space in the CI is increased. The Index Component is not altered.
INSERT 4058

SEQUENCE SET CI

4037 4065 4077 FS

CI 0 4012 4023 4034 4037 FREESPACE

CI 1 4041 4050 4052 4058 4065


DATA CA CI 2
4072 4073 4075 4077 FREESPACE

FREE SPACE
CI 3

CONTROL INTERVAL SPLIT

When inserting a record in the CI, if there is no enough free space in the CI,
then the CI will be split as follows:

iFrames Technologies 15
Mainframe VSAM

• Half of the full CI is moved to an empty / free CI within same CA. So, CA free
space is used.
• A new index entry is inserted in the sequence set record.
• The existing index entry is updated in the sequence set record.
As a result of the CI split, the physical sequence of the data is no longer the
same as the logical sequence.
This will be illustrated by the following diagram.
.
INSERT 4046
SEQUENCE SET

4037 4050 4065 4077

4012 4023 4034 4037 FREE SPACE

CI 0
4041 4046 4050 FREE SPACE

CI 1
4072 4073 4075 4077 FREE SPACE
DATA CA
CI 2
4052 4058 4065 FREE SPACE

CI 3

CONTROL AREA SPLIT

When there are no more free CI s in the CA then VSAM performs a control
area split.
o VSAM allocates a new CA at the end of the data component
o Approximately half of the data CI s are moved from the full CA to the
new CA.
o A new sequence set CI is created for the new data CA.
o The old sequence set CI is modified
o The index set is updated. In the given below example a new index set
CI will be created that will be the highest-level index set CI. Then VSAM
performs a control Interval split.
This will be illustrated by the following diagram.

iFrames Technologies 16
Mainframe VSAM

TO INSERT 4074

AFTER
BEFORE

SEQUENCE SET CI INDEX SET CI

4037 4050 4065 4077 4065


4077

SEQUENCE SET CI

4037 4050 4065 4074 4077


40654040654065

4012 4012
4023 4034 4037 4023 4034 4037

4041 4046 CA1 4050 4050


4041 4046
4073 4075
4072 4076 4077 4052 4058 4065
4052 4058 4065
FREE SPACE

4072 4073 4074

4076 4077 4075


CA2
FREE SPACE

FREE SPACE

SPANNED RECORDS

• Spanned records are records with a record size greater than the CI size
specified.

iFrames Technologies 17
Mainframe VSAM

• Spanned records can only be used in ESDS or KSDS organizations.


• Spanned records can “span” control intervals, but not control areas. So, one
spanned record is stored in several CI’s.

RECORD 1

RECORD 1 R R C RECORD 1 R R C RECORD 1 UNUSED R R C


SEGMENT1 D D I SEGMENT2 D D I SEGMENT3 SPACE D D I
F F D F F D F F D
2 1 F 2 1 F 2 1 F

As in the above diagram, the spanned record spans three CI’s. The ‘segment’
of the first CI contains part of data along with two RDF’s and one CIDF. The right
RDF gives the length of the segment. The left RDF gives the update number of the
segment (used to maintain update consistency of all segments during an update).
A CI that contains the record’s segment of a spanned record contains control
information. However a new record cannot be inserted into the same CI. As in the
diagram, the third CI contains the spanned data, and the rest of the space becomes
unused space. A new record would move into the fourth CI.

ACCESSING SPANNED RECORDS

Spanned records must be accessed in MOVE mode. The application program must
contain a work area as the largest spanned record in the data set.

iFrames Technologies 18
Mainframe VSAM

DATA BUFFERS

CI 1

CI 2

CI 3

WORK AREA

ADDRESS SPACE

REVIEW QUESTIONS:

1. Specifying CISZ (4096) at the cluster level for a KSDS results in

a) VSAM ignoring the specification


b) Data and index CISZ 4k each
c) Data CISZ 4k; index CISZ selected by VSAM
2. What is the use of Free Space in KSDS?
3. How do you define a KSDS?
4. VS COBOL II supports SKIP processing.
a) TRUE
b) FALSE
5. VSAM request macros (e.g., GET, PUT) point to which other macro(s)?
a) OPEN
b) ACB
c) RPL
d) CLOSE
e) (B) and (C)
6. NONSPANNED records may be accessed in either MOVE mode or LOCATE
mode.
a) TRUE
b) FALSE
7. What does a file status of 02 on a VSAM indicate?
8. Explain CI split and CA split

iFrames Technologies 19
Mainframe VSAM

CHAPTER - 4: ACCESS METHOD SERVICES (AMS)


One of VSAM’s strength is that a single set of data management facilities
called Access Method Service (AMS) manages both VSAM and non-VSAM datasets.
IDCAMS is a general-purpose utility program, used with VSAM, to establish
and maintain catalogs and data sets. It provides the services described above, and
more.
AMS uses a command processor called IDCAMS to handle a variety of
functions such as creating, reproducing, printing datasets and listing catalog
contents. These functions of AMS are performed thru functional commands.
A functional command can have one or more parameters that can be
positional or keyword. Positional parameters are identified by its position in relation
to other parameters: a keyword parameters can be used in any place in relation to
other keyword parameters because it is identified by the particular keyword used.
Types of AMS commands
• Functional commands
• Modal commands
Commonly used AMS commands
AMS command Function
Functional commands
ALTER Changes information specified for a catalog, cluster,
alternate index, or path at define time.
BLDINDEX Builds an alternate index.
DEFINE ALTERNATE Defines an alternate index.
INDEX
LISTCAT List information about data sets
REPRO Copies records from one file to another. The input and
output files can be VSAM or non-VSAM
PRINT Prints the contents of a VSAM or non-VSAM file.
DEFINE CLUSTER Defines a VSAM file, whether it’s KSDS, ESDS, or RRDS
DEFINE MASTER Defines a master catalog
CATALOG
DEFINE PATH Defines a path that relates an alternate index to its base
cluster
DEFINE USERCATALOG Defines a user catalog.
DELETE Removes a catalog entry for a catalog, cluster, alternate
index or path
EXPORT Produces a transportable file.
IMPORT Copies a previously exported file.

iFrames Technologies 20
Mainframe VSAM

Modal commands
IF Controls the flow of command execution by testing
condition codes returned by functional commands
SET Controls the flow of command execution by altering
condition codes returned by functional commands
PARM Sets options values that effect the way AMS executes.

AMS PERFORMANCE PARAMETERS

1) CONTROL INTERVAL SIZE

Syntax : CONTROLINTERVALSIZE (bytes)


Abbr : CISZ or CISIZE
Default : Calculated by VSAM
Control Interval size (CIDF & RDF) & FREESPACE must be taken into account
Thumb Rule for CISIZE
If the record length is <8192, multiples of 512, >=8192, multiples of 2048

2) FREESPACE
Syntax : FREESPACE (CI% CA%)
Default : FREESPACE(0 0)
• High Free space results in more I/O & consumes larger DASD space
• Very low FREESPACE results in CI splits and degrades performance
• Amount of FREESPACE depends on
o Rate of growth of records
o Expected number of records to be deleted
o Reorganization frequency
o Performance consideration
o
o 3) BUFFERSPACE
o Syntax : BUFFERSPACE (bytes)
o Abbr : BUFSP
o Default : Two data buffers plus one
additional index buffer for KSDS
o Used to improve Input/output performance
o Can also be specific in JCL EXEC parameter
o
o //DD1 DD DSNAME=ANYVSAM1,
o // AMP=('BUFND=4,BUFNI=4,STRNO=2')

iFrames Technologies 21
Mainframe VSAM

o
o More on VSAM Buffers
o
• Strings (STRNO in AMP parameter)
o Defines number of concurrent access
o For batch processing, a string of 1 is enough
o For online processing more strings is required
• Data Buffers (BUFND in AMP parameter)
• Random Access
o Minimum of 2 (One for normal access and one for split
processing) is required
Sequential Access
Ideal to process a track
Allocate number of buffers based on the number of CI/TRK
For READ add 1 more buffer and for WRITE add 2 more buffers
Index Buffers (BUFNI in AMP parameter)
Default of 1 index buffer is enough
Random Access
Ideal to keep the index set in virtual memory
Determine the number of levels (using LISTCAT)
Allocate number of levels + 1 buffer
o
o 4) RECOVERY / SPEED
Mutually Exclusive
RECOVERY allows you to recover if the job initially loading the dataset fails
SPEED is faster, but does not provide restart feature
• Default:
RECOVERY

• 5) SPANNED
• Syntax :

SPANNED/NONSPAN
NED
• Default
:
NONSPANNED
• Allows large records to span more than one Control Interval
• However, the records cannot span across Control areas
• RRDS does not support spanned records.

iFrames Technologies 22
Mainframe VSAM

• 6) KEYRANGES
• Syntax : KEYRANGES (Low - Val; High - Val)
• Default : None (No range assumed)
• Example :
• KEYRANGES ((000001 100000)+
• 100001 200000))
• The Key Ranges correspond to VOLUMES if ORDERED clause is specified.
• 7) ORDERED
• Syntax : ORDERED / UNORDERED
• Default: UNORDERED
• Goes together with KEYRANGES clause specifies the volume to which
the key values should go.

• 8) REUSE
• Syntax : REUSE/NOREUSE
• Default : NOREUSE
• REUSE specifies that the cluster can be loaded with fresh records with
an implicit delete of existing RECORDS
• REUSE cannot be used under following circumstances and hence not
recommended
• When KEYRANGES parameter is coded
• When alternate indexed are defined

• 9) REPLICATE
• Directs the VSAM to duplicate each index as many times as it will fit on
its assigned track
• Applies only to KSDS index component
• To reduce rotational delay and to make I/O faster
• Syntax : Replicate / No replicate
• Default : No replicate

• 10) VOLUMES
• Can specify different volumes for
• Data component
• Index component

• 11) IMBED
• Directs the VSAM to place the sequence set (the lowest level of index
next to the data component) on the first track of the data control area and
duplicate it as many times as it will fit. This process will reduce rotational
delay because the desired sequence set record is found faster
• Default: NO IMBED

iFrames Technologies 23
Mainframe VSAM

• Syntax : IMBED / NO IMBED


• Note:
• IMBED applies to the index component. Hence it is limited to a KSDS.
• IMBED places the sequence set CI for a data control area within the control
area.
• Uses IMBED only with large control area sizes.
• IMBED requires additional DASD space.
• IMBED should provide faster access to data.

• 12) SHARE OPTION
• Syntax : SHAREOPTIONS (Cross-region-value Cross-system-Val)
• Cross-region : Concurrent data access on a standalone system
(ex: TSO&CICS accessing same data)
• Cross-system : Data access for multiple computers (Two
different computers that are inter-connected)
• Default : SHAREOPTIONS (1 3)
• Multiple jobs can read only if no update takes place - Complete data integrity
• Multiple jobs can read and at the same time one job can update - Write, but
not read integrity
• Multiple jobs can read & write simultaneously - No integrity
• Same as option 3, but refreshes buffer after every read
• Share options 1 & 2 are not allowed for cross-system
• For cross region sharing, each batch job must have DISP=SHR
• For cross system sharing DISP parameter in the JCL is immaterial

• 13) ERASE / NOERASE
• Default : NOERASE
• ERASE instructs VSAM to move zeroes to all the bytes once the cluster is
deleted.

• INVOKING IDCAMS
• //MYJOB JOB……………
• //STEPA EXEC PGM = IDCAMS
• //SYSPRINT DD SYSOUT = *
• //SYSIN DD *
• DEFINE CLUSTER –
• .
• .
• IDCAMS commands can be processed as a job or job step (by
specifying PGM=IDCAMS) on the EXEC card.

iFrames Technologies 24
Mainframe VSAM

• BASIC IDCAMS COMMANDS


• The following are the commands which will be used with IDCAMS procedure.
• BUILDINDEX
• DEFINE
• IMPORT/EXPORT
• LISTCAT
• REPRO
• VERIFY
• AMS COMMAND SYNTAX

COMMAND PARAMETERS TERMINATOR

SERVICEFURTHER END OF COMMAND


REQUESTED DESCRIBES COMMAND

• Margins Default to 2&72


• Separators BLANK,COMMA
• Comments /*----------------*/
• Continuation HYPEN, PLUS SIGN
• Terminator SEMICOLON or Absence of Continuation mark
• There are two possible continuation characters:
• The PLUS sign (+): ignores the leading blanks on the next line.
• The HYPEN sign (-): doesn’t ignore the leading blanks on the next line.

• DEFINE SPECIFICATONS


• Data Set Name
• Data Set Type

Space Allocation

Where?

• How much?
• Data Set Attributes


• When defining a VSAM cluster using the DEFINE CLUSTER command, the
following must or can be specified.

iFrames Technologies 25
Mainframe VSAM

• The data set name:


• The cluster name is required.
• Component name(s) is/are optional.
• The type of the date set type:
• KSDS, ESDS, RRDS, LDS.

• The data set attributes:
• Record size and control interval size.
• For a KSDS: Key information and free space distribution.
• BASIC DEFINE COMMAND SYNTAX FOR CLUSTER:
• The DEFINE CLUSTER Command
• DEFINE CLUSTER ( NAME(entry – name)
• [ OWNER(owner – id) ]
• [ FOR(days) | TO(date) ]
• [ INDEXED | NONINDEXED | NUMBERED ]
• [ RECORDSIZE (avg max) ]
• [ CISZ(size)]
• [ SPANNED | NONSPANNED]
• [ KEYS (length offset)]
• [ FREESPACE ( ci ca) ]
• [ VOLUMES ( vol-ser no..)]
• [ FILE (ddname) ]
• [ { cylinders /kilobytes/megabytes/tracks/records} (primary
secondary)}]
• [ UNIQUE | SUBALLOCATION]
• [ REUSE | NOUSE]
• [ SHAREOPTIONS ( a b)]
• [ IMBED | NOIMBED]
• [ STORAGECLASS(storage – class)]
• [ DATACLASS(data-class)]
• [MANAGEMENTCLASS (management- class)]
• [ DATA ( [ NAME (entry – name) ]
• [ VOLUMES (vol –ser ….)]
• [ FILE (ddname) ]
• [ { cylinders/kilobytes/megabytes/tracks/ records} (primary
secondary) ] ) ]

• [ INDEX ( [ NAME( entry – name) ]
• [ VOLUMES ( Vol –ser ….)]
• [ { cylinders/kilobytes/megabytes/tracks/ records} (primary
secondary) ] ) ]

iFrames Technologies 26
Mainframe VSAM


• [CATALOG ( name [/ password]) ]

• Explanation
• NAME (entry –name) Specifies the name of the cluster or
component
• OWNER (owner –id) Specifies a 1 to 8 character owner-id.
• FOR (days) TO (date) Specifies a retention period ( in the format
dddd) or an expiration date (in the format
yyddd)
• INDEXED / NONINDEXED/NUMBERED Specifies the file organization: SDS

INDEXED), SDS NONINDEXED), OR RRDS


NUMBERED). The default is INDEXED.
• RECORDSIZE ( avg max) Specifies the average and maximum
record size.
• CISZ (Size) Specifies the size of the control intervals.
• SPANNED / NONSPANNED Specifies whether records can cross
control interval boundaries. The
default is NONSPANNED.
• KEYS (length offset) Specifies the length and offset of the
primary key.
• FREESPACE (ci ca) specifies the percentage of free space to
reserve in the control intervals and
control areas.
• VOLUMES (Vol-ser) Specifies one or more volumes that will
contain the cluster or component.
• FILE (dd name) Specifies a dd name that identifies a DD
statement that allocates the
volumes .Required only for mountable
DASD volumes.
• Primary Specifies the amount of space to initially
allocate, expressed in terms of cylinders,
kilobytes, megabytes, tracks or
records.
• Secondary Specifies the secondary space allocation.
• UNIQUE/SUBALLOCATION Specifies whether the file is unique or sub
allocated. The default is
SUBALLOCATION.
• REUSE / NOREUSE Specifies whether a file is reusable. The
default is NOREUSE.
• SHAREOPTIONS ( a b) Specifies the level of the file sharing
permitted.
• IMBED / NOIMBED Specifies whether sequence set records
should be imbedded in the data component of
a KSDS. The default is NOIMBED.

iFrames Technologies 27
Mainframe VSAM

• CATLOG (name[/password]) Specifies the name and password of the


catalog that will own the cluster. If
omitted, the high- level qualifier of the
cluster name or the stepcat, jobcat,
or master catalog identifies the catalog.

• NAME is a positional keyword parameter and must be coded first. Other
keywords can be placed anywhere
• EXAMPLES OF THE DEFINE CLUSTER:
• Example #1
• Define a key-sequenced data set (KSDS)
• DEFINE CLUSTER ( NAME (MTRG.CUSTOMER.MASTER) -
• OWNER(MTRG) -
• INDEXED -
• RECORDSIZE(80 80) -
• KEYS(6 0) -
• VOLUMES(SMS007) -
• UNIQUE -
• SHAREOPTIONS( 2 3) -
• IMBED) -
• DATA ( NAME(MTRG.CUSTOMER.MASTER.DATA) -
• CYLINDERS(50 5) -
• CISZ(4096) ) -
• INDEX ( NAME(MTRG.CUSTOMER.MASTER.INDEX))

• Example #2
• Define an entry-sequenced data set (ESDS)
• DEFINE CLUSTER (NAME (MTRG.CUSTOMER.MASTER) -
• OWNER (MTRG) -
• NONINDEXED -
• RECORDSIZE (180 80) -
• VOLUMES (SMS007) -
REUSE)
-
• DATA ( NAME (MTRG.CUSTOMER.MASTER.DATA) -
• CYLINDERS (50 5) )

• Example #3
• Define an relative-record data set (RRDS)
• DEFINE CLUSTER (NAME (MTRG.CUSTOMER.MASTER) -
• OWNER (MTRG) -
• NUMBERED -

iFrames Technologies 28
Mainframe VSAM

• RECORDSIZE (180 80) -


• VOLUMES (SMS007) -
UNIQUE)
-
• DATA (NAME (MTRG.CUSTOMER.MASTER.DATA) -
• CYLINDERS (50 5) )


• REVIEW QUESTIONS:
• 1. What is IDCAMS? And what is the purpose of it?
• 2. What is the significance of the SHAREOPTIONS parameter?
• 3. What is the use of REPRO command?
• 4. What are the different types of AMS commands?
• 5. What are the basic IDCAMS commands?
• 6. AMS will generate a data component name if it is not explicitly coded.
• a) TRUE
• b) FALSE
• 7. What are the parameters used in AMS commands?
• 8. Can AMS commands be run from the TSO prompt?
• 9. What is the base cluster?

• CHAPTER - 5: Creation of Clusters

• CREATION OF VSAM DATA SETS THROUGH JCL



// DD statement…………
with new parameters
and/or
info from ‘DATA CLASS’

• A Data Class is a description of data set characteristics under control


of SMS.
• JCL parameter overrides the specifications from a Data Class. VSAM
accomplishes JCL simplification by centralizing functions such as defining,

iFrames Technologies 29
Mainframe VSAM

deleting, and altering file characteristics in the AMS Utility program. VSAM
has much simpler JCL requirements than files of other access methods.

• How to allocate existing VSAM files
• The DSNAME parameter
• The DUMMY parameter
• The DISP parameter
• The AMP Parameter

• How to create VSAM files using JCL.
• The DD statement for allocating existing VSAM File

• //ddname dd DSNAME={data-set-name}
• {Dummy}[,Disp={old/shr},Normal-disp,Abnormal-disp]
• [,AMP=(option,option….)]

• Explanation:
• DSNAME Specifies the name of the VSAM dataset. Normally, the high
level qualifier of the name identifies the owning catalog.
• DUMMY Specifies that a VSAM file should not be allocated; instead, MVS
should simulate a VSAM FILE.
• DISP Specifies the file’s status and, the file’s normal & abnormal
disposition. The valid status options are OLD for exclusive access
and SHR for shared access. All of the disposition options
except UNCATLG are valid for VSAM files.
• AMP Specifies one or more processing options for VSAM files.

• The AMP parameter
• The AMP parameter is for VSAM files & the DCB parameter is for non-
VSAM files. It specifies execution time information that affects how the file is
processed.

• The AMORG sub parameter
• AMORG indicates that the files being accessed is a VSAM file.
Normally, MVS realizes that a VSAM file is being processed when it retrieves
the catalog information for the file. So we need to specify AMP=AMORG when
MVS doesn’t search the catalog.

• The AMP parameter
• AMP=[ AMPORG]
• [,BUFND=n]
• [,BUFNI=n]
• [,BUFSP=n]

iFrames Technologies 30
Mainframe VSAM

• [,OPTCD=OPTIONS]
• [,RECFM=FORMAT]
• [,STRNO=N]
• Explanation
• AMORG Specifies that the data set is a VSAM file. Normally not
required.
• BUFND Specifies the number of buffers to allocate for the data
component.
• BUFNI Specifies the number of buffers to allocate for the index
component.
• BUFSP Specifies the total amount of space in bytes to allocate for the
data and index buffers.
• OPTCD options for the ISAM interface. Code I , L, or IL. ‘I ‘ means that
if OPTCD=L is specified for the file in the processing
program, records marked for deletion by hex FF in the first
byte should be physically deleted from the file. If OPTCD=L
is not specified in the program, Specify OPTCD=IL in the DD
statement for the same effect.
• RECFM Specifies the format in which the ISAM program expects to
process records.
• STRNO Specifies the number of concurrent requests the program may
issue against the file.
• Example #1
• //CUSTMAST DD DSNAME=MTRG.CUSTOMER.MASTER, DISP=SHR,
• // AMP=(BUFND=2,BUFNI=6)

• Allocate a VSAM file for shared access, specifying that 2 data buffers
and 6 index buffers should be used.

• Example # 2
• //CUSTISAM DD DSNAME=MTRG.CUSTOMER.MASTER,DISP=SHR,
• // AMP=(AMORG,OPTCD=IL,RECFM=FB)

• Allocate VSAM file using the ISAM interface program, AMORG identifies
the file as VSAM, OPTCD specifies how logically deleted records should be
handled and RECFM specifies that the program expects fixed-length blocked
records.

• NEW PARAMETER USED IN VSAM

• ES
• RECORG = KS
RR
• LS
• KEYOFF = offset-to-key

iFrames Technologies 31
Mainframe VSAM

• (for KSDS Only)



• KEYLEN =Bytes
• (for KSDS and some non-VSAM data sets)

• RECORG parameter
o KS specifies a VSAM key-sequenced data set
o ES specifies a VSAM entry-sequenced data set
o RR specifies a VSAM relative record data set.
o LS specify a VSAM linear space data set.
o
o KSDS (EX1)
o
KSDS //DD1 DD DSNAME = MY.KSDATA,
o // DISP=(NEW,CATLG),
o // SPACE=(400,(50,5)),
// AVGREC=K,
o
// RECORG =KS
o // KEYLEN= 15,
o // KEYOFF=0,
// LRECL=250
o
o
o ESDS (EX2)
o
// DD2 DD DSNAME=MY.ESDATA
o // DISP=(NEW,CATLG),
o // SPACE=(100,(10,8)),
// RECORG =ES
o // LRECL=50
o
o
o RRDS (EX3)
o
LINEAR //DD3 DD DSNAME=&LIN,
o // DISP=(NEW,PASS),
o // SPACE=(1,(10)),
// AVGREC=M,
o
// RECORG=LS
o
o
o Not all VSAM options can be specified in the JCL, more options
and defaults may come from a Data class.
• EX1 shows a JCL statement containing all required information for a KSDS
data set.

iFrames Technologies 32
Mainframe VSAM

• Ex2 shows a JCL statement containing all required information for an ESDS
data set.
• Ex 3 shows a JCL statement of a temporary linear data set. This example
requires the assignment of a so-called storage Class.

• REPRO Command
• REPRO is an all-purpose load and backup utility command .
• It loads an empty VSAM cluster with records. The data and index components
(for a KSDS) are build automatically.
• It creates a backup of a VSAM dataset on a physical sequential dataset, and
then restore and rebuilds the VSAM dataset using this dataset as input
• It merges data from two VSAM datasets.

• REPRO terminates if One physical I/O error while writing to the output
dataset.
• A total of four errors encountered in any combination:
• A logical error while writing to the output data set.
• A logical error while reading the input data set.
• A physical error while reading the input data set.

• CREATION OF ESDS CLUSTER
• The definition of an ESDS cluster with the parameters described
above.

• //IFMAIN2 JOB (12345678),IFMAIN2,MSGCLASS=H,
• // MSGLEVEL=(1,1),CLASS=A,NOTIFY=&SYSUID
• //STEP1 EXEC PGM=IDCAMS
• //SYSOUT DD SYSOUT=*
• //SYSPRINT DD SYSOUT=*
• //SYSIN DD *
• DEFINE CLUSTER -
• (NAME (IFMAIN2.esds.CLUST) -
• RECORDSIZE (80,80) -
• TRACKS(5, 1) -
• CISZ(4096) -
• NONINDEXED -
• REUSE) -
• DATA (NAME(IFMAIN2.IFRAME.CLUST.DATA))
• /*
• //

iFrames Technologies 33
Mainframe VSAM

• The above example shows the creation of an ESDS cluster. After the
execution of this JCL the blank cluster will be created and it will be in the user
catalog for usability.

• COPYING ENTIRE DATA SETS
• The following screen shot will copy the EMP1.PS content to the above
created ESDS cluster, KSDS
• In this example, an entire input data set is copied to the output data set.
• Two parameters of REPRO are used.
• INDATASET (or IDS) Name of the entry to be copied or of the user catalog to
be merged.
• OUTDATASET (or ODS) Name of the target data set.
• Both INDATASET and OUTDATASET can be used to reference VSAM or non-
VSAM data sets.
• Example:
• //IFMAIN2 JOB NOTIFY=&SYSUID

• //STEP1 EXEC PGM=IDCAMS


• //SYSPRINT DD SYSOUT=*
• //SYSOUT DD SYSOUT=*
• //DD1 DD DSN=IFMAIN2.EMP1.PS,DISP=SHR
• //DD2 DD DSN=IFMAIN2.ESDS.CLUSTER,DISP=SHR
• //SYSIN DD *
• REPRO INDATASET(IFMAIN2.EMP1.PS) -
• OUTDATASET(IFMAIN2.ESDS.CLUSTER)
• /*
• //

• CREATION OF KSDS CLUSTER WITH REUSE OPTION.
• REUSE specifies that the cluster can be loaded with fresh records with
an implicit delete of existing records. The REUSE parameter can be specified
on both the DEFINE CLUSTER and the REPRO command.

• Example:
• //ifmain2 job notify=&sysuid
• //STEP1 EXEC PGM=IDCAMS
• //SYSPRINT DD SYSOUT=*
• //SYSOUT DD SYSOUT=*
• //SYSIN DD *
• DEFINE CLUSTER(NAME(IFMAIN2.KSDS.CLUSTER)-
• TRACKS(2,5)-
• RECORDSIZE(80,80)-

Here the KSDS


iFrames Technologies cluster 34
is
created with
REUSE option
Mainframe VSAM

• CONTROLINTERVALSIZE(512)-
• FREESPACE(20,20)-
• KEYS(4,0)-
• REUSE-
• INDEXED))-
• DATA(NAME(IFMAIN2.KSDS.DATA))-
• INDEXED(NAME(IFMAIN2.KSDS.INDEX))
• /*
• //

• REUSE cannot be used under following circumstances and hence not
recommended
• When KEYRANGES parameter is coded
• When alternate indexed are defined

• CREATION OF RRDS CLUSTER
• The following screenshot shows the definition of an KSDS cluster with
the parameters described above
• Example:
• //IFMAIN2 JOB NOTIFY=&SYSUID
• //STEP1 EXEC PGM=IDCAMS
• //SYSPRINT DD SYSOUT=*
• //SYSOUT DD SYSOUT=*
• //SYSIN DD *
• DEFINE CLUSTER(NAME(IFMAIN2.RRDS.CLUSTER)-
• TRACKS(2,5)-
• RECORDSIZE(80,80)-
• CONTROLINTERVALSIZE(512)-
• NUMBERED))-
• DATA(NAME(IFMAIN2.RRDS.DATA))
• /*
• //

• REPRO RECORD SELECTION
• DATA set can be copied partially using starting and ending delimiter
parameters on the REPRO command
• number = Number of records
• key-value = Record key for a KSDS
• rba = relative byte address for a record in a KSDS or ESDS
• rrn = Relative record number(slot) for RRDS records
• Where to start Where
to stop

• KSDS FROMKEY (rec-key) TOKEY (rec-key)

iFrames Technologies Here thEMP1.PS is 35


entirely copied to
ESDS.CLUSTER
Mainframe VSAM


• KSDS, ESDS FROMADDRESS(rba) TOADDRESS(rba)

• RRDS FROMNUMBER (rrn) TONUMBER (rrn)

• KSDS, ESDS SKIP(number) COUNT(number)
• RRDS, ISAM

• The Following The Selection Of Records In Different VSAM Files.
• ESDS CLUSTER
• //IFMAIN2 JOB NOTIFY=&SYSUID

• //STEP1 EXEC PGM=IDCAMS


• //SYSPRINT DD SYSOUT=*
• //SYSOUT DD SYSOUT=*

• //INPUT DD DSN=IFMAIN2.ESDS.CLUSTER,DISP=SHR

• //SYSIN DD *
• PRINT-
• INFILE(INPUT)-
• CHAR-

• FROMADDRESS(0)TOADDRESS(160)

• /*
• //

• The above program will display only the selected RBA address records which
are shown by the following screenshots.
• KSDS CLUSTER
• The following use the keys to select the particular records from the kSDS
cluster
• Example:
• //IFMAIN2 JOB NOTIFY=&SYSUID

• //STEP1 EXEC PGM=IDCAMS


• //SYSPRINT DD SYSOUT=*
• //SYSOUT DD SYSOUT=*

• //INPUT DD DSN=IFMAIN2.KSDS.CLUSTER,DISP=SHR

• //SYSIN DD *
• PRINT-

iFrames Technologies 36
Mainframe VSAM

• INFILE(INPUT)-
• CHAR-

• FROMKEY(1000)TOKEY(1004)

• /*

• //

• RRDS CLUSTER
• The following screen shots use the keys to select the particular records from
the kSDS cluster
• //IFMAIN2 JOB NOTIFY=&SYSUID

• //STEP1 EXEC PGM=IDCAMS


• //SYSPRINT DD SYSOUT=*
• //SYSOUT DD SYSOUT=*
• //INPUT DD DSN=IFMAIN2.RRDS.CLUSTER,DISP=SHR
• //SYSIN DD *
• PRINT-
• INFILE(INPUT)-
• CHAR-
• FROMNUMBERED(1000)TONUMBERED(1004)
• /*
• //
• REVIEW QUESTIONS:

• 1. Which of the following repro selection parameters can be specified for an
LDS?
• a) From key b) from address
• c) From number d) skip e) none of the above.

• 2. REPRO will stop processing records when a total of four physical I/O errors
occur while writing to the output data set.
A. TRUE
B. FALSE
C.
D. 3. REPRO REUSE against a non-empty target data set with NOREUSE will
reset target data set.
A. TRUE
B. FALSE
C.
D. 4. AMS will generate a data component name if it is not explicitly coded.

iFrames Technologies 37
Mainframe VSAM

A. TRUE
B. FALSE
C.
D. 5. When defining a KSDS, which of the following parameters is not required?
E.
A. Space allocation (either CYL, REC or TRK)
B. VOLUMES
C. KEYS
D. NAME
E.
F. 6. DEFINE CLUSTER for a KSDS will generate CLUSTER, DATA and INDEX
information even if only CLUSTER information is specified.
A. TRUE
B. FALSE
C.
D. 7. A “candidate” volume is not used when the data set is initially loaded.
A. TRUE
B. FALSE
C.
D. 8. If the key of a KSDS record begins in the second field (first field is 25 bytes
long), the offset in the KEYS parameter is:
E.
F. a) 24 b) 25 c) 26 d) None of the above.
G.
H. 9. Suppose TEST.DATASET is a KSDS. The following statement will print
CLUSTER information only: LISTCAT ENTRIES (TEST.DATASET) ALL
a. TRUE
b. FALSE.
c.
d.
e.
f.
g.
h.
i.
j.
k.
l.
m.
n.
o.

iFrames Technologies 38
Mainframe VSAM

p.
q.
r. CHAPTER --- 6 : Print and Additional Commands
s.
t. PRINT COMMAND
u. The PRINT command of Access Method Services is used to print
the contents of both VSAM and non-VSAM data sets. The command
syntax is similar to that of REPRO. While REPRO copies an input data
set into another output data set, PRINT dumps an input data set to a
printer. This command is versatile and can be used to print a complete
data set or only a selected part of it.
v.
w. The PRINT command
x.
y. PRINT { INDATASET(entry-name [/ password])}
z. [{CHARACTER/HEX/DUMP}]
aa. [{SKIP(count)/

FROMKEY(key)/FROMNUMBER(number)/FROMADDRESS(address)}]
bb.
[{COUNT(count)/TOKEY(key)/TONUMBER(number)/TOADDRESS(addre
ss)]
cc.
dd. Explanation
ee. CHARACTER/HEX/DUMP -Specifies the format of the output.
CHARACTER & HEX print the data in character or hex format. DUMP
prints data in both character and hex format. DUMP is default.
ff.
gg. Example
hh. To print records 29, 30 & 31 in character format.
ii. PRINT INDATASET(MTRG.CUSTOMER.MASTER) -
jj. CHARACTER -
kk. SKIP(28) -
ll. COUNT(3)
mm.
nn. To print records 29,30 & 31 in dump format.
oo. PRINT INDATASET (MTRG.CUSTOMER.MASTER) -
pp. DUMP -
qq. SKIP(28) -
rr. COUNT(3)
ss.
tt. Example:
uu. //ifmain2 job notify=&sysuid

iFrames Technologies 39
Mainframe VSAM

vv. //step1 exec pgm=idcams

ww. //sysprint dd sysout=*

xx. //sysout dd sysout=*

yy. //input dd dsn=ifmain2.rrds.cluster,disp=shr

zz. //sysin dd *
aaa. Print-
bbb. Infile(input)-
ccc. Char-
ddd. Skip(1)-
eee. Count(3)
fff. /*
ggg. //
hhh.
iii. EXPORT/IMPORT COMMAND
jjj. Export extracts catalog information and creates a copy of the
data records. When a base cluster and its alternate index are
permanently exported, the alternate index must be exported before
the base cluster. When exporting a data set for backup purpose specify
TEMPORARY to preserve the original data set.
kkk.
lll. EXPORT IMPORT

mmm.
nnn. Advantages
• Used for backup and recovery
• Catalog information also exported along with the data, unlike REPRO
• DFSMS classes are preserved

iFrames Technologies 40
Mainframe VSAM

• Cluster deletion and redefinition are not necessary during the import
• Can be easily ported to other systems
• Disadvantages
• The EXPORTED file not reusable until it is imported
• Slower than REPRO

Catalog Data set

EXPORT



• SYNTAX FOR EXPORT
• EXPORT entryname[/password] -
• {outfile(ddname) outdataset(entryname)} -
• [CIMODE | RECORDMODE] -
• [TEMPORARY | PERMANENT] -
• [INHIBITSOURCE
• NOINHIBITSOURCE] -
• [INHIBITTARGET
• |NOINHIBITTARGET] -
• [ERASE | NOERASE] -
• [PURGE | NOPURGE]

• RECORD MODE – RECORDS ARE EXPORTED ONE LOGICAL RECORD AT A
TIME.
• RECORDMODE is the default for ESDS, KSDS, and RRDS.
• CIMODE – CI rather than logical record exports data. CIMOD is
default for LDS.
• TEMPORARY – The data set is not deleted after export.
• PERMANENT- The data set is deleted after export.

iFrames Technologies 41
Mainframe VSAM

• INHIBITSOURCE – The original data set becomes read-only.


• NOINHIBITSOURCE - The original data can be updated.
• INHIBITTARGET - The copy data set becomes read-only.
• NOINHIBITTARGET - The target data set can be updated.
• ERASE - Causes the exported item to be overwritten with zeros
when it is deleted.
• NOERASE – Override whatever was specified for the item when it
was created.
• Example:
• //IFMAIN2 JOB NOTIFY=&SYSUID
• //STEP1 EXEC PGM=IDCAMS
• //SYSPRINT DD SYSOUT=*
• //SYSOUT DD SYSOUT=*
• //DD1 DD DSN=IFMAIN2.BACKUP.PS,
• // DISP=(NEW,CATLG,DELETE),
• // UNIT=SYSDA,
• // SPACE=(TRK,(2,3),RLSE),
• // DCB=(LRECL=80,RECFM=FB,BLKSIZE=800,DSORG=PS)
• //SYSIN DD *
• EXPORT-
• IFMAIN2.KSDS.CLUSTER-
• OUTFILE(DD1)
• /*
• //
• Now the above exported file is not available in user catalog. It is
permanently exported to the new PS which is created. To get back the
exported cluster we want to use import option to get back it in our user
catalog. This is illustrated in the following snapshots.

• SYNTAX OF IMPORT
• IMPORT-
• {INFILE(DDNAME) | INDATASET(ENTERYNAME)} –

• {OUTFILE(DDNAME) | UTDATASET(ENTERYNAME)} -

• [OBJECTS((ENTERYNAME - [NEWNAME(NAME)] -
• VOLUMES(VOLSER])[ENTRYNAME….)])] –
• [INTOEMPTY]

• NEWNAME – Objects beginning imported can be renamed.
• VOLUMES – Specifies the volume on which the cluster is to reside if
omitted the original volume is the receiving
volume
• INTOEMPTY – Indicates that the receiving dataset is empty.

iFrames Technologies 42
Mainframe VSAM

• On IMPORT the existing catalog entry is deleted unless the receiving data set
is empty.

IMPORT

Catalog Data set


• The following procedure provides backup and recovery capabilities and also
permits the modification of data set attributes when the data set is imported
during recovery or reorganization.

iFrames Technologies 43
Mainframe VSAM


STEP 4
STEP 1 IMPORT
EXPORT INTOEMPTY

STEP 2 STEP 3
ORIGINAL DELETE DEFINE NEW
MASTER MASTER


• Example:
• //IFMAIN2 JOB NOTIFY=&SYSUID
• //STEP1 EXEC PGM=IDCAMS
• //SYSPRINT DD SYSOUT=*
• //SYSOUT DD SYSOUT=*
• //DD1 DD DSN=IFMAIN2.BACKUP.PS,
• //SYSIN DD *
• IMPORT-
• INFLIE(DD)-
• OUTDATASET(IFMAIN2.KSDS.CLUSTER)
• /*
• //

• VERIFY COMMAND
• Verifies the catalog HURBA (High Used Relative Byte Address) field and stores
the true values from the control block HURBA field.
• It should be used against cluster name only and not against data or index
components.
• It is used to rectify some of the problems due to data corruption
• It can be issued from TSO or from a JCL


• Syntax: VERIFY FILE (<dd name>)

iFrames Technologies 44
Mainframe VSAM

• VERIFY DATASET (<dataset name>)




END-OF-DATA
END-OF-DATA
TEST.DATA.SET ? END-OF-KEY-
END-OF-KEY-RANGE RANGE




• Compares Catalog Information with the Data Set
• Corrects Catalog If A Disagreement Is Found
• Run VERIFY after a system failure.
• When sharing data sets, run VERIFY before opening a data set.
• VERIFY cannot be used for an empty data set or an LDS.



• Example:
• //IFMAIN2 JOB NOTIFY=&SYSUID
• //STEP1 EXEC PGM=IDCAMS
• //SYSPRINT DD SYSOUT=*
• //SYSOUT DD SYSOUT=*
• //SYSIN DD *
• VERIFY DATASET(IFMAIN2.KSDS.CLUSTER)
• /*
• //

• LISTCAT
• LISTCAT Command identify the catalog, the names of the entries to be
listed, the types of entries to be listed, and the amount of information about
each entry to be listed.

• LISTCAT [ CATALOG (name) ]
• [ ENTRIES (name - of - entries) ]
• [LEVEL (generic-level-names)]
• [ NAME/HISTORY/VOLUME/ALLOCATION/ALL}]

iFrames Technologies 45
Mainframe VSAM

• Catalog(name[/password]) Specifies the name and if, required,


password of the catalog from which
entries are to be listed.
• ENTRIES(entry-name[/password]) Specifies the names of the entries you
want to list. If omitted, all entries in
the specified catalog are listed.
• LEVEL(level) Specifies one or more levels of
qualifications. Any data sets whose name
matches those levels are listed.
• Entry –type Specifies the type of entries you want
listed. If both ENTRIES / LEVEL and
entry-type are omitted, all
entries of all types in the
specified catalog are listed. Code one of these
values: ALIAS, CLUSTER, DATA, INDEX, & PATH
• NAME Specifies that only the names and types of
the specified entries are to be listed.
Name is the default.
• HISTORY Specifies that the information listed by
NAME, Plus the history information
(such as creation and expiration dates) is
to be listed.
• VOLUME Specifies that the information listed by
HISTORY, plus the volume locations of
the specified entries, is to be listed.
• ALLOCATION Specifies that the information listed by
VOLUME, plus detailed extent
information, is to be listed.
• ALL Specifies that all available catalog
information for the specified entries is to be
listed.

• Examples
• To list the catalog entry for a VSAM file named
MTRG.CUSTOMER.MASTER
• ENTRIES (MTRG.CUSTOMER.MASTER)
• To list information for more than one file, just code several file names
in a single ENTRIES parameter, like this:
• ENTRIES (MTRG.CUSTOMER.MASTER -
• MTRG.SUPPLIER.MASTER -
• MTRG.ITEM.TRANS)
• We can specify a generic entry name by replacing one or more levels
of the file name with an asterisk.
• ENTRIES (MTRG.*.MASTER)
• All files whose names consists of three levels with MTRG as the first
level and MASTER as the third level, are listed. MTRG.CUSTOMER.MASTER
AND MTRG.SUPPLIER.MASTER meet these criteria, so they would be listed.

iFrames Technologies 46
Mainframe VSAM

• Example:
• //IFMAIN2 JOB NOTIFY=&SYSUID
• //STEP1 EXEC PGM=IDCAMS
• //SYSPRINT DD SYSOUT=*
• //SYSOUT DD SYSOUT=*
• //SYSIN DD *
• LISTCAT ENTRIES(IFMAIN2.VSAM.PDS)
• LISTCAT ENTRIES(IFMAIN2.VSAM.*)
• /*
• //

• ALTER
• We can use this powerful command to change certain attributes of
previously defined VSAM object. These objects include base cluster and it’s
data and index component and even alternate index cluster and it’s data or
index component and even a VSAM or ICF catalog. If you are properly
authorized you can ALTER NON-VSAM data set attributes also.



CATALOG CATALOG
EXAMPLE.KSDS EXAMPLE.KSDS
ALTER EXAMPLE.KSDS
SHAREOPTIONS(1 SHAREOPTIONS(2 3)
SHAREOPTIONS(2
3) 3)


• SYNTAX OF ALTER COMMAND

• ALTER entryname[/password] -
• SHAREOPTION(cross region cross system)
• Examples:
• ALTER MTRG.CUSTOMER.MASTER -
• NEWNAME(MTRG.CUSTMAST)
• ALTER EMPLOYEE.KSDS.CLUSTER
• FREESPACE(25,25)

• Change the filename of MTRG.CUSTOMER.MASTER to MTRG.CUSTMAST

iFrames Technologies 47
Mainframe VSAM


• ALTER MTRG.CUSTOMER.MASTER.DATA -
• ADDVOLUMES(VOL291 VOL292) -
• REMOVEVOLUMES(VOL 281 VOL 282)

• Add VOL291 and VOL292 to list of eligible volumes for
MTRG.CUSTOMER.MASTER.DATA and remove VOL281 and VOL282.
• Example:
• //IFMAIN2 JOB NOTIFY=&SYSUID
• //STEP1 EXEC PGM=IDCAMS
• //SYSPRINT DD SYSOUT=*
• //SYSOUT DD SYSOUT=*
• //SYSIN DD *
• ALTER IFMAIN2.KSDS.DATA –
• NEWNAME(IFMAIN2.VSAM.KSDS)
• /*
• //

• Likewise we can alter the other data attributes like:
• ADDVOLUME
• ATTEMPTS
• SHAREOPTIONS
• BUFFERSPACE
• FREESPACE
• PASSWORD

• ENTRY NAME is the cluster, data or index component name.
• PASSWORD is the master password if the VSAM data set is password
protected
• ALTER can also be used as a migration path to change an ESDS to LDS



• ALTER with ADDVOLUME/REMOVEVOLUME
• ADD VOLUME:
• //ALTJOB JOB ,,NOTIFY=userid
• //STEP1 EXEC PGM=IDCAMS
• //SYSPRINT DD SYSOUT=*
• //SYSIN DD *
• ALTER -
• USER1.KSDS.DATA -
• ADDVOLUMES(VS012)

iFrames Technologies 48
Mainframe VSAM


• REMOVE VOLUME:
• ALTER
• USER1.KSDS.DATA -
• REMOVEVOLUME(RTD2)

• ALTER WITH FREESPACE
• ALTER entryname[/password] -
• FREESPACE(CI-percent[ CA-percent]))
• Example:
• //ALTJOB JOB ……….
• //STEP1 EXEC PGM=IDCAMS
• //SYSPRINT DD SYSOUT=*
• //SYSIN DD *
• ALTER -
• USER1.KSDS.DATA -
• FREESPACE(30 30)


• Entryname must be the name of the cluster’s data component.
• This procedure has the following advantages.
• It prevents wasting space.
• It minimizes CI and CA splits.

• ALTERING PASSWORD
• Adding/Changing PASSWORD
• ALTER entryname[/password] -
• [READPW (password)] -
• [UPDATEPW (password)] -
• [CONTROLPW (password)]-
• [MASTERPW (password)]
• Nullifying PASSWORD
• ALTER entryname[/password] -
• NULLIFY -
• [READPW] -
• [UPDATEPW] -
• [CONTROLPW] -
• [MASTERPW ]

• DELETE COMMAND

iFrames Technologies 49
Mainframe VSAM

• DELETE command is used to remove entries from a VSAM catalog. To


delete more than one file, list the names in parentheses. The IDCAMS DELETE
command can be used to delete both VSAM and non-VSAM objects
• SYNTAX:
• DELETE entry name/password
• Example 1
• We can specify a generic name in a DELETE command by replacing
ONE level of the entry name with an asterisk, like this
• DELETE MTRG.CUSTOMER.*
• Example 2
• To delete MTRG.CUSTOMER.MASTER, whether or not it is expired.
• DELETE MTRG.CUSTOMER.MASTER –
• PURGE
• Example 3
• To delete the 3 named files.
• DELETE ( MTRG.CUSTOMER.MASTER -
• MTRG.CUSTMAST.AIX -
• MTRG.CUSTMAST.PATH)
• Example:
• //IFMAIN2 JOB NOTIFY=&SYSUID
• //STEP1 EXEC PGM=IDCAMS
• //SYSPRINT DD SYSOUT=*
• //SYSOUT DD SYSOUT=*
• //SYSIN DD *
• DELETE IFMAIN2.KSDS.CLUSTER
• /*
• //
• Some other options for Delete are:
• ALIAS
• ALTERNATEIND
• CLUSTER
• SPACE
• PURGE
• PATH
• REVIEW QUESTIONS:
• 1. The default print format is:
a. character
b. dump
c. hexadecimal
d. none of the above.
e. 2. Which of the following repro selection parameters can be specified
for an LDS?
A. from key

iFrames Technologies 50
Mainframe VSAM

B. from address
C. from number
D. skip
E. none of the above
F. 3. The replace parameter causes:
a. KSDS records to be replaced by an input record with the same key
b. ESDS records to be replaced by an input record with the same RBA

c. RRDS records to be replaced by an input record with the same RRN


d. a) and c)
e. all of the above
f. 4. Generic keys can be specified in PRINT FROM KEY and TOKEY
A. TRUE
B. FALSE
C. 5. REPRO will stop processing records when a total of four
physical I/O errors occur while writing to the output data set.
A. TRUE
B. FALSE
C. 6. Which of the following is not a valid command?
a. IF
b. THEN
c. ELSE
d. DO
e. GOTO
f. 7. REPRO REUSE against a non-empty target data set with NOREUSE
will reset the target data set.
A. TRUE
B. FALSE
C. 8. Can VSAM files be deleted with the DELETE option of the
DISPOSITION parameter of JCL?
D. 9. During processing of a VSAM file, some system error
occurs and it is subsequently unusable What do you do?
E.
F.
G. CHAPTER --- 7 : Alternate Indexes

H. An alternate index is used to an access the records of a


VSAM key-sequenced data set in an order other than the file’s
primary key (or base key). The data set over which an
alternate index exists is called a base cluster. Even we can
use an entry-sequenced data set as the base cluster for an
alternate index, most alternate indexes are built over KSDS
clusters. Used whenever the data is required to be retrieved

iFrames Technologies 51
Mainframe VSAM

on the basis of other field (than primary key field). An


alternate index cannot be defined for RRDS or LDS
I.
J.

ALTERNATE ALTERNATE
INDEX 1 INDEX 2
(DEPT NO) (SOCIAL SEC
NO)

BASE
CLUSTER
(NAME) 015-35-7890 WRIG
183-96-416 ADAM
234-04-2372 PETT
3235 NEWTON $…
3240 WRIGHT $.. ADAMS 3247 $…
3247 ADAMS $.. ARNOLD 4711 $…
3247 PETTY $ … KINNEY 3247 $……
NEWTON 3235 $..

K. MULTIPLE ALTERNATE INDEXES (AIXs) may be defined over a


base cluster.
L. If the user is sequentially retrieving records using AIX1,
then department number retrieves records in logical sequence
Access via AIX2 with an alternate key of social security
number results in the retrieval of base cluster records in
social security number sequence.
M. ADVANTAGES
• Can be defined for both KSDS & ESDS
• Reduce data redundancy
• Can have duplicates
• Easy to define using IDCAMS
• Allow datasets to be accessed sequentially or randomly
• Can be updated automatically
• DISADVANTAGES
• Performance degradation
• Complex update logic

iFrames Technologies 52
Mainframe VSAM


• NEED FOR ALTERNATE INDEX:

• Alternate Indexes save sorting or maintaining duplicate data that
might otherwise be required.An alternate index cannot be defined for an
RRDS or LDS

• KSDS



INDEX:
• EMPLOYEE NAME



DATA:
EMPLOYEE RECORDS






A. ACCESS A KSDS BY KEY OTHER THAN THE PRIMARY KEY
1. SOCIAL SECURITY NUMBER
2. DEPARTMENT NUMBER
3. EMPLOYEE NUMBER
4. ZIP CODE
5. B. ACCESS AN ESDS BY KEY
6.
7. ALTERNATE INDEX DATA RECORD FORMAT
8.
9. PRIME KEY LENGTH *
10. NUMBER NONUNIQUE
PRIME KEYS
11. + ALTERNATE KEY +
RECORD =5 -0R-
SIZE 12. LENGTH 4 *NUMBER
13. NONUNIQUE POINTERS
POINTERS
14.
15.
16.
17.
18. Each AIX data record is variable length and contains system
header information, the alternate key and at least one pointer to the

iFrames Technologies 53
Mainframe VSAM

base cluster. AIX s are spanned record data sets, since there may be
many base cluster records associated with a given alternate key.
19. Pointers to the base cluster are of two forms, either an RBA (for
an ESDS base cluster)or a prime key for a ksds base cluster).The
pointers are the same type throughout the entire AIX.
20.
21.ALTERNATE INDEX ORGANIZATION
 Alternate Indexes are KSDS by themselves and have their own data and index
components
• AIX data components contain the alternate index key values and pointers to
each record containing the key value
• AIX index components contain highest key value in an AIX data CI and a
pointer to that CI
• AIX data component has variable length records if duplicate is allowed (due to
multiple pointers)

• STEPS FOR CREATING ALTERNATE INDEX
• Define AIX using IDCAMS DEFINE AIX
• Build AIX & populate it using IDCAMS BLDINDEX
• Specify Alternate Index Path using IDCAMS DEFINE PATH

• CREATING AN ALTERNATE INDEX
• DEFINE ALTERNATEINDEX-
• (NAME(AIX NAME)-
• RELATE(BASE CLUSTER NAME)-
• KEYS (LENGTH OFFSET)-
• UNIQUEKEY/NONUNIQUEKEY-
• UPGRADE/ NOUPGRADE
• RECORDSIZE (AVG MAX)-
• VOL (VOLSER) –
• CYL/TRK/REC(PRI SEC))
• NAME
• Syntax: NAME
• Required parameter: Specifies the name of AIX

• VOLUMES
• Syntax: Volumes (Vol-ser-1 ..... vol-ser-n)
• Required parameter: Assigning base cluster & AIX in different volumes
improves performance

• RELATE
• Syntax: RELATE (base cluster name)

iFrames Technologies 54
Mainframe VSAM

• Required parameter: Establishes relationship between the base cluster & AIX

• UPGRADE/NOUPGRADE
• Syntax: UPGRADE/NOUPGRADE
• UPGRADE specifies that records in AIX are to be updated automatically
whenever the base cluster is updated .The use of UPGRADE makes the
alternate index part of the cluster’s so called “UPGRADE SET”
• Default: UPGRADE






• AIX 1
• AIX 2 AIX 3






• Base cluster


• KEYS
• Syntax: KEYS (length offset)
• Optional: primary key values are taken as default, if not specified.Defeats the
purpose of Alternate Index, if not specified

• RECORD SIZE
• Syntax: RECORD SIZE (average maximum)
• Default: RECORDSIZE (4086 32600)
• Abbr: RECSZ
• Average & max. Are same for UNIQUEKEY AIX and may be different for
NONUNIQUEKEY




• HOW TO CALCULATE THE RECORD SIZE?

iFrames Technologies 55
Mainframe VSAM

• AIX for a KSDS RECSZ = 5 + AIXKL + (n x BCKL)


• AIX for ESDS RECSZ = 5 + AIXKL + (n x 4)
• Where:
• AIXKL is the alternate-key length
• BCKL is the base cluster's prime-key length
• n = 1 when UNIQUEKEY is specified
• n = the number of data records in the base cluster that contain the
same alternate-key value, when NONUNIQUEKEY is specified.

• Other AIX parameter
• ATTEMPTS
• AUTH (entry point)
• BUFFERSPACE (bytes)
• CATALOG (catalog/pw)
• CODE (code)
• CISZ (bytes)
• CONTROLPW (password)
• ERASE (NOERASE)
• EXCEPTIONEXIT (entry point)
• KEYRANGES (low-key high key)
• MASTERPW (password)
• ORDERED/UNORDERED
• READPW (password)
• REPLICATE/NOREPLICATE
• REUSE/NOREUSE
• SHAREP[TOPMS
• SPEED/RECOVERY
• UNIQUEKEY/NONUNIQUEKEY
• UPDATEPW (password)
• WRITECHECK/NOWRITECHECK
• EXAMPLE:
• //STEP1 EXEC PGM =IDCAMS
• //SYSPRINT DD SYSOUT = *
• //SYSIN DD *
• DEFINE ALTERNATEINDEX(USER1.KSDS.AIX)-
• VOLUME(V001) -
• RELATE(USER1.KSDS.CLUSTER)-
• UPGRADE-
• CYLINDERS(2 1)-
• KEYS(25 9)-

iFrames Technologies 56
Mainframe VSAM

• RECORDSIZE(70 110)-
• FREESPACE(20 10)-
• NONUNIQUEKEY-
• DATA
• (NAME(USER1.KSDS.AIX.DATA))-
• INDEX
• (NAME(USER1.KSDS.AIX.INDEX))

• BUILD INDEX
• SYNTAX:
• BLDINDEX
• {INFILE(ddname) / INDATASET (base cluster name)} -
• {OUTFILE(ddname) / OUTDATASET (AIX NAME)} -
• [EXTERNALSORT / INTERNALSORT] -
• [WORKFILES(ddname ddname) ]
• INFILE /INDATASET IDENTIFIES THE BASE CLUSTER.
• OUTFILE / OUTDATASET IDENTIFIES THE AIX TO BE LOADED

 INTERNALSORT Requires AMS to build the Alternate Index Records
within the user’s address space if possible
 EXTERNALSORT Indicates that two ESDS work Files are to be used by
AMS for the sort
 WORKFILES Specifies The DD names to be used instead of the default
Names
 EXAMPLE
 BLDINDEX INDATASET(USER1.KSDS.CLUSTER)-
 OUTDATASET(USER1.KSDS.AIX)

 CREATION OF PATH
• Once you have defined any alternate indexes, You must define a separate
path for each one, using the IDCAMS DEFINE PATH command.
• This path name is the dataset name that you use in the jcl when processing
an alternate index. It is a separate catalog entry and forms a logical
connection(path) through the alternate index to the base cluster
• A path is a catalog record. It is normally used to relate the alternate index
and the base cluster
• IDCAMS DEFINE PATH is used to create a path record in the catalog.


• SYNTAX:
• DEFINE PATH(NAME(PATH NAME) -
• PATHENTRY(AIX NAME) -

iFrames Technologies 57
Mainframe VSAM

• UPDATE / NOUPDATE)
• NAME specifies the name of the PATH.
• PATHENTRY associates the AIX with the path name.
• UPDATE / NOUPDATE specifies whether all of the upgrade set
should be maintained by VSAM when accessing through this path
• EXAMPLE:
• DEFINE PATH ( -
• NAME(USER1.KSDS.PATH) –
• PATHENTRY(USER1.KSDS.AIX)-
• UPDATE )

• ALTERNATE INDEX FOR ESDS
• Same syntax & parameters as KSDS
• Not supported in Batch COBOL (OS/VS & VSII)
• Used under CICS environment
• Step 2: BUILDING THE INDEX
• BLDINDEX Command actually builds the index and populates it with
records

• //BLDINDX EXEC PGM=IDCAMS
• //SYSPRINT DD SYSOUT = *
• //DD1 DD DSN=XIND.NLT.VSAM,DISP=OLD
• //DD2 DD DSN=XIND.NLT.VSAM.DEPT.AIX,DISP=OLD
• //IDCVT1 DD DSN=XIND.NLT.WRKFILE1, DISP=OLD
• //IDCVT2 DD DSN=XIND.NLT.WRKFILE2, DISP=OLD
• //SYSIN DD *
• BLDINDEX INFILE (DD1) OUTFILE (DD2) -
• INTERNALSORT
• /*
• Step 3: SPECIFYING THE ALTERNATE INDEX PATH
• Example:
• DEFINE PATH -
• (NAME(XIND.NLT.VSAM.DEPT.PATH) -
• PATHENTRY -
• (XIND.NLT.VSAM.DEPT.AIX) UPDATE)
• - Path is a VSAM object though it doesn’t contain any records
• - Same command for KSDS & ESDS
• - Path is used to link JCL DSN to VSAM AIX (specifies that the given AIX is to
be used).
• NAME
• Syntax: NAME (pathname). Pathname becomes the DSN in the run JCL

iFrames Technologies 58
Mainframe VSAM



• PATHENTRY
• Syntax: PATHENTRY (entry name/password).
• Entry name: name assigned to alternate index cluster. Required for an
alternate index

• RESTRICTIONS FOR ALTERNATE INDEX
• No Alternate Index For RRDS and LDS.

• Base Cluster Must Not Be Empty For Buildindex.

• Length Of The Alternate Index Not Exceed 255

• Maximum Number Of Alternate Key Pointers Is 32k.

• Records Larger Than 32760 Not Supported By Repro/Export.

• For A Base Cluster With Alternate Index(Es) And Path(S),Delete Cluster


Deletes Not Only The Base Cluster But Also The Associated Alternate Index

• Maximum Alternate Indexes Can Be 253 For A Single Dataset(ESDS&KSDS)













• REVIEW QUESTIONS:
• 1. An alternate index can be defined for which cluster type(s)?
• a.) KSDS AND RRDS
• b) KSDS AND ESDS
• c) KSDS only
• d) KSDS,ESDS AND RRDS.
• 2. The size of an alternate index is about the same of it’s base cluster.
• a) true
• b)false

iFrames Technologies 59
Mainframe VSAM

• 3. If an application program accesses a base cluster in alternate key


sequence,
• then DD statements are needed for which data set(s)?
• a) Base cluster
• b) alternate index
• c) path
• d) (a) and(b)
• e) (a) and c
• 4. An alternate index itself is which cluster type?
• a) LDS
• b) RRDS
• c) ESDS
• d) KSDS
• e) NONE OF THE ABOVE.
• 5 An alternate index is a spanned record dataset.
• a) true
• b)false
• 6) A path is required so that an application program base cluster keys
and retrieve alternate records.
• a) true
• b) false
• 7) Is it slower if you access a record through ALTERNATIVE INDEX as
compared to Primary INDEX?
• 8) What could be the maximum number of the AIXs per base cluster?
• 9) Can AIX be defined over an ESDS, which does not have any Key?

• 10) What is an Alternate Index?


• 11) What are the steps used to create an Alternate Index?
• 12) What are the restrictions to be considered while creating an Alternate
Index?

iFrames Technologies 60

Вам также может понравиться