Showing posts with label VSAM. Show all posts
Showing posts with label VSAM. Show all posts

Thursday, 3 January 2019

VSAM Intro

VSAM - Virtual Storage Access Method

A VSAM cluster is a logical definition for a VSAM data set and has one or two components. viz.,
Index component - Contains pointers to all data records to access them
Data component - Contains actual records


VSAM commands:

All the following operations (including CREATE and DELETE) should be done through IDCAMS utility.

ALTER - To modify the attributes of VSAM file.
REPRO - To load the data into VSAM data set (from sequential file to VSAM file), to copy the data from one VSAM file to another VSAM file.
LISTCAT - To get the catalog information of a VSAM dataset like dataset attributes, allocation information, volume information...  
EXAMINE - Checks the structural integrity of a given KSDS cluster. It checks index and data components and reports if there are any issues.
VERIFY - Checks and fix VSAM files which are not closed properly after an error

An Alternate Index provides access to records using more than one key. The key of an alternate Index can be a unique/non-unique key. We define alternate index for a given VSAM cluster.

Wednesday, 19 August 2015

Control Interval (CI) and Control Area (CA)

Control Interval (CI)
  • The unit of data transmission between virtual and auxiliary storage (DASD) for each physical i/o operation is defined as Control Interval. It contains data, control information and free space ( which later may be used to insert records).
  • Control information in each CI contains 1) RDF (Record Definition Field) which is 3 bytes long contains the length of the records and how many records are of same length 2) CIDF (Control Information Definition Field) which is of 4 bytes long contains information about CI.
  • When a VSAM gets loaded, control intervals are created and records are written into them.
  • In KSDS, each control interval will have some space to insert the records later.
  • In ESDS, each control interval is completely filled with records and once it is full then we start writing records in another CI
  • In RRDS, control intervals are filled with fixed length slots containing either active record or dummy record. Slots containing dummy records are used to fill the new records.
  • The default CI size is 4K and can be extended up to 32k.
Control Area (CA)
  • A group of control intervals is called a control area.
  • For ESDS and RRDS, control areas are filled with control intervals that contains records.
  • For KSDS, control areas may contain CIs with complete free space which may later be used to fill records.
  • A CA contains two or more CIs and a VSAM dataset consists of one or more CAs



VSAM file types

KSDS (Key Sequential DataSet)
  • The data records are identified based on the key value.
  • The data in the KSDS is divided into two components viz., Index component and data component. Index component contains the unique key value and its corresponding memory location.Data component contains the memory address and actual data.
  • Index component contains pointers to all the data records and Data component contains actual data records which were arranged in logical order based on key fields. 
  • If we want to search for a particular record, we will give the unique key value. Then the corresponding address location for that key will be retrieved. This location will be used to get the data record.
Notes from IBM manual on KSDS:

To find the physical location of a record in a KSDS, VSAM creates and maintains an index. This relates the key of each record to the record's relative location in the data set. When you add or delete records, this index is updated accordingly.

ESDS (Entry Sequential DataSet)
  • The data records are stored in the order they are entered into the dataset. New records will be added after the last record.
  • The data records are identified by relative byte address (RBA). For eg., If the file has 100 byte records, the RBA for the first record is 0, the RBA for the second record is 100, the RBA for the third record is 200 and so on.
  • The records can be accessed either sequentially or directly by providing RBA value of the corresponding record.
  • The records in ESDS are either fixed length or variable length. 
  • It contains only data component, no index component.
RRDS (Relative Record DataSet)
  • The records are identified by RRN (Relative Record Number ).
  • RRN is a sequence number relative to the first record.
  • All the records must be of fixed length. The records can be accessed sequentially in the order by RRNs, or directly by providing the RRN.
  • The records are filled in each block until we cannot fit the another record. The space in each block will be left unused.
LDS (Linear DataSet)
  • This is a byte-stream data set and is the only form of byte stream data set in traditional OS files.
  • A linear data set (LDS) contains data that can be accessed as byte-addressable strings in virtual storage.
  • It will have only data component like ESDS and RRDS. This does not have RDFs and CIDFs but have a control interval with size of 4K bytes.