👁 0
Q: What is the difference between KSDS and ESDS?
Answer:
KSDS (Key Sequenced Data Set):
- Records accessed by unique key
- Records stored in key sequence
- Has both data and index components
- Supports random and sequential access
- Can delete and reinsert records
- Most commonly used VSAM type
ESDS (Entry Sequenced Data Set):
- Records stored in arrival order
- Accessed by RBA (Relative Byte Address)
- No index component
- Cannot delete records (only mark inactive)
- Similar to sequential files
- Good for logs, audit trails
Use KSDS when: You need key-based access, updates, deletes
Use ESDS when: Sequential processing only, append-only data
👁 0
Q: What is RRDS in VSAM?
Answer:
RRDS (Relative Record Dataset) accesses by relative record number (slot). Fixed length slots numbered 1, 2, 3... Can be empty slots. Good for direct access by position. Less common than KSDS/ESDS.
👁 0
Q: What is ORGANIZATION clause?
Answer:
ORGANIZATION specifies file structure: SEQUENTIAL (default), INDEXED (VSAM KSDS), RELATIVE (RRDS). Determines access methods available. INDEXED requires RECORD KEY. ACCESS MODE can be SEQUENTIAL, RANDOM, or DYNAMIC.
👁 0
Q: How to define KSDS cluster?
Answer:
IDCAMS DEFINE CLUSTER(NAME(ds.name) INDEXED KEYS(len offset) RECORDSIZE(avg max) SHAREOPTIONS(2 3)) DATA(NAME(ds.data) CYLINDERS(5 1)) INDEX(NAME(ds.index) CYLINDERS(1 1)). Keys required for INDEXED.
👁 0
Q: How to handle file status 22?
Answer:
Status 22 is duplicate key on WRITE or REWRITE attempt. KSDS primary key must be unique. Check program logic. May indicate data error. Use DUPLICATES option on AIX only if needed.
👁 0
Q: What is KSDS key format?
Answer:
Keys defined by KEYS(length offset). Offset is 0-based. Key extracted from record at offset for length bytes. Alphanumeric comparison. Numeric keys need proper format. Key must be contiguous.
👁 0
Q: What is RBA?
Answer:
RBA (Relative Byte Address) is byte offset from dataset start. ESDS uses RBA for access. KSDS index points to RBA. Changed by REORG. Use key for KSDS, RBA only when necessary.
👁 0
Q: How to update KSDS record?
Answer:
READ record (optionally FOR UPDATE). Modify record area. REWRITE record. Key cannot change on REWRITE. Status 00 if successful. ACCESS MODE must allow updates.
👁 0
Q: How to handle variable length KSDS?
Answer:
Define with RECORDSIZE(avg max). Read/write variable length records. COBOL RECORD VARYING clause. Key position fixed. Read returns actual length. Write length implicit from record.
👁 0
Q: What is KEYRANGES?
Answer:
KEYRANGES distributes KSDS across volumes by key value. KEYRANGES((low1 high1) (low2 high2)). Each range on different volume. Improves parallel access. Rarely used now.
👁 0
Q: How to improve KSDS performance?
Answer:
Appropriate CISIZE, FREESPACE. Adequate buffers (BUFND/BUFNI). Index in cache if possible. IMBED obsolete. Keep file organized (REORG). Monitor CA/CI splits. Sequential access for bulk.
👁 0
Q: How to load VSAM from sequential?
Answer:
REPRO INFILE(seqfile) OUTFILE(vsamfile). REPLACE option to overwrite existing. Records must match VSAM format. For KSDS, records must be sorted by key. IDCAMS job.
👁 0
Q: Explain NONUNIQUEKEY?
Answer:
AIX can have NONUNIQUEKEY (duplicates). Base cluster KSDS always unique primary key. NONUNIQUEKEY AIX returns first match, use READ NEXT for others. UNIQUEKEY if one-to-one.
👁 0
Q: What is backward READ?
Answer:
READ PREVIOUS for backward sequential. Must establish position first (START or READ). KSDS and ESDS support backward. Useful for end-of-file processing or range searches.
👁 0
Q: How to read VSAM sequentially?
Answer:
OPEN INPUT file. START if positioning needed. READ NEXT repeatedly until status 10 (end of file). CLOSE file. START optional - defaults to beginning. READ NEXT gets records in key sequence for KSDS.
👁 0
Q: How to write VSAM random?
Answer:
ACCESS MODE IS RANDOM or DYNAMIC. WRITE record writes at key position. For KSDS, key must not exist (status 22). For ESDS, writes at end. RANDOM/DYNAMIC MODE required.
👁 0
Q: How to delete records from KSDS?
Answer:
READ record with key. DELETE record-name. Status 00 if successful. In COBOL, DELETE uses primary key. Can delete current record after READ. Cannot delete from ESDS.
👁 0
Q: Explain DEFINE CLUSTER syntax
Answer:
DEFINE CLUSTER(NAME(ds) ...) DATA(NAME(ds.data) ...) INDEX(NAME(ds.index) ...). CLUSTER level: type, SHAREOPTIONS. DATA level: space, RECORDSIZE. INDEX level: space for KSDS index.
👁 0
Q: What is BDAM conversion to VSAM?
Answer:
BDAM is block-oriented, VSAM is record-oriented. Convert: analyze BDAM access, choose KSDS/RRDS/ESDS. REPRO or IDCAMS copy. Program changes for VSAM access. Test thoroughly.