Accessing VSAM means your job step already has a cataloged cluster or path, and you want a program or utility to open it for read, update, append, or unload. The JCL side is mostly the DD statement: correct DSN spelling, DISP that matches catalog state, optional AMP tuning, and sometimes explicit UNIT or VOLUME overrides in non-SMS scenarios. The program side supplies OPEN mode and record areas. This page focuses on the JCL patterns operations and developers copy from golden jobs: how to wire a COBOL or PL/I step to a KSDS, how REPRO and PRINT expect their DDs, how paths differ from base clusters on the DD card, and how shared read jobs differ from exclusive update jobs in terms of DISP and scheduling discipline.
12345//RUNUPD EXEC PGM=CUSTPGM //CUSTMAS DD DSN=PROD.SALES.CUSTOMER.KSDS, // DISP=OLD //RPTOUT DD SYSOUT=*
The program CUSTPGM must open CUSTMAS for INPUT or I-O consistent with its logic and RACF profile. DISP=OLD asserts the dataset exists before the step runs; if the name is misspelled, allocation fails early, which is cheaper than an ABEND inside the program. If multiple read-only jobs should run together, your standards may switch this line to DISP=SHR when SHAREOPTIONS and security allow concurrent readers.
1234567891011//COPYVS EXEC PGM=IDCAMS //SYSPRINT DD SYSOUT=* //INVSAM DD DSN=PROD.SALES.CUSTOMER.KSDS,DISP=SHR //OUTSEQ DD DSN=WORK.CUSTFLAT.SEQ, // DISP=(NEW,CATLG,DELETE), // SPACE=(CYL,(5,5)),UNIT=SYSDA, // DCB=(RECFM=FB,LRECL=500,BLKSIZE=0) //SYSIN DD * REPRO INFILE(INVSAM) OUTFILE(OUTSEQ) /*
Here INVSAM is the DD name REPRO reads. DISP=SHR fits read-only unload while other jobs may still read the VSAM file depending on SHAREOPTIONS. OUTSEQ is a sequential flat file receiving records; DCB attributes must match the logical record length you expect in the unload. If the VSAM records are variable length, your flat file DCB and LRECL strategy must follow the unload format your program or SORT step expects downstream.
| Workload | JCL and program alignment |
|---|---|
| Read-only batch | DISP=SHR or OLD on cluster DD; program opens INPUT. AMP optional based on SMF evidence. |
| Update in place | DISP=OLD (or SHR when standards allow) with program opening I-O; RACF often requires UPDATE authority. |
| Append ESDS style | Program may open EXTEND; DISP and MACRF/AMP must align with site guidance for append workloads. |
| Utility unload | REPRO INFILE points at VSAM DD; OUTFILE sequential receives extracted records. |
JCL cannot see inside the program to know whether the next READ is sequential or random; it only supplies allocation. That is why MACRF on AMP, when used, must agree with actual program behavior documented in the design spec. Performance teams correlate SMF records with JCL to see whether AMP tuning matches the dominant access path; mismatches show up as higher than expected EXCP counts for index or data components.
When the DD names a path, the catalog entry describes how VSAM should traverse the alternate index structure to reach base data. Programs coded for path access expect key layouts that match the alternate key definition, not the primary key layout alone. If you accidentally code the base cluster name while the program positions on alternate keys, you will see wrong data or file status errors that look mysterious until someone opens the path definition in LISTCAT and compares it to the SELECT statement in COBOL.
Even perfect DISP and SHAREOPTIONS cannot fix two batch jobs that both rewrite the same logical records without coordination. Many shops serialize update jobs with job scheduling dependencies or enqueue logic in programs. JCL is only the doorway; the workflow design prevents logical corruption. When you see SHR on a master file, ask whether readers are truly read-only or whether a hidden program opens for OUTPUT in a later step of the same job network.
Allocating VSAM was like building a locker tower. Accessing VSAM is like checking out a locker you already built. Your JCL pass is the hall monitor checking your ID and saying yes this locker exists. Your program is the kid actually opening the door and putting books inside. If two kids try to write in the same notebook at the same time, hall monitor permission is not enough—you still need playground rules about taking turns.
1. Before accessing VSAM in an application step, what must be true in the catalog?
2. REPRO copies data from INFILE to OUTFILE. The INFILE DD usually points to:
3. Why might DISP=SHR on a cluster still fail OPEN?