VSAM DAY 2
Course schedule
UNIT VSAM Continued..
Topics: Control Area Access Method Services RRDS fixed and Variable length record KSDS
08
09
10
12
14
15
20
21
22
24
25
29
30
35
36
Index
Separate entity Organized similar to Data component (CI & CA) Has different CI size VSAM builds Index when data is loaded Index is organised as Inverted Binary Tree VSAM compresses keys to conserve space Can have several Levels of Indexes
Index (Contd..)
Lowest level of index is called Sequence set One sequence set for one Control Area Are always in the key order whereas data CI need not be in key order Each entry has the highest key(or one less than the 1st key of the next CI so that the sequence set need not be updated when higher key added to the CI) in the CI and points to the RBA of the CI (Vertical Pointer)
Index (Contd..)
Next level is called index set
Contains Primary keys and pointers to the sequence set More than one level of Index set based on number of Sequence set records Top level index always one record
Ptr
...
Set
Sequence Set 2
Key Ptr Key Ptr Key Ptr
...
Sequence Set
Data Component
CI 1 CI 2 CI 3 Control Area 1
CI 4 CI 5 CI 6 Control Area 2
...
Control Areas
CI & CA Split
CI split happens while Adding new records or extending an old record And not enough room in the CI to complete the operation
CI split may trigger a CA split Splits generally degrades performance Specify freespace to reduce CI & CA splits
0 Data
Record A Record B Record F Record G U CF S
Component
100
Record J Record K FSPC U S CF
200
FSPC U CF S
0 Data Component
Record A Record B Record C FSPC U S CF
100
Record J Record K FSPC U CF S
200 Record F
Record G
FSPC
U CF S
VSAM BUFFERS
DATA BUFFERS CI CI DASD CI INDEX BUFFER
VIRTUAL STORAGE
Index Data
CI SIZE
VSAM can select an efficient size if you ignore Large CI size for Batch Sequential Processing Small CI size for random processing
What is Integrate Data Catalog Access Method Services? Integrated Data Catalog Access Method Services (IDCAMS) is the program name for VSAMs AMS utility. IDCAMS is easy to use and multipurpose in nature. IDCAMS performs the following functions:
It defines a data set It loads a data set It changes certain attributes of a data set
It copies or backs up a data set It lists data set attributes and statistical information It prints the contents of a It deletes a data set data set
A data set must be defined before it is loaded with data or accessed by a processing program.
The following items must be addressed when the data set is to defined. The name of the data set : Define dataset The name of the volume on which it will be allocated Volumes(Volume-no) The amount of space that is to be allocated Tracks(3,3),Cylinders(1,1) The size of the control interval ControlIntervalSize(number-of-bytes) The amount of free space within CI and the amount of utilization of each CI Freespace(percent1,percent2) The size of the key Keys(n1,n2) , n1 = length of the key , n2=offset of the key The Size of the record Recordsize(n1,n2) n1 Average Record Length n2 - Maximum Record Length
Initial Loading
Once a data set has been defined, it needs to be loaded with data. The IDCAMS REPRO function is used for initial loading of a data set. The REPRO function can be used to: Load data from input file to output file. Input file and output file must be KSDS,ESDS,RRDS,Physical sequential or member of the partitioned data set.
Other IDCAMS functions IDCAMS can be used to perform a variety of data set management functions. Listed below are some of the commonly used IDCAMS functions
PRINT ALTER LISTCAT DELETE Prints a VSAM data set Changes certain attributes of a VSAM data set Lists data set attribute and statistical information Deletes a data set
ESDS
In an ESDS records are stored in the order in which they are written and can be read in the same order. The characteristics of ESDS are summarized below:
Records are stored sequentially. Records can be of fixed or variable length. Records are physically grouped into control intervals. Control intervals contain control information along with data
RRDS
Relative Record Data Set ,records are in relative to the record number. Defining is simliar to ESDS. RRDS also has data component. Key fields are not coded. Free space is not coded. Keyword parameter numbered is coded to indicated that the data set is RRDS. RRDS contains fixed length records only coded in RECORD SIZE parameter. The space requirements of a data set are specified in terms of a primary allocation and a secondary allocation. Total extents Primary extents 123 1
R1
R2
RDFs
Variable-Length RRDS
A variable-length RRDS contains records that vary in size. Like a fixed-length RRDS, each record of a variablelength RRDS has a unique Relative Record Number (RRN). Each record is stored and retrieved using this number. Unlike a fixed-length RRDS, a variable-length RRDS does not have slots.
332 Variable-Length Relative Record Data Set
380
380
380
Continued
RRN 1
RRN 2
RRN 3
RRN 4
RRN 5
Free Space
3 3 2
3 8 0
3 3 2
1 8 0 4
2 2 8
The control interval format of the variable-length RRDS is similar to that of a KSDS with free space. The number of RDFs in a variable-length RRDS depends on the number of contiguous records of the same length. If a record differs in size from its adjacent records Continued then it will have its own RDF.
In a variable-length RRDS, no space is reserved for RRNs that are not in use. This is an advantage over Fixed-length RRDS. However the performance of a variable-length RRDS is not as good as that of a fixed-length RRDS. IDCAMS must be used to define a variable-length RRDS.
Deleting Records
When a record is deleted, VSAM does not fill the position with binary zeros as is the case with a fixed-length RRDS.
Records in a variable-length RRDS are physically erased and the space occupied by the record is made available as free space.
Concepts
Updating Records
In a variable-length RRDS, the length of a record can be changed during an update operation. When updating records, if the size of a record is reduced, VSAM reclaims the space as free space. If the size of a record is increased, VSAM provides the needed space by making use of available free space within the control interval. If free space is not available, VSAM will perform a control interval or a control area split.
Concepts
Type of Access Sequential Fixed Initial Data Set Loading Record Addition Yes Yes (empty slot) Yes Yes (no length change) Yes (slot can be reused) Variable Yes Yes (free space) Yes Yes Yes (space is reclaimed) Random/Skip-Sequential Fixed Yes Yes (empty slot) Yes Yes Yes (slot can be reused) Variable No Yes (free space) Yes Yes Yes (space is reclaimed)
KSDS
Key Sequential Data Set Each record in file is embedded with a unique key. Random and sequential access is possible.
Key Sequential DataSet ,records are identified by unique key field. Defining is simliar to ESDS,RRDS. KSDS also has data component and index Component. Key fields are coded. Free space is coded. Keyword parameter indexed is coded to indicated that the data set is KSDS. RRDS contains fixed length records only coded in RECORD SIZE parameter. The space requirements of a data set are specified in terms of a primary allocation and a secondary allocation. Total extents 123 Primary extents 1 Secondary Extends - 122
KSDS JCL
//SAMP003B JOB ,,CLASS=M, // MSGLEVEL=(1,1),NOTIFY=SAMP003,TIME=(1) //EXEC1 EXEC PGM=IDCAMS //SYSPRINT DD SYSOUT=* //SYSIN DD * DEFINE CLUSTER ( NAME(SAMP003.KSDS.CLUSTER) TRACKS(2,1) CISZ(512) RECORDSIZE(80,80) Keys(4,0) FreeSpace(10,10) Indexed ) /* //