You are on page 1of 50

VSAM - Day 2

UNIT Topics:

 Control Area

 Access Method Services

 RRDS fixed and Variable


length record

 KSDS
Control Area

What is a control area?

The control intervals for a data set are grouped into


one or more control areas.

The number of control intervals in a control area is


fixed by VSAM.

Maximum size of CA is 1 cylinder.


Minimum size of CA is 1 Track.
What is Control Area?

Collection of control intervals


Minimum size of CA is 1 Track
Maximum size of CA is 1 Cylinder
Control Area
with Control Intervals

05 08 09 10

12 14 15 20

21 22 24 25

29 30 35 36
Control Area

CIs are grouped into CA

Can have more than one CA in a VSAM data set

CA is VSAMs internal unit for allocating space


Control Area

Smallest is a TRACK, and the largest is a


CYLINDER

VSAM determines CA size & number of CIs in CA


based on
CI size specified
Record size
Index
Separate entity

Organized similar to Data component (CI & CA)

Has different CI size

VSAM builds Index when data is loaded


Index is organized as Inverted Binary Tree

VSAM compresses keys to conserve space

Can have several Levels of Indexes


Lowest level of index is called ‘Sequence set’

One sequence set for one Control Area

Are always in the key order whereas data CI need not


be in key order
Each entry has the highest key(or “one” less than
the 1st key of the next CI so that the sequence set
need not be updated when higher key added to the
CI) in the CI and points to the RBA of the CI.
(Vertical Pointer)
Next level is called index set

Contains Primary keys and pointers to the

sequence set

More than one level of Index set based on

number of Sequence set records

Top level index always one record


Index &Sequence Set
Index
Key Ptr Key Ptr ... Set

Index
Component Sequence Set 1 Sequence Set 2
Sequence
...
Key Ptr Key Ptr Key Ptr Key Ptr Key Ptr Key Ptr
Set

...
Data CI 1 CI 2 CI 3 CI 4 CI 5 CI 6
Control
Component Areas
Control Area CI and CA Split
CI split happens while
Adding new records or extending an old
record
And not enough room in the CI to complete
the operation
CI split may trigger a CA split
Splits generally degrades performance
Specify free space to reduce CI & CA splits
Before control interval split
Sequence ...
Set I 0 M 100
Record
C

0
Data Record A Record B Record F Record G U CF
Component S
100
Record J Record K FSPC U CF
S
200
FSPC U CF
S
After control interval split

Sequence ...
Set E 0 I 200 M 100

0
Data Record A Record B Record C FSPC U CF
Component S
100
Record J Record K FSPC U CF

200
Record F Record G FSPC U CF
S
Control Area
VSAM BUFFERS
DATA BUFFERS
CI
CI
VIRTUAL
DASD
STORAGE
CI

INDEX BUFFER
 Holds control interval either before or after
processing
 Two types
 Index
 Data
Control Area

CI SIZE

VSAM can select an efficient size if you ignore

Large CI size for Batch Sequential Processing

Small CI size for random processing


Control Area

Control interval splits:

In a KSDS records are stored in key sequence


when the record is added it is inserted in correct
sequential location in proper control interval and
the records followed will be shifted to next control
intervals
Control Area

Control area split:

If no free CI’s found in CA it will go for the split of


CA.
First it will go for CI split and then for CA split
Access Method Services

What is Access Method Services?

VSAM uses certain utility programs for managing


and maintaining data sets.
Access Method Services

Access Method Services (AMS) is a utility that


defines VSAM data sets and allocates space for
them. It also converts indexed sequential data sets
to KSDS with indexes.

AMS can also be used to perform some functions


for non-VSAM data sets.
Access Method Services

What is Integrate Data Catalog Access Method


Services?

Integrated Data Catalog Access Method Services


(IDCAMS) is the program name for VSAM’s AMS
utility.

IDCAMS is easy to use and multipurpose in nature.


Access Method Services

IDCAMS performs the following functions:

• It defines a data set

• It loads a data set

• It copies or backs up a data set

• It prints the contents of a data set


Access Method Services

• It changes certain attributes of a data set

• It lists data set attributes and statistical


information

• It deletes a data set


Access Method Services

Defining a VSAM Data Set with IDCAMS

What is defining a data set?

The process of creating catalog entries for a VSAM

data set and allocating space for them is called

defining the data set.

A data set must be efined before it is loaded with

data or accessed by a processing program.


Access Method Services

The following items must be addressed when the


data set is to defined.

 The name of the data set :


Define dataset

 The name of the volume on which it will be


allocated
Volumes(Volume-no)
Access Method Services

 The amount of space that is to be allocated

Tracks(3,3),Cylinders(1,1)

 The size of the control interval

ControlIntervalSize(number-of-bytes)
Access Method Services

 The amount of free space within CI and the


amount of utilization of each CI
Free space(percent1,percent2)

 The size of the key


Keys(n1,n2) , n1 = length of the key , n2=offset
of the key

 The Size of the record


Record size(n1,n2)
n1 – Average Record Length
n2 - Maximum Record Length
Access Method Services

Initial Loading

Once a data set has been defined, it needs to be


loaded with data. The IDCAMS
REPRO function is used for initial loading of a
data set.
Access Method Services

The REPRO function can be used to:

• Load data from input file to output file.

• Input file and output file must be


KSDS,ESDS,RRDS,Physical sequential or
member of the partitioned data set.
Access Method Services
Other IDCAMS functions

IDCAMS can be used to perform a variety of data

set management functions.


Listed below are some of the commonly used
IDCAMS functions

PRINT – Prints a VSAM data set

ALTER – Changes certain attributes of a VSAM data set

