Академический Документы
Профессиональный Документы
Культура Документы
Catalog Management
• The catalog contains information about the VSAM data sets. The catalog can
be an ICF Catalog or a VSAM catalog (older versions of the operating
system). DFSMS/MVS deals only with ICF catalogs.
• All VSAM data set information is maintained in the ICF catalog and it can be
easily retrieved using AMS commands (Access Method Services).
Record management
VSAM HISTORY
In the year 1973 VSAM was introduced with ESDS & KSDS only and in the
year 1975 the concept of Alternate Index, RRDS, and Catalog Recovery features
were introduced. VSAM was re-introduced with a facility called as Integrated Catalog
Facility (ICF). In the year 1983 VSAM was introduced with DFP/VSAM (Data Facility
Product) which can run under MCS/XA. Later in the year 1987 the DFP/VSAM 2.3
with LDS facility was introduced and another VSAM 3.1 under MVS/ESA with DFSMS
(Data Facility Storage Management System). In the year 1991, VSAM 3.3 was
introduced with variable length records for RRDS
iFrames Technologies 1
Mainframe VSAM
STRUCTURE OF VSAM
Master Catalog
Every system that uses VSAM has one, and only one, master catalog. The
master catalog contains entries about system datasets and VSAM structures used to
manage the operation of VSAM. The master catalog is created during the System
Generation process and usually resides on the System Residence volume. The
master catalog "owns" all other VSAM resources in a computer system, and this is
denoted by the position of the master catalog.
User Catalogs
Advantages:
• The retrieval of records is faster because of an efficiently organized index. The
index is small because of a key compression algorithm used to store and
retrieve its records.
• Imbedded free space makes the insertion of records easy, and data sets
therefore require less reorganization.
• The deletion of records in VSAM, unlike that in ISAM, means that they are
physically deleted, thus allowing the reclaiming of free space within the data
set.
• VSAM data sets are device-independent.
• VSAM catalogs and data sets are portable between operating systems.
• Records can be accessed randomly by key or by address and can also be
accessed sequentially at the same time.
Disadvantages:
• To take advantage of the partial self-reorganization capabilities of VSAM data
sets, free space must deliberately be left. For data sets that are used for read
only purposes, no free space is required.
• Except for read-only data sets, the integrity of VSAM data sets in cross-
system and cross –region sharing must be controlled by the user. Data
integrity must be a prime consideration in the initial design of applications
that will be shared across systems.
iFrames Technologies 2
Mainframe VSAM
VSAM TERMINOLOGY
LR
LR LR LR LR
The fundamental building block of every component of a VSAM data set is the
control interval. A control interval is the unit of information that VSAM transfers
between the storage device and the virtual storage. One CI can be made of one or
more physical blocks of DASD.
iFrames Technologies 3
Mainframe VSAM
Control
Logical Record Interval
Area Record
definition Definition
field field
Free space Area
R R
D D
RECORD 1 RECORD 2 F F
1 2
A CI consists
• Logical records stored from beginning to end
• Unused space, referred to as free space, for data records to be inserted into
or lengthened
• The maximum size of a CI is 32k and the minimum size is 512 bytes.
• Control information, which is made up of two types of fields; one Control
Interval Definition Field (CIDF) per CI, and one or more Record Definition
Fields (RDF) per logical record.
1. CIDF is a 4-byte field. It contains information about the length of data
in the CI and the amount and location of free space.
2. RDF is a 3-byte field. It describes the length of records and how many
adjacent records are of the same length.
iFrames Technologies 4
Mainframe VSAM
CA1
LR1 LR2 FREE SPACE RDF2 RDF1 CIDF
REVIEW QUESTIONS
1. What is VSAM?
iFrames Technologies 5
Mainframe VSAM
CI
LR2
WORK AREA
The VSAM data set organizations are superior to the native access methods.
VSAM provides for alternate indexes, a feature not available in native access
methods. It has an admirable catalog facility that stores more information about
VSAM and other data sets. The powerful AMS utility in VSAM provides a variety of
services dealing with catalogs, files, security, file management, etc. It provides
iFrames Technologies 6
Mainframe VSAM
A linear data set (LDS) contains data that can be accessed as byte-addressable
strings in virtual storage. It is a VSAM data set with a control interval size of 4096
bytes.
DATA CA
DATA
DATA
DATA
DATA CA DATA
DATA
DATA
An LDS has no imbedded control information in its CI, which is, no RDFs and
CIDFs. All LDS bytes are data bytes. Logical records must be blocked and de blocked
by the application program, but records do not exist from the point of view of VSAM.
An LDS contains a data component only.
LDS are generally used for fast random access to data that has no
hierarchical structure - i.e., for data, that is a large flat file, such as a table or array.
A relational database is just this. You specify the LDS organization with the IDCAMS
DEFINE command specifying the LINEAR parameter.
iFrames Technologies 7
Mainframe VSAM
CI 1
UNUSED SPACE
RBA 8192
Records can be updated, but without length change. To change the length of
a record, you must either store it at the end of the data set as a new record, or
override an existing record of the same length that you have flagged as inactive.
Sequential processing:
VSAM automatically retrieves records in stored sequence. Sequential
processing can be started from the beginning or somewhere in the middle of a data
set. If processing is to begin in the middle of a data set, positioning is necessary
before sequential processing can be performed.
Direct processing:
When a record is loaded or added, VSAM indicates its RBA. To retrieve records
directly, you must supply the RBA for the record as a search argument. Although an
ESDS does not contain an index component, you can build an alternate index to keep
track of these RBAs.
Empty spaces in the CI are referred to as unused space because they can
never be used.
You specify ESDS organization using the IDCAMS DEFINE command and
specifying the NONINDEXED parameter.
iFrames Technologies 8
Mainframe VSAM
The relative position of each slot is called relative record number (RRN). An
RRN is an integer that identifies the position of the slot no the value of a particular
field within the slot. Each slot of an RRDS may or may not contain a record. Records
in an RRDS may be inserted, retrieved, updated, and deleted both sequentially and
randomly. Records in an RRDS are always fixed in the length. RRDS has only data
component. When a record is deleted from a particular slot, the slot remains in the
same physical location although a record does not exist in that slot anymore
You specify the RRDS organization using the IDCAMS DEFINE command with
the NUMBERED option.
TYPICAL RRDS PROCESSING
CONTROL AREA 2 CI
APPLICATION 29 30 31 32
PROGRAM
CI
GET RECORD 25 25 26 27 28
CI
CI
13 14 15 16 21 22 23 24
CI CI
9 10 11 12 17 18 19 20
CI
SLOT 8
5 6 7 8
CONTROL AREA 1
Slot8
CI
1 2 3 4
iFrames Technologies 9
Mainframe VSAM
REVIEW QUESTIONS.
a) LDS
b) RRDS
c) ESDS
d) KSDS
a) LDS
b) B. RRDS
c) C. ESDS
d) D. KSDS
3. For a KSDS, the larger the data CA size, the smaller the number of index CIs.
A. TRUE
B. FALSE.
iFrames Technologies 10
Mainframe VSAM
4. VSAM control intervals containing data records have at least one RDF and one
CIDF.
A. TRUE
B. FALSE
5. In which cluster type are records always added at the end of the data set?
a) LDS
b) RRDS
c) ESDS
d) KSDS
a) LDS
b) RRDS
c) ESDS
d) KSDS
a) sequential
b) skip-sequential
c) direct
d) a and b
e) a, b and c
a) Sequential
b) skip-sequential
c) Direct
d) a and b
e) a and c
iFrames Technologies 11
Mainframe VSAM
CHAPTER - 3: KSDS
In a KSDS, records are placed in the data set in ascending collating sequence
by key. The records for KSDS can be fixed-length or variable-length records. The key
of the record contains a unique value that determines the record's collating position
in the data set. The key must be in the same position in each record.
INDEX COMPONENT
DATA COMPONENT
The key data must be contiguous and each record's key must be unique. After
it is specified, the value of the key cannot be altered, but the entire record can be
deleted. When a new record is added to the data set, it is inserted in its collating
sequence by key.
A KSDS has a data and an Index Component. The Index Component keeps
track of the used keys and is used by VSAM to retrieve quickly a record from the
data component, when a request is made for a record with a certain key. A KSDS
can have fixed or variable length records. A KSDS can be accessed either
sequentially or directly or skip-sequentially.
You specify the KSDS organization using the IDCAMS DEFINE command with the
INDEXED parameter.
A KSDS has an index that relates key values to the relative locations of the
logical records in a data set. This index is called the Prime Index. It has two uses:
• Locate the collating position when inserting records.
• Locate records for retrieval.
When initially loading a data set, records must be presented to VSAM in key
sequence. The Index is built automatically by VSAM as the data set is loaded with
records. When a data CI is loaded with records, VSAM makes an entry in the index.
The entry consists of the highest possible key in the data CI and a pointer to the
beginning of that CI.
VSAM index can consists of more than one index level. Each level contains a
set of records with entries giving The location of the records in the next lower level.
iFrames Technologies 12
Mainframe VSAM
INDEX COMPONENT
079 236
DATA COMPONENT
0
67 079
iFrames Technologies 13
Mainframe VSAM
LOADING A KSDS:
When loading a KSDS, logical records are stored in ascending key sequence
within a data CI. The data component for a KSDS can contain user specified
FREESPACE. This free space is used later, when records are inserted or expanded.
• CI Free Space: Percentage of CI left empty / unused at load time.
• CA Free Space: Percentage of CIs in eachFSdata CA empty / unused at load
time.
SEQUENCE SET CI
iFrames Technologies 14
Mainframe VSAM
FREESPACE
CI 3
SEQUENCE SET CI
FREE SPACE
CI 3
When inserting a record in the CI, if there is no enough free space in the CI,
then the CI will be split as follows:
iFrames Technologies 15
Mainframe VSAM
• Half of the full CI is moved to an empty / free CI within same CA. So, CA free
space is used.
• A new index entry is inserted in the sequence set record.
• The existing index entry is updated in the sequence set record.
As a result of the CI split, the physical sequence of the data is no longer the
same as the logical sequence.
This will be illustrated by the following diagram.
.
INSERT 4046
SEQUENCE SET
CI 0
4041 4046 4050 FREE SPACE
CI 1
4072 4073 4075 4077 FREE SPACE
DATA CA
CI 2
4052 4058 4065 FREE SPACE
CI 3
When there are no more free CI s in the CA then VSAM performs a control
area split.
o VSAM allocates a new CA at the end of the data component
o Approximately half of the data CI s are moved from the full CA to the
new CA.
o A new sequence set CI is created for the new data CA.
o The old sequence set CI is modified
o The index set is updated. In the given below example a new index set
CI will be created that will be the highest-level index set CI. Then VSAM
performs a control Interval split.
This will be illustrated by the following diagram.
iFrames Technologies 16
Mainframe VSAM
TO INSERT 4074
AFTER
BEFORE
SEQUENCE SET CI
4012 4012
4023 4034 4037 4023 4034 4037
FREE SPACE
SPANNED RECORDS
• Spanned records are records with a record size greater than the CI size
specified.
iFrames Technologies 17
Mainframe VSAM
RECORD 1
As in the above diagram, the spanned record spans three CI’s. The ‘segment’
of the first CI contains part of data along with two RDF’s and one CIDF. The right
RDF gives the length of the segment. The left RDF gives the update number of the
segment (used to maintain update consistency of all segments during an update).
A CI that contains the record’s segment of a spanned record contains control
information. However a new record cannot be inserted into the same CI. As in the
diagram, the third CI contains the spanned data, and the rest of the space becomes
unused space. A new record would move into the fourth CI.
Spanned records must be accessed in MOVE mode. The application program must
contain a work area as the largest spanned record in the data set.
iFrames Technologies 18
Mainframe VSAM
DATA BUFFERS
CI 1
CI 2
CI 3
WORK AREA
ADDRESS SPACE
REVIEW QUESTIONS:
iFrames Technologies 19
Mainframe VSAM
iFrames Technologies 20
Mainframe VSAM
Modal commands
IF Controls the flow of command execution by testing
condition codes returned by functional commands
SET Controls the flow of command execution by altering
condition codes returned by functional commands
PARM Sets options values that effect the way AMS executes.
2) FREESPACE
Syntax : FREESPACE (CI% CA%)
Default : FREESPACE(0 0)
• 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
o Rate of growth of records
o Expected number of records to be deleted
o Reorganization frequency
o Performance consideration
o
o 3) BUFFERSPACE
o Syntax : BUFFERSPACE (bytes)
o Abbr : BUFSP
o Default : Two data buffers plus one
additional index buffer for KSDS
o Used to improve Input/output performance
o Can also be specific in JCL EXEC parameter
o
o //DD1 DD DSNAME=ANYVSAM1,
o // AMP=('BUFND=4,BUFNI=4,STRNO=2')
iFrames Technologies 21
Mainframe VSAM
o
o More on VSAM Buffers
o
• Strings (STRNO in AMP parameter)
o Defines number of concurrent access
o For batch processing, a string of 1 is enough
o For online processing more strings is required
• Data Buffers (BUFND in AMP parameter)
• Random Access
o Minimum of 2 (One for normal access and one for split
processing) is required
Sequential Access
Ideal to process a track
Allocate number of buffers based on the number of CI/TRK
For READ add 1 more buffer and for WRITE add 2 more buffers
Index Buffers (BUFNI in AMP parameter)
Default of 1 index buffer is enough
Random Access
Ideal to keep the index set in virtual memory
Determine the number of levels (using LISTCAT)
Allocate number of levels + 1 buffer
o
o 4) RECOVERY / SPEED
Mutually Exclusive
RECOVERY allows you to recover if the job initially loading the dataset fails
SPEED is faster, but does not provide restart feature
• Default:
RECOVERY
•
• 5) SPANNED
• Syntax :
SPANNED/NONSPAN
NED
• Default
:
NONSPANNED
• Allows large records to span more than one Control Interval
• However, the records cannot span across Control areas
• RRDS does not support spanned records.
•
iFrames Technologies 22
Mainframe VSAM
• 6) KEYRANGES
• Syntax : KEYRANGES (Low - Val; High - Val)
• Default : None (No range assumed)
• Example :
• KEYRANGES ((000001 100000)+
• 100001 200000))
• The Key Ranges correspond to VOLUMES if ORDERED clause is specified.
• 7) ORDERED
• Syntax : ORDERED / UNORDERED
• Default: UNORDERED
• Goes together with KEYRANGES clause specifies the volume to which
the key values should go.
•
• 8) REUSE
• Syntax : REUSE/NOREUSE
• Default : NOREUSE
• REUSE specifies that the cluster can be loaded with fresh records with
an implicit delete of existing RECORDS
• REUSE cannot be used under following circumstances and hence not
recommended
• When KEYRANGES parameter is coded
• When alternate indexed are defined
•
• 9) REPLICATE
• Directs the VSAM to duplicate each index as many times as it will fit on
its assigned track
• Applies only to KSDS index component
• To reduce rotational delay and to make I/O faster
• Syntax : Replicate / No replicate
• Default : No replicate
•
• 10) VOLUMES
• Can specify different volumes for
• Data component
• Index component
•
• 11) IMBED
• Directs the VSAM to place the sequence set (the lowest level of index
next to the data component) on the first track of the data control area and
duplicate it as many times as it will fit. This process will reduce rotational
delay because the desired sequence set record is found faster
• Default: NO IMBED
iFrames Technologies 23
Mainframe VSAM
iFrames Technologies 24
Mainframe VSAM
iFrames Technologies 25
Mainframe VSAM
iFrames Technologies 26
Mainframe VSAM
•
• [CATALOG ( name [/ password]) ]
•
• Explanation
• NAME (entry –name) Specifies the name of the cluster or
component
• OWNER (owner –id) Specifies a 1 to 8 character owner-id.
• FOR (days) TO (date) Specifies a retention period ( in the format
dddd) or an expiration date (in the format
yyddd)
• INDEXED / NONINDEXED/NUMBERED Specifies the file organization: SDS
iFrames Technologies 27
Mainframe VSAM
• Example #3
• Define an relative-record data set (RRDS)
• DEFINE CLUSTER (NAME (MTRG.CUSTOMER.MASTER) -
• OWNER (MTRG) -
• NUMBERED -
iFrames Technologies 28
Mainframe VSAM
•
• REVIEW QUESTIONS:
• 1. What is IDCAMS? And what is the purpose of it?
• 2. What is the significance of the SHAREOPTIONS parameter?
• 3. What is the use of REPRO command?
• 4. What are the different types of AMS commands?
• 5. What are the basic IDCAMS commands?
• 6. AMS will generate a data component name if it is not explicitly coded.
• a) TRUE
• b) FALSE
• 7. What are the parameters used in AMS commands?
• 8. Can AMS commands be run from the TSO prompt?
• 9. What is the base cluster?
•
• CHAPTER - 5: Creation of Clusters
// DD statement…………
with new parameters
and/or
info from ‘DATA CLASS’
iFrames Technologies 29
Mainframe VSAM
deleting, and altering file characteristics in the AMS Utility program. VSAM
has much simpler JCL requirements than files of other access methods.
•
• How to allocate existing VSAM files
• The DSNAME parameter
• The DUMMY parameter
• The DISP parameter
• The AMP Parameter
•
• How to create VSAM files using JCL.
• The DD statement for allocating existing VSAM File
•
• //ddname dd DSNAME={data-set-name}
• {Dummy}[,Disp={old/shr},Normal-disp,Abnormal-disp]
• [,AMP=(option,option….)]
•
• Explanation:
• DSNAME Specifies the name of the VSAM dataset. Normally, the high
level qualifier of the name identifies the owning catalog.
• DUMMY Specifies that a VSAM file should not be allocated; instead, MVS
should simulate a VSAM FILE.
• DISP Specifies the file’s status and, the file’s normal & abnormal
disposition. The valid status options are OLD for exclusive access
and SHR for shared access. All of the disposition options
except UNCATLG are valid for VSAM files.
• AMP Specifies one or more processing options for VSAM files.
•
• The AMP parameter
• The AMP parameter is for VSAM files & the DCB parameter is for non-
VSAM files. It specifies execution time information that affects how the file is
processed.
•
• The AMORG sub parameter
• AMORG indicates that the files being accessed is a VSAM file.
Normally, MVS realizes that a VSAM file is being processed when it retrieves
the catalog information for the file. So we need to specify AMP=AMORG when
MVS doesn’t search the catalog.
•
• The AMP parameter
• AMP=[ AMPORG]
• [,BUFND=n]
• [,BUFNI=n]
• [,BUFSP=n]
iFrames Technologies 30
Mainframe VSAM
• [,OPTCD=OPTIONS]
• [,RECFM=FORMAT]
• [,STRNO=N]
• Explanation
• AMORG Specifies that the data set is a VSAM file. Normally not
required.
• BUFND Specifies the number of buffers to allocate for the data
component.
• BUFNI Specifies the number of buffers to allocate for the index
component.
• BUFSP Specifies the total amount of space in bytes to allocate for the
data and index buffers.
• OPTCD options for the ISAM interface. Code I , L, or IL. ‘I ‘ means that
if OPTCD=L is specified for the file in the processing
program, records marked for deletion by hex FF in the first
byte should be physically deleted from the file. If OPTCD=L
is not specified in the program, Specify OPTCD=IL in the DD
statement for the same effect.
• RECFM Specifies the format in which the ISAM program expects to
process records.
• STRNO Specifies the number of concurrent requests the program may
issue against the file.
• Example #1
• //CUSTMAST DD DSNAME=MTRG.CUSTOMER.MASTER, DISP=SHR,
• // AMP=(BUFND=2,BUFNI=6)
•
• Allocate a VSAM file for shared access, specifying that 2 data buffers
and 6 index buffers should be used.
•
• Example # 2
• //CUSTISAM DD DSNAME=MTRG.CUSTOMER.MASTER,DISP=SHR,
• // AMP=(AMORG,OPTCD=IL,RECFM=FB)
•
• Allocate VSAM file using the ISAM interface program, AMORG identifies
the file as VSAM, OPTCD specifies how logically deleted records should be
handled and RECFM specifies that the program expects fixed-length blocked
records.
•
• NEW PARAMETER USED IN VSAM
•
• ES
• RECORG = KS
RR
• LS
• KEYOFF = offset-to-key
iFrames Technologies 31
Mainframe VSAM
iFrames Technologies 32
Mainframe VSAM
• Ex2 shows a JCL statement containing all required information for an ESDS
data set.
• Ex 3 shows a JCL statement of a temporary linear data set. This example
requires the assignment of a so-called storage Class.
•
• REPRO Command
• REPRO is an all-purpose load and backup utility command .
• It loads an empty VSAM cluster with records. The data and index components
(for a KSDS) are build automatically.
• It creates a backup of a VSAM dataset on a physical sequential dataset, and
then restore and rebuilds the VSAM dataset using this dataset as input
• It merges data from two VSAM datasets.
•
• REPRO terminates if One physical I/O error while writing to the output
dataset.
• A total of four errors encountered in any combination:
• A logical error while writing to the output data set.
• A logical error while reading the input data set.
• A physical error while reading the input data set.
•
• CREATION OF ESDS CLUSTER
• The definition of an ESDS cluster with the parameters described
above.
•
• //IFMAIN2 JOB (12345678),IFMAIN2,MSGCLASS=H,
• // MSGLEVEL=(1,1),CLASS=A,NOTIFY=&SYSUID
• //STEP1 EXEC PGM=IDCAMS
• //SYSOUT DD SYSOUT=*
• //SYSPRINT DD SYSOUT=*
• //SYSIN DD *
• DEFINE CLUSTER -
• (NAME (IFMAIN2.esds.CLUST) -
• RECORDSIZE (80,80) -
• TRACKS(5, 1) -
• CISZ(4096) -
• NONINDEXED -
• REUSE) -
• DATA (NAME(IFMAIN2.IFRAME.CLUST.DATA))
• /*
• //
iFrames Technologies 33
Mainframe VSAM
• The above example shows the creation of an ESDS cluster. After the
execution of this JCL the blank cluster will be created and it will be in the user
catalog for usability.
•
• COPYING ENTIRE DATA SETS
• The following screen shot will copy the EMP1.PS content to the above
created ESDS cluster, KSDS
• In this example, an entire input data set is copied to the output data set.
• Two parameters of REPRO are used.
• INDATASET (or IDS) Name of the entry to be copied or of the user catalog to
be merged.
• OUTDATASET (or ODS) Name of the target data set.
• Both INDATASET and OUTDATASET can be used to reference VSAM or non-
VSAM data sets.
• Example:
• //IFMAIN2 JOB NOTIFY=&SYSUID
• CONTROLINTERVALSIZE(512)-
• FREESPACE(20,20)-
• KEYS(4,0)-
• REUSE-
• INDEXED))-
• DATA(NAME(IFMAIN2.KSDS.DATA))-
• INDEXED(NAME(IFMAIN2.KSDS.INDEX))
• /*
• //
•
• REUSE cannot be used under following circumstances and hence not
recommended
• When KEYRANGES parameter is coded
• When alternate indexed are defined
•
• CREATION OF RRDS CLUSTER
• The following screenshot shows the definition of an KSDS cluster with
the parameters described above
• Example:
• //IFMAIN2 JOB NOTIFY=&SYSUID
• //STEP1 EXEC PGM=IDCAMS
• //SYSPRINT DD SYSOUT=*
• //SYSOUT DD SYSOUT=*
• //SYSIN DD *
• DEFINE CLUSTER(NAME(IFMAIN2.RRDS.CLUSTER)-
• TRACKS(2,5)-
• RECORDSIZE(80,80)-
• CONTROLINTERVALSIZE(512)-
• NUMBERED))-
• DATA(NAME(IFMAIN2.RRDS.DATA))
• /*
• //
•
• REPRO RECORD SELECTION
• DATA set can be copied partially using starting and ending delimiter
parameters on the REPRO command
• number = Number of records
• key-value = Record key for a KSDS
• rba = relative byte address for a record in a KSDS or ESDS
• rrn = Relative record number(slot) for RRDS records
• Where to start Where
to stop
•
• KSDS FROMKEY (rec-key) TOKEY (rec-key)
•
• KSDS, ESDS FROMADDRESS(rba) TOADDRESS(rba)
•
• RRDS FROMNUMBER (rrn) TONUMBER (rrn)
•
• KSDS, ESDS SKIP(number) COUNT(number)
• RRDS, ISAM
•
• The Following The Selection Of Records In Different VSAM Files.
• ESDS CLUSTER
• //IFMAIN2 JOB NOTIFY=&SYSUID
• //INPUT DD DSN=IFMAIN2.ESDS.CLUSTER,DISP=SHR
• //SYSIN DD *
• PRINT-
• INFILE(INPUT)-
• CHAR-
• FROMADDRESS(0)TOADDRESS(160)
• /*
• //
•
• The above program will display only the selected RBA address records which
are shown by the following screenshots.
• KSDS CLUSTER
• The following use the keys to select the particular records from the kSDS
cluster
• Example:
• //IFMAIN2 JOB NOTIFY=&SYSUID
• //INPUT DD DSN=IFMAIN2.KSDS.CLUSTER,DISP=SHR
• //SYSIN DD *
• PRINT-
iFrames Technologies 36
Mainframe VSAM
• INFILE(INPUT)-
• CHAR-
• FROMKEY(1000)TOKEY(1004)
• /*
• //
• RRDS CLUSTER
• The following screen shots use the keys to select the particular records from
the kSDS cluster
• //IFMAIN2 JOB NOTIFY=&SYSUID
iFrames Technologies 37
Mainframe VSAM
A. TRUE
B. FALSE
C.
D. 5. When defining a KSDS, which of the following parameters is not required?
E.
A. Space allocation (either CYL, REC or TRK)
B. VOLUMES
C. KEYS
D. NAME
E.
F. 6. DEFINE CLUSTER for a KSDS will generate CLUSTER, DATA and INDEX
information even if only CLUSTER information is specified.
A. TRUE
B. FALSE
C.
D. 7. A “candidate” volume is not used when the data set is initially loaded.
A. TRUE
B. FALSE
C.
D. 8. If the key of a KSDS record begins in the second field (first field is 25 bytes
long), the offset in the KEYS parameter is:
E.
F. a) 24 b) 25 c) 26 d) None of the above.
G.
H. 9. Suppose TEST.DATASET is a KSDS. The following statement will print
CLUSTER information only: LISTCAT ENTRIES (TEST.DATASET) ALL
a. TRUE
b. FALSE.
c.
d.
e.
f.
g.
h.
i.
j.
k.
l.
m.
n.
o.
iFrames Technologies 38
Mainframe VSAM
p.
q.
r. CHAPTER --- 6 : Print and Additional Commands
s.
t. PRINT COMMAND
u. The PRINT command of Access Method Services is used to print
the contents of both VSAM and non-VSAM data sets. The command
syntax is similar to that of REPRO. While REPRO copies an input data
set into another output data set, PRINT dumps an input data set to a
printer. This command is versatile and can be used to print a complete
data set or only a selected part of it.
v.
w. The PRINT command
x.
y. PRINT { INDATASET(entry-name [/ password])}
z. [{CHARACTER/HEX/DUMP}]
aa. [{SKIP(count)/
FROMKEY(key)/FROMNUMBER(number)/FROMADDRESS(address)}]
bb.
[{COUNT(count)/TOKEY(key)/TONUMBER(number)/TOADDRESS(addre
ss)]
cc.
dd. Explanation
ee. CHARACTER/HEX/DUMP -Specifies the format of the output.
CHARACTER & HEX print the data in character or hex format. DUMP
prints data in both character and hex format. DUMP is default.
ff.
gg. Example
hh. To print records 29, 30 & 31 in character format.
ii. PRINT INDATASET(MTRG.CUSTOMER.MASTER) -
jj. CHARACTER -
kk. SKIP(28) -
ll. COUNT(3)
mm.
nn. To print records 29,30 & 31 in dump format.
oo. PRINT INDATASET (MTRG.CUSTOMER.MASTER) -
pp. DUMP -
qq. SKIP(28) -
rr. COUNT(3)
ss.
tt. Example:
uu. //ifmain2 job notify=&sysuid
iFrames Technologies 39
Mainframe VSAM
zz. //sysin dd *
aaa. Print-
bbb. Infile(input)-
ccc. Char-
ddd. Skip(1)-
eee. Count(3)
fff. /*
ggg. //
hhh.
iii. EXPORT/IMPORT COMMAND
jjj. Export extracts catalog information and creates a copy of the
data records. When a base cluster and its alternate index are
permanently exported, the alternate index must be exported before
the base cluster. When exporting a data set for backup purpose specify
TEMPORARY to preserve the original data set.
kkk.
lll. EXPORT IMPORT
mmm.
nnn. Advantages
• Used for backup and recovery
• Catalog information also exported along with the data, unlike REPRO
• DFSMS classes are preserved
iFrames Technologies 40
Mainframe VSAM
• 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
•
•
EXPORT
•
•
• SYNTAX FOR EXPORT
• EXPORT entryname[/password] -
• {outfile(ddname) outdataset(entryname)} -
• [CIMODE | RECORDMODE] -
• [TEMPORARY | PERMANENT] -
• [INHIBITSOURCE
• NOINHIBITSOURCE] -
• [INHIBITTARGET
• |NOINHIBITTARGET] -
• [ERASE | NOERASE] -
• [PURGE | NOPURGE]
•
• RECORD MODE – RECORDS ARE EXPORTED ONE LOGICAL RECORD AT A
TIME.
• RECORDMODE is the default for ESDS, KSDS, and RRDS.
• CIMODE – CI rather than logical record exports data. CIMOD is
default for LDS.
• TEMPORARY – The data set is not deleted after export.
• PERMANENT- The data set is deleted after export.
iFrames Technologies 41
Mainframe VSAM
• {OUTFILE(DDNAME) | UTDATASET(ENTERYNAME)} -
• [OBJECTS((ENTERYNAME - [NEWNAME(NAME)] -
• VOLUMES(VOLSER])[ENTRYNAME….)])] –
• [INTOEMPTY]
•
• NEWNAME – Objects beginning imported can be renamed.
• VOLUMES – Specifies the volume on which the cluster is to reside if
omitted the original volume is the receiving
volume
• INTOEMPTY – Indicates that the receiving dataset is empty.
•
iFrames Technologies 42
Mainframe VSAM
• On IMPORT the existing catalog entry is deleted unless the receiving data set
is empty.
•
•
IMPORT
•
• The following procedure provides backup and recovery capabilities and also
permits the modification of data set attributes when the data set is imported
during recovery or reorganization.
•
•
iFrames Technologies 43
Mainframe VSAM
•
STEP 4
STEP 1 IMPORT
EXPORT INTOEMPTY
STEP 2 STEP 3
ORIGINAL DELETE DEFINE NEW
MASTER MASTER
•
• Example:
• //IFMAIN2 JOB NOTIFY=&SYSUID
• //STEP1 EXEC PGM=IDCAMS
• //SYSPRINT DD SYSOUT=*
• //SYSOUT DD SYSOUT=*
• //DD1 DD DSN=IFMAIN2.BACKUP.PS,
• //SYSIN DD *
• IMPORT-
• INFLIE(DD)-
• OUTDATASET(IFMAIN2.KSDS.CLUSTER)
• /*
• //
•
• VERIFY COMMAND
• Verifies the catalog HURBA (High Used Relative Byte Address) field and stores
the true values from the control block HURBA field.
• It should be used against cluster name only and not against data or index
components.
• It is used to rectify some of the problems due to data corruption
• It can be issued from TSO or from a JCL
•
•
• Syntax: VERIFY FILE (<dd name>)
iFrames Technologies 44
Mainframe VSAM
END-OF-DATA
END-OF-DATA
TEST.DATA.SET ? END-OF-KEY-
END-OF-KEY-RANGE RANGE
•
•
•
• Compares Catalog Information with the Data Set
• Corrects Catalog If A Disagreement Is Found
• Run VERIFY after a system failure.
• When sharing data sets, run VERIFY before opening a data set.
• VERIFY cannot be used for an empty data set or an LDS.
•
•
•
• Example:
• //IFMAIN2 JOB NOTIFY=&SYSUID
• //STEP1 EXEC PGM=IDCAMS
• //SYSPRINT DD SYSOUT=*
• //SYSOUT DD SYSOUT=*
• //SYSIN DD *
• VERIFY DATASET(IFMAIN2.KSDS.CLUSTER)
• /*
• //
•
• LISTCAT
• LISTCAT Command identify the catalog, the names of the entries to be
listed, the types of entries to be listed, and the amount of information about
each entry to be listed.
•
• LISTCAT [ CATALOG (name) ]
• [ ENTRIES (name - of - entries) ]
• [LEVEL (generic-level-names)]
• [ NAME/HISTORY/VOLUME/ALLOCATION/ALL}]
•
iFrames Technologies 45
Mainframe VSAM
iFrames Technologies 46
Mainframe VSAM
• Example:
• //IFMAIN2 JOB NOTIFY=&SYSUID
• //STEP1 EXEC PGM=IDCAMS
• //SYSPRINT DD SYSOUT=*
• //SYSOUT DD SYSOUT=*
• //SYSIN DD *
• LISTCAT ENTRIES(IFMAIN2.VSAM.PDS)
• LISTCAT ENTRIES(IFMAIN2.VSAM.*)
• /*
• //
•
• ALTER
• We can use this powerful command to change certain attributes of
previously defined VSAM object. These objects include base cluster and it’s
data and index component and even alternate index cluster and it’s data or
index component and even a VSAM or ICF catalog. If you are properly
authorized you can ALTER NON-VSAM data set attributes also.
•
•
•
•
CATALOG CATALOG
EXAMPLE.KSDS EXAMPLE.KSDS
ALTER EXAMPLE.KSDS
SHAREOPTIONS(1 SHAREOPTIONS(2 3)
SHAREOPTIONS(2
3) 3)
•
•
• SYNTAX OF ALTER COMMAND
•
• ALTER entryname[/password] -
• SHAREOPTION(cross region cross system)
• Examples:
• ALTER MTRG.CUSTOMER.MASTER -
• NEWNAME(MTRG.CUSTMAST)
• ALTER EMPLOYEE.KSDS.CLUSTER
• FREESPACE(25,25)
•
• Change the filename of MTRG.CUSTOMER.MASTER to MTRG.CUSTMAST
iFrames Technologies 47
Mainframe VSAM
•
• ALTER MTRG.CUSTOMER.MASTER.DATA -
• ADDVOLUMES(VOL291 VOL292) -
• REMOVEVOLUMES(VOL 281 VOL 282)
•
• Add VOL291 and VOL292 to list of eligible volumes for
MTRG.CUSTOMER.MASTER.DATA and remove VOL281 and VOL282.
• Example:
• //IFMAIN2 JOB NOTIFY=&SYSUID
• //STEP1 EXEC PGM=IDCAMS
• //SYSPRINT DD SYSOUT=*
• //SYSOUT DD SYSOUT=*
• //SYSIN DD *
• ALTER IFMAIN2.KSDS.DATA –
• NEWNAME(IFMAIN2.VSAM.KSDS)
• /*
• //
•
• Likewise we can alter the other data attributes like:
• ADDVOLUME
• ATTEMPTS
• SHAREOPTIONS
• BUFFERSPACE
• FREESPACE
• PASSWORD
•
• ENTRY NAME is the cluster, data or index component name.
• PASSWORD is the master password if the VSAM data set is password
protected
• ALTER can also be used as a migration path to change an ESDS to LDS
•
•
•
• ALTER with ADDVOLUME/REMOVEVOLUME
• ADD VOLUME:
• //ALTJOB JOB ,,NOTIFY=userid
• //STEP1 EXEC PGM=IDCAMS
• //SYSPRINT DD SYSOUT=*
• //SYSIN DD *
• ALTER -
• USER1.KSDS.DATA -
• ADDVOLUMES(VS012)
iFrames Technologies 48
Mainframe VSAM
•
• REMOVE VOLUME:
• ALTER
• USER1.KSDS.DATA -
• REMOVEVOLUME(RTD2)
•
• ALTER WITH FREESPACE
• ALTER entryname[/password] -
• FREESPACE(CI-percent[ CA-percent]))
• Example:
• //ALTJOB JOB ……….
• //STEP1 EXEC PGM=IDCAMS
• //SYSPRINT DD SYSOUT=*
• //SYSIN DD *
• ALTER -
• USER1.KSDS.DATA -
• FREESPACE(30 30)
•
•
• Entryname must be the name of the cluster’s data component.
• This procedure has the following advantages.
• It prevents wasting space.
• It minimizes CI and CA splits.
•
• ALTERING PASSWORD
• Adding/Changing PASSWORD
• ALTER entryname[/password] -
• [READPW (password)] -
• [UPDATEPW (password)] -
• [CONTROLPW (password)]-
• [MASTERPW (password)]
• Nullifying PASSWORD
• ALTER entryname[/password] -
• NULLIFY -
• [READPW] -
• [UPDATEPW] -
• [CONTROLPW] -
• [MASTERPW ]
•
• DELETE COMMAND
iFrames Technologies 49
Mainframe VSAM
iFrames Technologies 50
Mainframe VSAM
B. from address
C. from number
D. skip
E. none of the above
F. 3. The replace parameter causes:
a. KSDS records to be replaced by an input record with the same key
b. ESDS records to be replaced by an input record with the same RBA
iFrames Technologies 51
Mainframe VSAM
ALTERNATE ALTERNATE
INDEX 1 INDEX 2
(DEPT NO) (SOCIAL SEC
NO)
BASE
CLUSTER
(NAME) 015-35-7890 WRIG
183-96-416 ADAM
234-04-2372 PETT
3235 NEWTON $…
3240 WRIGHT $.. ADAMS 3247 $…
3247 ADAMS $.. ARNOLD 4711 $…
3247 PETTY $ … KINNEY 3247 $……
NEWTON 3235 $..
iFrames Technologies 52
Mainframe VSAM
•
• NEED FOR ALTERNATE INDEX:
•
• Alternate Indexes save sorting or maintaining duplicate data that
might otherwise be required.An alternate index cannot be defined for an
RRDS or LDS
•
• KSDS
•
•
•
INDEX:
• EMPLOYEE NAME
•
•
•
DATA:
EMPLOYEE RECORDS
•
•
•
•
•
•
A. ACCESS A KSDS BY KEY OTHER THAN THE PRIMARY KEY
1. SOCIAL SECURITY NUMBER
2. DEPARTMENT NUMBER
3. EMPLOYEE NUMBER
4. ZIP CODE
5. B. ACCESS AN ESDS BY KEY
6.
7. ALTERNATE INDEX DATA RECORD FORMAT
8.
9. PRIME KEY LENGTH *
10. NUMBER NONUNIQUE
PRIME KEYS
11. + ALTERNATE KEY +
RECORD =5 -0R-
SIZE 12. LENGTH 4 *NUMBER
13. NONUNIQUE POINTERS
POINTERS
14.
15.
16.
17.
18. Each AIX data record is variable length and contains system
header information, the alternate key and at least one pointer to the
iFrames Technologies 53
Mainframe VSAM
base cluster. AIX s are spanned record data sets, since there may be
many base cluster records associated with a given alternate key.
19. Pointers to the base cluster are of two forms, either an RBA (for
an ESDS base cluster)or a prime key for a ksds base cluster).The
pointers are the same type throughout the entire AIX.
20.
21.ALTERNATE INDEX ORGANIZATION
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)
•
• STEPS FOR CREATING ALTERNATE INDEX
• Define AIX using IDCAMS DEFINE AIX
• Build AIX & populate it using IDCAMS BLDINDEX
• Specify Alternate Index Path using IDCAMS DEFINE PATH
•
• CREATING AN ALTERNATE INDEX
• DEFINE ALTERNATEINDEX-
• (NAME(AIX NAME)-
• RELATE(BASE CLUSTER NAME)-
• KEYS (LENGTH OFFSET)-
• UNIQUEKEY/NONUNIQUEKEY-
• UPGRADE/ NOUPGRADE
• RECORDSIZE (AVG MAX)-
• VOL (VOLSER) –
• CYL/TRK/REC(PRI SEC))
• NAME
• Syntax: NAME
• Required parameter: Specifies the name of AIX
•
• VOLUMES
• Syntax: Volumes (Vol-ser-1 ..... vol-ser-n)
• Required parameter: Assigning base cluster & AIX in different volumes
improves performance
•
• RELATE
• Syntax: RELATE (base cluster name)
iFrames Technologies 54
Mainframe VSAM
• Required parameter: Establishes relationship between the base cluster & AIX
•
• UPGRADE/NOUPGRADE
• Syntax: UPGRADE/NOUPGRADE
• UPGRADE specifies that records in AIX are to be updated automatically
whenever the base cluster is updated .The use of UPGRADE makes the
alternate index part of the cluster’s so called “UPGRADE SET”
• Default: UPGRADE
•
•
•
•
•
•
• AIX 1
• AIX 2 AIX 3
•
•
•
•
•
•
• Base cluster
•
•
• KEYS
• Syntax: KEYS (length offset)
• Optional: primary key values are taken as default, if not specified.Defeats the
purpose of Alternate Index, if not specified
•
• RECORD SIZE
• Syntax: RECORD SIZE (average maximum)
• Default: RECORDSIZE (4086 32600)
• Abbr: RECSZ
• Average & max. Are same for UNIQUEKEY AIX and may be different for
NONUNIQUEKEY
•
•
•
•
• HOW TO CALCULATE THE RECORD SIZE?
iFrames Technologies 55
Mainframe VSAM
iFrames Technologies 56
Mainframe VSAM
• RECORDSIZE(70 110)-
• FREESPACE(20 10)-
• NONUNIQUEKEY-
• DATA
• (NAME(USER1.KSDS.AIX.DATA))-
• INDEX
• (NAME(USER1.KSDS.AIX.INDEX))
•
• BUILD INDEX
• SYNTAX:
• BLDINDEX
• {INFILE(ddname) / INDATASET (base cluster name)} -
• {OUTFILE(ddname) / OUTDATASET (AIX NAME)} -
• [EXTERNALSORT / INTERNALSORT] -
• [WORKFILES(ddname ddname) ]
• INFILE /INDATASET IDENTIFIES THE BASE CLUSTER.
• OUTFILE / OUTDATASET IDENTIFIES THE AIX TO BE LOADED
•
INTERNALSORT Requires AMS to build the Alternate Index Records
within the user’s address space if possible
EXTERNALSORT Indicates that two ESDS work Files are to be used by
AMS for the sort
WORKFILES Specifies The DD names to be used instead of the default
Names
EXAMPLE
BLDINDEX INDATASET(USER1.KSDS.CLUSTER)-
OUTDATASET(USER1.KSDS.AIX)
CREATION OF PATH
• Once you have defined any alternate indexes, You must define a separate
path for each one, using the IDCAMS DEFINE PATH command.
• This path name is the dataset name that you use in the jcl when processing
an alternate index. It is a separate catalog entry and forms a logical
connection(path) through the alternate index to the base cluster
• A path is a catalog record. It is normally used to relate the alternate index
and the base cluster
• IDCAMS DEFINE PATH is used to create a path record in the catalog.
•
• SYNTAX:
• DEFINE PATH(NAME(PATH NAME) -
• PATHENTRY(AIX NAME) -
iFrames Technologies 57
Mainframe VSAM
• UPDATE / NOUPDATE)
• NAME specifies the name of the PATH.
• PATHENTRY associates the AIX with the path name.
• UPDATE / NOUPDATE specifies whether all of the upgrade set
should be maintained by VSAM when accessing through this path
• EXAMPLE:
• DEFINE PATH ( -
• NAME(USER1.KSDS.PATH) –
• PATHENTRY(USER1.KSDS.AIX)-
• UPDATE )
•
• ALTERNATE INDEX FOR ESDS
• Same syntax & parameters as KSDS
• Not supported in Batch COBOL (OS/VS & VSII)
• Used under CICS environment
• Step 2: BUILDING THE INDEX
• BLDINDEX Command actually builds the index and populates it with
records
•
• //BLDINDX EXEC PGM=IDCAMS
• //SYSPRINT DD SYSOUT = *
• //DD1 DD DSN=XIND.NLT.VSAM,DISP=OLD
• //DD2 DD DSN=XIND.NLT.VSAM.DEPT.AIX,DISP=OLD
• //IDCVT1 DD DSN=XIND.NLT.WRKFILE1, DISP=OLD
• //IDCVT2 DD DSN=XIND.NLT.WRKFILE2, DISP=OLD
• //SYSIN DD *
• BLDINDEX INFILE (DD1) OUTFILE (DD2) -
• INTERNALSORT
• /*
• Step 3: SPECIFYING THE ALTERNATE INDEX PATH
• Example:
• DEFINE PATH -
• (NAME(XIND.NLT.VSAM.DEPT.PATH) -
• PATHENTRY -
• (XIND.NLT.VSAM.DEPT.AIX) UPDATE)
• - Path is a VSAM object though it doesn’t contain any records
• - Same command for KSDS & ESDS
• - Path is used to link JCL DSN to VSAM AIX (specifies that the given AIX is to
be used).
• NAME
• Syntax: NAME (pathname). Pathname becomes the DSN in the run JCL
iFrames Technologies 58
Mainframe VSAM
•
•
• PATHENTRY
• Syntax: PATHENTRY (entry name/password).
• Entry name: name assigned to alternate index cluster. Required for an
alternate index
•
• RESTRICTIONS FOR ALTERNATE INDEX
• No Alternate Index For RRDS and LDS.
•
•
•
•
•
•
•
•
•
•
•
•
• REVIEW QUESTIONS:
• 1. An alternate index can be defined for which cluster type(s)?
• a.) KSDS AND RRDS
• b) KSDS AND ESDS
• c) KSDS only
• d) KSDS,ESDS AND RRDS.
• 2. The size of an alternate index is about the same of it’s base cluster.
• a) true
• b)false
iFrames Technologies 59
Mainframe VSAM
iFrames Technologies 60