Sunteți pe pagina 1din 205

VSAM 1

VIRTUAL STORAGE
ACCESS METHOD
(VSAM)
Version 2.1
VSAM 2
VSAM
VSAM means virtual storage access method
High performance access method and dataset
organization designed specifically for VS
environment.
It resides in virtual storage
Organizes and maintains data via a cataloged
structure
VSAM 3
VSAM HISTORY
B] A+RRDS & AIX, Catld. Facility
Enhanced VSAM
C] DF/EF VSAM
ICF Cataloging
MVS/XA Ver. 1
Changes were compatible
with DF/EF VSAM
A] Standard VSAM. Only ESDS & KSDS
MVS/XA Ver. 2
LDS were added
VSAM 4
FEATURES OF VSAM
One coherent file storage system
(Stores and Retrieves Data)
Not a database management system
Not a programming language
Not a communication system
VSAM has no equivalent for a PDS
Introduction by IBM in 1973
DFP/VSAM Ver 1 in 1989
VSAM 5
ADVANTAGES OF VSAM
Protection of Data
Cross-system (MVS & VSE) Compatibility
Device Independence (Access Via Catalog)
IDCAMS commands can be included in JCL to handle VSAM
Used by CICS (OLTP) to store and retrieve data
VSCOBOL II/PL-I/ASSMB. Long can access VSAM dataset
VSAM 6
TYPES OF VSAM DATASETS
Based on the way in which we store and access the records:
KSDS Key Sequenced dataset
ESDS Entry Sequenced dataset
RRDS Relative record dataset
LDS Linear dataset
All the four methods contain a data area in which data records
are placed
For KSDS, there is an index area in addition to data area
VSAM 7
VSAM files are often called clusters

A cluster is the set of catalog entries that represent a file

A cluster consists of one or two components, a data component,
which contains the actual records of a file, and for a KSDS only,
an index component, which contains the indexes used to
access records in the data component.
Must be defined for each dataset
CLUSTERS
VSAM 8
CLUSTERS
INDEX COMPONENT
DATA
COMPONENT
I. KSDS CLUSTER
DATA
COMPONENT
II. ESDS, RRDS Cluster

VSAM 9
VSAM RECORDS
Can be fixed or variable length

Records can also be spanned

A Linear dataset has no records

Note : LDS - Linear dataset
(Newest Type)
It is just a long string of bytes divided into 4k pages. Accessed
by Relative Byte Address
VSAM 10
CONTROL INTERVAL
A control interval is the unit of data VSAM transfers between
virtual and disk storage
Is similar to the concept of blocking in non-VSAM files.
Generally contains more than one record
The size of CI must be between 512 bytes to 32K
Upto 8K bytes it must be multiple of 512, beyond this it is
multiple of 2K.
Fixed length, selected at file creation time
For index, the size of CI is 512, 1K, 2K or 4K bytes
VSAM 11
CONTROL INTERVAL
A control Interval contains
Logical Records
Control Information
Free Space
Control Interval Descriptor Field(CIDF) contains information
about available space with in CI.
Record Descriptor Field (RDF) contains the length of each
record and how many adjacent records are of the same
length.
One RDF for each record in variable length files
Only two RDFs per CI in case of fixed length files
RDF is of 3 bytes long
VSAM 12
CONTROL INTERVAL
FSPS
U
S
CF
Logical Record Area (LRA)
Freespace Unused Control
Space Field
Rec 1 Rec 3 Rec 2
<------------------- CISZ ------------------------>
RDF
<---3 bytes--->
CIDF
<---4 bytes---->
Record definition
Field
Control Interval
Definition Field
CF
Logical Record Area (LRA)
VSAM 13
VSAM groups control intervals into contiguous, fixed length
areas of storage called control areas.
Maximum of 1 cylinder
Can specify freespace in CA
Number of CI/CA is fixed by VSAM.
CONTROL AREA(CA)
CONTROL INTERVAL
CONTROL INTERVAL
CONTROL INTERVAL
CONTROL INTERVAL
VSAM 14
Spanned records are records larger than CI size. So one
spanned record is stored in several CIs
Each CI that contains a record segment of a spanned record
has two RDFs. The right RDF gives the length of the segment
and the left gives the update number of the segment
Can only be used in ESDS and KSDS
A CI that contains a record segment of a spanned record
contains no other data
SPANNED RECORDS
VSAM 15
ESDS
ESDS is a sequential dataset:
Records are retrieved in the order in which they are written to
the dataset
Additions are made always at the end of the file
Records can be retrieved randomly by using RBA(Relative
Byte Address)
RBA is an indication of how far, in bytes, each record is
displaced from the beginning of the file
High-Used-RBA (HURBA)points to the end of the data
High-Allocated-RBA (HARBA)is the highest byte that can be
used
VSAM 16
HURBA AND HARBA
HARBA
HURBA
VSAM cluster
Data space
allocated but
empty
Data space
loaded with
records
VSAM 17
VSAM DATASET STRUCTURE
VSAM 18
KSDS
It is similar in many ways to ISAM file, with better index
structure and improved overflow handling
Can be processed sequentially and randomly
A KSDS consists of two components:
Index component
Data component
VSAM 19
DATA Component
I
II
III
IV
V
VI
Data Component Control Intervals
Control Areas
VSAM 20
INDEX COMPONENT
Index Component
Index Set
Sequence Set
Points to control Intervals
* There will be 1 record per CI
(lower level of Indexing)

Points to Sequence Set
* There will be one record per Sequence Set
(higher level of indexing)

VSAM 21
Key Ptr Key Ptr
CI1 CI2 CI3 CI3 CI4 CI5
Index Set and control areas for a KSDS
Control Area 1 Control Area 2
Sequence Set 1 Sequence Set 2
Index
Set
I
n
d
e
x

C
o
m
p
o
n
e
n
t

D
a
t
a

C
o
m
p
o
n
e
n
t

C
o
n
t
r
o
l

A
r
e
a
s

Key Ptr Key Ptr Key Ptr Key Ptr Key Ptr Key Ptr
KSDS STRUCTURE
VSAM 22
KSDS STRUCTURE
48424
(SS-REC-1)
95651
(SS-REC-2)
Hdr
Hdr 48011
(CI - 1)
48303
(CI - 2)
48424
(CI - 3)
Hdr 91761
(CI - A)
95651
(CI - B)
SS-Rec-1 SS-Rec-2
Binary
Zeroes
Sequence
Set Records
Index Set Record
Horizontal pointers
VSAM 23
KSDS STRUCTURE
CONTROL AREA 2

44012 44039 44136 FSPC


48012 48013 FSPC FSPC

48304 48416 48424 FSPC
CI-1
CI-2
CI-3
48525 90064 90403 FSPC

91762 92373 95651 FSPC
FREE SPACE
CI-A
CI-B
CI-C
D
a
t
a

R
e
c
o
r
d
s

CONTROL AREA 1
VSAM 24
SEQUENCE SET OF KSDS
Key Ptr
C 100
Key Ptr
F 300
Key Ptr
I 200
Key Ptr
L 400
Rec
A
Rec
B
Rec
C
FSPC
Rec
E
Rec
J
Rec
K
Rec
L
FSPC
FSPC
FSPC
Rec
D
Rec
G
Rec
H
Rec
I
Control Interval 4
Control Interval 3
Control Interval 2
Control Interval 1
100
200
300
400
CF
CF
CF
CF
VSAM 25
New
Record
Before Inserting
After Inserting
Record 1
Record 2 Record 3 FSPC
U
S
CF
Record 1
Record 2
Record 3
FSPC
U
S
CF
New Record
INSERTION & DELETION OF RECORDS
CONTROL INTERVAL SPLIT
VSAM 26
Record
1
Record
2
New
Record
Record
3
U
S
CF FSPC
To Delete
After Deletion:
Before Deletion:
Record
1
Record
2
Record
3
U
S
CF
FSPC
CONTROL INTERVAL SPLIT
INSERTION & DELETION OF RECORDS
VSAM 27
CONTROL INTERVAL SPLIT
New
Record
Record
1
Record
2
Record
3
Record
4
Record
5
Before Control Interval Split
U
S
CF
U
S
CF
Full
Control
Interval
Empty
Control
Interval
FSPC
VSAM 28
CONTROL INTERVAL SPLIT
After Control Interval Split
Record
2
New
Record
FSPC
Record
1
U
S
CF
Record
4
Record
5
FSPC
Record
3
U
S
CF
VSAM 29
Before Control Interval Split
Sequence set
Record
C
Record
B
Record
A
Record
F
Record
G
U
S
CF
Record
K
Record
J
FSPC
U
S
CF
FSPC
U
S
CF
0
100
200
D
a
t
a

C
o
m
p
o
n
e
n
t

CONTROL INTERVAL SPLIT
I 0 K 100
VSAM 30
FSPC
U
S
CF
Record
F
Record
G
CONTROL INTERVAL SPLIT
Sequence set
Record
B
Record
A
Record
C
FSPC
U
S
CF
Record
K
Record
J
FSPC
U
S
CF
0
100
200
D
a
t
a

C
o
m
p
o
n
e
n
t

E 0 I 200 K 100
VSAM 31
CONTROL AREA SPLIT
060 180 190
001 012 018
061 100 145 170
025 050
181 190
02 06 18 19
001 012 018
145
025 030 050
181 190
170
After adding 030 and 110
024 050
001 012 018
025 030 050
CA split after adding 111
111 145 170
061 100 110
061 110
110 180 190
100
181 190
Seq Set
D
A
T
A

A
R
E
A

D
A
T
A

A
R
E
A

