Sie sind auf Seite 1von 19

Access method:

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.

• Queued Sequential Access Method (QSAM)


• Basic Sequential Access Method (BSAM)
• Indexed Sequential Access Method (ISAM)
• Basic Direct Access Method (BDAM)
• Basic Partitioned Access Method (BPAM)
• Object Access Method (OAM)

Virtual storage access method

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.

A processing program invokes VSAM routines as subroutines.

In Assembler Language programs, subroutines are invoked by issuing VSAM macros. In


High Level Languages, the language compilers convert I/O statements into calls to the
appropriate VSAM routines. When the I/O request has been processed, control is returned
to the processing program.

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.

The four older access methods are:

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.

VSAM supports the following data set types:

• Entry-Sequenced Data Set (ESDS)


• Key-Sequenced Data Set (KSDS)
• Relative Record Data Set (RRDS)
• Linear Data Set (LDS)

Entry-Sequenced Data Set(ESDS):

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.

Key-Sequenced Data Set (KSDS)

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.

The advantages of KSDS are:

• Sequential processing is useful for retrieving records in the sorted form


• Random or direct processing of records is useful in on-line applications
Relative Record Data Set (RRDS)

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.

Linear Data Set

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:

In retrieving a record VSAM goes through the following

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.

Two important variations in the process of retrieving a record are:

? A record requested by a processing program may already be in virtual storage. No


physical I/O operations are needed in such a case.
? Sometimes due to the way VSAM stores data and variety of processing options it
supports, it must issue several I/O requests to retrieve a single record.

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.

VSAM Access types:

There are three types of access in VSAM:

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

Relative Byte Address

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.

What is a control interval?

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.

KSDS Organization and Storage

VSAM supports the various options provided by the KSDS, by providing a two-tiered
indexing structure to locate data records.

A KSDS has two components:


? Index component

? Data component

The data component of a KSDS has the following features:

? Data records are grouped into control intervals.

? Data records may be of fixed or variable length.

? Control intervals are grouped together into control areas.

The index component of a KSDS has the following features:

? The index component is divided into control intervals

? 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

Sequential Access of Records

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.

While accessing records sequentially, VSAM performs the following functions:

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

KEY SEQUENCED DATA SET

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.

• 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 (higher keyed) sequence set CI.

• Index Set: remainder of the index component.

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.

• Records are placed in ascending sequence using a key field


• Records can be accessed sequentially or randomly.
• Either by KEY FIELD or RBA accessed randomly.
• Can contain variable length records.
• Inserts records in appropriate place (i.e. ascending order of the key field).
• Physically remove the record when deleted.
• All addition, deletion, and updating is possible
• CI, CA Splits occurs only for this data set.
• Alternate index is possible.
• KSDS contains RDF and CIDF.

DATA / INDEX RELATIONSHIP


KSDS DATA SET

//KSDS1 JOB (123 ), ?INDUS?,NOTIFY=&SYSUID

//STEP1 EXEC PGM= IDCAMS

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

