Anda di halaman 1dari 35

Mainframe Application Programming

VSAM DAY 2

Course schedule
UNIT VSAM Continued..
Topics:  Control Area  Access Method Services  RRDS fixed and Variable length record  KSDS

What is a control area?


The control intervals for a data set are grouped into one or more control areas. The number of control intervals in a control area is fixed by VSAM. Maximum size of CA is 1 cylinder. Minimum size of CA is 1 Track.

What is Control Area?


Collection of control intervals Minimum size of CA is 1 Track Maximum size of CA is 1 Cylinder
05

Control Area with Control Intervals

08

09

10

12

14

15

20

21

22

24

25

29

30

35

36

CONTROL AREA (CA)


CIs are grouped into CA Can have more than one CA in a VSAM data set CA is VSAMs internal unit for allocating space Smallest is a TRACK, and the largest is a CYLINDER VSAM determines CA size & number of CIs in CA based on CI size specified Record size

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

Index &Sequence Set


Index Key Ptr Key Index Component Sequence Set 1
Key Ptr Key Ptr Key Ptr

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

Before control interval split


Sequence Set ...
I 0 Record C M 100

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

After control interval split


Sequence Set ...
E 0 I 200 M 100

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

Holds control interval either before or after processing Two types


 

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

Control interval splits:


In a KSDS records are stored in key sequence when the record is added it is inserted in correct sequential location in proper control interval and the records followed will be shifted to next control intervals

Control area split:


If no free CIs found in CA it will go for the split of CA. First it will go for CI split and then for CA split

Access Method Services


What is Access Method Services? VSAM uses certain utility programs for managing and maintaining data sets. Access Method Services (AMS) is a utility that defines VSAM data sets and allocates space for them. It also converts indexed sequential data sets to KSDS with indexes. AMS can also be used to perform some functions for non-VSAM data sets.

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

Defining a VSAM Data Set with IDCAMS


What is defining a data set?
The process of creating catalog entries for a VSAM data set and allocating space for them is called defining the 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

Secondary Extends - 122

Jcl for RRDS


//SAMP003B JOB ,,CLASS=M, // MSGLEVEL=(1,1),NOTIFY=SAMP003,TIME=(1) //EXEC1 EXEC PGM=IDCAMS //SYSPRINT DD SYSOUT=* //SYSIN DD * DEFINE CLUSTER ( NAME(SAMP003.RRDS.CLUSTER) TRACKS(2,1) CISZ(512) RECORDSIZE(80,80) NUMBERED ) DATA(NAME(SAMP003.RRDS.DATA)) /* //

Control Interval Format for a FixedLength RRDS


Each RDF in a fixedlength RRDS contains The length of the slot A flag indicating whether that slot is full or empty
Control Interval Format: RRDS Free Space 2 5 0 E 2 5 0 F 2 5 0 F 2 5 0 E 1 0 8 8 0 Relative Record Data Set (RRDS) Control Interval Format: KSDS and ESDS 2 5 0 1 0 8 0

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

Control Interval Format for a VariableLength RRDS


A Control Interval for a Variable-Length RRDS
RDF RDF RDF RDF 4 3 2 3 CIDF

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

2048 byte control interval

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.

Control Interval Format for a VariableLength RRDS


A Variable-Length RRDS Control Interval Where Some RRNS Are Not in Use
RDF1 RRN 3 RRN 7 RRN 10 Free Space RDF3 RDF5 CIDF

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)

Record Retrieval Record Updating Record Deletion

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 ) /* //

LOADING VSAM DATA SETS


The repro command reads records from input from input data set and copies them to output data set. The following must be specified in the command Syntax. Repro infile(ddname of inputFile) outfile(ddname of outputfile) or Repro indataset(inputdatasetname) outdataset(outputdatasetname)

Anda mungkin juga menyukai