VSAM - Session - 1

You might also like

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

Virtual Storage Access Method (VSAM)

Objectives of VSAM
To be strong on VSAM concepts
To be able to process a VSAM Dataset in a COBOL
program.

Learning & Culture


All work described was performed by Capgemini or a Capgemini affiliate
2007 Capgemini - All rights reserved 1

Table of Contents (Session 1)


Introduction to VSAM
Features of VSAM
Types of VSAM files
Characteristics of VSAM
VSAM objects
Control Interval
Control Area

Control Interval Splits and Control Area Splits.


Creation of a VSAM File using IDCAMS DEFINE CLUSTER
Adding Records to a VSAM file using IDCAMS REPRO
Common Errors
Changes to a COBOL Program while using a VSAM file.

Learning & Culture


All work described was performed by Capgemini or a Capgemini affiliate
2007 Capgemini - All rights reserved 2

Table of Contents (Session 2)


Introduction to VSAM-AIX
Rules for creating a VSAM AIX
AIX with Unique Keys and Non-Unique Keys
Creation of an VSAM-AIX File using IDCAMS DEFINE AIX
Adding Records to the AIX Cluster using IDCAMS BLDINDEX
Creation of a PATH using IDCAMS DEFINE PATH
Changes to a COBOL Program while using a VSAM file.
Changes to the Run JCL with respect to the PATH to be used.

Learning & Culture


All work described was performed by Capgemini or a Capgemini affiliate
2007 Capgemini - All rights reserved 3

VSAM Session 1
Introduction to VSAM
Features of VSAM
Types of VSAM files
Characteristics of VSAM
VSAM objects
Control Interval
Control Area

Control Interval Splits and Control Area Splits.


Creation of a VSAM File using IDCAMS DEFINE CLUSTER
Adding Records to a VSAM file using IDCAMS REPRO
Common Errors
Changes to a COBOL Program while using a VSAM file.

Learning & Culture


All work described was performed by Capgemini or a Capgemini affiliate
2007 Capgemini - All rights reserved 4

Introduction to VSAM

VSAM Virtual Storage Access Method

One of the High performance access method on IBM


Mainframe.
Used to organize, store, catalog, retrieve and delete
datasets
VSAM Dataset is also called as a CLUSTER

Learning & Culture


All work described was performed by Capgemini or a Capgemini affiliate
2007 Capgemini - All rights reserved 5

Features of VSAM
All VSAM files must be created before they can be used in
the program.
All VSAM clusters must be catalogued.
VSAM data space must be allocated before the creation of
the VSAM clusters.

The VSAM clusters must reside in the space specifically


allocated for VSAM Datasets.
All VSAM clusters exist only on DASDs.
Learning & Culture
All work described was performed by Capgemini or a Capgemini affiliate
2007 Capgemini - All rights reserved 6

Types of VSAM Data sets

ESDS Entry Sequenced Data Set

KSDS Key Sequenced Data Set


RRDS Relative Record Data Set

LDS Linear Data Set

Learning & Culture


All work described was performed by Capgemini or a Capgemini affiliate
2007 Capgemini - All rights reserved 7

Entry Sequenced Data sets


Similar to a conventional Physical Sequential File.
An ESDS Cluster consists of a Data component which
contains the actual records.
Records are retrieved in the order in which they have been
written.
New records are always added at the end of the file.
Physical deletion of records is not possible.
Access can be Sequential or Direct
Direct Access is possible using RBA (Relative Byte
Addressing).

Learning & Culture


All work described was performed by Capgemini or a Capgemini affiliate
2007 Capgemini - All rights reserved 8

Key Sequenced Data sets


Similar to a Indexed Sequential file in many ways.
A KSDS Cluster consists of a Data component which contains the
actual records and an Index component which contains the indexes
that are used to access the records in the data component.
Records are retrieved on the basis of the Key.
Each record can be identified by a Unique primary key.
Primary key is Unique and Not Null.
Access can be Sequential, Random or Dynamic.
Sequential Access Records are read in the sequence of the key
values stored in the files index.
Random Access Key value is supplied for the record to be read.
Dynamic Access Key value is supplied to position the file pointer on
the record required and then is read sequentially.