LISTCAT – Lists data set attribute and statistical


information

DELETE – Deletes a data set


ESDS

In an ESDS records are stored in the order in


which they are written and can be read in the
same order.
ESDS

The characteristics of ESDS are summarized below:


Records are stored sequentially.
Records can be of fixed or variable length.
Records are physically grouped into control
intervals.
Control intervals contain control information along
with data
RRDS

Relative Record Data Set ,records are in relative to


the record number.
Defining is simliar to ESDS.
RRDS also has data component.
Key fields are not coded.
Free space is not coded.
RRDS
Keyword parameter numbered is coded to indicated
that the data set is RRDS.
RRDS contains fixed length records only coded in
RECORD SIZE parameter.
The space requirements of a data set are specified in
terms of a primary allocation and a secondary
allocation.
Total extents – 123
Primary extents – 1
Secondary Extends - 122
RRDS
JCLfor RRDS
//SAMP003B JOB ,,CLASS=M,
// MSGLEVEL=(1,1),NOTIFY=SAMP003,TIME=(1)
//EXEC1 EXEC PGM=IDCAMS
//SYSPRINT DD SYSOUT=*
//SYSIN DD *
DEFINE CLUSTER -
( -
NAME(SAMP003.RRDS.CLUSTER) -
TRACKS(2,1) -
CISZ(512) -
RECORDSIZE(80,80) -
NUMBERED -
)
DATA(NAME(SAMP003.RRDS.DATA))
/*
//
RRDS
Control Interval Format for a Fixed-Length RRDS

Each RDF in a fixed- Relative Record Data Set

length RRDS contains (RRDS)

Control Interval Format:


The length of the slot KSDS and ESDS
2 1
5 0
0 8
A flag indicating 0

whether that slot is Control Interval Format:


RRDS
2 2 2 2 1
full or empty R1 R2
Free
Space
5
0
5
0
5
0
5
0
0
8 8
E F F E 0

RDFs
RRDS
Variable-Length RRDS
A variable-length RRDS
contains records that vary
in size.
 Like a fixed-length RRDS,
Variable-Length
each record of a variable- Relative Record Data Set
length RRDS has a unique
Relative Record Number
(RRN).
 Each record is stored and
retrieved using this 332 380 380 380
number.
 Unlike a fixed-length
RRDS, a variable-length
RRDS does not have slots.
Continued…
RRDS
Control Interval Format for a Variable-Length RRDS

A Control Interval for a Variable-Length RRDS


RDF RDF RDF RDF
4 3 2 3 CIDF

3 3 3 1 2
RRN RRN RRN RRN RRN Free 8
3 3 8 3 2
1 2 3 4 5 Space 0
2 0 2 8
4

2048 byte control interval

The control interval format of the variable-length RRDS is


similar to that of a KSDS with free space.
The number of RDFs in a variable-length RRDS depends on
the number of contiguous records of the same length.
If a record differs in size from its adjacent records then it will
Continued…
have its own RDF.
RRDS
Control Interval Format for a Variable-Length RRDS
A Variable-Length RRDS Control Interval Where Some RRNS Are Not in Use

RDF1 RDF3 RDF5 CIDF


RRN RRN RRN Free
3 7 10 Space

In a variable-length RRDS, no space is reserved for


RRNs that are not in use. This is an advantage over
Fixed-length RRDS. However the performance of a
variable-length RRDS is not as good as that of a
fixed-length RRDS.
IDCAMS must be used to define a variable-length
RRDS.
RRDS
Deleting Records

When a record is deleted, VSAM does not fill the

position with binary zeros as is the case with a

fixed-length RRDS.

Records in a variable-length RRDS are physically

erased and the space occupied by the record is

made available as free space.


Concepts
RRDS
Updating Records

In a variable-length RRDS, the length of a record


can be changed during an update operation.

If free space is not available, VSAM will perform a


control interval or a control area split.

Concepts
RRDS
Updating Records

When updating records, if the size of a record is


reduced, VSAM reclaims the space as free space.
If the size of a record is increased, VSAM provides
the needed space by making use of available free
space within the control interval
KSDS

Key Sequential Data Set

Each record in file is embedded with a unique key.

Random and sequential access is possible.


KSDS

Key Sequential DataSet ,records are identified by


unique key field.

Defining is simliar to ESDS,RRDS.

KSDS also has data component and index


Component.

Key fields are coded.

Free space is coded.


KSDS

Keyword parameter indexed is coded to indicated


that the data set is KSDS.

RRDS contains fixed length records only coded in


RECORD SIZE parameter.
KSDS

The space requirements of a data set are specified


in terms of a primary allocation and a secondary
allocation.
Total extents – 123
Primary extents – 1
Secondary Extends - 122
KSDS
JCL

//SAMP003B JOB ,,CLASS=M,


// MSGLEVEL=(1,1),NOTIFY=SAMP003,TIME=(1)
//EXEC1 EXEC PGM=IDCAMS
//SYSPRINT DD SYSOUT=*
//SYSIN DD *
DEFINE CLUSTER -
( -
NAME(SAMP003.KSDS.CLUSTER) -
TRACKS(2,1) -
CISZ(512) -
RECORDSIZE(80,80) -
Keys(4,0) -
FreeSpace(10,10) -
Indexed -
)
/*
//
KSDS

LOADING VSAM DATA SETS

The repro command reads records from input from


input data set and copies them to output data
set.The following must be specified in the command
KSDS

Syntax.
Repro infile(ddname of inputFile)
outfile(ddname of outputfile)
or
Repro indataset(inputdatasetname)
outdataset(outputdatasetname)

You might also like