Vsam
Vsam
Vsam
Most computer applications are designed to manipulate data and generate results based
on the data. Data must be stored in a way that its retrieval is easy and quick. Access
methods are ways to maximize the efficiency of data storage and retrieval.
Listed below are some of the traditional access methods that are available for the
Multiple Virtual Storage (MVS) mainframe environment.
In the early 1970s, VSAM (Virtual Sequential Access Method) was introduced by IBM
as a collection of three data set organizations ? sequential, indexed, and direct-access,
together with the access methods and utilities to be used on the large scale IBM operating
systems.
Virtual Storage Access Method (VSAM) is the first access method specifically designed
to operate in a virtual storage environment. VSAM is more compatible with operating
systems MVS, MVS/XA and MVS/ESA than other access methods. The compatibility of
VSAM with various operating systems provides greater efficiency for the application
programs using VSAM and also for the overall environment.
Role of VSAM:
VSAM acts as an interface between processing programs and the operating system.
VSAM supports four different data sets. This property of VSAM allows an installation to
replace or limit the
use of four older access methods that were not designed for the virtual storage
environment.
Queued Sequential Access Method (QSAM) and Basic Sequential Access Method
(BSAM): SAM data sets accessed using QSAM or BSAM are appropriate in applications
requiring generation data sets or sequential work data sets.
Indexed Sequential Access Method (ISAM): VSAM supports all the processing
capabilities of IAM more efficiently.
Basic Direct Access Method (BDAM): BDAM was designed for managing program
load modules.
Records in an ESDS are stored in the order in which they are written and are retrieved by
addressed access. Records are loaded irrespective of their contents and their byte
addresses cannot be changed. ESDS is also referred to as a sequential VSAM data set.
This is because records in an ESDS are normally processed sequentially. ESDS is best
suited for applications where most processing is done sequentially.
Records in a KSDS are stored in key sequence and are controlled by an index. The key
field of records determines the order in which records are stored. In a KSDS, records can
be processed both sequentially and randomly using their key field values.
Records in an RRDS are loaded into fixed-length or variable length slots. These records
are represented by the Relative Record Numbers (RRNs) of their slots. A processing
program uses RRN to provide random access to records.
The records in an RRDS can also be accessed sequentially in its RRN order. It is also
possible to convert key values into RRNs. Accessing data using RRNs is preferred by
many applications, such as inventory file management.
LDS is a data set containing only a contiguous string of data bytes with no intervening
control information. An LDS is divided into blocks. These blocks can be sequentially
retrieved by a processing program in physical order. A processing program can group
several logical records together into a single block LDS can be kept permanently in store
for enhanced performance.
The purpose of the LDS data set type is to provide a format that can be used more easily
with the extended addressing feature found in Multiple Virtual Storage / Enterprise
Systems Architecture (MVS/ESA). It is used for special applications requiring large
amount of data to be maintained in virtual storage. Application programs prefer an ESDS
to an LDS. ESDS provides same processing abilities and can block and unblock logical
records automatically.
Retrieve a record:
steps:
1. VSAM interprets the processing program?s logical request and determines what
services are desired.
2. VSAM makes the required Input or Output (I/O) request(s) to the operating
system.
3. The operating system performs the physical I/O operation(s) between the device
and the storage.
4. VSAM locates and extracts the desired data before returning it to the processing
program.
VSAM groups individual data records into larger units in order to reduce the number of
I/O requests required when sequentially retrieving records.
These larger units are transferred between the Direct Access Storage Device (DASD) and
virtual storage by the operating system.
Random: This is also referred to as direct access. The logical record needs to be located
by the use of a search argument coming from the application. There is no search
argument connection between two consecutive logical record accesses.
Sequential: The entire file is processed (for Read or Write), one logical record after the
other. The application does not need to provide any search argument. The access method
can implement a Read look ahead technique to load logical records in the buffers not yet
required by the application program.
Skip sequential: A combination of the two previous types of access. The application
randomly provides one search argument and from the located logical record on, all
records are processed sequentially. An example is sequentially processing all the
customers of a bank branch office in a file that has all the customers of the bank.
VSAM Terminology:
Logical Record
A logical record is a unit of information used to store data in a VSAM data set. It is made
up of a set of bytes containing a logical description of an item processed by an
application program. This item can be a customer with all his or her information, or an
employee with all associated data (name, serial number, department).
The Relative Byte Address (RBA) of a record is its displacement (in bytes) from the
beginning of the data set. VSAM treats data as a contiguous string of bytes. This
approach makes the address of a record device-independent. A VSAM data set can be
moved without effecting the RBAs of its records.
In addition to data records VSAM also stores control Information. The presence of
control Information affects the RBAs of subsequent data records. The example represents
a VSAM data set containing 100-byte, fixed-length records. The RBA of the first record
is 0. The RBA of the second record is 100. The RBA of the third record is 200 and so on.
A control interval is the amount of data transferred between the device and virtual
storage. When a record is read from or written to a data set, VSAM groups individual
data records into larger units of storage. These units of storage are called control
intervals.
A control interval is the amount of data transferred between the device and virtual
storage. VSAM groups individual data records into larger units of storage. These units of
storage are called control intervals. All control intervals for a given data set are of the
same size. However, the records within a control interval can vary in length.
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.
Cluster
A cluster is the collection of physical data sets that make up one logical data set.The
concept of a cluster is more suited for a KSDS. A KSDS cluster has two data sets. One
data set holds the actual data records. The other data set contains an index component.
The index component permits the direct retrieval of data.
With an ESDS, an RRDS and an LDS, the cluster name and the data set component
name both refer to the same data set and a cluster consists of only a single physical data
set: the data component.
VSAM supports the various options provided by the KSDS, by providing a two-tiered
indexing structure to locate data records.
? Data component
? Each index control interval is treated as a single record that is divided into
index entries
? The index records resemble a tree structure with a single index record at the
highest level
There are several ways in which records can be read from a KSDS. One way is to access
records sequentially. During the sequential access, the records are returned to the
processing program in key order.
? VSAM locates the records using the sequence set of the index component.
? VSAM keeps both the sequence set record and data control interval in virtual
storage.
? VSAM maintains its current position in the data set to identify the next record
to be retrieved by a subsequent sequential request.
A KSDS has an index that relates key values to the relative locations of the logical
records in a data set.
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.
A 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.
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 (higher keyed) sequence set CI.
If there is 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.
//SYSPRINT DD SYSOUT=*A
//SYSOUT DD SYSOUT=*
//SYSIN DD *
DEFINE CLUSTER -
(NAME( VASM1.KSDS.CLUSTER ) -
VOLUMES( VOL100 ) -
CYLINDERS ( 3,1 ) -
CISZ (4096 ) -
RECORDSIZE (80, 80 ) -
FREESPACE ( 10, 20 ) -
KEYS (5, 1 ) -
INDEXED -
) -
DATA -
( -
NAME( VASM1.KSDS.DATA ) -
) -
INDEX -
( -
NAME( VASM1.KSDS.INDEX ) -
)
/*
//
//SYSPRINT DD SYSOUT=*
//SYSIN DD *
DEFINE CLUSTER -
(NAME( VASM1.ESDS.CLUSTER ) -
VOLUMES( VOL100 ) -
CYLINDERS ( 3,1 ) -
CISZ (4096 ) -
NONINDEXED -
) -
DATA -
( -
NAME( VASM1.ESDS.DATA ) -
/*
//
RRDS DATA SET
//SYSPRINT DD SYSOUT=*
//SYSIN DD *
DEFINE CLUSTER -
(NAME( VASM1.RRDS.CLUSTER ) -
VOLUMES( VOL100 ) -
CYLINDERS ( 3,1 ) -
CISZ (4096 ) -
RECORDSIZE (80, 80 ) -
NUMBERED ) -
DATA -
( NAME( VASM1.RRDS.DATA ) ) -
/*
//
? IDCAMS REPRO: The IDCAMS REPRO function will copy the contents of
another data set into KSDS.
? Provides greater efficiency for the application programs and for the overall
environment
REPRO {INDATASET(entry-name[/password] ) )
{INFILE(ddname[/password] )
{OUTDATASET(entry-name[/password] ) )
{OUTFILE(ddname[/password] )
{SKIP(count) }
[ {FROMKEY(key) } ]
{FROMNUMBER(number) }
{FROMADDRESS(address) }
{COUNT(count) }
[ {TOKEY(key) } ]
{TONUMBER(number) }
{TOADDRESS(address) }
Syntax:
OUTDATASET (EXAMPLE.SAM.OUTPUT)
Syntax:
REPRO INFILE (DD Name of Input File) OUTFILE (DD Name of Output File)
//SYSPRINT DD SYSOUT=*
//SYSIN DD *
ODS (EXAMPLE.EXTRCT.ESDS) -
FROMKEY (NY002) -
TOKEY (NY148)
PRINT COMMAND:
Syntax:
The PRINT command prints VSAM data sets, non-VSAM data set, and catalogs.
The INDATASET, INFILE, OUTFILE PARAMETERS can be used to specify the input
or output data set.
- Alternative to INDATASET.
DELETE COMMAND
Non-VSAM data sets can be deleted by using the DISPOSITION parameter of JCL. This
method can not be used for VSAM data sets. Instead the DELETE command is used.
This command can also be used to delete the Non VSAM data sets.
1. base cluster
2. alternate index
3. path
EX:
//SYSPRINT DD SYSOUT=A
//SYSIN DD *
DELETE -
OZA059.KSDS.CLUSTER -
CLUSTER
/*
//
If the user is sequentially retrieving records using AIX1, then records are retrieved in
logical sequence by department number.
Access via AIX2 with an alternate key of EMP name results in the retrieval of
Base Cluster records in EMP name sequence
An AIX is a KSDS, which must be defined like any other KSDS by using IDCAMS.
In this example, each AIX record has department number as its key. Since more than one
name is associated with a department number, the AIX keys are not unique.
When defining an AIX, you must determine if the AIX has UNIQUE Keys or
NONUNIQUEKEYs.
EX:
//SYSPRINT DD SYSOUT=A
//SYSIN DD *
DEFINE AIX -
(NAME( VASM1.KSDS.CLUSTER )) -
DATA -
(NAME( VASM1.KSDS.DATA ) -
VOLUMES( CICT00 ) -
CYLINDERS ( 3,1 ) -
CONTROLINTERVALSIZE (4096 ) -
FREESPACE ( 10, 20 ) -
KEYS (5, 1 ) -
RECORDSIZE (80, 80 )) -
INDEX -
( -
NAME( VASM1.KSDS.INDEX ) -
CONTROLINTERVALSIZE (2048 ) -
) -
/*
//
PATH CONCEPT
//SYSPRINT DD SYSOUT=A
//SYSIN DD *
DEFINE PATH -
(NAME (KSDS.BASE.CLUSTER )
PATHENTRY (KSDS.AIX1.CLUSTER)
UPDATE)
/*
//
BLDINDEX:
This command loads alternate key ?pointer pair records into the alternate index cluster
after extracting them from the base cluster.
BLDINDEX
INDATASET(EXAMPLE1.KSDS.CLUSTER)
OUTDATASET(EXAMPLE2.KSDS.AIX.CLUSTER)
So if you want to work with the alternate index, first you must create or define an
alternate index and you have to use BUILD INDEX then you must define path to establish
a logical connection between alternate index and the base cluster.
The UPGRADE parameter is used at the time of defining alternate index to make the
alternate index a member of the upgrade set of base cluster. So that when you open the
base cluster for any updating the changes will automatically reflect in the alternate index.
For this you must define the path with the option UPDATE.
All AIXs to be updated when changes occur to the base cluster are called the upgrade set.
The user specifies the UPGRADE parameter in the DEFINE AIX to make the AIX a
member of the upgrade set.
KEY SEQUENCE
For a base cluster with alternate index(es) and path(s), DELETE CLUSTER deletes
not only the base cluster, but also all associated alternate index(es) and path(s).
DITTO
DITTO is a very powerful utility product that you can use to browse, edit, and delete
VSAM records. You can start DITTO in full-screen mode from a TSO terminal. Check
with your system programmer how to invoke DITTO as start procedures may vary with
the installation. In full-screen mode, you can use menus, online help, and interactive
browse and update functions. You will probably find full-screen mode the most
convenient way to run DITTO, especially if you are a new DITTO user.
You can also run DITTO in line, command, or batch modes. Refer to DITTO/ESA V1R3
User?s Guide, SH19-8221, for more information on using DITTO. From DITTO Task
Selection Menu. Choose option 1 and then option 3 to browse a VSAM data set.