Learning & Culture


All work described was performed by Capgemini or a Capgemini affiliate
2007 Capgemini - All rights reserved 9

Relative Record Data sets

Similar to a Relative file in many ways.


A RRDS Cluster consists of fixed length slots that are
numbered.
These are called as Relative Record Numbers (RRNs).
Each record can be accessed Sequentially or Randomly.

Learning & Culture


All work described was performed by Capgemini or a Capgemini affiliate
2007 Capgemini - All rights reserved 10

Linear Data sets

A Linear Data set is a VSAM dataset that has no record


organization.
Instead data is stored as a long stream of bytes with no
division into records.

Learning & Culture


All work described was performed by Capgemini or a Capgemini affiliate
2007 Capgemini - All rights reserved 11

Characteristics of VSAM

Data Access is faster, because of the way the VSAM


Datasets are organized.
KSDS Records are inserted in a more efficient manner,
with less organization required.
VSAM groups logical records into blocks called Control
Interval.
Control intervals in turn are grouped together into Control
Areas.

Learning & Culture


All work described was performed by Capgemini or a Capgemini affiliate
2007 Capgemini - All rights reserved 12

VSAM Objects Control Intervals


Control Intervals
Control Interval can be thought of as the unit of data that VSAM
transfers between virtual and disk storage.
This is similar to the blocking concept in Non-VSAM files.
The size of a control intervals are generally 2K or 4K.

Control Interval
Data

Free

(multiple recs.)

Space

RDF

CIDF

(one or more)
(3 bytes)

(4 bytes)

Learning & Culture


All work described was performed by Capgemini or a Capgemini affiliate
2007 Capgemini - All rights reserved 13

Control Intervals (continued)

A Control Intervals consists of

Data records
Free space
Un-used space
Control Information.
RDF Record Description Field (1 or more)
CIDF Control Interval Description Field.

Learning & Culture


All work described was performed by Capgemini or a Capgemini affiliate
2007 Capgemini - All rights reserved 14

VSAM Objects Control Area

Control Area

A collection of adjacent Control Intervals.


Contains a minimum of 2 CIs.
It is VSAMs internal unit for allocating space within a cluster.
VSAM computes an optimum CA size which can vary depending
on the unit of allocation.
The size of a CA could vary from a minimum of one track to a
maximum of one cylinder.

Learning & Culture


All work described was performed by Capgemini or a Capgemini affiliate
2007 Capgemini - All rights reserved 15

Control Areas (continued)

Control Areas
Control Interval 1

Record 1

Record 2

Record 3

Control Interval 2

Record 4

Record 5

Record 6

Record 7

Record 8

Record 9

Control Interval 3

Learning & Culture


All work described was performed by Capgemini or a Capgemini affiliate
2007 Capgemini - All rights reserved 16

Control Interval Split


Control Interval Split
Occurs only in KSDS
Occur as a result of record insertion.
An empty CI from the CA is inserted at the point where the new record is to
be inserted.
The records from the CI are put into this new CI, to make place for the new
record.
The record to be added is inserted at the point of split.
Subsequent records after insertion point are written on to a fresh CI.
Reorganization of data set is done automatically and is transparent to the
user.

Learning & Culture


All work described was performed by Capgemini or a Capgemini affiliate
2007 Capgemini - All rights reserved 17

CI Split (continued)

Current Status
Control Interval 1

Record 1

Record 2

Record 5

Control Interval 2

Record 7

Record 8

Record 9

Control Interval 3

Let us now say, that record 3 is to be added, then

Learning & Culture


All work described was performed by Capgemini or a Capgemini affiliate
2007 Capgemini - All rights reserved 18

CI Split (continued)

New Status
Control Interval 1

Record 1

Control Interval 2

Record 5

Control Interval 3

Record 7

Record 2

Record 3

Record 8

Record 9

Learning & Culture


All work described was performed by Capgemini or a Capgemini affiliate
2007 Capgemini - All rights reserved 19

Control Area Split

Control Area Split


Occurs only in KSDS
Occurs when there in no space for record insertion due to an
absence of free CIs.
It is similar to a CI Split
CA splits continue until space allocation limits are exceeded.

Learning & Culture


