Sie sind auf Seite 1von 101

VSAM VSAM

VSAM
Knowledge Level: Knowledge Level:
Basic Basic
Copyright 2004, Cognizant Academy, All Rights Reserved 2
Module Metadata
VSAM/PPT/0704/1.0 Version and
Date:
Swaminath Venkataraman
101823
Created By:
Copyright 2004, Cognizant Academy, All Rights Reserved 3
Module Information
TSO/ISPF
JCL
Prerequisites
Trainees / VSAM Beginners Target Audience
This Module will provide the students
Introduction to VSAM
Understanding VSAM dataset organizations
Using IDCAMS utility to manipulate VSAM datasets
Work with Alternate Indexes
Module
Description
Copyright 2004, Cognizant Academy, All Rights Reserved 4
Module Objective
Module Objective:
After completing this Module, you will be able to
Understand VSAM concepts & Dataset organizations
Use IDCAMS utility to manipulate VSAM datasets
Understand Alternate Index concepts
Module Outline:
1.
VSAM Basics
2.
Using Access
Method
Services
3.
Alternate
Indexes
4.
Generation
Data Group
Copyright 2004, Cognizant Academy, All Rights Reserved 5
1.0 VSAM Basics : Overview
Introduction:
This Topic gives an
Introduction to VSAM
VSAM concepts & Terminologies
Advantages & Disadvantages
Various Dataset Organizations
Objective:
After completing this Topic, you will be able to
Understand What VSAM is & What it is not
Understand How VSAM datasets are organized
Understand the various Dataset organizations and their structure
Understand Control Interval Split & Control Area Split
Copyright 2004, Cognizant Academy, All Rights Reserved 6
VSAM Concepts : What is an Access
Method?
Access Method stores and retrieves data between the Disk & Main
memory
Traditional Access Methods
BSAM Basic Sequential Access Method
QSAM Queued Sequential Access Method
ISAM Indexed Sequential Access Method
BDAM Basic Direct Access Method
Main
Storage
Disk
Access
Method
Data Data
Copyright 2004, Cognizant Academy, All Rights Reserved 7
VSAM Concepts : What is VSAM?
VSAM Virtual Storage Access Method
Introduced by IBM in 1973 which replaced the traditional access
methods
One of the several access methods on z/OS, intended to provide most
file organization needs for application programmers
There are 3 types of access in VSAM:
Random Also referred to as Direct Access. The logical record needs to be located
by the use of a search argument coming from the application.
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.
Skip sequential - 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.
Copyright 2004, Cognizant Academy, All Rights Reserved 8
VSAM Concepts : What is VSAM?
VSAM datasets have to be stored in DASD
All VSAM Datasets have to be cataloged
There are two major parts to VSAM
Catalog Management - The catalog, which contains information about the data
sets, can be an ICF or a VSAM catalog.
Record Management - The purpose of record management is to maintain records in
a VSAM data set for an application or a system program.
Copyright 2004, Cognizant Academy, All Rights Reserved 9
VSAM Concepts : What VSAM is not?
VSAM is not
A DBMS, as it does not provide for a relationship among the data
A programming language but is used in conjunction with languages like
COBOL, etc.
A communication system like VTAM or CICS
Copyright 2004, Cognizant Academy, All Rights Reserved 10
VSAM Concepts : Advantages
One access method supports all types of data retrieval
Supports Fixed & Variable record lengths
Ease of Use - IDCAMS utility to manage all VSAM operations
Portability - Portable across systems & device independent
Secure - They are protected by internal VSAM security and also by
products like RACF
Copyright 2004, Cognizant Academy, All Rights Reserved 11
VSAM Concepts : Advantages
Modular Catalog entry for a dataset contains all the information the
system needs to know, like space allocation, security, attributes, etc.
Supports Alternate Index
Can be accessed by both batch and online programs
Copyright 2004, Cognizant Academy, All Rights Reserved 12
VSAM Concepts : Disadvantages
VSAM requires a large amount of disk storage overhead
For KSDS, primary key cannot be changed
Performance can be slow because of complexity of Index
Only resides on DISK
Copyright 2004, Cognizant Academy, All Rights Reserved 13
VSAM Concepts : Logical Record
Logical Record
A logical record is 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.
Example: An Employee with all associated data (Employee ID, Name,
Address, Department, Project details, etc).
A logical record can be of a fixed size or a variable size depending on the
business requirements. VSAM supports both depending on the specific
organization.
A logical record is device independent
Copyright 2004, Cognizant Academy, All Rights Reserved 14
VSAM Concepts : Logical Record
Key Field
An important field in the logical record is the key, which can be used to
retrieve the specific logical record .
Example: Employee ID
Copyright 2004, Cognizant Academy, All Rights Reserved 15
VSAM Concepts : Physical Record
Physical record
A physical record is device dependent, its size is calculated at the time
the data set is defined.
All physical records have the same length.
Copyright 2004, Cognizant Academy, All Rights Reserved 16
VSAM Catalogs : Catalog Management
One of the Major parts to VSAM is Catalog Management. The catalog, which
contains information about the data sets.
All VSAM objects must be cataloged.
Unlike non-vsam datasets which can be stored in the DASD without a catalog entry
and can be accessed by specifying the VOLUME in which they reside
All access on a VSAM object is via the catalog.
So, it provides means to implement good control over all VSAM objects.
Catalog contains all information about the dataset
Like space, security, access criteria, attributes, processing statistics.
Non-vsam objects can also be defined within VSAM catalog (Including GDGs)
VSAM objects are portable from one system to another.
Copyright 2004, Cognizant Academy, All Rights Reserved 17
VSAM Catalogs : Catalog types
There are two types of catalog :VSAM catalog and ICF catalog
Generic catalog structure consists of one master & one/multiple user
catalogs
VSAM datasets have to be cataloged in the user or master catalog.
Non-VSAM datasets can be cataloged either in a master/user catalog or
in an OS catalog (Control Volume, CVOL)
Master Catalog
User
Catalog
User
Catalog
User
Catalog
Copyright 2004, Cognizant Academy, All Rights Reserved 18
VSAM Organization : Control Interval
Control Interval (CI)
CI is a contiguous area of direct access storage that VSAM uses to store
data records and control information that describes the records.
CI is the unit of information that VSAM transfers between the storage
device and the processor during one I/O operation. (Similar to a Block).
CI contains Records, Free space (Optional), Control Interval Definition
Field (CIDF) and Record Definition field (RDF)


