Professional Documents
Culture Documents
Objectives
Familiarization with
VSAM concepts
Space Allocation and types of data sets supported by VSAM
VSAM Characteristics
Introduction to VSAM
(Virtual Storage Access Method)
Session 1
Topics Covered
VSAM Basics
VSAM Dataset Organization
What is VSAM?
VSAM is a high-performance access method used in OS/390, MVS/ESA
and z/OS operating systems
Used as a Dataset in conjunction with programming languages (COBOL or
PL/I) to create Applications
Used by CICS to store and retrieve data
Not a database management system does not provide a relationship
among data (such as DB2 or IMS)
VSAM Characteristics
VSAM supports three types of data access: Sequential, Random (also
called Direct access) and Skip Sequential
Protection of data against unauthorized access is an inherent part of VSAM
Easily portable to AS/400, the PC or non-IBM computers (cross system
compatibility)
A format for storing data independently of the type of direct access storage
device on which it is stored
KSDS
RRDS
VRRDS
LDS
QSAM
ISAM
BDAM
10
Similar to
KSDS
ISAM
ESDS
BSAM/QSAM
RRDS
BDAM
11
12
Topics Covered
VSAM Catalog Structure
VSAM Terminology
13
VSAM Terminology
Catalog Management
Record management
Logical Record
Data component
Key Field
Master/User Catalog
Physical Record
Data Space
Cluster
Sphere
Alternate Indexes
Index component
Spanned Records
14
Catalog Management
VSAM maintains extensive information about data sets and direct access
storage space in an integrated catalog facility (ICF) catalog.
The catalogs collection of information about a data set defines that data
sets characteristics. All VSAM files
must be defined in an ICF catalog.
15
Record Management
The record management part of VSAM contains the access method code.
16
Logical record
Unit of information used to store data in a VSAM data set.
Set of bytes containing a logical description of an item processed
by an application program.
A logical record can be of a fixed size or a variable size depending on the
business requirements.
17
Key field
Identifies the item associated with the logical record.
Important Field whose contents can be used to retrieve the specific logical
record
18
Physical record
The data is usually a set of logical records (packed together) transferred
from or to memory by just one Read or Write CCW. The access method
uses the BLKSIZE parameter to determine the length of the physical record.
A large block size results in fewer gaps in the track but larger buffer in
memory to keep the data.
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.
19
Cluster
Collection of physical datasets that make up one logical data set.
Consists of Data Component or Data Component & Index Component
20
Sphere
A sphere is a base VSAM cluster and its associated clusters.
These associated clusters are the alternate indexes (AIXs) of the base
cluster.
21
22
Alternate Indexes
Alternate indexes (AIXs) allows logical records of a KSDS or of an ESDS 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.
24
Spanned Records
Spanned records are needed when the application requires very long logical
records. A spanned record may be the data component of an AIX cluster. If
spanned records are used for KSDS, the primary key must be within the first
control interval.
Spanned records are logical records that are larger than the CI size. To
have spanned records, the file must be defined with the SPANNED attribute
at the time it is created. Spanned records are allowed to extend across or
span control interval boundaries.
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.
25
26
Control Interval
VSAM Basic unit of work the minimum amount of data that is transferred
via buffers, between DASD and Main Memory
VSAM determines the size of the physical Record (BLOCK) based on CI
Size
The CI size can be from 512 byes to 32 KB
27
28
29
Unused Space
US CIF
CISZ
Control Information Field
30
31
Number of Records/CI
Fixed Length
Multiple
10
Fixed Length
Variable Length
32
FSPC
(4096*0.20)
819 bytes
US
67 bytes
CIF
10 bytes
Unused space =
4096 3200 819 10 = 67
33
Inserting a record in a CI
Before Inserting:
11111
22222
22222
US CIF
New record
After Inserting:
11111
(FSPC)
44444
34
11111
22222
44444
55555
66666 US CIF
(FSPC)
CI-2
US CIF
After CI Split:
CI-1
11111
22222
33333
(FSPC)
US CIF
CI-2
44444
55555
66666
(FSPC)
US CIF
35
Header
Entry1
Entry2
Entryn
CIF
36
37
Topics Covered
Types of VSAM Datasets
More on KSDS Index Structure
38
Objective
Understand the types and internal organization of VSAM datasets
Identify appropriate applications for VSAM data sets
Understand KSDS Index Search Techniques
39
40
41
ESDS CA Structure
42
43
RRDS Structure
44
45
46
KSDS Structure
47
48
49
LDS Structure
50
Comparison of VSAM DS
51
52
53
KSDS Structure
54
55
56
Vertical Search
For a Random Access, search is performed from the Index set
Once the key <= condition is met, then it follows a downward pointer to
the corresponding Sequence set
57
Example-1
How Index & Sequence Sets work
58
Example-2
Data Component Structure
Data Records
59
60
61
63
64
Topics Covered
Introduction to IDCAMS
IDCAMS Commands
Define and Load a VSAM dataset
VSAM Advanced Topics
65
Objectives
Use Access Method Services (AMS )
Identify some useful AMS Commands
Define and Load a Basic Cluster with IDCAMS
Define and Build Alternate Index
66
Introduction to IDCAMS
67
IDCAMS Utility
Multifunction utility program supplied with VSAM (IDCAMS) to manage
and maintain datasets
68
IDCAMS Features
IDCAMS can be used to
Define, Alter and Delete datasets and allocate space for them
Reorganize datasets
69
Invoking IDCAMS
1. As a Job or Job step
Example
//YOURJOB JOB (ACCT),'IDCAMS JOB',
//STEP1
EXEC PGM=IDCAMS
//SYSPRINT DD SYSOUT=*
//SYSIN
DD *
AMS commands and their parameters
/*
70
71
IDCAMS Commands
72
COMMANDS
Modal Commands
Functional Commands
73
COMMANDS (Contd..1)
COMMAND specifies the type of service requested
Default statement margins are positions 2 through 72.
Command stmt can be continued to the next line with - as the last
parameter
Comment may be embedded in Command statements between /* and */
74
COMMANDS (Contd..2)
75
Condition Codes
IDCAMS returns a condition code following the execution of each Command
76
77
Explanation
78
Explanation
A requested function was completed but major specifications
were unavoidably bypassed
12
16
79
Modal Commands
IF-THEN-ELSE :
Used to control command execution on the basis of condition codes
DO-END :
Used to specify the group of commands as a single unit
80
PARM
SET
81
82
Functional Commands
DEFINE Used to define the following objects
Alias
Alternate index
Cluster
Dataspace
Path
84
85
86
87
88
89
90
DEFINE CLUSTER
The DEFINE CLUSTER command can be used to define a cluster and
specify attributes for the cluster as a whole and for the components of the
cluster. The general format is :
91
92
LISTCAT
The LISTCAT command lists catalog entries.
Freespace, CI/CA split, Data Attributes, Statistics. Allocation information
93
LISTCAT Syntax
LISTCAT ALIAS | ALTERNATEINDEX |
CLUSTER | NONVSAM | PATH | ENTRIES(entryname/password
entryname/password..) |
LEVEL(level)
EXPIRATION(days)
NAME | HISTORY | VOLUME|
ALLOCATION | ALL
OUTFILE(ddname)
94
LISTCAT example
//JOBTRGXX ...
//LISTCAT1 EXEC PGM=IDCAMS
//SYSPRINT DD SYSOUT=A
//SYSIN
DD *
LISTCAT ENTRIES(TRGXXX.MAST.CLUSTER) CLUSTER ALL
/*
95
REPRO
The REPRO command copies VSAM and non-VSAM data sets, copies
catalogs.
96
REPRO Syntax
REPRO {INFILE(ddname)/password
INDATASET(entryname)/password
{OUTFILLE(ddname/password
OUTDATASET(entryname/password}
( CHARACTER | DUMP | HEX )
( FROMKEY(key) |
( FROMADDRESS(address) |
( FROMNUMBER(number) )
SKIP(number)
( TOKEY(key) |
TOADDRESS(address) |
TONUMBER(number) )
COUNT(Number)
97
REPRO example
Example: Load VSAM KSDS from Non-VSAM dataset and copy selected
records to an ESDS
//JOBTRGXX ...
//STEP1
EXEC PGM=IDCAMS
//INPUTDD
DD DSN=TRGXXX.DATA.RECORDS,DISP=OLD
//SYSPRINT DD SYSOUT=A
//SYSIN
DD *
REPRO INFILE(INPUTDD) OUTDATASET(TRGXXX.KSDS.CLUSTER)
/*
98
DELETE
The DELETE command deletes catalogs, VSAM datasets, non-VSAM
datasets and objects.
99
100
DELETE example
//DELMAST EXEC PGM=IDCAMS
//SYSPRINT DD SYSOUT=A
//SYSIN
DD *
DELETE (TRGXXX.MAST.CLUSTER TRGXXX.TEST.DATA) FILE(DD1) PURGE ERASE
/*
101
PRINT
PRINT: The PRINT command prints VSAM datasets, non-VSAM datasets,
and catalogs. The syntax is:
102
PRINT Syntax
PRINT {INFILE(ddname /password )
INDATASET(entryname /password ) }
CHARACTER| DUMP | HEX
FROMKEY(key) |
FROMADDRESS(address) |
FROMNUMBER(number) }
SKIP(number)
OUTFILE(ddname)
TOKEY(key) |
TOADDRESS(address) |
TONUMBER(number)|
COUNT(Number)
103
PRINT example
//JOBTRGXX ...
//DEFAIX
EXEC PGM=IDCAMS
//SYSPRINT DD SYSOUT=A
//SYSIN
DD *
PRINT INDATASET(TRGXXX.MAST.CLUSTER) FROMKEY(E00001) COUNT(100)
/*
104
VERIFY
The VERIFY command causes a catalog to correctly reflect the end of a
VSAM data set after an error occurs while closing a VSAM data set
The syntax is:
VERIFY {FILE(ddname/password) |
DATASET(entryname/password)}
105
VERIFY Example
Example of a typical VERIFY usage
Job TRGJJJJ has terminated abnormally and VSAM dataset
TRGXXX.MAST.CLUSTER is not closed correctly. This job is followed by
another job that uses this file for an IDCAMS copy. Following are the set of
return codes that will appear in the Job Spool
In JESMSGLG the error will be
IEC161I 056-084,TRGGXXXX,JS010,IFILE01,,,
In SYSPRINT of the step failed the error will be
IDC3300I ERROR OPENING TRGXX.MAST.CLUSTER
IDC3351I ** VSAM OPEN RETURN CODE IS 118
Solution: A VERIFY issued on VSAM file TRGXXX.MAST.CLUSTER will
correct this error
106
107
ALTERNATE INDEX
Allows for a KSDS to be accessed in a different order other than the primary
key
Allows the creation of an index for a non-indexed object, such as an ESDS
cluster
108
109
110
BLDINDX
The BLDINDEX command builds alternate indexes for existing data sets
Alternate Index can be built only after its base has been loaded with at least
one record
111
BLDINDX example
//JOBTRGXX ...
//BLDINDEX EXEC PGM=IDCAMS
//DD1
DD DSN=TRGXXX.TEMP.SEQ,DISP=SHR
//DD2
DD DSN=TRGXXX.MAST.TEMP.AIX,DISP=SHR
//IDCUT1 DD VOL=TEMPDA,UNIT=3380,DISP=OLD,AMP='AMORG
//IDCUT2 DD VOL=TEMPDA,UNIT=3380,DISP=OLD,AMP='AMORG'
//SYSPRINT DD SYSOUT=*
//SYSIN DD *
BLDINDEX INFILE(DD1) OUTFILE(DD2)
/*
112
DEFINE PATH
After defining an alternative index, a PATH must be defined to access the
data set. This forms the connection between the alternative index and the
base cluster, and the connection is stored in the catalog
When a program opens a path for processing, both the base cluster and the
alternate index are opened
113
114
GDG
A group of chronologically or functionally related data sets are called
Generation Data Group (GDG)
Each data set within a GDG is called a Generation Data Set or simply a
Generation
They are processed periodically, often by adding a new generation,
retaining previous generations, and sometimes discarding the oldest
generation
Each generation data set in the group will have the name as GDG
name.GxxxxVyy, where xxxx is the generation number and yy is the
version number
115
GDG (Contd..)
GDGs can be referred in a JCL by means of an absolute name or relative
name
Absolute name is by coding the complete Generation name as
GDGname.G0001V00
Relative name is a signed integer used to refer to the latest (0), the next to
the latest (1), and so forth, generation. The relative number can also be
used to catalog a new generation (+1)
116
GDG Advantages
The advantages of grouping related data sets are:
All of the data sets in the group can be referred to by a common name
The operating system is able to keep the generations in chronological
order
Outdated or obsolete generations can be automatically deleted by the
operating system
117
GDG Usage
One of the important usage of a GDG is for cataloging periodic backups of
VSAM datasets
Example, a GDG of limit 7 can be used to take backup of VSAM data
sets from the batch job for all 7 days of the week
The GDG base after data sets are cataloged will be as follows
GDGname.G0001V00
GDGname.G0001V01
GDGname.G0001V06
Another important usage of GDG is for cataloging periodic reports (weekly,
monthly, etc). Example, a GDG with limit 12 can hold monthly reports for a
year
118
GDG Syntax
DEFINE GENERATIONDATAGROUP
(NAME(entryname)
LIMIT(limit)
[EMPTY | NOEMPTY]
[SCRATCH | NOSCRATCH]
[TO(date) | FOR(days)])
119
GDG example
//JOBTRGXX ...
//DEFGDG
EXEC PGM=IDCAMS
//SYSPRINT DD SYSOUT=A
//SYSIN
DD *
DEFINE GENERATIONDATAGROUP ( - NAME(TRGXXX.MAST.GDG)
LIMIT(5)
SCRATCH )
/*
120
121
122
U.5.1 Option
Access method services (option u.5.1) provides
interface for the following functions
Define Cluster
Define alternate index
Define path
Alter VSAM dataset characteristics
Rename a dataset
Copy/Load a VSAM dataset
Delete a VSAM dataset
Print a VSAM dataset
Verify endfile markers
123
124
125
126
127
Discussion Topics
What does an index component contain in KSDS ?
How data is organized in Data Component ?
What is the Index search technique for a Random process?
Access Method Services, IDCAMS creates and maintains VSAM DS. State
True / False
128
129
Demo/Exercise
Session 4
130
Demo
Create a VSAM KSDS
Load VSAM KSDS (Use Repro)
Create an Alternate Index
Build Index
Define Path
Do a LISTCAT on KSDS and explain the output
131
References
MVS/VSAM for the Application Programmer Gary D.Brown & S.A.M.
Smith
VSAM Demystified Mary Lovelace et al. IBM Redbooks 2003 (Document
Number SG24-6105-01) in IBMs Website
DFSMS/MVS V1R2 Access Method Services for VSAM (Document Number
SC26-4905-01) in IBMs Website
132
THANK YOU
133