Seq Set
VSAM 32
IDCAMS COMMANDS
VSAM 33
How VSAM is used by Application Programmers:
Write IDCAMS utility program commands & execute them to
create VSAM dataset
Write application programs (in COBOL, PL/I Assembler
Language, in CICS) Using the statements provided by these
languages to write and read VSAM datasets
Use IDCAMS utility program commands to list, examine, print,
tune, backup, and export/import VSAM datasets
IDCAMS
VSAM 34
IDCAMS
Can be invoked
In batch mode with JCL
Interactively with TSO commands
With JCL
can print/display program and sys
messages and return codes
can code multiple commands per job
can specify IF-THEN-ELSE logic to
execute command/s selectively based on
condition codes LASTCC, MAXCC
VSAM 35
IDCAMS
Commands
FUNCTIONAL Commands
DEFINE
BUILDINDEX REPRO
PRINT DELETE
VERIFY ALTER
LISTCAT

MODAL Commands
IF-THEN-ELSE
SET

VSAM 36
// jobname JOB (parameters)
// stepname EXEC PGM=IDCAMS
// SYSPRINT DD SYSOUT = *
[// ddname DD DSN=datasetname,
DISP= SHR/ OLD
]
//SYSIN DD *
IDCAMS command/s coded
freely between 2 to 72 cols.
/*
//
IDCAMS
VSAM 37
IDCAMS
Optionally:

// JOBCAT DD DSN = catalogname, DISP= SHR

// STEPCAT DD DSN = catalogname, DISP = SHR

may be used to indicate catalog names for a job/step, in
which concerned dataset may be cataloged
VSAM 38
FORMAT OF IDCAMS COMMAND
verb object (parameters)
Example :
DEFINE CLUSTER -
NAME(DA0001T.LIB.KSDS.CLUSTER) -
CYLINDERS(5, 1) -
VOLUMES (BS3013) -
INDEXED -
)
Comment
/* comment */

IDCAMS
VSAM 39
CONDITION CODE:
0 : command executed with no errors
4 : warning - execution may go successful
8 : serious error - execution may fail
12 : serious error - execution impossible
16 : fatal error - job step terminates

condition codes are stored in LASTCC/MAXCC
both LASTCC and MAXCC contain zero by default
at the start of IDCAMS execution
IDCAMS RETURN CODES
VSAM 40

IF LASTCC/MAXCC comparand VALUE -
THEN -
command
ELSE
command

IF Syntax
VSAM 41
Comparands are : EQ/NE/GT/LT/GE/LE

Hyphen is the continuation character

Comment is assumed as Null statement

ELSE is optional

IF Syntax
VSAM 42
IF Syntax Example
.........
REPRO INFILE (INDD) -
OUTFILE (OUTDD)
................
IF LASTCC EQ 0 -
THEN -
PRINT OUTFILE (INDD)
ELSE
PRINT INFILE (OUTDD)

VSAM 43

IF MAXCC LT 4 -
THEN -
DO
/* COMMENT */
Command
Command
END
ELSE
Command

USE OF DO/END
VSAM 44
LASTCC and MAXCC can be set to a value between 0-16

setting MAXCC has no effect on LASTCC
setting LASTCC changes the value of MAXCC, if LASTCC
is set to a value larger than MAXCC
setting MAXCC = 16 terminates the job
e.g.
DEFINE CLUSTER
IF LASTCC > 0 THEN -
SET MAXCC = 16
ELSE REPRO
SET COMMAND
VSAM 45
DEFINING A CLUSTER
VSAM 46
The DEFINE CLUSTER Command

This command tells IDCAMS to create and name a VSAM cluster.

Format: DEFINE CLUSTER (NAME (cluster name) parameters)

Abbreviation: DEF CL

Used for: ESDS, KSDS, RRDS

Default: None

Example: DEFINE CLUSTER (NAME (DA0004T.LIB.KSDS.CLUSTER)) -
DATA (NAME (DA0004T.LIB.KSDS.DATA)) -
INDEX (NAME (DA0004T.LIB.KSDS.INDEX))

VSAM 47
The NAME parameter

This is a required positional parameter.