/*

//

ESDS DATA SET

//ESDS1 JOB (123) , ?INDUS?

//STEP1 EXEC PGM= IDCAMS

//SYSPRINT DD SYSOUT=*

//SYSIN DD *

DEFINE CLUSTER -

(NAME( VASM1.ESDS.CLUSTER ) -

VOLUMES( VOL100 ) -

CYLINDERS ( 3,1 ) -

CISZ (4096 ) -

RECORDSIZE (80, 100 ) -

NONINDEXED -

) -

DATA -

( -

NAME( VASM1.ESDS.DATA ) -

/*

//
RRDS DATA SET

//RRDS1 JOB (123) , ?INDUS?

//STEP1 EXEC PGM= IDCAMS

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

/*

//

Loading data into KSDS

Two ways of loading a KSDS are:

? IDCAMS REPRO: The IDCAMS REPRO function will copy the contents of
another data set into KSDS.

? Custom Program: Loading of KSDS using installation-written programs requires


that records be written to the data set in ascending key sequence.

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

The advantages of VSAM are:

? VSAM supports more data set types

? Simplifies record processing

? Supports a variety of I/O techniques

? Provides greater efficiency for the application programs and for the overall
environment

ACCESS METHOD SERVICES ? IDCAMS ?REPRO

• REPRO is short for reproduce.


• It is used to copy contents of a data set into another data set.
• Unlike the EXPORT command, the output of REPRO can be read by an
application program.

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

• COPYING ENTIRE DATA SET:

Syntax:

REPRO INDATASET (EXAMPLE.SAM.INPUT) -

OUTDATASET (EXAMPLE.SAM.OUTPUT)

INDATASET and OUTDATASET can be abbreviated to IDS and ODS.

• REPRO WITH INFILE/OUTFILE:

Syntax:

REPRO INFILE (DD Name of Input File) OUTFILE (DD Name of Output File)

INFILE and OUTFILE can be abbreviated to IFILE and OFILE.

• COPYING A SELCTED RECORDS IN A DATA SET:

Where to start REPRO Where to stop REPRO Valid for:

FROMKEY (rec-key) TOKEY (rec-key) KSDS,ISAM

FROMADDRESS (rba) TOADDRESS (rba) KSDS,ESDS

FROMNUMBER (rrn) TONUMBER (rrn) RRDS

SKIP (number) COUNT (number) KSDS,ESDS.RRDS,ISAM,SAM


REPRO EXAMPLE

//STEPA1 EXEC PGM=IDCAMS

//SYSPRINT DD SYSOUT=*

//SYSIN DD *

REPRO IDS (EXAMPLE.LASTNAME.INDEX) -

ODS (EXAMPLE.EXTRCT.ESDS) -

FROMKEY (NY002) -

TOKEY (NY148)

PRINT COMMAND:

Syntax:

PRINT INDATASET (TSOXXXX.TEST.SAMPLE.KSDS) CHAR COUNT (3)

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.

INDATASET (or IDS):

- Can be used for VSAM or non-VSAM data sets.

- The data set must be cataloged.

- AMS dynamically allocates the dataset, DISP= SHR.

INFILE (or IFILE):

- Alternative to INDATASET.

- Refers to DDNAME in the JCL.

OUTFILE (or OFILE):


- Alternative to SYSPRINT.

- Refers to DDNAME in the JCL.

• PRINTING A SELCTED RECORDS IN A DATA SET:

Where to start PRINTING Where to stop PRINTIN


SKIP (number) COUNT (number)

FROMKEY (key-value) TOKEY (key-value)

FROMADDRESS (rba) TOADDRESS (rba)

FROMNUMBER (rrn) TONUMBER (rrn)

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.

We can use this delete command for deleting

1. base cluster

2. alternate index

3. path

EX:

//KSDS1 JOB (123) , ?INDUS?

//STEP1 EXEC PGM= IDCAMS

//SYSPRINT DD SYSOUT=A

//SYSIN DD *
DELETE -

OZA059.KSDS.CLUSTER -

CLUSTER

/*

//

Multiple alternate indexes (AIX) may be defined over a base 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.

HANDLING OF NON-UNIQUE KEYS

• Point positions to first ?non-unique? of alternate index record (adams)


• Get skip-sequential or direct retrieves first ?non-unique? as indicated an
alternate index record (adams)
• Get sequential retrieves ?non-unique? in order indicated in alternate index
record (adams, petty, kinney)

EX:

//KSDS1 JOB A123 , ?K. RAMANA?

//STEP1 EXEC PGM= IDCAMS

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

• Path is vehicle for access via alternate key


• Path consists of base cluster and an alternate index
• Multiple paths for same alternate index
• 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.
• This command establishes a path between the alternate index and base cluster.
EX:

//KSDS1 JOB A123 , ?K. RAMANA?

//STEP1 EXEC PGM= IDCAMS

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

WHAT IS AN UPGRADE SET?

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.

STEPS FOR LOADING AN ALTERNATE INDEX

1. DEFINE THE ALTERNATE INDEX AND PATH.

2. EXTRACT ALTERNATE KEYS AND POINTERS.

3. ORDER KEYS AND POINTERS BY ALTERNATE

KEY SEQUENCE

4. BUILD ALTERNATE INDEX RECORDS

Steps 2, 3 and 4 can be accomplished by a user program or by IDCAMS BLDINDEX.

ALTENATE INDEX RESTRICTIONS

• No alternate indexes for RRDS or lds


• Base cluster must not be empty for BLDINDX
• Upgrade done only for non-empty alternate indexes
• Length of alternate keys must 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 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.

Das könnte Ihnen auch gefallen