How to Read VSAM File Randomly in COBOL

Here’s a sample COBOL program that reads VSAM file randomly. The logic given here is helpful to use in your projects.


Storage of VSAM Files

  1. Entries will store in Master or User catalog
  2. Plainly, the Master and User-catalog both can have entries of VSAM and non-VSAM datasets.
  3. Only KSDS datasets have Indexed. The ESDS and RRDS have only the data components. That means they do not have an index.
    • |Data component|Index component|
  4. While working with ESDS and RRDS you need not index.
  5. KSDS index is a combination of Key and Value. Also, KSDS supports an alternate index.
    • Index key|Sequence value
  6. In KSDS, firstly, it locates the index, then finds corresponding sequence value. From this it gets data from control interval and area.
  7. The catalog that stores information of VSAM and non-VSAM datasets is called the ICF integrated catalog facility.
VSAM COBOL Example Program Read Today

How to READ VSAM Files Randomly

SELECT TEST1 ASSIGN TO TEST1
ORGANIZATION IS INDEXED
ACCESS IS RANDOM
RECORD-KEY IS TS-EMPLOYEE-NUMBER
ALTERNATE RECORD KEY IS TS-SOCIAL-SECURITY-NO
ALTERNATE RECORD KEY IS TS-DEPT-NO
WITH DUPLICATES.

Related Posts

Author: Srini

Experienced software developer. Skills in Development, Coding, Testing and Debugging. Good Data analytic skills (Data Warehousing and BI). Also skills in Mainframe.