All work described was performed by Capgemini or a Capgemini affiliate
2007 Capgemini - All rights reserved 20

Creation of a VSAM Cluster

To create a KSDS Cluster using IDCAMS, we use the


DEFINE CLUSTER Command.
Incase of a KSDS Dataset, usually DATA and INDEX
parameters are also coded.

The DATA and the INDEX components are two physical


datasets viewed as a cluster.

Learning & Culture


All work described was performed by Capgemini or a Capgemini affiliate
2007 Capgemini - All rights reserved 21

Creation of a VSAM Cluster (continued)


To create a KSDS Cluster using IDCAMS, we use the Command DEFINE CLUSTER
DEFINE CLUSTER
(NAME (USER1.KSDS.CLUSTER)
RECORDSIZE (80 80)
KEYS
(5 0 )
VOLUME
(USER02)
INDEXED
CISZ
(1000 )
REUSE
FREESPACE
(20 10)
)
DATA
(NAME
(USER1.KSDS.DATA)
)
INDEX
(NAME
( USER1.KSDS.INDEX)
)
CATALOG (USER1.USER.CATAL)

Learning & Culture


All work described was performed by Capgemini or a Capgemini affiliate
2007 Capgemini - All rights reserved 22

Adding Records to a VSAM file


To add records to a VSAM Cluster using IDCAMS, we use
the REPRO Command.
It is used to load VSAM cluster with records and build data
& index components for KSDS.
The records must be in the sequence of the Primary Key
field.
It can also be used to backup VSAM data on to a Physical
Sequential dataset.

Learning & Culture


All work described was performed by Capgemini or a Capgemini affiliate
2007 Capgemini - All rights reserved 23

Adding Records to a VSAM file (continued)

To copy records to a VSAM cluster we use the IDCAMS


command - REPRO
REPRO
INFILE (ddname of the Input file)

OUTFILE (ddname of output file)

or
REPRO
INDATASET (DSN of the Input file)

OUTDATASET (DSN of output file)

Learning & Culture


All work described was performed by Capgemini or a Capgemini affiliate
2007 Capgemini - All rights reserved 24

Common Errors

IDC3003I Dataset not found or missed hyphen

IDC3013I Duplicate Dataset name


IDC3314I- Action error on xxx or Record xxx out of
sequence.

Learning & Culture


All work described was performed by Capgemini or a Capgemini affiliate
2007 Capgemini - All rights reserved 25

Changes to COBOL program while using a VSAM Dataset


Changes to the SELECT Clause
SELECT filename ASSIGN TO ddname
ORGANIZATION INDEXED
ACCESS SEQUENTIAL / RANDOM / DYNAMIC
RECORD KEY primary-key
FILE STATUS working-storage-variable.

Changes to the modes in the OPEN verb


The OUTPUT mode is no longer required, as the VSAM datasets
should be existing before they can be used.
The EXTEND modes is no longer required, as we can add the records
in the I-O mode itself.

Learning & Culture


All work described was performed by Capgemini or a Capgemini affiliate
2007 Capgemini - All rights reserved 26

Changes to COBOL program while using a VSAM Dataset


(continued)
Changes to the WRITE and REWRITE commands
WRITE record
INVALID KEY imperative statement.
REWRITE record
INVALID KEY imperative statement.

Additional commands added for KSDS Clusters


The DELETE Command
DELETE filename RECORD INVALID KEY imperative statement.

The START Command


START filename KEY = key-field INVALID KEY imperative statement.

Learning & Culture


All work described was performed by Capgemini or a Capgemini affiliate
2007 Capgemini - All rights reserved 27

Changes to COBOL program while using a VSAM Dataset


(continued)
Changes to the READ commands
Depending on the ACCESS Method defined in the SELECT Clause,
we can have three different types of READ.
Sequential Access
READ filename AT END imperative statement.

Random or Dynamic Access


READ filename KEY IS key-field
INVALID KEY imperative statement.

Dynamic Access
READ filename NEXT AT END imperative statement.

Learning & Culture


All work described was performed by Capgemini or a Capgemini affiliate
2007 Capgemini - All rights reserved 28

Thank You For Your Time


www.capgemini.com

You might also like