Format: (NAME (cluster name)
cluster name: The name to be assigned to the cluster.

Abbreviation: None

Used for: ESDS, KSDS, RRDS

Default: Yes

Example: DEFINE CLUSTER (NAME (DA0004T.LIB.KSDS.CLUSTER)) -
DATA (NAME (DA0004T.LIB.KSDS.DATA)) -
INDEX (NAME (DA0004T.LIB.KSDS.INDEX))

VSAM 48

The DATA parameter

The DATA parameter tells IDCAMS that you going to create a separate data component.
DATA is optional, but if coded must follow all of the parameters that apply to the cluster as a whole.

Format: DATA (NAME (data name) parameters)
NAME parameter is optional, but you should usually code it.
If coded, it must the first DATA parameter.
data name: The name you choose to name the data component.

Abbreviation: None

Used for: ESDS, KSDS, RRDS

Required: No

Default: None

Example: DATA (NAME (DA0004T.LIB.KSDS.DATA))
INDEX (NAME (DA0004T.LIB.KSDS.INDEX))

VSAM 49
The INDEX parameter

The INDEX parameter creates a separate index component. INDEX is optional,
but if coded must follow all of the parameters that apply only to the data component.

Format: INDEX (NAME (index name) parameters)

index name: The name you choose for the index component.

Abbreviation: IX

Used for: KSDS

Required: No

Default: None

Example: INDEX (NAME (DA0004T.LIB.KSDS.INDEX))

VSAM 50


The SPACE ALLOCATION parameter

The space allocation parameter specifies space allocation values in the units shown below:

Format: Code only one of the following:
CYLINDERS (primary secondary) or
TRACKS (primary secondary) or
RECORDS (primary secondary) or
KILOBYTES (primary secondary) or
MEGABYTES (primary secondary)

Abbreviation: CYL, TRK, REC, KB, MB

Used for: KSDS, ESDS, RRDS

Required: Yes

Default: None

Example: CYLINDERS (10 4)
RECORDS (400 500)

VSAM 51
Remark: It is best to apply space allocation to the entire cluster or to the data component, because VSAM then
calculates the amount of space needed for the index, generally the most efficient technique; for example:

DEFINE CLUSTER (NAME (DA0004T.LIB.KSDS.CLUSTER) -
CYLINDERS (5 3) -
) -
DATA (NAME (DA0004T.LIB.KSDS.DATA)) -
INDEX (NAME (DA0004T.LIB.KSDS.INDEX))

Or

DEFINE CLUSTER (NAME (DA0004T.LIB.KSDS.CLUSTER) -
DATA (NAME (DA0004T.LIB.KSDS.DATA) -
CYLINDERS (5 3) -
) -
INDEX (NAME (DA0004T.LIB.KSDS.INDEX))

VSAM 52
Primary : Allocated once when the dataset is created
Secondary : Allocated a maximum of 122 times as needed
during the life of the dataset
DEFINE CLUSTER
VSAM 53
The VOLUMES parameter

The VOLUMES parameter assigns one or more storage volumes to your dataset.
Multiple volumes must be of the same device type (3390, for example).

Format: VOLUMES (vol ser) or VOLUMES (vol ser ........ vol ser)
vol ser: The six-digit volume serial number of a volume.

Abbreviation: VOL

Used for: KSDS, ESDS, RRDS

Required: Yes

Default: None

Example: VOLUMES (BS3011)
VOLUMES (BS3011 BS3040 BS3042)

VSAM 54

You can store the data and index on separate volumes and
this may provide a performance advantage for large dataset.
DEFINE CLUSTER
VSAM 55

The RECORDSIZE parameter
This parameter tells VSAM what size records to expect. The avg and max are average and
maximum values for variable-length records If records are of fixed length, avg and max should be the same.

Format: RECORDSIZE (avg max)
avg : Average length of records
max : Maximum length of records

Abbreviation: RECSZ

Used for: KSDS, ESDS, RRDS

Required: No

Default: RECORDSIZE (4086 4086)

Example: RECORDSIZE (80 80) [Fixed Length records]
RECORDSIZE (80 120) [Variable Length records]

RECORDSIZE can be assigned at the cluster or data level. For a KSDS,
VSAM calculates the RECORDSIZE of the index based on the KEYS parameter.

VSAM 56


The KEYS parameter

This parameter defines the length and offset of the primary key in a KSDS record.
The offset is the primary keys displacement (in bytes) 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 with records (0 to n)

Abbreviation: None

Used for: KSDS

Required: No

Default: KEYS (64 1)

Example: KEYS (8 0)

VSAM records begin in position zero
VSAM 57

The dataset-type parameter
This parameter specifies whether the dataset is INDEXED (KSDS), NONINDEXED (ESDS),
or NUMBERED (RRDS).

Format: INDEXED| NONINDEXED | NUMBERED

INDEXED: - Specifies a KSDS and is the default
NONINDEXED: - Specifies an ESDS.
No index is created and records are accessed sequentially or by relative byte address
NUMBERED: - Specifies an RRDS
LINEAR: - Specifies a LINEAR dataset

Abbreviation: IXD| NIXD | NUMD

Used for: KSDS, ESDS, RRDS

Required: Yes

Default: INDEXED

Example: INDEXED
NONINDEXED
NUMBERED

VSAM 58


//DA0001TA JOB LA2719, PCS,MSGLEVEL=(1,1), MGCLASS=A,NOTIFY=DA0001T
// * Define Cluster for ESDS VSAM Dataset
//STEP1 EXEC PGM=IDCAMS
// SYSPRINT DD SYSOUT=*
// SYSIN DD *
DEFINE CLUSTER (NAME (DA0001T.LIB.ESDS.CLUSTER) -
NONSPANNED -
REUSE -
NOERASE -
VOLUMES (BS3005) -
RECORDSIZE (80 80) -
RECORDS (30 50) -
CISZ (4096) -
SHR (1 3) -
) -
DATA (NAME (DA0001T.LIB.KSDS.DATA))
/*
//

VSAM 59


//DA0001TA JOB LA2719, PCS,MSGLEVEL=(1,1), MGCLASS=A,NOTIFY=DA0001T
// * Define Cluster for KSDS VSAM Dataset
//STEP1 EXEC PGM=IDCAMS
// SYSPRINT DD SYSOUT=*
// SYSIN DD *
DEFINE CLUSTER (NAME (DA0001T.LIB.KSDS.CLUSTER) -
INDEXED -
KEYS (4 0) -
FSPC (10 20) -
NONSPANNED -
NOREUSE -
NOERASE -
VOLUMES (BS3005) -
SHR (1 3) -
) -
DATA (NAME (DA0001T.LIB.KSDS.DATA) -
RECORDSIZE (80 80) -
RECORDS (30 50) -
CISZ (4096) -
) -
INDEX (NAME (DA0001T.LIB.KSDS.INDEX))
/*
//

VSAM 60

The CONTROLINTERVALSIZE parameter

This parameter specifies the Control Interval size. It is usually abbreviated CISZ.

Format: CONTROLINTERVALSIZE (bytes)

bytes: The size of control interval in bytes. It should be a multiple of 512 or
2048 bytes, depending upon the type of catalog (ICF or VSAM) and the length
of the record. VSAM rounds the CISZ value up to the next highest multiple of 512
Or 2048 if necessary.

Abbreviation: CISZ

Used for: KSDS, ESDS, RRDS

Required: No, because of the default

Default: Calculated by VSAM

Example: CISZ (4096)

Note: If omitted VSAM calculates CISZ based on record size and other control information

VSAM 61
The FREESPACE parameter


Format: FREESPACE (ci% ca%)

ci%: - Percentage of control interval to leave free for expansion
ca%: - Percentage of control area to leave free for expansion

Abbreviation: FSPC

Used for: KSDS

Required: No, because of default.

Default: FREESPACE (0 0)

Example: FREESPACE (20 10)
FREESPACE (20) Control interval only
FREESPACE (0 30) Control area only

VSAM 62
This FREESPACE parameter, which applies to the KSDS,
allocates some percentage of control interval and control area
for planned freespace. This freespace can be used for adding
new records or for expanding existing variable records.

DEFINE CLUSTER
VSAM 63
DEFINE CLUSTER
Too much freespace results in more i/o, especially when
doing sequential processing. Too little results in excessive
control interval and control area split


VSAM 64
The BUFFERSPACE parameter

Buffer space represents the amount of storage (in bytes) required to process the contents of a minimum of
one control intervals worth of data.

Format: BUFFERSPACE (bytes)

Bytes: The number of bytes to allocate to each buffer.

Abbreviation: BUFSP

Used for: KSDS, ESDS, RRDS

Required: No, because of default.

Default: Two data buffers for all types of datasets, plus one additional index
buffer for KSDS.

Example: BUFSP (8704)

VSAM 65
The following example shows the AMP parameter specifying additional data buffers to accommodate sequential and random
processing.

//DD1 DD DSN=DA0001T.LIB.KSDS.CLUSTER,DISP=SHR,AMP=(BUFND=10)

//DD1 DD DSN=DA0001T.LIB.KSDS.CLUSTER,DISP=OLD,
// AMP=(BUFND=10,BUFNI=3)

VSAM 66

The RECOVERY | SPEED parameter

These parameters are mutually exclusive. RECOVERY, the default, reformats the control areas during your initial
dataset load, so that you can restart the job if it abends for some reason. The disadvantage of this parameter
is that programmer has to write recovery routine to restart the job.

SPEED is faster and does not pre-format the control areas. You must reload the dataset from the beginning if the job
fails during initial loading.

Format: RECOVERY | SPEED

Abbreviation: RCVY | None

Used for: KSDS, ESDS, RRDS

Required: No, because of default.

Default: RECOVERY

Example: RECOVERY
SPEED

VSAM 67

The SPANNED | NONSPANNED parameter

This parameter allows large record to span more than one control interval. However records cannot span Control Areas.
The resulting free space in the spanned control interval is unusable by other records, even if they fit logically in the
unused bytes. [NONSPANNED is the default] and it means that records cannot span control intervals

Format: SPANNED | NONSPANNED

Abbreviation: SPND | NSPND

Used for: KSDS, ESDS

Required: No, because of default.

Default: NONSPANNED

Example: NONSPANNED
SPANNED

VSAM 68

The REUSE | NOREUSE parameter

The REUSE parameter specifies that the cluster can be opened a second time as a reusable cluster.
NOREUSE is the default, and specifies the cluster as non-reusable.

Format: REUSE | NOREUSE

Abbreviation: RUS | UNRUS

Used for: KSDS, ESDS, RRDS

Required: No, because of default.

Default: NOREUSE

Example: REUSE
NOREUSE

VSAM 69
Some application call for temporary dataset or workfile that must
be created, used and deleted each time the application run. To
simplify these applications, VSAM lets you create reusable files.
DEFINE CLUSTER
VSAM 70
The SHAREOPTIONS parameter

This parameter tells VSAM whether you want to let two or more jobs to process your file at the same time. It specifies
how a VSAM dataset can be shared among different users.

Format: SHAREOPTIONS (cr value cs value)
cr value : Specifies the value for cross region sharing. Cross region sharing is defined as different jobs running on the
same system using Global Resource Serialization (GRS), a resource control facility available only under MVS/XA and ESA
cs value : Specifies the value for cross system sharing means different jobs running on different system in a NONGRS
environment
Value
1 multiple read OR single write
2 multiple read AND single write
3 multiple read AND multiple write

Abbreviation: SHR

Used for: KSDS, ESDS, RRDS

Required: No, because of default.

Default: SHR (1 3)
Example: SHR (1)
SHR (2 3)
VSAM 71
cr value : Specifies the value for cross region sharing. Cross region
sharing is defined as different jobs running on the same system
using Global Resource Serialization(GRS), a resource control
facility available only under MVS/XA and ESA

cs value : Specifies the value for cross system sharing means
different jobs running on different system in a NONGRS
environment


DEFINE CLUSTER
VSAM 72
The ERASE | NOERASE parameter

The ERASE parameter instructs VSAM to overwrite sensitive data component with binary zeros when the cluster is
deleted.
NOERASE is the default and means that the deleted cluster is not to be overwritten with binary zeros.

Format: ERASE | NOERASE

Abbreviation: ERAS | NERAS

Used for: KSDS, ESDS, RRDS

Required: No, because of default.

Default: NOERASE

Example: NOERASE
ERASE

VSAM 73
The Password Protection Parameter
VSAM provides a hierarchical list of parameters that you can specify for a non-DFSMS-managed VSAM dataset.
However DFSMS-managed dataset you must use a security package like RACF.

Format: MASTERPW (password)
Allows the highest level of access to all cluster components, including DELETE and
ALTER authority.

UPDATEPW (password)
Allows write authority to the cluster.

READPW (password)
Allows read-only access to the cluster.

Abbreviation: MRPW, UPDPW, RDPW

Used for: KSDS, ESDS, RRDS

Required: No

Default: None
Example: MASTERPW (PATNI)
UPDATEPW (XYZ) or READPW (ABC)

VSAM 74
LISTCAT
VSAM 75
LISTCATs basic function is to list information about VSAM and
NONVSAM objects


LISTCAT
VSAM 76

Format: LISTCAT ENTRIES (entry name) options

LISTCAT LEVEL (level) options

entry name: The generic name of each entry to list.

level: The level of qualification at which to begin listing.

Abbreviation: LISTC ENT
LIST LVL

Used for: KSDS, ESDS, RRDS and non-VSAM

Required: No, because of default.

Default: All entries are listed if just LISTCAT is coded

Example: LISTCAT ENTRIES (da0001t.lib.ksds.cluster)

LISTCAT LEVEL (da0001t.lib.ksds. *)

VSAM 77
Options are:
HISTORY or HIST
VOLUME or VOL
ALLOCATION or ALLOC
ALL


Examples:



LISTCAT ENTRIES (DA0001T.VSAM.KSDS.CLUSTER) -
CLUSTER -
ALL


VSAM 78
//STEP1 EXEC PGM=IDCAMS
//SYSPRINT DD SYSOUT=*
//SYSIN DD *
LISTCAT ENTRIES (DA0001T.LIB.KSDS.CLUSTER) ALL
/*

Example 4.2 LISTCAT

Example

LISTCAT LVL (DA0001T.*.KSDS) ALL

VSAM 79
Example 1 : (in JCL)
//STEP1 EXEC PGM=IDCAMS
//SYSPRINT DD SYSOUT=*
//SYSIN DD *
LISTCAT -
ENTRIES(DA0001T.LIB.KSDS.CLUSTER) ALL
/*
Example 2 : (from TSO prompt)
LISTCAT ENTRIES (LIB.KSDS.CLUSTER) ALL
LISTCAT
VSAM 80
ALTERNATE INDEXES
VSAM 81
ALTERNATE INDEX
1 ... x
2 ... y
3 ... x
4 ... z
5 ... t
6 ... x
7 ... q
8 ... z
9 ... y
10 ... b
11 ... c
12 ... t
Book No. Author
other fields of a record
Data set having
Book No as a
Primary Key
VSAM 82
3
6
9
12
1 ... x 2 ... y 3 ... x us
C
F
4 ... Z 5 ... t 6 ... x us
C
F
10 .. .b 11 ... c 12 ... t us
C
F
7 ... q 8 ... z 9 ... y us
C
F
Index
Component
Data
Component
ALTERNATE INDEX
BASE CLUSTER (KSDS)
VSAM 83
b ... 10

c ... 11

q ... 7

t ... 5, 12

x ... 1, 3, 6

y ... 2, 9

z ... 4, 8
Author Book No.
ALTERNATE INDEX
VSAM 84
ALTERNATE INDEX CLUSTER
FOR NON UNIQUE ALTERNATE KEY
S
X
Z
Index
Component
Data
Component
b 10 c 11 q 7
C
F
t 5 12 x 1 3 6
C
F
y 2 9 z 4 8
C
F
VSAM 85
Key Ptr Key Ptr
ALTERNATE INDEX
Hdr Key Ptr 4 FSPC

U CF
S
Index Component :
Control Interval 1
Control Interval 2
The pointers point to a control interval in the data component of
the base cluster that contains the record
Hdr Key Ptr1 Ptr2 Ptr3
Hdr Key Ptr12 FSPC

U CF
S
Hdr Key Ptr9 Ptr10 Ptr11
VSAM 86
ORGANIZATION OF AN
ALTERNATE INDEX
HK
5
AUTH-LAST_NAME
25
LIB_NUM
8
LIB_NUM
8
LIB_NUM
8
<-------------- PRM_KEY (S) ------------->
RECORDSIZE(54 110)
ESDS :
ALT-INDX-KEY PRM-KEY
KSDS :
HOUSE KEEPING
5
SOC_SEC_NUM
9
EMP_NUM
8
RECORDSIZE(22 22)
HK
5
TIMESTAMP
12
RBA
4
- Occupies Less Space
- RBA-Access is Faster
DATA COMPONENT :
VSAM 87
May be defined on one or more than one Alternate Key(s)
i.e. Field(s) other than primary key
Alternate Key(s) need not be unique
Separate cluster is defined
A path is also defined for connection between base cluster
and alternate index cluster
Each ALT. Index itself is a KSDS
Consists of both data component and an index component
Alternate Index upgradation is by default
For ESDS, Vsam builds ALT. index by mapping one field to
the records RBA.
ALTERNATE INDEX(S)
VSAM 88
Supported only for assembler or online CICS

Do not support a reusable base cluster

Greatly reduce data redundancy

May lead to performance Degradation

Build the ALT. index after the base cluster has been both
defined and loaded with atleast 1 record.
ALTERNATE INDEX(S)
VSAM 89
Creating an alternate index requires three separate steps:

Define the alternate index using the IDCAMS DEFINE AIX command

Define an alternate index path using the IDCAMS DEFINE PATH command

Build the alternate index and populate it with records using the IDCAMS BLDINDEX command

The above three steps need to repeated for each alternate index built over the base cluster.

VSAM 90
STEP 1: Defining the Alternate Index
The first step in creating an alternate index is to define with the DEFINE AIX command


The DEFINE ALTERNATEINDEX Command

Define the Alternate Index Cluster using the IDCAMS DEFINE AIX command.

Format: DEFINE ALTERNATEINDEX

Abbreviation: DEF AIX

Use: Alternate index over a KSDS, ESDS

Required: Yes, if an alternate index is defined.

Default: None

Example: DEFINE AIX

VSAM 91
The NAME parameter

It is mandatory parameter that names the alternate index.

Format: NAME (index cluster name)

Abbreviation: None

Use: Alternate index over a KSDS, ESDS

Required: Yes, if an alternate index is defined.

Default: None

Example: NAME (da0001t.lib.ksds.ename.aix)

VSAM 92
The VOLUMES parameter

The VOLUMES parameter specifies the volume (or volumes) where the alternate index is to be stored.

Format: VOLUMES (vol ser) or VOLUMES (vol ser ... vol ser)
Vol ser: The six-digit volume serial number of a volume.

Abbreviation: VOL

Used for: Alternate index over a KSDS, ESDS.

Required: Yes, if an alternate index is defined.

Default: None

Example: VOLUMES (BS3011)
VOLUMES (BS3011 BS3040 BS3042)

VSAM 93
The RELATE parameter

This parameter establishes the relationship between the base cluster and the alternate index via the use of the
base cluster name. It is unique to the DEFINE AIX command, and it is required.

Format: RELATE (base cluster name)

Abbreviation: REL

Use: Alternate index over a KSDS, ESDS

Required: Yes, if an alternate index is defined.

Default: None

Example: RELATE (da0001t.lib.ksds.cluster)

VSAM 94
The UPGRADE parameter

Format: UPGRADE | NOUPGRADE

Abbreviation: UPG | NUPG

Use: Alternate index over a KSDS, ESDS

Required: No, because of default.

Default: UPGRADE

Example: UPGRADE
NOUPGRADE

VSAM 95




Changes made to the base cluster would be reflected
automatically in all the alternates indexes provided you have
specified UPGRADE option in each of the base clusters
alternate indexes (DEFINE AIX command).

For this to happen the application program has to open the
base cluster

The set of alternate indexes VSAM updates automatically is
called Upgrade set


VSAM 96
The KEYS parameter

This parameter defines the length and offset of the alternate index key.

Format: KEYS (length offset)
length: length in bytes of the alternate key
offset: The offset is the keys displacement (in bytes) from the beginning of the record.

Abbreviation: None

Used for: Alternate index over a KSDS, ESDS.

Required: No, because of the default.

Default: KEYS (64 0)

Example: KEYS (30 4)

VSAM 97
The RECORDSIZE parameter

The RECORDSIZE parameter specifies the average and maximum of each alternate index record.

Format: RECORDSIZE (avg max)

Abbreviation: RECSZ

Use: Alternate index over a KSDS, ESDS.

Required: No

Default: RECORDSIZE (4086 32600)

Example: RECORDSIZE (80 120)

VSAM 98
ORGANIZATION OF AN
ALTERNATE INDEX
HK
5
AUTH-LAST_NAME
25
LIB_NUM
8
LIB_NUM
8
LIB_NUM
8
<-------------- PRM_KEY (S) ------------->
RECORDSIZE(54 110)
ESDS :
ALT-INDX-KEY PRM-KEY
KSDS :
HOUSE KEEPING
5
SOC_SEC_NUM
9
EMP_NUM
8
RECORDSIZE(22 22)
HK
5
TIMESTAMP
12
RBA
4
- Occupies Less Space
- RBA-Access is Faster
DATA COMPONENT :
VSAM 99
The FREESPACE parameter
This FREESPACE parameter, allocates some percentage of both the control interval and control area for
planned free space. This free space can be used for adding new records. FREESPACE applies only to the data component

Format: FREESPACE (ci% ca%)

ci%: - Percentage of control interval to leave free for expansion
ci%: - Percentage of control area to leave free for expansion

Abbreviation: FSPC

Use: Alternate index over KSDS, ESDS.

Required: No, because of default.

Default: FREESPACE (0 0)

Example: FREESPACE (20 10)

VSAM 100
Other DEFINE AIX Parameters

You can also add the following parameters to your DEFINE AIX command.
These parameters have been described in DEFINE CLUSTER command.

BUFFERSPACE (bytes)
CISZ (bytes)
ERASE | NOERASE
REUSE | NOREUSE
SHAREOPTIONS
UNIQUEKEY | NONUNIQUEKEY

VSAM 101
//STEP1 EXEC PGM=IDCAMS
//SYSPRINT DD SYSOUT =*
//SYSIN DD *
DEFINE AIX (NAME (DA0001T.LIB.KSDS.EMPNAME.AIX) -
VOLUMES (BS3013) -
RELATE (DA0001T.LIB.KSDS.CLUSTER) -
UPGRADE -
SHR (1 3) -
NOERASE -
NOREUSE -
KEYS (30 8) -
NONUNIQUEKEY -
FREESPACE (20 10) -
) -
DATA (NAME (DA000A1T.LIB.KSDS.EMPNAME.DATA) -
TRACKS (10 1) -
RECORDSIZE (75 125) -
) -
INDEX (NAME (DA0001T.LIB.KSDS.EMPNAME.INDEX))
/*
//

VSAM 102
Note :
Path is defined for each ALT. Index

Path is a separate catalog entry

Path is a logical connection thru the ALT. Index to the base
cluster

Pathname is the dataset name in JCL (DSN=PATHNAME)


DEFINE AN ALTERNATE INDEX PATH
VSAM 103
DEFINE PATH Command

A path is considered a VSAM object that does not contain any records. The path name is specified in the JCL
for applications that access records via the alternate index.

Format: DEFINE PATH (NAME (path name) parameters)

Abbreviation: DEF PATH

Use: Alternate index over a KSDS, ESDS.

Required: Yes, for an alternate index.

Default: None

Example: DEFINE PATH (NAME (da0001t.lib.ksds.ename.path))

VSAM 104
The PATHENTRY parameter

The PATHENTRY parameter specifies the alternate index cluster name.
This establishes the pathentry between alternate index cluster and the path.

Format: PATHENTRY (entry name)
entry name: The name assigned to the alternate index cluster

Abbreviation: PENT

Use: Alternate index over a KSDS, ESDS.

Required: Yes, for an alternate index.

Default: None

Example: PATHENTRY (da0001t.lib.ksds.ename.aix)

VSAM 105
The UPDATE parameter

Format: UPDATE | NOUPDATE

Abbreviation: UPD | NUPD

Use: Alternate index over a KSDS, ESDS.

Required: Yes, for an alternate index.

Default: UPDATE

Example: UPDATE
NOUPDATE

VSAM 106




Changes made to the base cluster would be reflected
automatically in all other alternates indexes provided you
have specified UPDATE in DEFINE PATH and UPGRADE
in DEFINE AIX command

For this to happen the application program has to open the
alternate index path



VSAM 107
//STEP1 EXEC PGM=IDCAMS
//SYSPRINT DD SYSOUT =*
//SYSIN DD *
DEFINE PATH (NAME (DA0001T.LIB.KSDS.EMPNAME.PATH) -
PATHENTRY (DA0001T.LIB.KSDS.AUTHNAME.AIX) -
UPDATE -
)
/*
//


Example JCL to define PATH for the AIX

VSAM 108
Note :

To populate the data component of ALT. index with records

VSAM constructs the index component of ALT. Index as it
does for any KSDS

Assume absolute control of base cluster by DISP=OLD

Output dataset can be ALT. index cluster or pathname
BUILD THE ALTERNATE INDEX
VSAM 109
The BLDINDEX command


Format: BLDINDEX
INFILE (ddname)
OUTFILE (ddname)
INTERNALSORT | EXTERNALSORT

INFILE and OUTFILE to DD statements.

BLDINDEX
INDATASET (dataset name)
OUTDATASET (dataset name)
INTERNALSORT | EXTERNALSORT

Abbreviation: BIX

Use: Alternate index over a KSDS, ESDS.

Required: Yes, for an alternate index.

Default: None

VSAM 110
The INFILE/INDATASET parameters

The INFILE parameter specifies a DD statement that refers to the input dataset.
The INDATASET parameter names the dataset.

Format: INFILE (ddname) | INDATASET (dataset name)

Abbreviation: IFILE | IDS

Use: KSDS, ESDS.

Required: Yes, you must code one or the other.

Default: None

Example: INFILE (dd1)
INDATASET (da0001t.lib.ksds.cluster)

VSAM 111
The OUTFILE/OUTDATASET parameters
The OUTFILE parameter specifies a DD statement that refers to the output dataset.
The OUTDATASET parameter names the dataset.

Format: OUTFILE (ddname) | OUTDATASET (dataset name)

Abbreviation: OFILE | ODS

Use: KSDS, ESDS.

Required: Yes, you must code one or the other.

Default: None

Example:
OUTFILE (dd2)
OUTDATASET (da0001t.lib.ksds.empname.aix)

IDS and ODS dynamically allocate the input and output datasets and ensure that the job
contains exclusive contro.

VSAM 112
//STEP1 EXEC PG=IDCAMS
//SYSPRINT DD SYSOUT =*
//DD1 DD DSN=DA0001T.LIB.KSDS.CLUSTER,
// DISP=OLD
//IDCUT1 DD UNIT=SYSDA,SPACE=(TRK, (2, 1))
//IDCUT2 DD UNIT=SYSDA,SPACE=(TRK, (2, 1))
// SYSIN DD *
BLDINDEX -
INFILE (DD1) -
OUTDATASET (da0001t.lib.ksds.empname.aix) -
INTERNALSORT
/*
//

VSAM 113
//STEP1 EXEC PGM=IDCAMS
//SYSPRINT DD SYSOUT =*
//SYSIN DD *
DEFINE AIX -
(NAME(DA0001T.LIB.KSDS.EMPNAME.AIX) -
VOLUMES (BS3013) -
RELATE(DA0001T.LIB.KSDS.CLUSTER) -
UPGRADE -
KEYS(25 9) -
FREESPACE(20 10) -
SHAREOPTIONS(1) -
NONUNIQUEKEY) ) -
DATA(NAME(DA000A1T.LIB.KSDS.EMPNAME.DATA) -
TRACKS(10 1) -
RECORDSIZE(70 110) -
CISZ(4096) -
) -
INDEX(NAME(DA0001T.LIB.KSDS.EMPNAME.INDEX)
/*

DEFINE AN ALTERNATE INDEX
VSAM 114
JCL:
//STEP1 EXEC PGM=IDCAMS
//SYSPRINT DD SYSOUT =*
//SYSIN DD *
DEFINE PATH -
NAME(DA0001T.LIB.KSDS.EMPNAME.PATH) -
PATHENTRY(DA0001T.LIB.KSDS.EMPNAME.AIX) -
UPDATE -
)
/*
//
DEFINE AN ALTERNATE INDEX
VSAM 115
JCL:
//STEP1 EXEC PG=IDCAMS
//SYSPRINT DD SYSOUT =*
//DD1 DD DSN=DA0001T.LIB.KSDS.CLUSTER,
// DISP=OLD
//IDCUT1 DD UNIT=SYSDA,SPACE=(TRK, (2, 1))
//IDCUT2 DD UNIT=SYSDA,SPACE=(TRK, (2, 1))
// SYSIN DD *
BLDINDEX -
INFILE(DD1) -
OUTDATASET(DA0001T.LIB.KSDS.AUTHNAME.AIX) -
INTERNALSORT
/*
BUILD THE ALTERNATE INDEX
VSAM 116
DEFINE CLUSTER (NAME(DA0001T.LIB.KSDS.CLUSTER)
.
)
DEFINE AIX (NAME(DA0001T.LIB.KSDS.AUTHNAME.AIX)
RELATE(DA0001T.LIB.KSDS.CLUSTER)
.
)
DEFINE PATH (NAME(DA0001T.LIB.KSDSK.AUTHNAME.PATH)
PATHENTRY(DA0001T.LIB.KSDS.AUTHNAME.AIX)
.
)
BLDINDEX
INDATASET(DA0001T.LIB.KSDS.CLUSTER)
OUTDATASET(DA0001T.LIB.KSDS.AUTHNAME.AIX)
.
)
SEQUENCE FOR BUILDING INDEX
VSAM 117
REPRO COMMAND
VSAM 118
Loads empty VSAM cluster with records.
Creates backup of a dataset
Merges data from two datasets (REPLACE)
Catalog information is not copied
Incase of KSDS, data and index component are build
automatically

REPRO
VSAM 119
Example Loading Dataset:
//DD1 DD DSN=DA0001T.INPUT.KSDS,DISP=OLD
//DD2 DD DSN=DA0001T.OUTPUT.KSDS, DISP=OLD
//SYSIN DD *
REPRO -
INFILE(DD1) -
OUTFILE(DD2) -
FROMKEY(A001) -
TOKEY(A069)


REPRO
VSAM 120
REPRO
Backup Considerations
Easy to transport data to another system
DELETE-DEFINE-REPRO sequence required to
restore the cluster incase of KSDS, CI & CA splits
are eliminated, Primary index is rebuild, freespace
redistributed. Alternate Indexes to be redefined

VSAM 121
Example :
//DD1 DD DSN=DA0001T.LIB.KSDS.BACKUP(0),
// DISP=OLD, UNIT=TAPE,LABEL=(1,SL)
//SYSIN DD *
DELETE DA0001T.LIB.KSDS.CLUSTER
DEFINE CLUSTER (NAME(DA0001T.LIB.KSDS.CLUSTER) -
INDEXED -
KEYS(4 0) -
RECORDSIZE(80 80) -
VOLUMES(BS3013) -
) -
DATA(NAME(DA0001T.LIB.KSDS.DATA)) -
INDEX(NAME(DA0001T.LIB.KSDS.INDEX))
REPRO -
INFILE(DD1) -
OUTDATASET(DA0001T.LIB.KSDS.CLUSTER)
/*
DELETE-DEFINE-REPRO
VSAM 122
REPRO Command

Format: REPRO
INFILE (ddname) | INDATASET (dsname) -
OUTFILE (ddname) | OUTDATASET (dsname) -
optional parameters

Abbreviation: None

Use: KSDS, ESDS. RRDS

Required: Yes.

Default: None

Example: REPRO -
INFILE (dd2) -
OUTDATASET (da0001t.lib.ksds.empname.aix)

VSAM 123
Limiting Input and Output Records



The FROMKEY and TOKEY parameters

FROMKEY specifies the key of the input record at which to begin reading. TOKEY specifies the key of the last input
record to write. You can code either or both parameters.

Format: FROMKEY (key)
TOKEY (key)
key: You can code an asterisk (*) as the last character. Copying starts or stops if a record is encountered
that matches all the characters up to *.

Abbreviation: FKEY, TKEY

Use: KSDS, ISAM

Required: No

Default: First record in dataset for FROMKEY and last record in dataset for TOKEY.

Example: FROMKEY (PAI)
TOKEY (PAI*)

VSAM 124
The FROMADDRESS and TOADDRESS parameters

FROMADDRESS specifies the relative byte address (RBA) value of the key of the input
record at
which to begin copying. TOADDRESS specifies the relative byte address (RBA) value of
the key
of the last input record to copy. You can code either or both parameters.

Format: FROMADDRESS (address)
TOADDRESS (address)
address: The RBA address of the first or last record to copy.

Abbreviation: FADDR, TADDR

Use: KSDS, ESDS

Required: No

Default: First record in dataset for FROMADDRESS and last record in
dataset for TOADDRESS.

Example:
FROMADDRESS (6250)
TOADDRESS (12684)

VSAM 125
The FROMNUMBER and TONUMBER parameters

FROMNUMBER specifies the relative record number of the first RRDS record to copy.
TONUMBER specifies the relative record number of the last record to copy. You can code
either or both parameters.

Format: FROMNUMBER (relative number)
TONUMBER (relative number)
relative number: The relative record number of the first or last
record
to copy. The first record is number 0.

Abbreviation: FNUM, TNUM

Use: RRDS

Required: No

Default: First record in dataset for FROMNUMBER and last record in
dataset for TONUMBER.

Example: FROMNUMBER (10)
TONUMBER (1000)

VSAM 126
The SKIP and COUNT parameters

SKIP specifies the number of input records to skip before beginning to copy.
COUNT specifies the number of output records to skip to copy. You can code either
or both parameters.

Fomat: SKIP (number)
COUNT (number)
number: The number of records to
skip or copy.

Abbreviation: None

Use: KSDS, ESDS, RRDS, non-VSAM datasets

Required: No

Default: SKIP defaults to the first record in dataset, and COUNT defaults
to all the records in the dataset.

Example: SKIP (10)
COUNT (1000)

VSAM 127
//DD1 DD DSN=DA0001T.INPUT.KSDS,DISP=OLD
//DD2 DD DSN=DA0001T.OUTPUT.KSDS, DISP=OLD
//SYSIN DD *
REPRO -
INFILE (DD1) -
OUTFILE (DD2) -
FROMKEY (A001) -
TOKEY (A069)
/*

Example JCL for Loading Dataset:

VSAM 128
The REPLACE Parameter for Merge Operations with REPRO

The REPRO command can also be used to merge two datasets into one. The target dataset can be
a nonempty KSDS, ESDS or RRDS. If the target dataset is an ESDS, the merged records are added
to the end of the existing dataset. You specify the REPLACE option as part of the REPRO command
with duplicate primary keys (in case of a KSDS) or duplicate relative record numbers (in case of an
RRDS)

Format: REPLACE

Abbreviation: REP

Use: KSDS, ESDS, RRDS

Required: No

Default: matching records are not replaced.

Example: REPLACE -
COUNT (500)
VSAM 129
The VERIFY command
Judicious use of the verify command is important for preserving data integrity. VERIFY verifies and
updates
the catalog with information from the physical end of the data in the cluster via a field called the
HURBA
(High Used Relative Address). VERIFY verifies that the catalog HURBA field stores the true values
from the control block HURBA field in the data component.

Format: VERIFY FILE (ddname /password)
Or
VERIFY DATASET (entry name /password)

Abbreviation: VFY

Use: KSDS, ESDS, RRDS (not valid for an LDS)

Required: No

Default: None.

Example: VERIFY da0001t.lib.ksds.cluster
VERIFY DATASET (da0001t.lib.ksds.cluster)
VERIFY FILE (dd1)

VSAM 130
The DELETE command

The DELETE command can be used to delete both VSAM and non-VSAM objects.

Format: DELETE entry name
DELETE entry name/password options

Entry name: The name of the entry to delete. An asterisk can be
coded as a wild card character in place of a name.

Password: The password for the entry if there is one. Omit the /password if the
entry doesnt have a password.

Abbreviation: DEL

Use: KSDS, ESDS, RRDS, non-VSAM

Required: No

Default: None.

Example: DELETE da0001t.lib.ksds.cluster

VSAM 131
Optional parameters are:

ALIAS
AIX
CLUSTER
NONVSAM
PATH
GDG
ERASE | NOERASE
FORCE | NOFORCE
PURGE | NOPURGE
SCRATCH | NOSCRATCH

VSAM 132
//DA0001TA JOB LA2179,PCS,MSGLEVEL=(1, 1),NOTIFY=DA0001T
//* Deletes VSAM Dataset
//STEP1 EXEC PGM=IDCAMS
//SYSPRINT DD SYSOUT = *
//SYSIN DD *
DELETE DA0001T.LIB.KSDS.CLUSTER ERASE
/*
//

VSAM 133
The PRINT command
The PRINT command is used to view the contents of the dataset.
Format: PRINT INDATASET (entry name/password) options
PRINT INFILE (ddname/password)
Entry name: The
name of the entry to print
Password: The password for the entry if there is one. Omit the /password
if the entry doesnt have a password.

ddname: The name of a DD statement

Abbreviation: PRINT IDS (entry name /password)
PRINT IFILE (ddname /password)

Use: KSDS, ESDS, RRDS, non-VSAM

Required: No

Default: None.
Example: PRINT da0001t.lib.ksds.cluster
PRINT INDATASET (da0001t.lib.ksds.cluster)
PRINT INFILE (dd1)

The default output destination for PRINT is SYSPRINT.
VSAM 134
The following options are allowed:

CHARACTER | DUMP | HEX or CHAR

Options
CHAR | DUMP | HEX
COUNT (number)
FROMADDRESS,
[TOADDRESS]
FROMKEY, [TOKEY]
FROMNUMBER, [TONUMBER]
OUTFILE (ddname)
SKIP (number)

VSAM 135
//DA0001TA JOB LA2179,PCS,MSGLEVEL=(1, 1),NOTIFY=DA0001T
//* Print VSAM Dataset
//PRG1 EXEC PGM=IDCAMS
//FILE1 DD DSN=DA0001T.LIB.KSDS.CLUSTER, DISP=SHR
//SYSPRINT DD SYSOUT = *
// SYSIN DD *
PRINT INFILE (FILE1) CHARACTER
/*
//

Example Print VSAM Dataset

VSAM 136
If you want the printed output directed to other than SYSPRINT, such as another dataset,
you can the OUTFILE parameter.

Format: OUTFILE (ddname/password)

ddname: The name of a DD statement specifying where the output is to be
written.

Abbreviation: OFILE

Use: KSDS, ESDS, RRDS, non-VSAM

Required: No, because of default.

Default: OUTFILE (SYSPRINT)

Example: PRINT da0001t.lib.ksds.cluster -
OUTFILE (dd1)
PRINT INDATASET (da0001t.lib.ksds.cluster)
-
OUTFILE (dd1)
VSAM 137
The ALTER command
The general form of the ALTER command is as follows:

Format: ALTER entry name/password parameters
PRINT INFILE (ddname/password)

Entry name: The name of the entry to alter

Password: The password for the entry if there is one. Omit the
password if the entry doesnt have a password.

parameters

Abbreviation: None

Use: KSDS, ESDS, RRDS, non-VSAM

Required: No

Default: None.

Example: ALTER da0001t.lib.ksds.cluster -
FSPC (30 20)

VSAM 138
The following is a list of common attributes that are completely alterable.



Change name of the object
Add volumes/Remove volumes
Change Keys and uniqueness
Change record size
Change Upgrade option
Change % of FREESPACE etc.

VSAM 139
Options:

ADDVOLUMES (volumes)
AUTHORIZATION (entry string)
BUFFERSPACE (size)
ERASE | NOERASE
FREESPACE (ci% ca%)
MASTERPW (password)
NEWNAME (newname)
READPW (password)
SCRATCH | NOSCRATCH (for GDG)
SHAREOPTIONS (cross region cross system)
TO (date) |FOR (days)
UPDATE | NOUPDATE
UPDATEPW (password)
UPGRADE | NOUPGRADE

VSAM 140
ALTER DA0001T.LIB.KSDS.CLUSTER -
NEWNAME (DA0001T.MY.CLUSTER)


Example 7.6 Altering name of a Dataset



ALTER DA0001T.LIB.KSDS.CLUSTER -
ADDVOLUMES (BS3001 BS3005)


Example 7.7 Adding additional volumes

VSAM 141
The following attributes are alterable only for empty clusters


KEYS (length offset)
RECORDSIZE (avg max)
UNIQUEKEY | NONUNIQUEKEY


The following attributes are unalterable. You have to DELETE the cluster and redefine it with new attributes.

CISZ
Cluster type,
IMBED/REPLICATE
REUSE | NOREUSE

VSAM 142
ALTER PRINT DELETE COMMANDS
VSAM 143
Format: VERIFY FILE (ddname /password)
Or
VERIFY DATASET (entry name /password)

Abbreviation: VFY

Use: KSDS, ESDS, RRDS (not valid for an LDS)

Required: No

Default: None.

Example:
VERIFY da0001t.lib.ksds.cluster
VERIFY DATASET (da0001t.lib.ksds.cluster)
VERIFY FILE (dd1)

VSAM 144
There are actually two HURBAs: one in the VSAM control block of the cluster and one in the catalog entry for the cluster. The danger is that if the catalog HURBA field is
incorrect, theres a possibility that if that previously added records may be overwritten, especially in the event of this relationship.



VERIFY DATASET (DA0001T.LIB.KSDS.CLUSTER)


Example 7.1 VERIFY



Remark: VERIFY can be issued from a TSO or within a JCL statement either the FILE or DATASET parameter.

VSAM 145
End of data

CA splits

Control block HURBA

Catalog HURBA

VSAM cluster








Catalog












Fig: 7.2 Relationship between HURBA in catalog and cluster.

VSAM 146
The DELETE command

The DELETE command can be used to delete both VSAM and non-VSAM objects.

Format: DELETE entry name
DELETE entry name/password options

Entry name: The name of the entry to delete. An asterisk can be coded as a wild card character in place of a name.

Password: The password for the entry if there is one. Omit the /password if the entry doesnt have a password.


Abbreviation: DEL

Use: KSDS, ESDS, RRDS, non-VSAM

Required: No

Default: None.

Example:
DELETE da0001t.lib.ksds.cluster

VSAM 147



DELETE DA0001T.LIB.KSDS.CLUSTER -
ERASE

Example 7.3 Deleting a Cluster

VSAM 148
Optional parameters are:

ALIAS
AIX
CLUSTER
NONVSAM
PATH
GDG
ERASE | NOERASE
FORCE | NOFORCE
PURGE | NOPURGE
SCRATCH | NOSCRATCH

VSAM 149
//DA0001TA JOB LA2179,PCS,MSGLEVEL=(1, 1),NOTIFY=DA0001T
//* Deletes VSAM Dataset
//STEP1 EXEC PGM=IDCAMS
//SYSPRINT DD SYSOUT = *
//SYSIN DD *
DELETE DA0001T.LIB.KSDS.CLUSTER ERASE
/*
//

Example 7.4 Delete VSAM Dataset

VSAM 150
The PRINT command

The PRINT command is used to view the contents of the dataset.

Format: PRINT INDATASET (entry name/password) options
PRINT INFILE (ddname/password)

Entry name: The name of the entry to print

Password: The password for the entry if there is one. Omit the /password if the entry doesnt have a password.

ddname: The name of a DD statement

Abbreviation: PRINT IDS (entry name /password)
PRINT IFILE (ddname /password)

Use: KSDS, ESDS, RRDS, non-VSAM

Required: No

Default: None.

Example:
PRINT da0001t.lib.ksds.cluster
PRINT INDATASET (da0001t.lib.ksds.cluster)
PRINT INFILE (dd1)

VSAM 151
The default output destination for PRINT is SYSPRINT.
The following options are allowed:

CHARACTER | DUMP | HEX or CHAR

Options
CHAR | DUMP | HEX
COUNT (number)
FROMADDRESS, [TOADDRESS]
FROMKEY, [TOKEY]
FROMNUMBER, [TONUMBER]
OUTFILE (ddname)
SKIP (number)

VSAM 152
//DA0001TA JOB LA2179,PCS,MSGLEVEL=(1, 1),NOTIFY=DA0001T
//* Print VSAM Dataset
//PRG1 EXEC PGM=IDCAMS
//FILE1 DD DSN=DA0001T.LIB.KSDS.CLUSTER,
// DISP=SHR
//SYSPRINT DD SYSOUT = *
// SYSIN DD *
PRINT INFILE (FILE1) CHARACTER
/*
//

Example 7.5 Print VSAM Dataset

If you want the printed output directed to other than SYSPRINT, such as another dataset, you can the OUTFILE parameter.
VSAM 153
Format: OUTFILE (ddname/password)

ddname: The name of a DD statement specifying where the output is to be written.

Abbreviation: OFILE

Use: KSDS, ESDS, RRDS, non-VSAM

Required: No, because of default.

Default: OUTFILE (SYSPRINT)

Example:
PRINT da0001t.lib.ksds.cluster -
OUTFILE (dd1)

PRINT INDATASET (da0001t.lib.ksds.cluster) -
OUTFILE (dd1)
VSAM 154
The ALTER command

The general form of the ALTER command is as follows:

Format: ALTER entry name/password parameters
PRINT INFILE (ddname/password)

Entry name: The name of the entry to alter

Password: The password for the entry if there is one. Omit the /password if the entry doesnt have a password.

parameters

Abbreviation: None

Use: KSDS, ESDS, RRDS, non-VSAM

Required: No

Default: None.

Example:
ALTER da0001t.lib.ksds.cluster -
FSPC (30 20)

VSAM 155
You can use this powerful command to change certain (but by no means all) attributes of a previously defined VSAM object. These objects include a base cluster and its data or
index component, an alternate index cluster and its data or index component.

The following is a list of common attributes that are completely alterable.



Change name of the object


Add volumes/Remove volumes
Change Keys and uniqueness
Change record size
Change Upgrade option
Change % of FREESPACE etc.

VSAM 156
Options:

ADDVOLUMES (volumes)
AUTHORIZATION (entry string)
BUFFERSPACE (size)
ERASE | NOERASE
FREESPACE (ci% ca%)
MASTERPW (password)
NEWNAME (newname)
READPW (password)
SCRATCH | NOSCRATCH (for GDG)
SHAREOPTIONS (cross region cross system)
TO (date) |FOR (days)
UPDATE | NOUPDATE
UPDATEPW (password)
UPGRADE | NOUPGRADE

VSAM 157
ALTER DA0001T.LIB.KSDS.CLUSTER -
NEWNAME (DA0001T.MY.CLUSTER)


Example 7.6 Altering name of a Dataset



ALTER DA0001T.LIB.KSDS.CLUSTER -
ADDVOLUMES (BS3001 BS3005)


Example 7.7 Adding additional volumes

VSAM 158
The following attributes are alterable only for empty clusters


KEYS (length offset)
RECORDSIZE (avg max)
UNIQUEKEY | NONUNIQUEKEY


The following attributes are unalterable. You have to DELETE the cluster and redefine it with new attributes.


CISZ
Cluster type,
IMBED/REPLICATE
REUSE | NOREUSE
VSAM 159
VSAM 160
Verify - preserves data integrity (HURBA)
Format : VERIFY FILE(ddname/passwd)
or
VERIFY DATASET(entryname/passwd)
VERIFY entryname/passwd (TSO)

Example :
VERIFY DATASET(DA0001T.LIB.KSDS.CLUSTER)
Remark :
1. VERIFY can be issued from a TSO or within a JCL statement.
2. It is valid only for VSAM dataset except LDS.
VERIFY
VSAM 161
- logically deletes dataset
- catalog entry deleted

Format :
DELETE entryname/passwd -
optional parameters
Example :
DELETE DA0001T.LIB.KSDS.CLUSTER -
ERASE
Optional parameters are :

DELETE
- ERASE | NOERASE
- FORCE | NOFORCE
- PURGE | NOPURGE
- SCRATCH | NOSCRATCH
- AIX
- CLUSTER
- NONVSAM
- PATH
VSAM 162
default O/P destinations is SYSPRINT
prints in CHAR/HEX/DUMP format
limiting parameters like REPRO are available
Format 1 :
PRINT INDATASET (entryname/passwd) -
options
Format 2 :
PRINT INFILE (ddname/passwd) -
options
PRINT
VSAM 163
PRINT
Options
CHAR | DUMP | HEX
COUNT (number)
FROMADDRESS, [TOADDRESS]
FROMKEY, [TOKEY]
FROMNUMBER, [TONUMBER]
OUTFILE (ddname)
SKIP (number)
VSAM 164
Used to change certain attributes of a previously defined
VSAM object
Following can be done with ALTER
change names
Add volumes/Remove volumes
Change Keys and uniqueness
Change record size
Change Upgrade option
Change % of freespace
etc.
Format :
ALTER entryname/passwd parameters

ALTER
VSAM 165
ALTER
Options :
ADDVOLUMES (volumes)
BUFFERSPACE (size)
ERASE | NOERASE
FREESPACE(ci% ca%) -
MASTERPW(password)
NEWNAME(newname)
READPW (password)

VSAM 166
ALTER
SCRATCH | NOSCRATCH
SHR(cross region cross system)
TO(date) |FOR(days)
UPDATE | NOUPDATE
UPDATEPW(password)
UPGRADE |NOUPGRADE
VSAM 167
Examples
ALTER -
DA0001T.LIB.KSDS.CLUSTER -
NEWNAME(A2000.MY.CLUSTER)
ALTER -
DA0001T.LIB.KSDS.INDEX -
FREESPACE(30 30)
The following attributes are alterable only for empty clusters
KEYS(length offset)
RECORDSIZE(avg max)
UNIQUEKEY | NONUNIQUEKEY
ALTER
VSAM 168
ALTER
The following attributes are unalterable. You have to
DELETE the cluster and redefine it with new
attributes.
- CISZ
- Cluster type,
- IMBED/REPLICATE
- REUSE | NOREUSE
VSAM 169
SAMPLE PROGRAMS
VSAM 170
//DA0001TA JOB LA1279,PCS,MSGLEVEL=(1,1),
// MSGCLASS=A, NOTIFY=DA0001T
//* Input instream Data into ESDS VSAM Dataset
// STEP1 EXEC PGM=IDCAMS
// SYSPRINT DD SYSOUT = *
// DD1 DD *
123456789123456789
AAAAAAAABBBBBBCCCC
/*
//DD2 DD DSN=DA0001T.ESDS.CLUSTER
//SYSIN DD *
REPRO -
INFILE(DD1) -
OUTFILE(DD2)
/*
//

SAMPLE PROGRAM
VSAM 171
//DA0001TA JOB LA2719,PCS,MSGLEVEL= (1,1),
// MSGCLASS=A, NOTIFY=DA0001T
//* Load Data from a file into ESDS VSAM Dataset
//STEP1 EXEC PGM=IDCAMS
//SYSPRINT DD SYSOUT = *
//DD1 DD DSN=DA0001T.ESDS.CLUSTER1
//DD2 DD DSN=DA0001T.ESDS.CLUSTER2
//SYSIN DD *
REPRO -
INFILE(DD1 -
OUTFILE(DD2)
/*
//

SAMPLE PROGRAM
VSAM 172
//DA0001TA JOB LA2179,PCS,MSGLEVEL=(1, 1) ,
// NOTIFY=DA0001T
//* Print VSAM Dataset
//PRG1 EXEC PGM=IDCAMS
//FILE1 DD DSN=DA0001T.LIB.KSDS.CLUSTER,
// DISP=SHR
//SYSPRINT DD SYSOUT = *
// SYSIN DD *
PRINT INFILE(FILE1) CHARACTER
/*
//

SAMPLE PROGRAM
VSAM 173
//DA0001TA JOB LA2179,PCS,MSGLEVEL=(1, 1) ,
// NOTIFY=DA0001T
//* Deletes VSAM Dataset
//STEP1 EXEC PGM=IDCAMS
//SYSPRINT DD SYSOUT = *
//SYSIN DD *
DELETE DA0001T.TRAIN.ITMFOIV
/*
//

SAMPLE PROGRAM
VSAM 174
GENERATION DATA GROUP
VSAM 175
Group of datasets which are related to each other
chronologically and functionally

Generations can continue until a specified limit is reached

Limit specifies total number of generations that can exist at
any one time

Once limit is reached the oldest generation is deleted.
GENERATION DATA GROUP
VSAM 176
MVS uses the generation data groups catalog entry to keep
track of relative generation numbers. As a result, GDGs must
be cataloged and each generation dataset thats a part of the
group must be cataloged too.

When you create a generation data groups catalog entry, you
specify how many generations should be maintained eg. You
may specify that five generations including the current
generation, be maintained. During each processing cycle, the
new version of the file becomes the current version.
GENERATION DATA GROUP
VSAM 177
file.c1(+1) Next Generation
file.c1(0) Current Generation
file.c1(-1) Previous Generations
file.c1(-2)
file.c1(-3)

There are 3 previous generation, note that generations are
numbered relative to the current generation, file.c1(0).
Relative generation numbers are adjusted when each
processing cycle completes, so that the current generation is
always referred to as relative generation 0.
GENERATION DATA GROUP
VSAM 178
MVS uses Absolute Generation Numbers in the form
GnnnnV00 to identify each generation dataset uniquely.
GnnnnV00 represents the chronological sequence number
of the generation, beginning with G0000.

V00 is a version number, which lets you maintain more
than one version of a generation. Each time a new
generation dataset is created, mvs adds one to the
sequence number.
GENERATION DATA GROUP
VSAM 179
filename.GnnnnV00

35 chars 9 chars
Example : Using GDG

// IN DD DSN=DA0001T.MASTER, DISP=SHR
// OUT DD DSN=DA0001T.MASTER.DAY(+1),
DISP= (NEW,CATLG,DELETE),
UNIT=3390, VOL=SER=BP0031,
SPACE= (CYL,(10,5),RLSE),
DCB=(PROD.GDGMOD,
BLKSIZE=23440,LRECL=80,RECFM=FB)
GENERATION DATA GROUP
VSAM 180
Relative Name and Absolute Name
DA0002T.MASTER.DAY90) ---> Relative Name
DA0002T.MASTER.DAY.G00001V00 -->Absolute Name
Defining a GDG
// Step1 EXEC PGM=IDCAMS
// SYSPRINT DD SYSOUT = *
// SYSIN DD *
DEFINE GDG(NAME(DA0001T.MASTER.DAY) -
LIMIT(5) -
SCRATCH -
EMPTY)
/*
//
GENERATION DATA GROUP
VSAM 181
Following code contains 1 job with 2 steps....
//DA0003TA JOB
//UPDATE EXEC PGM=PAY3200
//OLDMAST DD DSN=DA0001T.MMA2.PAY.MAST(0),DISP=OLD
//NEWMAST DD DSN=DA0001T.MMA2.PAY.MAST(+1),
// DISP= (NEW,CATLG),UNIT=3300,
// VOL=SER=BS3001,
// DCB=(LRECL=80,BLKSIZE=1600)
//PAYTRAN DD DSN=DA0001T.MMA2.PAY.TRAN,DISP=OLD
//PAYLIST DD SYSOUT=*
//REPORT EXEC PGM=PAY3300
//PAYMAST DD DSN=DA0001T.MMA2.PAY.MAST(+1),DISP=OLD
//PAYRPT DD SYSOUT=*
GENERATION DATA GROUP
VSAM 182
Following code contains 2 jobs.........
//JOB1 JOB
//UPDATE EXEC PGM=PAY3200
//OLDMAST DD DSN=DA0001T.MMA2.PAY.MAST(0),DISP=OLD
//NEWMAST DD DSN=DA0001T.MMA2.PAY.MAST(+1),
// DISP=(NEW, CATLG), UNIT=3300,
// VOL=SER=BS3001,
// DCB=(LRECL=80, RECFM=FB,BLKSIZE=0)
//PAYTRAN DD DSN=DA0001T.MMA2.PAY.TRAN,DISP=OLD
//PAYLIST DD SYSOUT =*
//*
//JOB2 JOB ...........
//REPORT EXEC PGM=PAY3300
//PAYMAST DD DSN=DA0001T.MMA2.PAY.MAST(0),DISP=OLD
//PAYRPT DD SYSOUT=*
GENERATION DATA GROUP
VSAM 183
Have to be created before data sets that are to be included in
them can be made a part of them

Model containing parameter information of the datasets to be
included in the GDG has to be specified

System must be informed each time a new dataset added to or
deleted from GDG

System must be informed if the entire GDG is to be deleted
CONSIDERATIONS FOR USING GDGs
VSAM 184
Name of the GDG

Number of generations that are to be retained

Action when number of generations to be retained reaches the
limit
SPECIFICATIONS FOR CREATING A GDG
VSAM 185
All datasets within a GDG will have the same name

Generation number of a dataset within a GDG is automatically
assigned by OS when created

Datasets within a GDG can be referenced by there relative
generation number

Generation 0 always references current generation
FEATURES OF GDGs
VSAM 186
CREATION OF GDGs
Create and catalog the index
Use IDCAMS statement DEFINE GDG for creating Index
Parameters for creating index
SPECIFICATION
Name of GDG
Number of generations
Uncataloging oldest generation once limit reached
Uncataloging all generations when limit reached
Physical deletion of entry
Uncataloging entry without physical deletion
Defining a model for the GDG.
GDGs
VSAM 187

NAME
LIMIT
NOEMPTY
EMPTY
SCRATCH
NOSCRATCH
GDGs
VSAM 188
GDGs
JCL for creating index
//STEP1 EXEC PGM=IDCAMS
//SYSIN DD
DEFINE GDG -
(NAME(DA0001T.ACCOUNTS.MONTHLY) -
LIMIT(5) -
EMPTY -
SCRATCH -
)
/*
//
VSAM 189
Modifying Features of GDG
Can be modified by the ALTER command

Example :
//STEP1 EXEC PGM=IDCAMS
//SYSIN DD
ALTER DA0001T.ACCOUNTS.MONTHLY -
NOSCRATCH -
EMPTY
/*
//
GDGs
VSAM 190

Deleting GDG Index
Can be deleted by the DELETE parameter of IDCAMS
Will result in an error on reference to any generation datasets of
the GDG

/STEP1 EXEC PGM=IDCAMS
//SYSIN DD
DELETE DA0001T.ACCOUNTS.MONTHLY GDG
/*
//

GDGs
VSAM 191
Adding a Dataset to a GDG
Name of the model containing the GDG DCB parameters is
coded in the DCB parameter of the DD statement
Example :
//STEP1 EXEC PGM=GDG1
//FILE1 DD DSN=DA0001T.ACCOUNTS.MONTHLY(+1),
// DISP=(NEW,CATLG,DELETE),UNIT=SYSDA,
// SPACE=(TRK,(30,10),RLSE),
// DCB=(MODEL.DCB,RECFM=FB,LRECL=80,
// BLKSIZE=800)


GDGs
VSAM 192
Deleting GDG Index and Datasets
FORCE parameter in the DELETE statement of
IDCAMS can be used
Example :

/STEP1 EXEC PGM=IDCAMS
//SYSIN DD
DELETE DA0001T.ACCOUNTS.MONTHLY -
GDG -
FORCE
/*
//
GDGs
VSAM 193
COBOL VSAM CONSIDERATIONS
VSAM 194
SELECT CLAUSE

SELECT file ASSIGN TO DDNAME / AS-DDNAME
ORGANIZATION IS SEQUENTIAL/INDEXED/RELATIVE
ACCESS MODE IS SEQUENTIAL/DYNAMIC/RANDOM
RECORD KEY IS <primary Key Dataname>
ALTERNATE KEY IS <Alternate Key Dataname> [WITH DUPLICATES]
FILE STATUS IS status-key

Note:
A prefix AS- has to be attached to DDNAME to indicate to
COBOL that the file selected is an ESDS dataset.
COBOL-VSAM CONSIDERATIONS
VSAM 195
FD Entry

Should have the record structure

If KSDS then key field must match with length and position of
KEYS parameter in DEFINE CLUSTER information

COBOL - VSAM CONSIDERATIONS
VSAM 196
Alternate index processing :
In your JCL there must be a DD statement for base cluster
and one or more DD statement for alternate index path
name.
Note:
There is no COBOL standard for assigning ddnames to
alternate indexes,so a quasi-standard has emerged
whereby a sequential number is appended to the eighth
character of the base cluster ddname.
COBOL-VSAM CONSIDERATIONS
VSAM 197
COBOL-VSAM CONSIDERATIONS
For e.g :
//LIBMAST DD DSN=DA0001T.LIB.KSDS.CLUSTER,
// DISP=SHR
//LIBMAST1 DD DSN=DA0001T.LIB.KSDS.NAME.PATH,
// DISP=SHR
//LIBMAST2 DD DSN=DA0001T.LIB.KSDS.DEPT.PATH,
// DISP=SHR
In the example above LIBMAST is the base cluster and
LIBMAST1, LIBMAST2 are path names of Alternate
Indexes built on the base cluster

VSAM 198
REMARK:
No matter how many alternate indexes you specify in the
program, there is only one ASSIGN clause pointing to the
ddname of the base cluster.
SELECT file ASSIGN TO LIBMAST
RECORD KEY IS ............
ALTERNATE KEY IS .........
[WITH DUPLICATES]
ALTERNATE KEY IS .........
[WITH DUPLICATES]
FD : Should have record description having
primary key dataname and alternate key
dataname

COBOL-VSAM CONSIDERATIONS
VSAM 199
Key of Reference
The key that is currently being used to access records.
primary key becomes, by default, the key of reference. To
access records by an alternate index key, you merely
change the key of reference by using the KEY phrase as
part of one of the following statements.

A random READ statement, for example
READ EMP-MAST KEY IS EMP-NAME

Position record pointer on the desired record
START EMP-MAST KEY IS EQUAL TO EMP-NAME.
COBOL-VSAM CONSIDERATIONS
VSAM 200
VSAM I/O ERROR PROCESSING.

Most programmers ignore errors, because the access method
will abend the program if a serious I/O error occurs. Not so
when processing Vsam datasets.

VSAM places program control in the hands of the
programmer,not the O/S. For this reason,it is important to
check the COBOL status key designated in the FILE STATUS
clause after every I/O operation.
FILE STATUS CODES
VSAM 201
For these status key values,continue processing normally :
00 successful I/O.
02 duplicate alternate key encountered (expected).
10 end of file.

For these status key values,bypass the record,display pertinent
information, and continue processing :
21 Input record out of sequence.
22 duplicate primary key or unique alternate key
encountered(un-expected).
23 record (or Key) not found.

FILE STATUS CODES
VSAM 202
Note:
You may want to have the program count the number of
times these key values are returned and terminate the
program if the counter reaches an unacceptable number,
which is likely to indicate that your input is bad
FILE STATUS CODES
VSAM 203
For the following status key values,terminate the program :
24 out-of-space condition(KSDS or RRDS).
30 Nonspecific I/O problem.
34 out-of-space condition(ESDS).
49 REWRITE attempted;dataset not opened for I-O.
90 Dataset unusable or logic error.
92 logic error.
93 Resource not available.

FILE STATUS CODES
VSAM 204
FILE STATUS CODES
94 current record pointer undefined.
95 Nonzero HURBA for OPEN OUTPUT.
96 No corresponding JCL DD statement.
97 If your shop has enabled the implicit
VERIFY command, this means that the
dataset was opened after and implicit
VERIFY, and you can continue
processing.
VSAM 205
MVS/VSAM for Application Programmer by Brown and
Smith


VSAM by Doug Lowe


VSAM for COBOL Programmer by Doug Lowe

BIBLIOGRAPHY

S-ar putea să vă placă și