VSAM also known as IBM (Virtual Storage Access Method), it is among the most commonly used Access Methods in the MVS, ZOS, and OS/390 operating systems. Virtual Storage Access Method designed to enhance features, easy to use, and overcome issues pertaining to performance and device dependence.
Preparing for an interview means knowing several topics. So, if you do not know what VSAM is, let’s briefly introduce the topic before we jump to the VSAM interview questions.
What is VSAM?
VSAM (Virtual Storage Access Method) is a file storage access method developed by International Business Machines (IBM). It is used to organize data in files in Mainframes. To be more specific, data is stored using control information keys. The system can then find an item without searching all the previous items in a data set. This access method is popular for randomly ordered, frequently used data items. It is used in MVS, ZOS, and OS/390 operating systems.
Now that we know what VSAM is, let’s move on to the questions.
VSAM Interview Questions for Freshers
1. What is a dataset in VSAM?
Ans: A VSAM dataset is a record that contains files specific to an interface.
2. What are the different types of VSAM datasets?
Ans: VSAM datasets are of three types:
(i) Entry Sequence Data Set (ESDS), accessed through relative byte addresses. (ii) Key Sequence Data Set (KSDS), accessed through secondary indices. (iii) Relative Record Data Set (RRDS), accessed through relative record numbers.
3. What are the main components of VSAM?
Ans: The main components of VSAM are: (i) VSAM clusters - They are the part whose access an OS gives to the program. They contain all parts of a dataset: index, sequence sets, and data portions. (ii) Control Interval - It is a unit of information transferred between the virtual and auxiliary storage. (iii) Control Area - It is a group of control intervals.
4. What type of objects do VSAM files contain?
Ans: Every VSAM file contains two things that define its storage structure. These objects are:
(i) File Object - It is a single file. It has file methods like Read, Delete, Write, Rewrite and Unlock.
(ii) File Browse Object - Objects performing browse operations using IDCAMS (Integrated Data Cluster Access Method Services) or TSO (Time Sharing Options) prompts.
5. How are records in ESDS stored?
Ans: Records are stored in the order in which they are included in a file in ESDS.
6. What output is obtained on opening an empty VSAM file in COBOL (Common Business Oriented Language)?
Ans: A file with no records is unavailable to the user in COBOL. But on being opened for output, COBOL writes a dummy record in it. This dummy record is later deleted after the user has opened it.
7. What is freespace?
Ans: Freespace defines the percentage of available storage reserved for the dataset’s control intervals and control areas. Its default value is 0%.
Syntax: FREESPACE (CI-percent, CA-percent)
8. What is an alternate index(AIX)?
Ans: An alternate index is a file that allows a VSAM dataset to be accessed by a key other than its primary key.
9. What is a path?
Ans: A path is a file that provides an association between the AIX and the base cluster.
10. What is a base cluster?
Ans: A base cluster is a file that contains the data and the primary index of a KSDS.
11. Do primary and alternate keys have to be unique?
Ans: Primary keys must be unique, since a cluster is exclusively access by its primary key. On the other hand, alternate keys do not necessarily have to be unique. In case of duplicate alternate keys, multiple records can be accessed with a single key.
12. What are the three levels in the definition of VSAM DEFINE?
Ans: The three levels in the definition are:
(i) DEFINE CLUSTER - used to create a cluster (similar to initializing a variable)
(ii) DATA - the data stored
(iii) INDEX - used to access the cluster
VSAM Interview Questions for Experienced
13. How do you calculate an alternate cluster’s record size for unique and non-unique cases?
Ans: For unique case: 5 + (alt-key-length + primary-key)
For non-unique case: 5 +(alt-key-length + N * primary key), where ‘N’ is the number of duplicate records of the alternate key
14. How are different versions of Generation Data Group (GDG) named?
Ans: Different versions of GDG are named following the given syntax:
base-file-name.GnnnnVmm
Where ‘nnnn’ is the generation number in the range of 0000-9999, and ‘mm’ is the version number in the range 00-99.
15. Which kind of datasets allows the usage of ALT INDEX in VSAM?
Ans: ALT INDEX is used to access a cluster with a key other than its primary key. Only KSDS and ESDS datasets allow the use of ALT INDEX, while RRDS does not.
16. Name some VSAM commands and give their use and syntax.
Ans: Some VSAM commands, along with their syntax, are:
Alter - It is used to modify the file attributes. Syntax: ALTER file-cluster-name [password]
Repro - It loads and copies data from one VSAM to another. Syntax: REPRO INFILE (in-ddname) OUTFILE (out-ddname)
Listcat - It is used to fetch the catalog details of datasets. Syntax: LISTCAT ENTRY (vsam-file-name) ALL
Examine - It checks the structural integrity of KSDS clusters. Syntax: EXAMINE NAME (vsam-ksds-name)
Verify - It is used to verify VSAM files that may not have been closed properly. Syntax: VERIFY DS (vsam-file-name)
17. What are the differences between Control Interval and Control Area?
Ans: The differences between Control Interval and Control Area are:
Control Interval (CI)
Control Area (CA)
The unit of representation is 1/0.
The unit of cylinders is used to represent CA.
The unit ranges from 512 to 32 KB.
The maximum size of a record is one cylinder.
It gives the smallest unit for datasets.
It is a group of control intervals.
It offers better results with sequential processing.
Its performance is dependent on the reserved space when a dataset is created.
18. What are the differences between CI split and CA split?
Ans: The differences between CI split and CA split are:
CI Split
CA Split
It occurs when a particular control interval is full while the control area may still have free space.
It occurs when all the control intervals in a control area are full.
Half of the records in a control interval are moved to another vacant one in the same control area.
Half of the control intervals in a control area are moved to a separate control area with available memory.
19. What are the differences between VSAM and non-VSAM files?
Ans: The differences between VSAM and non-VSAM files are:
VSAM Files
Non-VSAM Files
Only Access Method Service (AMS) programs are used to create them.
We can use both Job Control Language (JCL) and Interactive System Productivity Facility (ISPF) programs to create them.
Datasets are of three types - key sequenced, entry sequenced, and relative record sequence.
Datasets are sequenced, indexed sequential direct, and partitioned.
20. What is AMS?
Ans: AMS stands for Access Method Service. It is used in several functions in VSAM and non-VSAM datasets and catalogues. It contains a vital utility program called IDCAMS that is invoked by JCL and carries out AMS functions through commands. These commands are of two types:
(i) Functional commands - Commands defining real actions like DEFINE CLUSTER, REPRO, DELETE, etc.
(ii) Modal commands - Commands specifying conditional statements like if-then-else.
21. What is the use of JCL?
Ans: JCL stands for Job Control Language. It is used to describe the units of work to mainframe operating systems. This is done since the OS allocates its time and space resources depending on the number of jobs the computer has started.
22. Name a few VSAM File status codes.
Ans: Some of the VSAM File status codes are: (i) 00: Operation was successful (ii) 04: Fixed length record was invalid (iii) 20: Invalid key for KSDS or RRDS (iv) 22: Duplicate primary key found (v) 23: Error locating the record or file (vi) 30: Permanent I/O fault (vii) 38: Locked file is being opened (viii) 91: Invalid authorization (ix) 93: Resources unavailable (x) 95: Invalid or incomplete file information (xi) 98: Failed to open file (xii) 99: Failed to access record
23. How are the optimum values for CI and freespace chosen?
Ans: The optimum value for CI size is chosen by using the record’s length and the processing type. Commonly it is 4K, but it may be 6K or 8K for records longer than 1K. While choosing the freespace, for a high number of insertions, it is kept large. For heavy updates, it is set to (20-20).
24. How can you fix the issue of VSAM running out of space?
Ans: The problem is fixed as follows: (i) Create a new VSAM with the extra space allocated. (ii) Copy the old VSAM files to this new one. (iii) Alter, rename, or delete the old VSAM. (iv) Rename the new dataset with the original one’s name.
25. What is the syntax to define a KSDS?
Ans: The syntax to define a KSDS is:
DEFINE CLUSTER (NAME(ksds-file-name)
VOLUMES(volume-serial)
INDEXED
RECORDSIZE (average maximum)
[FREESPACE(CI-Percentage,CA-Percentage)]
KEYS(length, offset)
CISZ(number)
DATA - (NAME(ksds-file-name.data))
INDEX - (NAME(ksds-file-name.index))
26. What are the problems with the ‘VSAM out of space’ condition?
Ans: While defining a dataset in VSAM, its size is predefined. So it may happen that it runs out of space. This condition is called the VSAM out of space condition.
The problems with this condition are (i) Allocating more space while defining a new VSAM dataset (ii) Copying the old VSAM dataset to a new one using IDCAMS (iii) Altering or renaming an old dataset with IDCAMS
27. What is IDCAMS?
Ans: IDCAMS stands for Integrated Data Cluster Access Method Services. It is an AMS that is used to create, modify and delete datasets. IDCAMS program is run by giving it AMS commands like DELETE, DEFINE, REPRO, etc. Furthermore, it can handle both VSAM and non-VSAM datasets. In short, IDCAMS is an IBM utility used to manipulate datasets.
28. How do you create an alternate index?
Ans: The steps to create an alternate index are
(i) Define an alternate index - The “DEFINE ALTERNATEINDEX” command is first used to create an alternate index.
(ii) Define the path - By defining the path, the alternate index is related to the base cluster.
(iii) Build the alternate index - In this step, the alternate index is built. This is done by extracting the important information from base cluster.
Thus, the entire code to build an alternate index is:
29. What are the Upgrade and Noupgrade options in the Alternate index?
Ans: The Upgrade option specifies that if the base cluster is modified, the alternate index should be modified too. On the other hand, the Noupgrade option specifies that the alternate index should not be altered even if the base cluster is changed. A base cluster is a file that contains the data and the primary index of a KSDS.
30. Can you specify the freespace in ESDS?
Ans: No, the freespace cannot be set in ESDS. This is because we cannot insert records in an ESDS. While rewriting a record, the freespace length must be the same. Thus, there is no necessity to specify the freespace.
Conclusion
In this article, we first learned a bit about VSAM. After that, we went through a whole lot of 30 most asked VSAM interview questions. With the help of these questions you can prepare for technical interviews as well as online selection tests during campus placements and interviews. You can go through more interview questions related to VSAM, like Mainframe, COBOL, computer architecture or learn about company-specific tests like for IBM. Apart from that, you may also refer to the interview preparation blogs on topics like, Java inheritance and stack and queue.