VSAM access modes for files awesome details

You can read VSAM files in COBOL with 3 ways. Sequential Reading, Random reading and Dynamic reading.

Access Modes:

Sequential read – Only sequentially you can read. First you need to give START command to establish a key. Then READ NEXT to get next record and so on.


Random read – You can go to any key either forward way or backward way.

Dynamic read – You can read a record Sequentially and also you can read random record.

When a direct READ is performed for a VSAM indexed file, based on an alternate index for which duplicates exist, only the first record in the data set (base cluster) with that alternate key value is retrieved. You need a series of READ NEXT statements to retrieve each of the data set records with the same alternate key. A file status code of 02 is returned if there are more records with the same alternate key value to be read; a code of 00 is returned when the last record with that key value has been read.


Author: Srini

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