# VSAM File Operations

> [← Back to README](../../README.md) | [DB2 Integration →](./db2-ims-mq-jcl.md#db2-integration-optional-modules)

## VSAM File Types in CardDemo

| File | Type | Key | Record Length | CSD Name |
|:-----|:-----|:----|-------------:|:---------|
| Account Master | KSDS | ACCT-ID (11) | 300 | ACCTDAT |
| Card Master | KSDS | CARD-NUM (16) | 150 | CARDDAT |
| Card AIX Path | AIX | CARD-ACCT-ID | 150 | CARDAIX |
| Cross-Reference | KSDS | XREF-CARD-NUM (16) | 50 | CCXREF |
| Xref AIX Path | AIX | XREF-ACCT-ID | 50 | CXACAIX |
| Customer Master | KSDS | CUST-ID (9) | 500 | CUSTDAT |
| Transaction Master | KSDS+AIX | TRAN-ID (16) | 350 | TRANSACT |
| User Security | KSDS | SEC-USR-ID (8) | 80 | USRSEC |
| Daily Transactions | PS (Seq) | — | 350 | DALYTRAN |
| Category Balance | KSDS | Composite (17) | 50 | TCATBALF |
| Disclosure Groups | KSDS | Composite (16) | 50 | DISCGRP |
| Transaction Types | KSDS | TRAN-TYPE (2) | 60 | TRANTYPE |
| Transaction Categories | KSDS | Composite (6) | 60 | TRANCATG |

## CSD File Configuration

All VSAM files in the CSD share these settings:
- `LSRPOOLNUM(1)` — LSR pool for buffer sharing
- `READINTEG(UNCOMMITTED)` — Read without lock
- `STRINGS(1)` — Single string (concurrent access limit)
- `DISPOSITION(SHARE)` — Shared access
- `RECORDFORMAT(V)` — Variable-length records
- `ADD(YES) BROWSE(YES) DELETE(YES) READ(YES) UPDATE(YES)` — Full access
- `JOURNAL(NO) RECOVERY(NONE)` — No journaling or recovery

## File Status Code Handling (Batch)

Batch programs check `FILE STATUS` after each I/O:

| Status | Meaning | Action |
|:-------|:--------|:-------|
| 00 | Success | Continue |
| 02 | Duplicate alternate key | Continue (non-unique AIX) |
| 10 | End of file | End read loop |
| 22 | Duplicate primary key | Error handling |
| 23 | Record not found | Error handling |
| 35 | File not defined | Abend |

## ESDS/RRDS Support (Optional)

The ESDSRRDS JCL job (`app/jcl/ESDSRRDS.jcl`) creates ESDS and RRDS VSAM files, demonstrating support for all three VSAM access methods.

---

*See also: [Data Models](../../reference/data-models.md) | [Dependencies](../../architecture/dependencies.md)*
