VSAM interview questions and answers for mainframe developers
VSAM interview questions check whether you understand how keyed and sequential files are physically stored on z/OS and how to keep them fast and recoverable. Expect cluster types (KSDS, ESDS, RRDS, LDS), control intervals and control areas, the IDCAMS parameters you choose at define time, alternate indexes, share options, buffering and the file status codes a COBOL program sees. Senior rounds turn into tuning and recovery stories: split storms, a file that will not open, a broken index.
By Evin JohnPublished 9 min read
Where VSAM questions come from
VSAM rarely gets a whole interview of its own. It shows up as a block inside a COBOL, CICS or batch support interview, and the depth depends on the team. An application team asks how your program opens and reads the file and what each status code means. A team that owns the files (often called storage, data management or the batch platform group) asks why you chose a control interval size, how splits hurt, and how you rebuild an index without losing updates. If you have only used VSAM through COBOL, say so, then show you know what sits underneath. For the rest of the stack, see the mainframe interview questions.
- Definitions round: cluster types, components, what a control interval holds, how keys are stored.
- Define and tune round: you are handed an IDCAMS DEFINE and asked what each line does, or asked to write one for a stated workload.
- Program round: OPEN modes, START and READ NEXT, WRITE versus REWRITE, and the FILE STATUS value after each.
- Support round: a job that failed opening a file, an online region that slowed down, a file that grew extents overnight.
VSAM fundamentals questions
| Question | What it tests | What a strong answer shows |
|---|---|---|
| What is a VSAM cluster? | Vocabulary | The catalog entry that ties together a data component and, for a KSDS, an index component. Programs and JCL refer to the cluster name, not the parts. |
| Name the four dataset organizations. | Types | KSDS stores records in key order with an index. ESDS keeps records in the order written and addresses them by RBA. RRDS holds records in numbered slots. LDS is a byte stream with no record structure, used by DB2 and similar software. |
| What is a control interval? | Storage unit | The unit VSAM moves between disk and memory. It holds records, free space and control fields at the end: one CIDF describing free space and RDFs describing record lengths. |
| What is a control area? | Storage unit | A group of control intervals, often a cylinder's worth. In a KSDS one index set entry at the lowest level (the sequence set) covers each CA. |
| How does a KSDS find a record by key? | Index | It walks the index set from the top level down to the sequence set record for one CA, which points to the control interval that holds the key range. One extra read usually fetches the CI. |
| What is an RBA? | Addressing | Relative byte address: the offset of a record from the start of the data component. ESDS programs use it to go back to a record; a KSDS can change a record's RBA when it splits. |
| Can you delete a record from an ESDS? | Limits | No. Records stay where they were written. Applications mark a record as logically deleted with a flag field and skip it on read. |
| What makes an LDS different? | Types | It has no records or RDFs, just 4K pages addressed by offset. DB2 table spaces and some system datasets are built on it, and applications do not read it with COBOL READ. |
| What is a variable-length RRDS? | Types | An RRDS that allows records of different lengths, still addressed by relative record number. VSAM keeps it with a hidden index, so it behaves partly like a KSDS internally. |
| Which utility defines and manages VSAM files? | Tooling | IDCAMS (Access Method Services). DEFINE CLUSTER creates it, DELETE removes it, REPRO copies data, LISTCAT reports catalog details, VERIFY fixes end-of-file information. |
Define time: the IDCAMS parameters interviewers pick apart
//DEFCUST EXEC PGM=IDCAMS
//SYSPRINT DD SYSOUT=*
//SYSIN DD *
DELETE PROD.CUST.KSDS CLUSTER PURGE
SET MAXCC = 0
DEFINE CLUSTER (NAME(PROD.CUST.KSDS) -
INDEXED -
KEYS(10 0) -
RECORDSIZE(250 400) -
FREESPACE(20 10) -
SHAREOPTIONS(2 3) -
CYLINDERS(100 20)) -
DATA (NAME(PROD.CUST.KSDS.DATA) -
CONTROLINTERVALSIZE(4096)) -
INDEX (NAME(PROD.CUST.KSDS.INDEX))
DEFINE ALTERNATEINDEX (NAME(PROD.CUST.AIX) -
RELATE(PROD.CUST.KSDS) -
KEYS(12 40) NONUNIQUEKEY UPGRADE -
RECORDSIZE(60 2000) -
CYLINDERS(10 5))
DEFINE PATH (NAME(PROD.CUST.PATH) -
PATHENTRY(PROD.CUST.AIX))
BLDINDEX INDATASET(PROD.CUST.KSDS) -
OUTDATASET(PROD.CUST.AIX)
/*- What does KEYS(10 0) say? The prime key is 10 bytes long and starts at offset 0 of the record. Offsets count from zero, which trips up people who think in COBOL positions.
- RECORDSIZE(250 400)? Average and maximum record length. The maximum is a hard limit; the average helps space estimates. Equal values make records fixed length.
- FREESPACE(20 10)? Leave 20 percent of each CI empty and 10 percent of the CIs in each CA empty at load time, so inserts land without splitting. Read-only files can use zero.
- How would you pick a CI size? Smaller CIs suit random reads of single records, since less data moves per read. Larger CIs suit sequential processing. Many shops start at 4K for online files and go larger for batch-only files, then measure.
- What does SHAREOPTIONS(2 3) mean? The first number is sharing across regions on one system: 2 allows one writer plus many readers. The second is across systems, where 3 lets anyone open it and leaves integrity entirely to the programs. Explain that VSAM does not protect you at 3 or 4.
- What does REUSE do? Lets a program open the cluster for output and reset it to empty without deleting and redefining it. Handy for work files; it cannot be combined with an alternate index.
- What is SPANNED for? Allows a record longer than a CI to span several CIs in one CA. It solves a sizing problem but costs performance and is not allowed for every organization.
- Why the DELETE and SET MAXCC = 0 at the top? It makes the job rerunnable: the first run fails the DELETE with a not-found code, and resetting MAXCC stops that from failing the step.
- What does UPGRADE on an alternate index mean? VSAM keeps the AIX in step when the base cluster changes, as long as the update comes through the base or a path opened with the AIX in its upgrade set.
Intermediate questions: splits, alternate indexes and buffers
| Question | What it tests | What a strong answer shows |
|---|---|---|
| What happens on a CI split? | Internals | An insert does not fit, so VSAM moves roughly half the records in that CI to a free CI in the same CA and updates the sequence set. Logical order stays correct but physical order no longer matches it. |
| And a CA split? | Internals | No free CI is left in the CA, so VSAM gets a new CA, moves about half the CIs there and updates the index. It costs far more I/O and can need a new extent. |
| How do you know a file is splitting badly? | Diagnosis | LISTCAT shows SPLITS-CI, SPLITS-CA and EXTENTS. Rising counts between reorganizations, plus slower sequential reads, mean free space is wrong for the insert pattern. |
| How do you reorganize a KSDS? | Maintenance | REPRO the data out to a sequential file, delete and redefine the cluster (adjusting FREESPACE or size), REPRO back in, then rebuild alternate indexes with BLDINDEX. Schedule it when no one has the file open. |
| Why do keys inserted at the end matter? | Insert pattern | Ascending keys like timestamps all land in the last CA. Spread free space does nothing for them, so give the high end room or accept regular CA splits. |
| What is an alternate index? | Access | A separate KSDS whose records map an alternate key to one or more prime keys. You read the base file through a PATH defined over it. |
| What is the job of BLDINDEX? | Access | It reads the base cluster, sorts the alternate keys and loads the AIX. Run it after defining an AIX and after reloading the base. |
| Unique versus non-unique alternate keys? | Design | NONUNIQUEKEY lets many base records share one alternate key, and a COBOL READ returns status 02 when more remain. Size the AIX record for the largest group. |
| What do BUFND and BUFNI control? | Buffering | Data and index buffers under non-shared resources. Sequential batch reads gain from more data buffers; random reads gain from enough index buffers to keep the index set in memory. |
| NSR versus LSR? | Buffering | Non-shared resources give each open file its own buffers, which suits batch. Local shared resources share a pool across files, which CICS regions use so hot index CIs stay in memory. |
| What does System-Managed Buffering offer? | Buffering | With SMS-managed extended format files, the system can pick buffer counts from the access pattern you declare. Know that it exists and that shops differ on using it. |
File status codes interviewers expect you to know
COBOL programs see VSAM results through the FILE STATUS field, and a support interview often reads a code aloud and waits. Learn the first digit groups (0 success, 1 end of file, 2 key problems, 3 permanent errors, 4 logic errors, 9 implementation-specific) and these common values:
| Status | Meaning | First thing to check |
|---|---|---|
| 00 | Successful | Nothing, but still test it after every I/O. |
| 02 | Success with a duplicate alternate key | Expected on non-unique AIX reads; keep reading while it repeats. |
| 10 | End of file on a sequential read | Normal loop exit, not an error. |
| 21 | Sequence error | Keys written out of ascending order in sequential mode, or the key changed between READ and REWRITE. |
| 22 | Duplicate key on WRITE | The record already exists; decide whether the logic should REWRITE instead. |
| 23 | Record not found | Key value, key length and whether a START positioned you where you thought. |
| 35 | File not found at OPEN | The DD statement, the cluster name and whether it was defined, or a mandatory file missing. |
| 37 | Open mode not allowed | Opening for output or I-O when the dataset or its access does not permit it. |
| 39 | Attribute conflict at OPEN | Record length, key length or position in the COBOL FD versus the DEFINE. |
| 41, 42, 43 | Logic errors | Already open, not open, or REWRITE/DELETE without a prior successful READ. |
| 46, 92 | Read past end, or a general logic error | 46 means a sequential READ after end of file was already reached; 92 is a catch-all logic error, so trace the I/O sequence in the program. |
| 93 | Resource not available | Another job or region holds the file; check share options and the schedule. |
| 97 | Opened after an implicit VERIFY | The file was not closed cleanly before. The open worked, but find out why the last user abended. |
Senior and scenario questions
- An online transaction against a KSDS slowed down over three weeks. Where do you look? LISTCAT for split counts and extents, the LSR pool statistics for buffer hit ratios on the index, and whether a new process started inserting at the high end. Fix the cause (free space, CI size, pool size), not just the symptom with a reorg.
- The batch job gets status 93 every night at 1 a.m. What now? Something else holds the file. Check which CICS region or job has it open, whether the file should be closed to the region during batch, and whether the scheduler dependency is missing.
- A job abended mid-update and the next open returns 97. Is the data safe? VSAM fixed the end-of-file pointers, but records written in that last unit of work may be partial from the business's view. Check the job's own restart and commit logic and reconcile counts.
- How would you back up a VSAM file used by an online region? Close it to the region or use a backup method that supports open files, depending on what the shop has. A plain REPRO while updates run can copy an inconsistent picture.
- When would you choose ESDS over KSDS? For append-only logs and audit trails where you never update or delete and always read in arrival order. Writes are cheap because there is no index to maintain.
- A base cluster was reloaded but nobody rebuilt the AIX. What breaks? Reads through the path return wrong or missing records, because the AIX still points to old prime keys. Rebuild with BLDINDEX before the path is used.
- Share options are set to 3 across two systems. What is your concern? Neither VSAM nor the catalog serializes updates for you, so two writers can corrupt index and data. Either use record-level sharing where the shop supports it, or redesign to one updater.
- How would you move VSAM data to a relational database? Map the copybook to columns, handle packed and binary fields, decide what to do with REDEFINES, unload with REPRO or a vendor tool, load, and compare record counts and key totals.
SELECT CUST-FILE ASSIGN TO CUSTKSDS
ORGANIZATION IS INDEXED
ACCESS MODE IS RANDOM
RECORD KEY IS CUST-ID
FILE STATUS IS WS-CUST-STATUS.
* ...
MOVE IN-CUST-ID TO CUST-ID
READ CUST-FILE
EVALUATE WS-CUST-STATUS
WHEN '00' PERFORM PROCESS-CUSTOMER
WHEN '23' PERFORM LOG-MISSING-CUSTOMER
WHEN OTHER PERFORM ABEND-WITH-STATUS
END-EVALUATEFictional example
- Interviewer
- We need a KSDS for orders. About a million records a year, read randomly from CICS, updated all day. How do you define it?
- Candidate
- First I would ask about the key. If it is an ascending order number, new records all land at the end, so spread free space helps little and I would plan for CA splits at the high end or a key that spreads inserts. For random online reads I would start with a 4K data CI and enough index buffers in the LSR pool to hold the index set. I would size from the average record length times the yearly volume plus growth, give a sensible secondary, and set share options for one writer and many readers within the system. After a month I would check LISTCAT for splits and extents and adjust before the first reorg, rather than guess the perfect numbers on day one.
A one-week VSAM practice plan
- Day 1: draw a KSDS on paper: index set, sequence set, CAs and CIs with records, free space, CIDF and RDFs. Explain a key lookup aloud.
- Day 2: write a DEFINE CLUSTER from memory for a stated workload and defend every parameter.
- Day 3: walk through a CI split and a CA split step by step, then explain how LISTCAT shows them.
- Day 4: drill the file status table until you can give meaning and first check in one breath.
- Day 5: rehearse two support stories: a 93 contention problem and a 97 after an abend, with the fix and the prevention.
VSAM questions sit next to JCL interview questions for the jobs that define and load the files, COBOL interview questions for the programs that read them, and CICS interview questions for online access. Integration teams that expose mainframe records to newer systems meet the same files from the other side, covered in webMethods interview questions.
VSAM answers are judged on whether you can reason about bytes, intervals and contention without a manual open. Natively, an AI interview assistant for Mac and Windows, transcribes a mock VSAM round on your computer so you can see where your split explanation got vague. When you practice, it can read an IDCAMS listing or a LISTCAT excerpt from a screenshot and suggest what to point out, and with Pro or the free trial it draws on the résumé and job description you add. The transcript and notes stay available for review afterward.
Questions people ask
What VSAM questions are asked in mainframe interviews?
Cluster types and components, control intervals and control areas, IDCAMS DEFINE CLUSTER parameters, CI and CA splits, alternate indexes with PATH and BLDINDEX, share options, buffering, and the file status codes a COBOL program gets back.
What is the difference between KSDS and ESDS?
A KSDS keeps records in key order with an index, so you can read, insert, update and delete by key. An ESDS keeps records in the order they were written, addressed by RBA, and records cannot be physically deleted.
What does VSAM file status 35 mean?
The file was not found when the program opened it. Check the DD statement, the cluster name and whether the cluster was actually defined.
What causes a CA split in VSAM?
An insert needs room in a control interval and no free CI is left in that control area, so VSAM moves about half the CIs to a new CA. Wrong free space settings or keys that always arrive at the high end are common causes.
Where to go next
Practice with the same assistant you would use on a call: it listens, transcribes and suggests answers from your own resume and the job description.
Facts on this page were last checked on . Product details come from the Natively app itself; if something here is out of date, tell us at hello@heynatively.com.
