Mainframe
VSAM
CHAPTER - 1: Introduction to VSAM Virtua Virtuall Sto Storag rage e Acc Access ess Method Method - VS VSAM AM - is a data data manage managemen mentt system system intr introd oduc uced ed by IBM IBM in the the 1970s 1970s as part part of the the OS/V OS/VS1 S1 and and OS/V OS/VS2 S2 oper operat atin ing g systems. systems. Although Although there are still datasets datasets that are best managed with the several other other (non(non-VS VSAM) AM) data data managem management ent method methods, s, VS VSAM AM is a major major compon component ent of modern IBM operating systems. VSAM is a high performance access method used to organize data and to maintain information about that data in an index or library called a catalog. VSAM acts as interface between Operating System and Application Program. VSAM is an access method used to organize data and maintain information about the data in a catalog. All VSAM data sets reside on DASD Devices and must be defined in a catalog. There are two major parts to VSAM: •
Catalog management
•
Record management
Catalog Management •
•
The catalog contains contains information about about the VSAM VSAM data sets. The catalog can be an an ICF ICF Catal Catalog og or a VSA VSAM M catal catalog og (old (older er vers version ions s of the operat operating ing 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 The purpose of record management is to maintain records in a VSAM data set for an application or a system program. VSAM supports five data set organizations: •
Key-sequenced data set (KSDS)
•
Entry-sequenced data set (ESDS)
•
Fixed-length relative record data set (RRDS)
•
Variable-length relative record data set (VRRDS)
•
Linear data set (LDS)
The primary difference between the VSAM data set organizations is in the way the records are stored and accessed. 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 (Data Facili Facility ty Stora Storage ge Manage Managemen mentt System System). ). In the year 1991, 1991, VS VSAM AM 3.3 was introduced with variable length records for RRDS
iFrames Technologies
1
Mainframe
VSAM
STRUCTURE OF VSAM VSAM provides a comprehensive catalog facility that stores information about VSAM data sets and other files. There are two types of catalogs: •
Master Catalogs
•
User Catalogs
Master Catalog Every system system that uses VSAM VSAM has one, and only one, master master catalog. catalog. The master catalog contains entries about system datasets and VSAM structures used to manage the operation operation of VSAM. VSAM. The master master catalog is created created during the System System Genera Generatio tion n proces process s and usually usually reside resides s on the System System Reside Residenc nce e volume 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 A user catalog is a catalog created to contain entries about application specific datasets. The information defining defining a user catalog is stored into a catalog entry in the master catalog. A production system system might have any number number of user catalogs, with with the datasets cataloged in a specific user catalog related by application type.
ADVANTAGES & DISADVANTAGES OF VSAM 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. Imbedd Imbedded ed free free space space makes makes the insert insertion ion of record records s easy, easy, and data data sets 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 Except for read-onl read-only y data data sets, sets, the integrit integrity y of VS VSAM AM data data sets sets in crosscrosssystem system and cross cross –region –region sharin sharing g must must be contro controlle lled d by the user. user. Data Data integrity must be a prime consideration in the initial design of applications that will be shared across systems.
iFrames Technologies
2
Mainframe
VSAM
MAJOR AREAS WHERE VSAM IS USED •
•
•
•
It can be used as a stand-alone product. VSAM data sets can be created and processed by a powerful software product called IDCAMS. Batch application programs in COBOL, PL/I, Assembler, etc. can access VSAM data sets. In data data set manage managemen ment, t, PDS direct directori ories, es, catalo catalogs, gs, and genera generatio tion n data data groups can be manipulated through specific IDCAMS commands. GDGs and catalogs are themselves VSAM data sets, Also, the IDCAMS utility can be used to process older, non-VSAM data set organizations. Many major IBM software products, such as CICS, IMS, DB2 and TSO, use VSAM data sets in a majority of applications. In some of them, VSAM data sets are the only ones that are compatible.
VSAM is available under all IBM’s Mainframe operating systems; MVS, VM, and VSE. The MVS implementation of VSAM is the most comprehensive. Also, VSAM data sets can be stored on almost all standard disk drives, such as 3390, 3380, 3350, 3370, etc. Present and future mainframe software released by IBM will be designed to process records storage in VSAM data sets. VSAM is going to be around for a long time to come. VSAM TERMINOLOGY Before we discuss VSAM data set organizations in detail, we need to review some terms that will be used throughout the book. •
Logical record
•
Control interval
•
Control area
Logical record (LR) A logical record is a unit of information used to store data in a VSAM data set. Logical records in VSAM data sets are stored differently than logical records in nonVSAM data sets.
LR A LR is comparable to the logical-record –length (lrecl) for a Non-Vsam dataset, as in the DCB Parameter of JCL. Control Interval (CI) Logical records are contained in a control interval (CI). A group of LRs will make one CI.
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 Interval Format for a Non- LDS Cluster .
Logical Record Area Free space Area
Control Interval Definition field
Record definition field
RECORD 1 RECORD 2
R D F 1
R D F 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. Control area (CA) •
•
•
A control area (CA) is one or more CIs put together into fixed-length contiguous areas of DASD. A VSAM data set is composed of one or more CAs. The number of CIs in a CA is fixed by VSAM. The CA size is implicitly defined when you specify the size of a data set at data set definition. The maximum size of a CA is one cylinder and the minimum size is one track.
iFrames Technologies
4
Mainframe
VSAM
Figure 1-2 shows the structure of a CA.
CA1
LR1
CA2
LR3
CA3
LR5
LR2
LR4
LR6
FREE SPACE
RDF2
FREE SPACE
FREE SPACE
RDF1
CIDF
RDF4
RDF1
CIDF
RDF
RDF
CIDF
CA 1
REVIEW QUESTIONS 1. What is VSAM? 2. What are the major parts in VSAM? 3. What are the two Catalogs available in VSAM? 4. What is Control Interval? 5. What is Control Area? 6. How many Bytes occupied for RDF and CIDF? 7. The Maximum and
minimum size of
a Control Area is
__________,
_________. 8. What are the advantages and disadvantages of VSAM? 9. What are the different datasets supported by VSAM? 10. What is a logical record? 11. What's the biggest disadvantage of using a VSAM dataset?
iFrames Technologies
5
Mainframe
VSAM
CHAPTER --- 2 : Dataset Organization
VSAM DATASET ORGANIZATION
LR1
LR2
LR3
CI
LR2
WORK AREA
Whenever a record is retrieved from DASD, the entire CI containing the record is read into a VSAM I/O buffer in virtual storage. From the VSAM buffer, the desired record is transferred to a user defined buffer or work area. The physical organization of VSAM data sets differs considerably from those used by other access methods. VSAM data sets are held in control intervals and control areas; the size of these is normally determined by the access method, and the way in which they are used is not visible to you. TYPES OF DATASET ORGANISATION VSAM supports 5 different organizations. They are as follows: •
Linear Data Set – LDS – with no record organization
•
Entry-Sequenced Data Set – ESDS - is like a standard sequential data set.
•
Fixed-length Relative-Record Data Set - FRRDS - Fixed length RRDS
•
Variable-length Relative Record Data Set - VRRDS - Variable length RRDS
•
Key-Sequenced Data Set – KSDS- is like an indexed sequential access method file.
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
comprehensive support for application development in many environments such as COBOL, PL/I, FORTRAN, Assembler and CICS. LINEAR DATA SET (LDS) 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. ENTRY SEQUENCED DATA SET (ESDS) An ESDS is a sequential file, in which records are typically retrieved in the order in which they were written to the data set and additions are always made at the end of the file. Each record can be identified by a relative byte address or RBA. Records cannot be physically deleted. Since records in an ESDS are not sequenced on any key field, there is no primary key index component. Imbedded free space is not allocated at the time of allocation of an ESDS, since records are not added to the middle of the file. Records in an ESDS may be of variable length.
iFrames Technologies
7
Mainframe
VSAM
CI 1 RECORD1
RECORD2
RECORD3
RECORD4
RECORD7
RECORD8
RBA
0 CI 2 RECORD5
RBA
RECORD6
4096 CI 3 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. A record can be accessed sequentially or directly by its RBA: Relative Byte Address (RBA) is the address of a record in a dataset. Records can be accessed sequentially or by relative byte address (RBA).The RBA of the first logical record is 0. The second record has an RBA equal to the length of the first record and so on. TYPICAL ESDS PROCESSING 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
RELATIVE RECORD DATASET (RRDS) 1)
FIXED LENGTH RECORDS
In an RRDS the entire data set is a string of fixed length slots. Each slot occupies a fixed position and is identified by its position relative to the first slot of the data set.
DATA CA
DATA CA
RECORD1
RECORD2
RECORD3
RECORD4
RECORD5
RECORD6
RECORD7
RECORD8
RECORD9
RECORD10
RECORD11
RECORD12
RECORD13
RECORD14
RECORD15
RECORD16
RECORD17
RECORD18
RECORD19
RECORD20
RECORD21
RECORD22
RECORD23
RECORD24
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 PROGRAM
29
30
31
32 CI
GET RECORD 25
25
26
27
28
CI
CI
13
14
15
16
21
22
23
24
CI
9
10
11
12 CI
SLOT 8
5
6
7
CI
17
18
19
20
8
CONTROL AREA 1
Slot8 CI
1
2
iFrames Technologies
3
4 9
Mainframe
VSAM
The relative record number can be used as a search argument. The application program inputs the relative record number of the target record and VSAM is able to find its location quickly using an internal algorithm. An RRDS can be processed sequentially, directly or skip-sequentially. •
•
•
RRDS sequential processing is treated the same way as ESDS sequential processing. Empty slots are automatically skipped by VSAM. An RRDS can be processed directly by supplying the relative record number as a key. VSAM accesses the appropriate slot and returns the record to the user’s buffer. RRDS direct address processing by supplying the RBA is not supported. Skip-sequential processing is treated like an RRDS direct processing request, but the position is maintained. Records must be in ascending sequence.
2. VARIABLE RELATIVE RECORD DATA SET (VRRDS) A VRRDS is similar to a fixed-length RRDS, except that it contains variablelength records. Each record has a unique relative record number, and is placed in ascending relative record number order. Each record is stored and retrieved using its relative record number. VRRDS has no preformatted slots. The relative record number of a record cannot change. When that record is erased, the relative record number can be reused for a new record. You can specify free space for inserting records and increasing the length of a record. VRRDS is a KSDS processed as an RRDS, so an index will be created. You specify the VRRDS organization with the IDCAMS DEFINE command with the NUMBERED option and variable length record. REVIEW QUESTIONS. 1. Which VSAM cluster support only fixed length records? a) LDS b) RRDS c) ESDS d) KSDS 2. FREESPACE can be specified for which type of cluster? 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?
6.
a)
LDS
b)
RRDS
c)
ESDS
d)
KSDS
Which VSAM clusters support only fixed length records? a) LDS b) RRDS c) ESDS d) KSDS
7. The types of processing supported by RRDS are a)
sequential
b)
skip-sequential
c)
direct
d)
a and b
e)
a, b and c
8. The types of processing supported by ESDS are a)
Sequential
b)
skip-sequential
c)
Direct
d)
a and b
e)
a and c
9. What is the Difference between LDS & ESDS? 10. How Many Times Secondary Space Allocated? 11. What is the RRN for the first record in RRDS?
iFrames Technologies
11
Mainframe
VSAM
CHAPTER - 3: KSDS KEY SEQUENCED DATASET (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. DATA / INDEX RELATIONSHIP 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
Sequence Set: contains the index CI’s at the lowest level.
There is one CI in the sequence set for each data CA. It contains pointers and high key information for each CI within the data CA. It contains also horizontal pointers from one sequence set CI to the next sequence set CI. •
Index Set: remainder of the index component.
If there is more than one sequence set level record, VSAM automatically builds another index level. Each CI in the index set contains pointers and high key information for CI’s in the next lower level of the index.
Index Component
IS1 IS2IS3
Index set
SS1
SS2
CA1
Data Component
SS3
CA2
SS4
CA3
CA4
SS5
Sequence set
CA5
CI1
CI1
CI1
CI1
CI1
CI2
CI2
CI2
CI2
CI2
CI3
CI3
CI3
CI3
CI3
TYPICAL KSDS PROCESSING: INDEX COMPONENT 079
007
021
001
002
079 004
FS
099
124
236
236
FS
007 DATA COMPONENT
008
012
0 67
079
018
021
iFrames Technologies
13
Mainframe
VSAM
CONTROL AREAS There are three methods by which to access a KSDS. These are sequential, direct, or skipsequential.
084
087
111
124
099
2 38
Sequential access is used to load a KSDS, and to retrieve, update, add and delete records in an existing data set. Sequential access means that records are retrieved one-by-one, starting from the first record, in the order that they are placed in the dataset.. When retrieving records, you do not need to specify key values because VSAM automatically obtains the next logical record in sequence. The sequence set is used to find the next logical CI. Sequential access allows you to avoid searching the index more than once. Sequential is faster than direct for accessing multiple data records in ascending key order. Direct access is used to retrieve, update, add and delete records in an existing data set. You need to supply a key value for each record to be processed. You can supply the full key or a generic key. The generic key is the high order portion of a full key. For example, you might want to retrieve all records whose keys begin with XY (where XY is the generic key), regardless of the full key value. VSAM searches the index from the highest-level index set CI to the sequence set for a record to be accessed. Vertical pointers in the sequence set CI are used to access the data CA containing the record. Direct access saves you a lot of overhead by not retrieving the entire data set sequentially to process a small percentage of the total number of records. Skip-sequential access is used to retrieve, update, add and delete records in an existing data set. In skip-sequential method of access, the record pointer can be placed anywhere within the dataset (by giving the key) and records can then be retrieved sequentially from that point. 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 eachFS data CA empty / unused at load time. SEQUENCE SET CI 4037
iFrames Technologies
4065
4077
14
Mainframe
VSAM
CI 0
4012
4023
CI 1
4041
4050
CI 2
4072
4073
4034
4037
FREE SPACE
4052 4085
4075
4077
FREE SPACE
FREE SPACE
FREESPACE CI 3
UPDATING A KSDS CLUSTER: Insertion: While Inserting a Record in the KSDS Cluster, the records are placed in logical sequence. The CI free space is used. The Index Component is not altered. Deletion: While deleting a record from the KSDS Cluster, the records are physically removed from CI. The records in CI with higher keys are shifted left and the available free space in the CI is increased. The Index Component is not altered. INSERT 4058 SEQUENCE SET CI
4037
DATA CA
4065
4077
FS
CI
0
4012
4023
4034
4037
CI
1
4041
4050
4052
4058
4072
4073
4075
4077
CI
CI
2
3
FREESPACE 4065 FREESPACE
FREE SPACE
CONTROL INTERVAL SPLIT 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
CI
4037
4050
4065 4077
4012
4023 4034 4037
FREE SPACE
4041
4046
4050
FREE SPACE
4072
4073
4075
4077 FREE SPACE
4058
4065
FREE SPACE
0
1
DATA CA CI
2
CI
3
4052
CONTROL AREA SPLIT 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
4037
4050
INDEX SET CI
4065
4065
4077
4077 SEQUENCE SET CI
4037 4050 4065
4012
4023
4034
4046 CA1
4041
4073
4072 4052
4075
4058
4012
4037
4050 4076
4077
4023
4034
4050
4041
4046
4052
4058
4065
4037
4065 FREE SPACE
4072
4076
4073
4077
4074
4075
CA2
FREE SPACE FREE SPACE
SPANNED RECORDS •
Spanne Spanned d record records s are records records with with a record record size greate greaterr than than the CI siz size e specified.
iFrames Technologies
17
Mainframe
•
•
VSAM
Spanned records can only be used in ESDS or KSDS organizations. Spanned records can “span” control intervals, but not control areas. So, one spanned record is stored in several CI’s.
RECORD 1
RECORD 1 R SEGMENT1 D F 2
R D F 1
C I D F
RECORD 1 R R SEGMENT2 D D F F 2 1
C I D F
RECORD 1 UNUSED SEGMENT3 SPACE
R D F 2
R C D I F D 1 F
As in the above above diagram, the spanned record record spans three three CI’s. The ‘segment’ ‘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. ACCESSING SPANNED RECORDS 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: 1.
Specifyin Specifying g CISZ (4096) (4096) at the cluster cluster level for a KSDS results results in a) VSAM ignoring the specification b) Data and index CISZ 4k each c) Data CISZ 4k; index CISZ selected by VSAM
2.
What What is the use use of Free Free Space Space in KSDS? KSDS?
3.
How do you define a KSDS?
4.
VS COBOL COBOL II suppor supports ts SKIP SKIP proces processin sing. g. a) TRUE b) FALSE
5.
VSAM VSA M request request macros macros (e.g., (e.g., GET, PUT) point to which which other macro(s) macro(s)? ? a) OPEN b) ACB c) RPL d) CLOSE e) (B) and (C)
6. NONS NONSPA PANNE NNED D reco record rds s may may be acce access ssed ed in in eithe eitherr MOVE MOVE mod mode e or LOCA LOCATE TE mode. a)
TRUE
b)
FALSE
7.
What does a file status of 02 on a VSAM indicate?
8.
Explain CI split and CA split
iFrames Technologies
19
Mainframe
VSAM
CHAPTER - 4: ACCESS METHOD SERVICES (AMS) One of VSAM’s strength is that a single set of data management facilities called Access Method Service (AMS) manages both VSAM and non-VSAM datasets. IDCAMS is a general-purpose utility program, used with VSAM, to establish and maintain catalogs and data sets. It provides the services described above, and more. AMS uses a command processor called IDCAMS to handle a variety of functions such as creating, reproducing, printing datasets and listing catalog contents. These functions of AMS are performed thru functional commands. A functional command can have one or more parameters that can be positional or keyword. Positional parameters are identified by its position in relation to other parameters: a keyword parameters can be used in any place in relation to other keyword parameters because it is identified by the particular keyword used. Types of AMS commands •
Functional commands
•
Modal commands
Commonly used AMS commands AMS command
Function
Functional commands ALTER
Changes information specified for a alternate index, or path at define time.
BLDINDEX
Builds an alternate index.
DEFINE INDEX
ALTERNATE
catalog,
cluster,
Defines an alternate index.
LISTCAT
List information about data sets
REPRO
Copies records from one file to another. The input and output files can be VSAM or non-VSAM
PRINT
Prints the contents of a VSAM or non-VSAM file.
DEFINE CLUSTER
Defines a VSAM file, whether it’s KSDS, ESDS, or RRDS
DEFINE CATALOG
Defines a master catalog
MASTER
DEFINE PATH
Defines a path that relates an alternate index to its base cluster
DEFINE USERCATALOG
Defines a user catalog.
DELETE
Removes a catalog entry for a catalog, cluster, alternate index or path
EXPORT
Produces a transportable file.
IMPORT
Copies a previously exported file.
iFrames Technologies
20
Mainframe
VSAM
Modal commands IF
Controls the flow of command execution by condition codes returned by functional commands
testing
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.
AMS PERFORMANCE PARAMETERS 1) CONTROL INTERVAL SIZE Syntax
: CONTROLINTERVALSIZE (bytes)
Abbr
: CISZ or CISIZE
Default
: Calculated by VSAM
Control Interval size (CIDF & RDF) & FREESPACE must be taken into account Thumb Rule for CISIZE If the record length is <8192, multiples of 512, >=8192, multiples of 2048 2) FREESPACE Syntax
:
Default
FREESPACE (CI% CA%) :
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 : additional index buffer for KSDS
Two
data
o
Used to improve Input/output performance
o
Can also be specific in JCL EXEC parameter
buffers
plus
one
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 Minimum of 2 (One for normal access and one for split processing) is required o
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 •
•
Allows large records to span more than one Control Interval
•
However, the records cannot span across Control areas
•
RRDS does not support spanned records.
Default : NONSPANNED
•
iFrames Technologies
22
Mainframe
•
VSAM
6) KEYRANGES
•
Syntax: KEYRANGES (Low - Val; High - Val)
•
Default
•
•
Example
: None (No range assumed)
:
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
•
Default
•
•
:
REUSE/NOREUSE :
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
Syntax
•
•
•
VSAM
: IMBED / NO IMBED
Note:
IMBED applies to the index component. Hence it is limited to a KSDS. •
IMBED places the sequence set CI for a data control area within the control area.
•
Uses IMBED only with large control area sizes.
•
IMBED requires additional DASD space.
•
IMBED should provide faster access to data.
•
•
•
•
•
•
•
•
12) SHARE OPTION Syntax:
SHAREOPTIONS (Cross-region-value Cross-system-Val)
Cross-region : Concurrent data access on a standalone system (ex: TSO&CICS accessing same data) Cross-system : Data access for different computers that are inter-connected) Default
:
SHAREOPTIONS (1
multiple
computers
(Two
3)
Multiple jobs can read only if no update takes place - Complete data integrity Multiple jobs can read and at the same time one job can update - Write, but not read integrity
•
Multiple jobs can read & write simultaneously - No integrity
•
Same as option 3, but refreshes buffer after every read
•
Share options 1 & 2 are not allowed for cross-system
•
For cross region sharing, each batch job must have DISP=SHR
•
For cross system sharing DISP parameter in the JCL is immaterial
•
•
•
•
13) ERASE / NOERASE Default : NOERASE ERASE instructs VSAM to move zeroes to all the bytes once the cluster is deleted.
•
•
INVOKING IDCAMS
•
//MYJOB
JOB……………
•
//STEPA
EXEC PGM = IDCAMS
•
//SYSPRINT
DD SYSOUT = *
•
//SYSIN
DD * DEFINE CLUSTER –
•
•
.
•
.
•
IDCAMS commands can be processed as a job or job step (by specifying PGM=IDCAMS) on the EXEC card.
•
iFrames Technologies
24
Mainframe
VSAM
•
BASIC IDCAMS COMMANDS
•
The following are the commands which will be used with IDCAMS procedure.
•
BUILDINDEX
•
DEFINE
•
IMPORT/EXPORT
•
LISTCAT
•
REPRO
•
VERIFY
•
AMS COMMAND SYNTAX
•
COMMAND
PARAMETERS
SERVICEFURTHER REQUESTED
END OF COMMAND DESCRIBES COMMAND
•
Margins
Default to 2&72
•
Separators
BLANK,COMMA
•
Comments
/*----------------*/
•
Continuation HYPEN, PLUS SIGN
•
Terminator
•
TERMINATOR
SEMICOLON or Absence of Continuation mark
There are two possible continuation characters:
•
The PLUS sign (+): ignores the leading blanks on the next line.
•
The HYPEN sign (-): doesn’t ignore the leading blanks on the next line.
•
•
DEFINE SPECIFICATONS
•
•
•
•
•
Data Set Name Data Set Type Space Allocation
•
•
•
•
Where? How much? Data Set Attributes
•
•
•
When defining a VSAM cluster using the DEFINE CLUSTER command, the following must or can be specified.
iFrames Technologies
25
Mainframe
VSAM
•
The data set name:
•
The cluster name is required.
•
Component name(s) is/are optional. The type of the date set type:
•
•
KSDS, ESDS, RRDS, LDS.
•
•
The data set attributes:
•
Record size and control interval size.
•
For a KSDS: Key information and free space distribution.
•
BASIC DEFINE COMMAND SYNTAX FOR CLUSTER :
•
The DEFINE CLUSTER Command
•
DEFINE CLUSTER (
NAME(entry – name)
•
[ OWNER(owner – id) ]
•
[ FOR(days) | TO(date) ]
•
[ INDEXED | NONINDEXED | NUMBERED ]
•
[ RECORDSIZE (avg max) ]
•
[ CISZ(size)]
•
[ SPANNED | NONSPANNED]
•
[ KEYS (length offset)]
•
[ FREESPACE ( ci ca) ]
•
[ VOLUMES ( vol-ser no..)]
•
[ FILE (ddname) ] [ { cylinders /kilobytes/megabytes/tracks/records} (primary
•
secondary)}] •
[ UNIQUE | SUBALLOCATION]
•
[ REUSE | NOUSE]
•
[ SHAREOPTIONS ( a b)]
•
[ IMBED | NOIMBED]
•
[ STORAGECLASS(storage – class)]
•
[ DATACLASS(data-class)]
•
[MANAGEMENTCLASS (management- class)] [ DATA ( [ NAME (entry – name) ]
•
[ VOLUMES (vol –ser ….)]
•
[ FILE (ddname) ]
•
[ { cylinders/kilobytes/megabytes/tracks/ records} (primary
•
secondary) ] ) ] •
[ INDEX ( [ NAME( entry – name) ]
•
[ VOLUMES ( Vol –ser ….)]
•
[ { cylinders/kilobytes/megabytes/tracks/ records} (primary
•
secondary) ] ) ]
iFrames Technologies
26
Mainframe
VSAM
•
[CATALOG ( name [/ password]) ]
•
•
•
•
•
•
•
Explanation NAME (entry –name) component
Specifies the name of the cluster or
OWNER (owner –id)
Specifies a 1 to 8 character owner-id.
FOR (days) dddd) yyddd)
Specifies a retention period ( in the format or an expiration date (in the format
TO (date)
INDEXED / NONINDEXED/NUMBERED
Specifies the file organization: SDS
INDEXED), SDS NONINDEXED), OR RRDS NUMBERED). The default is INDEXED. •
•
•
•
•
•
•
RECORDSIZE ( avg max) record size.
Specifies
CISZ (Size)
Specifies the size of the control intervals.
SPANNED / NONSPANNED control default is NONSPANNED.
Specifies
KEYS (length offset) primary
Specifies the length and offset of the key.
FREESPACE (ci ca) reserve control areas.
specifies the percentage of free space to in the control intervals and
VOLUMES (Vol-ser) contain
Specifies one or more volumes that will the cluster or component.
FILE (dd name)
Specifies a dd name that identifies a DD statement that allocates the only for mountable
volumes .Required DASD volumes.
the
average
and
maximum
whether records can cross interval boundaries. The
Primary allocate, kilobytes, records.
Specifies the amount of space to initially expressed in terms of cylinders, megabytes, tracks or
•
Secondary
Specifies the secondary space allocation.
•
UNIQUE/SUBALLOCATION
Specifies whether the file is unique or sub allocated. The default is
•
SUBALLOCATION. •
•
•
REUSE / NOREUSE default is
Specifies whether a file is reusable. The NOREUSE.
SHAREOPTIONS ( a b) permitted.
Specifies the level of the file sharing
IMBED / NOIMBED should be a KSDS. The
Specifies whether sequence set records imbedded in the data component of default is NOIMBED.
iFrames Technologies
27
Mainframe
•
VSAM
CATLOG (name[/password]) Specifies the name and password of the catalog that will own the cluster. If omitted, the highlevel qualifier of the cluster name or the stepcat, jobcat, or master catalog identifies the catalog.
•
•
NAME is a positional keyword parameter and must be coded first. Other keywords can be placed anywhere
•
EXAMPLES OF THE DEFINE CLUSTER:
•
Example #1
•
•
Define a key-sequenced data set (KSDS) DEFINE CLUSTER ( NAME (MTRG.CUSTOMER.MASTER)
-
•
OWNER(MTRG)
-
•
INDEXED
-
•
RECORDSIZE(80 80)
•
KEYS(6 0)
-
•
VOLUMES(SMS007)
-
•
UNIQUE
-
•
SHAREOPTIONS( 2 3)
-
•
IMBED)
-
DATA
•
-
( NAME(MTRG.CUSTOMER.MASTER.DATA)
-
CYLINDERS(50 5)
•
CISZ(4096) )
•
-
INDEX ( NAME(MTRG.CUSTOMER.MASTER.INDEX))
•
•
•
•
•
Example #2 Define an entry-sequenced data set (ESDS) DEFINE CLUSTER (NAME (MTRG.CUSTOMER.MASTER)
-
•
OWNER (MTRG)
•
NONINDEXED
•
RECORDSIZE (180 80)
-
VOLUMES (SMS007) REUSE)
-
•
-
DATA
•
•
•
-
CYLINDERS (50 5) )
•
•
( NAME (MTRG.CUSTOMER.MASTER.DATA)
Example #3 Define an relative-record data set (RRDS) DEFINE CLUSTER (NAME (MTRG.CUSTOMER.MASTER)
-
•
OWNER (MTRG)
-
•
NUMBERED
-
iFrames Technologies
28
Mainframe
VSAM
•
•
RECORDSIZE (180 80)
-
VOLUMES (SMS007) UNIQUE)
-
DATA
•
(NAME (MTRG.CUSTOMER.MASTER.DATA)
-
CYLINDERS (50 5) )
•
•
•
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
CREATION OF VSAM DATA SETS THROUGH JCL
•
•
// DD statement………… with new parameters and/or info from ‘DATA CLASS’
•
•
A Data Class is a description of data set characteristics under control of SMS. JCL parameter overrides the specifications from a Data Class. VSAM accomplishes JCL simplification by centralizing functions such as defining,
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 level
Specifies the name of the VSAM dataset. Normally, the high qualifier of the name identifies the owning catalog.
DUMMY should
Specifies that a VSAM file should not be allocated; instead, MVS 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 nonVSAM 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 required.
Specifies that the data set is a VSAM file. Normally not
BUFND component.
Specifies the number of buffers to allocate for the data
BUFNI component.
Specifies the number of buffers to allocate for the index
BUFSP data
Specifies the total amount of space in bytes to allocate for the 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 process
Specifies the format in which the ISAM program expects to records.
STRNO issue
Specifies the number of concurrent requests the program may 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
•
•
•
RECORG
=
•
•
ES KS RR LS
KEYOFF = offset-to-key
iFrames Technologies
31
Mainframe
VSAM
(for KSDS Only)
•
•
•
KEYLEN =Bytes (for KSDS and some non-VSAM data sets)
•
•
•
RECORG parameter o
KS
specifies a VSAM key-sequenced data set
o
ES
specifies a VSAM entry-sequenced data set
o
RR
specifies a VSAM relative record data set.
o
LS
specify a VSAM linear space data set.
o
KSDS
o
(EX1)
o
KSDS //DD1 DD DSNAME = MY.KSDATA, o // DISP=(NEW,CATLG), // SPACE=(400,(50,5)), o // AVGREC=K, o // RECORG =KS o // KEYLEN= 15, // KEYOFF=0, o // LRECL=250 o
o
o
o
o
o
o
ESDS
(EX2)
// DD2 DD DSNAME=MY.ESDATA // DISP=(NEW,CATLG), // SPACE=(100,(10,8)), // RECORG =ES // LRECL=50
o
o
o
RRDS
(EX3)
o
LINEAR //DD3 DD DSNAME=&LIN, o // DISP=(NEW,PASS), // SPACE=(1,(10)), o // AVGREC=M, o // RECORG=LS o
o
o
•
Not all VSAM options can be specified in the JCL, more options and defaults may come from a Data class.
EX1 shows a JCL statement containing all required information for a KSDS data set.
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,
•
//
•
//STEP1
•
//SYSOUT
•
//SYSPRINT DD SYSOUT=*
•
//SYSIN
MSGLEVEL=(1,1),CLASS=A,NOTIFY=&SYSUID EXEC PGM=IDCAMS DD SYSOUT=* 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 nonVSAM data sets. Example:
•
//IFMAIN2 JOB
•
//STEP1
•
//SYSPRINT DD
•
//SYSOUT DD SYSOUT=*
•
//DD1 DD DSN=IFMAIN2.EMP1.PS,DISP=SHR
•
//DD2 DD DSN=IFMAIN2.ESDS.CLUSTER,DISP=SHR
•
//SYSIN DD *
EXEC PGM=IDCAMS
REPRO
•
NOTIFY=&SYSUID
SYSOUT=*
INDATASET(IFMAIN2.EMP1.PS) OUTDATASET(IFMAIN2.ESDS.CLUSTER)
•
•
/*
•
//
•
•
•
CREATION OF KSDS CLUSTER WITH REUSE OPTION. REUSE specifies that the cluster can be loaded with fresh records with an implicit delete of existing records. The REUSE parameter can be specified on both the DEFINE CLUSTER and the REPRO command.
•
•
• • • • • • • •
Example: //ifmain2 job notify=&sysuid //STEP1 EXEC PGM=IDCAMS //SYSPRINT DD SYSOUT=* //SYSOUT DD SYSOUT=* //SYSIN DD * DEFINE CLUSTER(NAME(IFMAIN2.KSDS.CLUSTER)TRACKS(2,5)RECORDSIZE(80,80)-
iFrames Technologies
Here the KSDS cluster 34 is created with REUSE option
Mainframe
VSAM
CONTROLINTERVALSIZE(512)FREESPACE(20,20)KEYS(4,0)REUSEINDEXED))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
iFrames Technologies
FROMKEY (rec-key)
TOKEY (rec-key)
Here thEMP1.PS is entirely copied to ESDS.CLUSTER
35
Mainframe
VSAM
•
•
KSDS, ESDS
FROMADDRESS(rba)
TOADDRESS(rba)
FROMNUMBER (rrn)
TONUMBER (rrn)
•
•
RRDS
•
•
KSDS, ESDS
•
RRDS, ISAM
SKIP(number)
COUNT(number)
•
•
The Following The Selection Of Records In Different VSAM Files.
•
ESDS CLUSTER
•
//IFMAIN2 JOB NOTIFY=&SYSUID
•
//STEP1 EXEC PGM=IDCAMS
•
//SYSPRINT DD SYSOUT=*
•
//SYSOUT DD SYSOUT=*
•
//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
•
//STEP1 EXEC PGM=IDCAMS
•
//SYSPRINT DD SYSOUT=*
•
//SYSOUT DD SYSOUT=*
•
//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
•
//STEP1 EXEC PGM=IDCAMS
•
//SYSPRINT DD SYSOUT=*
•
//SYSOUT DD SYSOUT=*
•
//INPUT DD DSN=IFMAIN2.RRDS.CLUSTER,DISP=SHR
•
//SYSIN DD * PRINT-
•
•
INFILE(INPUT)-
•
CHAR-
•
FROMNUMBERED(1000)TONUMBERED(1004)
•
/*
•
//
•
REVIEW QUESTIONS:
•
•
1. Which of the following repro selection parameters can be specified for an LDS?
•
a)
From key
b)
from address
•
c)
From number
d)
skip
e)
none of the above.
•
•
2. REPRO will stop processing records when a total of four physical I/O errors occur while writing to the output data set.
A. TRUE B. FALSE C. D. 3. REPRO REUSE against a non-empty target data set with NOREUSE will reset target data set. A. TRUE B. FALSE C. D. 4. AMS will generate a data component name if it is not explicitly coded.
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.
iFrames Technologies
//ifmain2 job notify=&sysuid
39
Mainframe
VSAM
vv.
//step1 exec pgm=idcams
ww.
//sysprint dd sysout=*
xx.
//sysout dd sysout=*
yy.
//input dd dsn=ifmain2.rrds.cluster,disp=shr
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
•
•
Catalog
Data set
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 – TIME.
RECORDS ARE EXPORTED ONE LOGICAL RECORD AT A RECORDMODE is the default for ESDS, KSDS, and RRDS.
•
CIMODE – default for
CI rather than logical record exports data. CIMOD is LDS.
•
TEMPORARY –
The data set is not deleted after export.
•
PERMANENT -
The data set is deleted after export.
•
iFrames Technologies
41
Mainframe
VSAM
•
INHIBITSOURCE –
•
NOINHIBITSOURCE - The original data can be updated.
•
INHIBITTARGET -
•
NOINHIBITTARGET - The target data set can be updated.
•
•
•
• • • •
• • • • •
•
Causes the exported item to be overwritten with zeros is deleted.
NOERASE – was created.
Override whatever was specified for the item when it
Example: //IFMAIN2 JOB NOTIFY=&SYSUID //STEP1 EXEC PGM=IDCAMS //SYSPRINT DD SYSOUT=* //SYSOUT DD SYSOUT=* //DD1 DD DSN=IFMAIN2.BACKUP.PS, // DISP=(NEW,CATLG,DELETE), // UNIT=SYSDA, // SPACE=(TRK,(2,3),RLSE), // DCB=(LRECL=80,RECFM=FB,BLKSIZE=800,DSORG=PS) //SYSIN DD * EXPORTIFMAIN2.KSDS.CLUSTEROUTFILE(DD1)
• •
• •
The copy data set becomes read-only.
ERASE when it
•
•
The original data set becomes read-only.
/* // Now the above exported file is not available in user catalog. It is permanently exported to the new PS which is created. To get back the exported cluster we want to use import option to get back it in our user catalog. This is illustrated in the following snapshots.
•
•
SYNTAX OF IMPORT
•
IMPORT-
•
{INFILE(DDNAME) | INDATASET(ENTERYNAME)} –
•
{OUTFILE(DDNAME) | UTDATASET(ENTERYNAME)} -
•
[OBJECTS((ENTERYNAME - [NEWNAME(NAME)] -
•
VOLUMES(VOLSER])[ENTRYNAME….)])] –
•
[INTOEMPTY]
•
•
•
•
NEWNAME –
Objects beginning imported can be renamed.
VOLUMES – omitted volume
Specifies the volume on which the cluster is to reside if the original volume is the receiving
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
Catalog
Data set
•
•
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 IMPORT INTOEMPTY
STEP 1 EXPORT
ORIGINAL MASTER
STEP 2 DELETE
STEP 3 DEFINE
NEW MASTER
•
•
Example:
•
//IFMAIN2 JOB NOTIFY=&SYSUID //STEP1 EXEC PGM=IDCAMS //SYSPRINT DD SYSOUT=* //SYSOUT DD SYSOUT=* //DD1 DD DSN=IFMAIN2.BACKUP.PS,
•
//SYSIN DD *
• • • •
IMPORTINFLIE(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:
iFrames Technologies
VERIFY FILE (
)
44
Mainframe
VSAM
VERIFY DATASET ()
•
•
•
•
END-OF-DATA END-OF-DATA TEST.DATA.SET
END-OF-KEYRANGE
END-OF-KEY-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
•
[ NAME/HISTORY/VOLUME/ALLOCATION/ALL}]
(generic-level-names)]
•
iFrames Technologies
45
Mainframe
•
•
•
•
•
•
•
•
•
VSAM
Catalog(name[/password]) password of entries are to be listed.
Specifies
the
name and the catalog
if, required, from which
ENTRIES(entry-name[/password]) Specifies the names of the entries you want to list. If omitted, all entries in the specified catalog are listed. LEVEL(level) qualifications. Any matches those levels are
Specifies
one or more levels of data sets whose name listed.
Entry –type Specifies the type of entries you want listed. If both ENTRIES / LEVEL and entry-type are omitted, all entries of all types in the specified catalog are listed. Code one of these values: ALIAS, CLUSTER, DATA, INDEX, & PATH NAME the Name is the
Specifies that only the names and types of specified entries are to be listed. default.
HISTORY NAME, (such as creation and to be listed.
Specifies that the information listed by Plus the history information expiration dates) is
VOLUME HISTORY, the specified entries,
Specifies that the information listed by plus the volume locations of is to be listed.
ALLOCATION VOLUME, information, is to be listed.
Specifies that the information listed by plus detailed extent
ALL information for listed.
Specifies
that all available catalog the specified entries is to be
•
•
•
•
•
•
Examples To list the catalog MTRG.CUSTOMER.MASTER
ENTRIES (MTRG.CUSTOMER.MASTER
•
MTRG.ITEM.TRANS)
•
a
VSAM
file
named
To list information for more than one file, just code several file names in a single ENTRIES parameter, like this: MTRG.SUPPLIER.MASTER
•
for
ENTRIES (MTRG.CUSTOMER.MASTER)
•
•
entry
-
We can specify a generic entry name by replacing one or more levels of the file name with an asterisk. ENTRIES (MTRG.*.MASTER) All files whose names consists of three levels with MTRG as the first level and MASTER as the third level, are listed. MTRG.CUSTOMER.MASTER AND MTRG.SUPPLIER.MASTER meet these criteria, so they would be listed.
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 EXAMPLE.KSDS SHAREOPTIONS(1 3)
CATALOG ALTER EXAMPLE.KSDS SHAREOPTIONS(2 3)
EXAMPLE.KSDS SHAREOPTIONS(2 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 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)
• • • •
for
/* //
•
•
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
•
//STEP1
EXEC PGM=IDCAMS
•
//SYSPRINT
DD
SYSOUT=*
•
//SYSIN
DD
*
•
ALTER
-
USER1.KSDS.DATA
•
•
,,NOTIFY=userid
-
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
DELETE command is used to remove entries from a VSAM catalog. To delete more than one file, list the names in parentheses. The IDCAMS DELETE command can be used to delete both VSAM and non-VSAM objects SYNTAX: DELETE entry name/password
•
•
•
Example 1 We can specify a generic name in a DELETE command by replacing ONE level of the entry name with an asterisk, like this DELETE MTRG.CUSTOMER.*
•
•
Example 2
•
To delete MTRG.CUSTOMER.MASTER, whether or not it is expired.
•
DELETE MTRG.CUSTOMER.MASTER –
•
PURGE
•
Example 3
•
To delete the 3 named files.
•
DELETE ( MTRG.CUSTOMER.MASTER
-
•
MTRG.CUSTMAST.AIX
-
•
MTRG.CUSTMAST.PATH)
•
• • • •
•
Example: //IFMAIN2 JOB NOTIFY=&SYSUID //STEP1 EXEC PGM=IDCAMS //SYSPRINT DD SYSOUT=* //SYSOUT DD SYSOUT=* //SYSIN DD * DELETE IFMAIN2.KSDS.CLUSTER
• • • •
/* // Some other options for Delete are:
•
ALIAS
•
ALTERNATEIND
•
CLUSTER
•
SPACE
•
PURGE
•
PATH
•
REVIEW QUESTIONS:
•
1. The default print format is: a. character b. dump c. hexadecimal d. none of the above. e.
A.
2. Which of the following repro selection parameters can be specified for an LDS?
from key
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 c. RRDS records to be replaced by an input record with the same RRN d. a) and c) e. all of the above f.
A.
TRUE
B.
FALSE
4. Generic keys can be specified in PRINT FROM KEY and TOKEY
C. 5. REPRO will stop processing records when a total of four physical I/O errors occur while writing to the output data set. A.
TRUE
B.
FALSE C. 6. Which of the following is not a valid command? a. IF b. THEN c. ELSE d. DO e. GOTO f.
A.
TRUE
B.
FALSE
7. REPRO REUSE against a non-empty target data set with NOREUSE will reset the target data set.
C. 8. Can VSAM files be deleted with the DELETE option of the DISPOSITION parameter of JCL? D. 9. During processing of a VSAM file, some system error occurs and it is subsequently unusable What do you do? E. F. G. CHAPTER --- 7 : Alternate Indexes H.
iFrames Technologies
An alternate index is used to an access the records of a VSAM key-sequenced data set in an order other than the file’s primary key (or base key). The data set over which an alternate index exists is called a base cluster. Even we can use an entry-sequenced data set as the base cluster for an alternate index, most alternate indexes are built over KSDS clusters. Used whenever the data is required to be retrieved
51
Mainframe
VSAM
on the basis of other field (than primary key field). alternate index cannot be defined for RRDS or LDS
An
I. J.
ALTERNATE INDEX 1 (DEPT NO)
ALTERNATE INDEX 2 (SOCIAL SEC NO)
BASE CLUSTER (NAME)
3235 NEWTON $… 3240 WRIGHT $.. 3247 ADAMS $.. 3247 PETTY $ …
015-35-7890 WRI 183-96-416 ADA 234-04-2372 PET
ADAMS 3247 $… ARNOLD 4711 $… KINNEY 3247 $…… NEWTON 3235 $..
K. MULTIPLE ALTERNATE INDEXES (AIXs) may be defined over a base cluster. L.
If the user is sequentially retrieving records using AIX1, then department number retrieves records in logical sequence Access via AIX2 with an alternate key of social security number results in the retrieval of base cluster records in social security number sequence.
M. ADVANTAGES •
Can be defined for both KSDS & ESDS
•
Reduce data redundancy
•
Can have duplicates
•
Easy to define using IDCAMS
•
Allow datasets to be accessed sequentially or randomly
•
Can be updated automatically
•
DISADVANTAGES
•
Performance degradation
•
Complex update logic
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. 10. RECORD SIZE
11.
=5
+ ALTERNATE KEY + 12. LENGTH
13.
PRIME KEY LENGTH * NUMBER NONUNIQUE PRIME KEYS -0R4 *NUMBER NONUNI UE 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
•
AIX for a KSDS RECSZ = 5 + AIXKL + (n x BCKL)
•
AIX for ESDS RECSZ = 5 + AIXKL + (n x 4)
•
Where:
•
AIXKL is the alternate-key length
•
BCKL is the base cluster's prime-key length
•
n = 1 when UNIQUEKEY is specified
•
n = the number of data records in the base cluster that contain the same alternate-key value, when NONUNIQUEKEY is specified.
•
•
Other AIX parameter
•
ATTEMPTS
•
AUTH (entry point)
•
BUFFERSPACE (bytes)
•
CATALOG (catalog/pw)
•
CODE (code)
•
CISZ (bytes)
•
CONTROLPW (password)
•
ERASE (NOERASE)
•
EXCEPTIONEXIT (entry point)
•
KEYRANGES (low-key high key)
•
MASTERPW (password)
•
ORDERED/UNORDERED
•
READPW (password)
•
REPLICATE/NOREPLICATE
•
REUSE/NOREUSE
•
SHAREP[TOPMS
•
SPEED/RECOVERY
•
UNIQUEKEY/NONUNIQUEKEY
•
UPDATEPW (password)
•
WRITECHECK/NOWRITECHECK
•
EXAMPLE:
•
//STEP1
•
//SYSPRINT DD
•
//SYSIN
•
EXEC DD
PGM =IDCAMS SYSOUT = * *
DEFINE ALTERNATEINDEX(USER1.KSDS.AIX)-
•
VOLUME(V001)
•
RELATE(USER1.KSDS.CLUSTER)-
•
UPGRADE-
•
CYLINDERS(2 1)-
•
KEYS(25
iFrames Technologies
-
9)-
56
Mainframe
VSAM
•
RECORDSIZE(70 110)-
•
FREESPACE(20 10)-
•
NONUNIQUEKEYDATA
•
(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 /
•
[WORKFILES(ddname
•
INFILE /INDATASET IDENTIFIES THE BASE CLUSTER.
•
OUTFILE / OUTDATASET IDENTIFIES THE AIX TO BE LOADED
INTERNALSORT]
-
-
ddname) ]
•
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:
•
•
iFrames Technologies
DEFINE
PATH(NAME(PATH NAME) PATHENTRY(AIX NAME)
-
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
•
-
•
- Path is a VSAM object though it doesn’t contain any records
•
- Same command for KSDS & ESDS
•
•
-
(XIND.NLT.VSAM.DEPT.AIX) UPDATE)
•
•
-
- 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.
•
Base Cluster Must Not Be Empty For Buildindex.
•
Length Of The Alternate Index Not Exceed 255
•
Maximum Number Of Alternate Key Pointers Is 32k.
•
Records Larger Than 32760 Not Supported By R epro/Export.
•
For A Base Cluster With Alternate Index(Es) And Path(S),Delete Cluster Deletes Not Only The Base Cluster But Also The Associated Alternate Index
•
Maximum Alternate Indexes Can Be 253 For A Single Dataset(ESDS&KSDS)
•
•
•
•
•
•
•
•
•
•
•
•
•
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