LR = Logical record
US = Unused Space
RDF = Record definition field
CIDF = Control interval definition field
R
D
F
1
R
D
F
2
R
D
F
n

Free Space
(FSPC)

LRn


LR2 LR1
C
I
D
F
Control Information Fields

U
S
Copyright 2004, Cognizant Academy, All Rights Reserved 19
VSAM Organization : Control Interval
Areas within a Control Interval
Logical Record Area (LRA) contains the records
Control Interval Free Space (FSPC) which does not have any records
Unused space, because the free space may not be a multiple of the
record length, there may be a small amount of space that cannot be used
Control Fields
RDF: Record Definition Field
3 bytes long and one or more per CI
Indicates length of records
Indicates how many adjacent records are of the same length
They are inserted right to left as records are added. The rightmost RDF describes
the first record in the CI
CIDF: Control Interval Definition Field
4 bytes long
One per CI
Indicates Free space
Copyright 2004, Cognizant Academy, All Rights Reserved 20
VSAM Organization : Control Interval
Examples
Record Length = 1024
Record Length = 380
Read RDF backwards, from right to left
A
150
B
150
C
150
Free
Space
RDF
3
RDF
150
CIDF
564
A
80
B
100
C
200
RDF
200
RDF
100
RDF
80
CIDF
0
Copyright 2004, Cognizant Academy, All Rights Reserved 21
VSAM Organization : Spanned Record
Spanned record
Spanned records are logical records that are larger than the CI size.
A spanned record cannot be larger than a CA.
The RDFs describe whether the record is spanned or not.
A spanned record must always begin on a control interval boundary and
fills one or more control intervals within a single control area.
A spanned record cannot share the CI with any other records.
Example:
Data component of an Alternate Index Cluster.
Copyright 2004, Cognizant Academy, All Rights Reserved 22
VSAM Organization : Control Area
Control Area (CA)
Control Intervals are grouped into Control Areas
A VSAM Dataset can have more than one CA
CA is VSAMs internal unit for allocating space
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
Copyright 2004, Cognizant Academy, All Rights Reserved 23
VSAM Organization : Relative Byte Address
Relative Byte Address (RBA)
The RBA of a logical record is the offset of its first byte from the
beginning of the file.
Then, the first logical record in a VSAM file has an RBA of zero; the
second logical record has an RBA equal to the length of the first record,
and so on.VSAM returns to the application the RBA of the stored logical
record. The RBA of a logical record in VSAM includes the free space and
control information stored before this logical record.
CI
RBA of B is 80 and C is 120
A B C
80 40 60
Copyright 2004, Cognizant Academy, All Rights Reserved 24
VSAM Organization : Types of Datasets
VSAM supports the following dataset organizations
Entry Sequenced Datasets (ESDS)
Key-Sequenced Datasets (KSDS)
Relative Record Datasets (RRDS) Fixed and Variable record length
Linear Datasets (LDS)
This can be illustrated using the concept followed in books
In early days books were sequential from Start to End with no breaks
(corresponds to Linear Dataset)
Afterwards, organized into chapters and paragraphs (corresponds to Entry
Sequenced Dataset)
Page numbers were introduced to identify a page (corresponds to Relative
Record Dataset)
Indices were later introduced to locate a topic directly (corresponds to key
sequenced Dataset)
Copyright 2004, Cognizant Academy, All Rights Reserved 25
VSAM Organization : Components
Components
A component is a name given to the individual parts of a VSAM data set
Each component has a name, an entry in the catalog and an entry in the
VTOC
There are two types of components - the data component and the index
component.
Data component - The data component is the part of a VSAM data set,
alternate index, or catalog that contains the data records.
Index component - The index component is a collection of logically
sequenced keys. The key is a value taken from a fixed defined field in each
logical record. The key determines the records position in the data set. Using
the index, VSAM is able to randomly retrieve a record from the data
component when a request is made for a record with a certain key.
Copyright 2004, Cognizant Academy, All Rights Reserved 26
VSAM Organization : Components
The KSDS and VRRDS organizations have data and index components.
ESDS, RRDS and LDS organizations only have data components.
Since VSAM supports random and sequential types of access, it divides
the index into two parts: Sequence Set and Index Set
Copyright 2004, Cognizant Academy, All Rights Reserved 27
VSAM Organization : Sequence Set
Sequence Set
Sequence set is used for sequential
access.
The sequence set is the lowest level
of index CIs and directly points to the
data CI in the CA.
There is one index entry per CI data
and consequently one index CI for
each data CA.
Every logical record contains pointers
and high key information for each
data CI.
It also contains horizontal pointers
from one sequence set CI to the next
higher keyed sequence set CI
Copyright 2004, Cognizant Academy, All Rights Reserved 28
VSAM Organization : Index Set
Index Set
The index set is used for random
access.
Contains Primary keys and pointers
to the sequence set
If there is more than one sequence
set CI, VSAM automatically builds
another index CI in other level.
Each CI in the index set contains
pointers and high key information for
CIs in the next lower level of the
index.
Top level index always one record
Copyright 2004, Cognizant Academy, All Rights Reserved 29
VSAM Organization : Cluster
Cluster
A cluster is a set of related components (maximum two).
Cluster is the catalog entry for the VSAM dataset to point to the allocated
space
For a KSDS, a cluster is the set of a data component and an index
component.
RRDS, ESDS, and LDS formats are considered to be clusters without index
components.
VSAM dataset is referred cluster name in the JCL
CLUSTER
INDEX
DATA
Copyright 2004, Cognizant Academy, All Rights Reserved 30
VSAM Organization : KSDS Structure
Key-Sequenced Data Set
(KSDS)
Consists of both an Index and Data
Component
Records are initially loaded in the data
component in ascending collating
sequence by key.
Each primary record must contain a
unique value and occupy the same
contiguous bytes in each record.
Length of key must be 1 byte to 255
bytes.
After it is specified, the value of the key
cannot be altered.
The entire record can be deleted
Allows Alternate Index
KSDS records can be fixed or variable
length. They can also be spanned.
Copyright 2004, Cognizant Academy, All Rights Reserved 31
VSAM Organization: KSDS Structure
Copyright 2004, Cognizant Academy, All Rights Reserved 32
VSAM Organization : KSDS Access
KSDS can be read and written sequentially. With sequential access, records are
read and written in consecutive order based on the primary key. Access is done
through the Index component, so that records are processed in the order of the
primary key
Copyright 2004, Cognizant Academy, All Rights Reserved 33
VSAM Organization : KSDS Access
KSDS can be read or written randomly. Records are accessed directly by providing
VSAM the key of the record. VSAM uses the index to locate the control area and the
control interval containing the record. It then reads that control interval and locates
the specific record within it by examining the record keys.
Copyright 2004, Cognizant Academy, All Rights Reserved 34
VSAM Organization : ESDS Structure
Entry Sequenced Dataset (ESDS)
It is similar to a sequential file
Has no index component and only a
data component
Records may be fixed or variable-
length
Sequenced by the order in which
data is entered/loaded
New records are added only at the
end
Records cannot be inserted or
deleted, except by copying the data
Records may be spanned
In CICS online applications records
can be retrieved sequentially,
randomly or dynamically using an
alternate index
Copyright 2004, Cognizant Academy, All Rights Reserved 35
VSAM Organization : RRDS Structure
Relative Record Dataset (RRDS)
It is similar to a table or an array
Has no index component and only a
data component
Records must be fixed length
Records are stored in numbered,
fixed length slots.
Each record is given a number,
Relative Record Number (RRN)
VSAM determines the number of
slots by Size of CI & Length of
Record
Records can be deleted physically
Empty slots can be filled up with new
records without shifting records
Can be processed sequentially,
directly or skip-sequentially.
It is very fast as there is no index to
search
Copyright 2004, Cognizant Academy, All Rights Reserved 36
VSAM Organization : LDS Structure
Linear Dataset (LDS)
Contains data that can be accessed as
byte-addressable strings in virtual
storage.
control interval size multiple of 4096
bytes.
An LDS has no imbedded control
information in its CI, that is, no RDFs and
CIDFs.
Has only the data component
The most common LDS exploiter is DB2.
Copyright 2004, Cognizant Academy, All Rights Reserved 37
VSAM Organization : Comparisons
Copyright 2004, Cognizant Academy, All Rights Reserved 38
Control Interval & Control Area Split
Control Interval & Control Area Splits
CI and CA splits occur as a result of data record insertions.
If a record is to be inserted and there is not enough free space in the CI,
the CI will be split.
Approximately half of the records in the CI are transferred to a free CI
and the record to be inserted is placed in the original CI.
If there are no free CIs and a record is to be inserted, a CA split occurs.
When a CA split occurs, half of the Control Interval is moved from the
original Control Area to the new Control Area.
The physical sequence of records and CIs is no longer the same as the
logical sequence after a split.
A new index entry is inserted in the sequence set for the new CI, and the
existing index entry is updated.
Copyright 2004, Cognizant Academy, All Rights Reserved 39
Control Interval & Control Area Split
Before the Split
Copyright 2004, Cognizant Academy, All Rights Reserved 40
Control Interval & Control Area Split
After the Split
Copyright 2004, Cognizant Academy, All Rights Reserved 41
2.0 Access Method Services: Overview
Introduction:
This Topic gives an
Introduction to Access Method Services
Defining a VSAM Cluster using IDCAMS
Loading data using REPRO
Other IDCAMS commands
Objective:
After completing this Topic, you will be able to
Define & Delete VSAM datasets
Understand the various VSAM definition parameters
Load data using the REPRO command
Copyright 2004, Cognizant Academy, All Rights Reserved 42
Access Method Services :Getting started
Access Method Services (AMS)
Manages both VSAM & non-VSAM datasets
AMS uses command processor called IDCAMS
IDCAMS handles functions like creating, reproducing, printing, etc.
Normally executed in Batch
Always has the following JCL structure
//STEP010 EXEC PGM=IDCAMS
//SYSPRINT DD SYSOUT=*
//SYSIN DD*
<IDCAMS command from col.2 to col.72>
/*
//*
Copyright 2004, Cognizant Academy, All Rights Reserved 43
Access Method Services : Getting started
Basic IDCAMS Commands
DEFINE (Cluster, Alternate Index etc.)
BUILDINDEX (Alternate Index)
REPRO (Cluster)
LISTCAT (Catalog Entries)
IMPORT / EXPORT (Cluster)
VERIFY (Cluster)
Copyright 2004, Cognizant Academy, All Rights Reserved 44
VSAM Definition : DEFINE CLUSTER
DEFINE CLUSTER syntax
This command tells IDCAMS to create and name a VSAM cluster
DATA and INDEX parameters are needed only for KSDS
Format:
DEFINE CLUSTER (NAME (cluster name) parameters)
NAME is defined as the first parameter
Abbreviation: DEF CL
Used for defining KSDS, ESDS, RRDS
Example:
DEFINE CLUSTER ( NAME(F800.LIB.KSDS.CLUSTER))
DATA ( NAME(F800.LIB.KSDS.DATA))
INDEX ( NAME(F800.LIB.KSDS.INDEX))
Copyright 2004, Cognizant Academy, All Rights Reserved 45
VSAM Definition : NAME parameter
NAME Parameter
NAME is a positional keyword parameter and must be coded first.
It is placed right after DEFINE CLUSTER
Example
DEFINE CLUSTER
(NAME (F800.LIB.KSDS.CLUSTER))
The cluster name becomes the dataset name in any JCL that invokes
this cluster, either as an input or output dataset
Example:
//INPUT DD DSN= F800.LIB.KSDS.CLUSTER,DISP=SHR
The rules for naming the VSAM datasets is same as non-VSAM
datasets
Copyright 2004, Cognizant Academy, All Rights Reserved 46
VSAM Definition : SPACE parameter
Space Allocation Parameter
Specifies the space allocation values in the units of Cylinders or tracks
or records or KB or MB
Format:
CYLINDERS (primary secondary) [CYL (primary secondary)]
TRACKS (primary secondary) [TRK (primary secondary)]
RECORDS (primary secondary) [REC (primary secondary)]
KILOBYTES (primary secondary) [KB (primary secondary)]
MEGABYTES (primary secondary) [MB (primary secondary)]
Used for: KSDS, ESDS, RRDS
Required: Yes
Example
CYLINDERS(5 1)
Copyright 2004, Cognizant Academy, All Rights Reserved 47
VSAM Definition : VOLUMES parameter
Volumes Parameter
Assigns one or more storage volumes to the dataset. Multiple volume
datasets should be of the same device type (3390, for example)
Format:
VOLUMES(vol ser) or VOLUMES(volser 1 volser2.volser n)
VOL(vol ser) or VOL(volser 1 volser2.volser n)
Used for: KSDS, ESDS, RRDS
Required: Yes
Example
VOLUMES(VS0102)
Data & Index components can be stored on separate volumes which
may provide a performance advantage for large datasets
Copyright 2004, Cognizant Academy, All Rights Reserved 48
VSAM Definition : Dataset type
Dataset type parameter
Specifies whether the dataset is KSDS, RRDS or ESDS
Format:
KSDS : INDEXED or IXD
ESDS : NONINDEXED or NIXD
RRDS : NUMBERED
LDS : LINEAR
Default is INDEXED
Required : No
Copyright 2004, Cognizant Academy, All Rights Reserved 49
VSAM Definition : Record size parameter
Record size parameter
Specifies the size of the records. Optional
Format :RECORDSIZE (Average Maximum) / RECSZ(Average
Maximum)
Default : RECORDSIZE(4086 4086)
Required : No
Used for: KSDS, ESDS, RRDS
Average & Maximum are same for Fixed length records
Example:
RECSZ (80 80) [Fixed length records]
RECSZ(80 120) [Variable length records]
Copyright 2004, Cognizant Academy, All Rights Reserved 50
VSAM Definition : KEYS parameter
KEYS Parameter
Defines the length and offset of the primary key in a KSDS record. The
offset is the keys displacement from the beginning of the record
Format: KEYS (length offset)
Length: Length in bytes of the primary key
Offset: Offset in bytes of the primary key within the record (0 to n)
Used for: KSDS
Default Value : KEYS(64 1) (Key is in bytes 2 through 65)
Required: No
Example:
KEYS(8 0)
VSAM records begin in position zero. Here the primary key begins in
position 0 for length of 8 bytes (bytes1 through 8)
Copyright 2004, Cognizant Academy, All Rights Reserved 51
VSAM Definition : DATA parameter
DATA Parameter
DATA parameter tells IDCAMS that a separate data component will be
created.
Must follow the parameters that apply to the cluster as a whole.
Format:
DATA( NAME(data name) parameters)
Data name: The name given to the data component and the name should
confirm to the same rules & conventions as the cluster name
Used for : ESDS, KSDS, RRDS
Example : DATA (NAME (F800.LIB.KSDS.DATA))
Copyright 2004, Cognizant Academy, All Rights Reserved 52
VSAM Definition : INDEX parameter
INDEX Parameter
INDEX parameter tells IDCAMS that a separate data component will be
created.
Must follow the parameters that apply to the data component.
Format:
INDEX( NAME(index name) parameters)
Index name: The name given to the index component and the name should
confirm to the same rules & conventions as the cluster name
Used for : KSDS
Example : INDEX (NAME (F800.LIB.KSDS.INDEX))
Copyright 2004, Cognizant Academy, All Rights Reserved 53
VSAM Definition : Example
Example Define command syntax for VSAM KSDS
//STEP010 EXEC PGM=IDCAMS
//SYSPRINT DD SYSOUT=*
//SYSIN DD *
DEFINE CLUSTER ( NAME(F800.LIB.KSDS.CL) -
CYLINDERS(5 1) -
VOLUMES(VOL001) -
INDEXED -
RECSZ(80 100) -
KEYS(10 0) -
) -
DATA ( NAME(F800.LIB.KSDS.DATA)) -
INDEX ( NAME(F800.LIB.KSDS.INDEX))
/*
{`- is the continuation character and are normally aligned}
Copyright 2004, Cognizant Academy, All Rights Reserved 54
Definition parameters : More parameter
AMS performance parameters
The performance related parameters are coded in the DEFINE CLUSTER
command in order to
Reduce the amount of Physical I/O
Make necessary I/O faster
Optimize disk utilization
Copyright 2004, Cognizant Academy, All Rights Reserved 55
Definition parameters : Control Interval Size
Control Interval Size
Control Interval is the VSAM basic amount of data transferred, via
buffers, between DASD and main memory.
Format: CONTROLINTERVALSIZE (bytes)
Byte: size of control interval in bytes. It should be multiple of 512 or 2048
bytes
Abbreviated as : CISZ or CISIZE
Default: Calculated by VSAM
Required: No
Used for: KSDS, ESDS, RRDS
Thumb Rule for CISIZE
If the record length is <8192, multiples of 512,
If the record length is >=8192, multiples of 2048
Example: CISZ(4096)
Copyright 2004, Cognizant Academy, All Rights Reserved 56
Definition parameters : FREESPACE
FREESPACE
Allocates some percentage of Control Interval & Control Area for
planned free space. This free space can be used for adding new
records or expanding existing variable records
Applies to the data component but can be coded at the data component
level or the cluster level
Format: FREESPACE (CI% CA%)
ci% - Percentage of control intervals to leave free for expansion
ca% - Percentage of control areas to leave free for expansion
Default: FREESPACE(0 0)
Used for: KSDS
Example: FREESPACE(20 10)
Copyright 2004, Cognizant Academy, All Rights Reserved 57
Definition parameters : FREESPACE
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
Rate of growth of records
Expected number of records to be deleted
Reorganization frequency
Performance consideration
Copyright 2004, Cognizant Academy, All Rights Reserved 58
Definition parameters : BUFFERSPACE
BUFFERSPACE
Buffer space represents the amount of storage(in bytes) required to process
one control interval worth of data
Format: BUFFERSPACE (bytes)
Used for: KSDS, ESDS, RRDS
Default: Two data buffers & one additional index buffer for KSDS
Buffering depends on the type of dataset
Sequential: Only data buffers are required
Random: More Index buffers than data buffers. At least one buffer for each
level of index
Dynamic: Proportional to the ratio of sequential to random processing
Buffer space can be overridden AMP JCL parameter.
//DD1 DD DSN=F800.LIB.CLUSTER,AMP=('BUFND=4,BUFNI=4,STRNO=2')
BUFND No. of data buffers, BUFNI No. of Index buffers
STRNO Strings which indicates the No. of concurrent access. It should 1 for
batch and more for online.
Copyright 2004, Cognizant Academy, All Rights Reserved 59
Definition parameters : KEYRANGES
KEYRANGES
Divides a large dataset among several volumes based on the key
Format : KEYRANGES (low-key high-key)
low-key: The low value for the range of key to be placed on a volume
high-key: The high value for the range of key to be placed on a volume
Default : None (No range assumed)
Used for : KSDS
Example :
KEYRANGES ( (000001 100000) -
(100001 200000))
Then the volume is specified on which the records should be placed with
the VOLUMES parameter.
The Key Ranges correspond to VOLUMES if ORDERED clause is
specified.
Copyright 2004, Cognizant Academy, All Rights Reserved 60
Definition parameters : ORDERED
ORDERED
This parameter tells VSAM to assign the KEYRANGES values to the
volumes, one by one, in the order in which the KEYRANGES and
VOLUMES are specified.
Format : ORDERED | UNORDERED
Default : UNORDERED
Used for : KSDS
Example : KEYRANGES ( (000001 100000) -
(100001 200000)) -
VOLUMES (VS0001 -
VS0002) -
ORDERED
Copyright 2004, Cognizant Academy, All Rights Reserved 61
Definition parameters : REUSE
REUSE
REUSE specifies that the cluster can be loaded with fresh records with
an implicit delete of existing records.
Format : REUSE/NOREUSE
Default : NOREUSE
Used for : KSDS, ESDS, RRDS
Example : NOREUSE
REUSE
A Cluster is not reusable under the following conditions
A KEYRANGES parameter is coded
An alternate index is built
Copyright 2004, Cognizant Academy, All Rights Reserved 62
Definition parameters: SHAREOPTIONS
SHAREOPTIONS
SHAREOPTIONS specifies how a VSAM dataset can be shared
Format : SHAREOPTIONS (Cross-region-value Cross-system-
value)
Cross-region: Defined as different jobs running on the same system
(ex:TSO&CICS accessing same data)
Cross-system: Defined as different jobs running on different systems
Values:
1 Multiple read OR Single write (Complete data integrity)
2 Multiple read AND Single write (Write but not read integrity)
3 Multiple read AND Multiple write (No integrity)
4 Same as 3, but refreshes buffers for each random access.
Copyright 2004, Cognizant Academy, All Rights Reserved 63
Definition parameters: SHAREOPTIONS
SHAREOPTIONS
Used for : KSDS, ESDS, RRDS
Default : SHAREOPTIONS (1 3)
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
Copyright 2004, Cognizant Academy, All Rights Reserved 64
Definition parameters : Other parameters
Other Parameters
RECOVERY | SPEED
SPANNED | NOSPANNED
IMBED | NOIMBED
REPLICATE | NOREPLICATE
ERASE | NOERASE
Copyright 2004, Cognizant Academy, All Rights Reserved 65
Return Codes
MAXCC & LASTCC
MAXCC - on IF and SET commands, is the highest condition code
returned by any preceding command in the job step or since the last
SET command changed the maximum condition code.
LASTCC - on IF and SET commands, is the condition code returned by
the immediately preceding command.
Possible values for LASTCC and MAXCC set by IDCAMS are 0, 4, 8,
12, or 16.
Copyright 2004, Cognizant Academy, All Rights Reserved 66
More Commands: Repro
REPRO
All purpose load and backup utility command
Can be used against empty / loaded VSAM file with another VSAM file
or sequential file
Much easier to use than IEBGENER
Can be used against all four types of VSAM datasets
Performs three basic functions
Loads an empty VSAM cluster with records. The data and index (for
KSDS) components are built automatically
Creates a backup of a VSAM dataset on a physical sequential dataset, and
then restores and rebuilds the VSAM dataset using this dataset as input.
Merges data from two VSAM datasets
Copyright 2004, Cognizant Academy, All Rights Reserved 67
More Commands: Repro Syntax
REPRO Syntax
Format: REPRO
INFILE(ddname) | INDATASET(dsname)
OUTFILE(ddname) | OUTDATASET(dsname)
optional parameters
Used for: KSDS, ESDS, RRDS
Required: Yes
Example: REPRO -
INFILE(DD1) -
OUTFILE(DD2)
Copyright 2004, Cognizant Academy, All Rights Reserved 68
More Commands: Repro Examples
Repro Examples
//COPYSTEP EXEC PGM=IDCAMS
//SYSPRINT DD SYSOUT=*
//INPUTFL DD DISP=SHR,DSN=A2000.LIB.SEQFILE,
// DISP=SHR
//OUTPUTFL DD DSN=A2000.LIB.KSDS.CL,
// DISP=SHR
//SYSIN DD *
REPRO INFILE(INPUTFL) OUTFILE(OUTPUTFL)
/*
//
Copyright 2004, Cognizant Academy, All Rights Reserved 69
More Commands: Repro Examples
Repro Examples
//COPYSTEP EXEC PGM=IDCAMS
//SYSPRINT DD SYSOUT=*
//SYSIN DD *
REPRO INDATASET(A2000.LIB.SEQFILE) -
OUTDATASET(A2000.LIB.KSDS.CL)
/*
//COPYSTEP EXEC PGM=IDCAMS
//SYSPRINT DD SYSOUT=*
//INPUTFL DD DSN=A2000.LIB.SEQFILE,DISP=SHR
//SYSIN DD *
REPRO INFILE(INPUTFL) -
OUTDATASET(A2000.LIB.KSDS.CL)
/*
Copyright 2004, Cognizant Academy, All Rights Reserved 70
More Commands: Repro Parameters
FROMKEY/TOKEY Parameter
FROMKEY specifies the key of the input record at which to begin
reading
TOKEY specifies the key of the last input record to write
Either or both the parameters can be coded
Format : FROMKEY(key)
TOKEY(key)
Used for : KSDS
Required : No
Default : First record in dataset for FROMKEY and last record in
dataset for TOKEY
Example : FROMKEY(AAA1000)
TOKEY(CCC9999)
If VSAM does not find a match for the FROMKEY value, it starts loading
the records at the next higher value
If VSAM does not find a match for the TOKEY, it stops loading at the
previous lower value
Copyright 2004, Cognizant Academy, All Rights Reserved 71
More Commands: Repro Parameters
SKIP / COUNT Parameter
SKIP specifies the number of input records to skip before beginning to
copy
COUNT specifies the number of output records to copy
Format : SKIP(number)
COUNT(number)
number: Number of records to skip or copy
Used for : KSDS, ESDS, RRDS, non-VSAM datasets
Copyright 2004, Cognizant Academy, All Rights Reserved 72
More Commands: Repro Parameters
SKIP / COUNT Parameter
Required : No
Default : SKIP defaults to the First record in the dataset and
COUNT defaults to all the records in the dataset
Example : SKIP(50)
COUNT(1000)
Copyright 2004, Cognizant Academy, All Rights Reserved 73
More Commands: Repro Parameters
REUSE / REPLACE Parameter
REUSE parameter
Can be used only if the VSAM dataset was originally defined with REUSE
option
Has the effect of logically deleting records before loading
REPLACE parameter
Replaces the records for which primary keys are matching between input
and output records
If not specified, the matching key records are untouched
If the target is ESDS the records are appended and REPLACE is
inappropriate.
Copyright 2004, Cognizant Academy, All Rights Reserved 74
More Commands: Export / Import
EXPORT / IMPORT
Used for backup and recovery
Export a dataset, an alternate index, or even a Catalog information to a
different (compatible) system
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
Copyright 2004, Cognizant Academy, All Rights Reserved 75
More Commands: VERIFY
VERIFY
Used for preserving data integrity
Syntax : VERIFY FILE (<ddname>)
VERIFY DATASET(<datasetname>)
Used for : KSDS, ESDS, RRDS
Can be issued from TSO or from a JCL
Verifies the catalog HURBA (High Used Relative Byte Address) field and
stores the true values from the control block HURBA field.
Should be used against cluster name only and not against data or index
components
Used to rectify some of the problems due to data corruption
Copyright 2004, Cognizant Academy, All Rights Reserved 76
More Commands: LISTCAT
LISTCAT
Used to list the contents of a master or user catalog.
Format : LISTCAT CATALOG (name)
ENTRIES (name - of - entries)
LEVEL (generic-level-names)
Used for : KSDS, ESDS, RRDS
Default : All catalogs
Example : LISTCAT
CATALOG(CAT001)
LEVEL(A2000)
Lists all the entries in the CAT001 catalog with the high-level qualifier
A2000
Copyright 2004, Cognizant Academy, All Rights Reserved 77
More Commands: ALTER
ALTER
ALTER changes certain dataset attributes
Format : ALTER entry-name
entry-name: The name of the entry to alter.
Used for : KSDS, RRDS, ESDS, non-VSAM
Examples of some attributes that can be altered
FREESPACE, BUFFERSPACE
Example :
ALTER A2000.LIB.KSDS,CLUSTER FREESPACE(30 30)
Copyright 2004, Cognizant Academy, All Rights Reserved 78
More Commands: DELETE
DELETE
IDCAMS DELETE command be used to delete both VSAM and non-VSAM
objects
Format : DELETE entry-name
entry-name: The name of the entry to delete
Used for : KSDS, RRDS, ESDS, non-VSAM
Parameters : CLUSTER, ALTERNATEINDEX, PATH, etc
All the parameters are optional. When no parameter is specified it deletes
all related objects such as AIX, Path
Example : DELETE A2000.LIB.KSDS.CLUSTER
DELETE A2000.LIB.KSDS.AIX ALTERNATEINDEX
=> Deletes the Alternate index
Copyright 2004, Cognizant Academy, All Rights Reserved 79
More Commands: DELETE
Some Common DELETE Parameters
ERASE / NO ERASE : ERASE writes binary zeroes after deletion
PURGE / NO PURGE : PURGE allows deletion even though
expiration date is still due
ALTERNATE INDEX Or AIX : Deletes only Alternate index of the
cluster
PATH : Requests only path name to be deleted.
FORCE / NO FORCE : FORCE deletes the dataset even if it is not
empty
Copyright 2004, Cognizant Academy, All Rights Reserved 80
3.0 ALTERNATE INDEX: Overview
Introduction:
This Topic gives an
Introduction to Alternate Index
Steps involved in creating an Alternate Index
Defining an ALTERNATE INDEX using IDCAMS
Defining a PATH entry using IDCAMS
Building the ALTERNATE INDEX using IDCAMS
Objective:
After completing this Topic, you will be able to
Understand the need for an Alternate Index
Understand the various steps involved in creating Alternate Index
Define the Alternate Index and build the index
Copyright 2004, Cognizant Academy, All Rights Reserved 81
Alternate Index : Introduction
ALTERNATE INDEX
Alternate indexes (AIXs) allows logical records of a KSDS or of an ESDS
(in this context called a base cluster) to be accessed sequentially and
directly by more than one key field
AIXs eliminate the need to store the same data in different sequences in
multiple data sets for the purposes of various applications
Each alternate index is a KSDS cluster consisting of an index component
and a data component
Copyright 2004, Cognizant Academy, All Rights Reserved 82
Alternate Index : Introduction
ALTERNATE INDEX
Any field in the base cluster record can be used as an alternate key. It
may also overlap the primary key (in a KSDS), or with any other alternate
key.
The same base cluster may have several AIXs varying the alternate key.
There may be more than one primary key value per the same alternate
key value.
Example: The primary key is an employee number and the alternate key
is the department name, obviously the same department name may have
several employee numbers
Copyright 2004, Cognizant Academy, All Rights Reserved 83
Alternate Index : Introduction
AIX can be updated automatically when the base cluster is updated.
Automatic update is an option that is chosen when defining the alternate
index.
Theoretically a maximum of 255 alternate keys per base cluster.
ALTERNATE INDEX - Disadvantages
Performance degradation
Complex update logic
Copyright 2004, Cognizant Academy, All Rights Reserved 84
Alternate Index : Organization
ALTERNATE INDEX
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)
Copyright 2004, Cognizant Academy, All Rights Reserved 85
Alternate Index : Organization
U
Hdr Key Ptr1 Ptr2 Ptr3 Hdr Key Ptr4 FSPC S CF

Key Ptr Key Ptr
U
Hdr Key Ptr5 dr Key Ptr6 Ptr7 SPC S CF
Ptr1 to Ptr7 point to the data component of the base
cluster
AIX
data
CIs
AIX Index Component
Copyright 2004, Cognizant Academy, All Rights Reserved 86
Alternate Index : Steps for creation
Steps to Crate an ALTERNATE INDEX
1. Define the Alternate Index using the IDCAMS DEFINE AIX command
2. Specify the Alternate Index path using the IDCAMS DEFINE PATH
command. The path forms a connection between the alternate index and
the base cluster. While path is a VSAM object, it contains no records.
The path name becomes a catalog entry
3. Build the alternate index and populate it with records using the IDCAMS
BLDINDEX command.
Copyright 2004, Cognizant Academy, All Rights Reserved 87
AIX definition : Define AIX
Define AIX Command
This command is similar to the DEFINE CLUSTER which tells VSAM that
an alternate index is to be created
Format : DEFINE ALTERNATE INDEX parameters
Abbreviation: DEFINE AIX parameters
Used for : Alternate index for a KSDS, ESDS
Required : Yes if an alternate index is defined
Example : DEFINE ALTERNATEINDEX
Copyright 2004, Cognizant Academy, All Rights Reserved 88
AIX definition : NAME parameter
NAME Parameter
NAME is a positional keyword parameter and must be coded first.
It is placed right after DEFINE AIX
Format : NAME(index cluster name)
Example
DEFINE AIX -
(NAME (F8000.LIB.KSDS.AIX))
The rules for naming the VSAM datasets is same as non-VSAM
datasets
Copyright 2004, Cognizant Academy, All Rights Reserved 89
AIX definition : VOLUMES parameter
VOLUMES Parameter
Specifies where the alternate index is to be stored
Format:
VOLUMES(vol ser) or VOLUMES(volser 1 volser2.volser n)
VOL(vol ser) or VOL(volser 1 volser2.volser n)
Used for : Alternate Index over a KSDS, ESDS
Required: Yes
Example
VOLUMES(VS0102)
Copyright 2004, Cognizant Academy, All Rights Reserved 90
AIX definition : RELATE parameter 2
RELATE Parameter
This parameter establishes the relationship between the base cluster and
the alternate index
Format : RELATE(base cluster name)
Used for : Alternate index over a KSDS, ESDS
Required : Yes
Example : RELATE(A2000.LIB.KSDS.CLUSTER)
Copyright 2004, Cognizant Academy, All Rights Reserved 91
AIX definition : UPGRADE parameter
UPGRADE Parameter
This parameter specifies whether the records in the alternate index are
the be updated automatically
Format : UPGRADE | NOUPGRADE
Used for : Alternate index over a KSDS, ESDS
Default : UPGRADE
Required : No
Example : UPGRADE
NOUPGRADE
Copyright 2004, Cognizant Academy, All Rights Reserved 92
AIX definition : KEYS parameter
KEYS Parameter
Defines the length and offset of the alternate index key
Format: KEYS (length offset)
Length: Length in bytes of the key
Offset: Offset in bytes of the key within the record (0 to n)
Used for : Alternate index over a KSDS, ESDS
Default : KEYS(64 0)
Required: No, because of default, which is same as Primary key
Example:
KEYS(25 9)
Although not a required parameter, defeats the purpose of an alternate index if not
specified and different from the primary key
Copyright 2004, Cognizant Academy, All Rights Reserved 93
AIX definition : UNIQUEKEY parameter
UNIQUEKEY / NONUNIQUEKEY Parameter
Specifies whether the alternate index key is Unique or Non-unique
Format: UNIQUEKEY | NONUNIQUEKEY
Used for : Alternate index over a KSDS, ESDS
Default : UNIQUEKEY
Required: No, because of default
Example: UNIQUEKEY
Each unique alternate index record built over a KSDS consists of following:
5 bytes of VSAM housekeeping information
Alternate Index key
Single primary key pointer that the alternate index resolves to
Each non-unique alternate index record built over a KSDS consists of
following:
5 bytes of VSAM housekeeping information
Alternate Index key
One or more primary key pointer that the alternate index resolves to
Copyright 2004, Cognizant Academy, All Rights Reserved 94
AIX definition : Recordsize parameter
RECORDSIZE Parameter
Specifies the average and maximum length of the alternate index key
Format: RECORDSIZE (avg max)
Used for : Alternate index over a KSDS, ESDS
Default : RECORDSIZE(4086 32600)
Required: No, because of default
Example:
RECORDSIZE(100 200)
Average & Max record size are same for UNIQUEKEY
Average & Max record size are different for UNIQUEKEY
RECORDSIZE for KSDS AIX = 5 + Alternate Key + (n * Primary Key
length) where n=1 for UNIQUEKEY and n=number of data records that
contain the same alternate key value when NONUNIQUEKEY is
specified
Copyright 2004, Cognizant Academy, All Rights Reserved 95
PATH definition : Define PATH
Define PATH Command
The path name is what is used in the JCL while processing an alternate
index
It is a separate catalog entry and forms a logical connection (path) through
the alternate index to the base cluster
Format : DEFINE PATH
( NAME(path-name)
PATHENTRY (entry-name)
UPDATE | NOUPDATE
)
Used for : Alternate index for a KSDS, ESDS
Required : Yes if an alternate index is defined
Example : DEFINE PATH
( NAME(A2000.LIB.KSDS.PATH) -
PATHENTRY (A2000.LIB.KSDS.AIX) -
UPDATE
)
Copyright 2004, Cognizant Academy, All Rights Reserved 96
PATH definition:PATHENTRY parameter
PATHENTRY Parameter
The PATHETRY parameter specifies the alternate index name. This
establishes the path entry between the alternate index cluster and the path
Format : PATHENTRY (entry-name)
entry-name: Alternate Index sluster name
Used for : Alternate index for a KSDS, ESDS
Required : Yes if an alternate index is defined
Example : PATHENTRY (A2000.LIB.KSDS.AIX)
Copyright 2004, Cognizant Academy, All Rights Reserved 97
PATH definition:UPDATE parameter
UPDATE Parameter
The UPDATE parameter specifies whether the base clusters alternate index
are to be updated automatically when the path is opened for processing.
NOUPDATE specifies that the indexes are not be automatically updated.
Works in tandem with the UPGRADE / NOUPGRADE option of the alternate
index definition
Format : UPDATE | NOUPDATE
Used for : Alternate index for a KSDS, ESDS
Required : Yes.
Example : UPDATE
NOUPDATE
Copyright 2004, Cognizant Academy, All Rights Reserved 98
Build Index : BLDINDEX command
BLDINDEX Command
This is the command that builds the Alternate index and populate it with
records.
The base cluster should already be defined and loaded with records before
the BLDINDEX operation
Format : BLDINDEX
INFILE(ddname) OUTFILE(ddname)
INTERNALSORT | EXTERNALSORT
BLDINDEX
INDATASET(datasetname) OUTDATASET(outdatasetname)
INTERNALSORT | EXTERNALSORT
Used for : Alternate index for a KSDS, ESDS
Required : Yes.
Example : BLDINDEX -
INDATASET(A2000.LIB.KSDS.CLUSTER) -
OUTDATASET(A2000.LIB.KSDS.AIX) -
INTERNALSORT
Copyright 2004, Cognizant Academy, All Rights Reserved 99
4.0 Generation Data groups (GDG)
Generation Data groups
GDG is used to maintain different generations of Physical Sequential
Datasets.
Used to create multiple generations of Master file backups.
In typical production runs it is used as a backup to be restored, if the job
abends.
Format : DEFINE GENERATIONDATA GROUP
LIMIT(N)
EMPTY | NOEMPTY
SCRATCH | NOSCRATCH
Copyright 2004, Cognizant Academy, All Rights Reserved 100
VSAM: Next Step
The following items will provide more information on the subjects covered in this
Module:
e-learning
Module
Reference Topic or Topic Description Resource
Type
J .Ranade VSAM Concepts, Programming &
Design
Book
http://www.redbooks.ibm.co
m
VSAM Demystified PDF
PDF
URL
Classroom
training
Gary D Brown, SAM Smith MVS / VSAM for the application
programmer
Book
Congratulations!
You have successfully
completed
Congratulations!
Congratulations!
You have successfully
You have successfully
completed
completed
VSAM
VSAM

Das könnte Ihnen auch gefallen