Let's understand Mainframe
Home Tutorials Interview Q&A Quiz Mainframe Memes Contact us About us

Module 2: VSAM Concepts


KSDS -Key Sequenced Data Sets

  • As name implies, data records in KSDS are organized by a unique key field thus no two records can save same key value. This unique key are sometimes also called as primary key
  • In all logical records, the key length must be same. The key length can range from one to 255 bytes
  • Accessing a KSDS record via key field is similar to searching for topic in a book; where in the Index contains the topic heading and page number; Using this page number it is easy to find topic explanation; In KSDS organization, the topic explanation is analogous to actual Data Record, the topic heading is Key value field(unique) and page number is pointer to the location of actual record
  • KSDS records can be access randomly, having said that you know the value of its key field
  • For any existing records in KSDS dataset, the value of the key cannot be altered, however the entire record can be deleted
  • KSDS dataset can have alternate index which need not be unique
  • KSDS allows storing of fixed as well as variable length records
  • In a KSDS organization, records are kept sorted in ascending order key-field value.
  • KSDS allows deleting of records and resulting free space can be used for insertion/updation of records
  • In KSDS organization, data records can be accessed sequentially or directly.
  • KSDS allows spanned records
  • For KSDS datasets, we must code INDEXED inside the DEFINE CLUSTER command. This will be explained further in next Module
  • Like other files, KSDS can be used in COBOL. For this, we can specify name of the file in JCL and we can use it inside COBOL program for processing. To use KSDS file in COBOL program, specify file organization as INDEXED and access mode can be specified as SEQUENTIAL, RANDOM or DYNAMIC

Internal organization of KSDS

  • KSDS have two components: Data Component and Index Component.
  • Index component contains an entries with key field and pointer to the location of its corresponding record.
  • Data component contains actual data records(along with its Key field value)
  • Please refer topic ‘CLUSTER’ where in we have elaborated these two components in details along with help of example
  • KSDS Example:-
  • In above shown figure, left part shows index component and right part shows Data component. Data component contains two control areas and each control area contains 4 control intervals. Index component maintains sequence set for each control area. Thus total two sequence set exist. Sequence set contains highest Key value from each Control interval along with pointer.
  • Then comes Index set which contains highest key vale from sequence set and pointer to location of that sequence set
  • In order to access record with key ‘787’, only 3 I/O will be needed as key is known to us. First I/O to read from Index set. Here first entry of Index set is ignored as value ‘787‘ is greater than ‘397’. And next entry will meet our need thus using pointer S2, (Second I/O) sequence set S2 will be explored to find out the correct CI. And in third I/O record will be read from Control interval - C7






© copyright mainframebug.com
Privacy Policy