---
title: "COBOL VSAM Files READ with START Logic"
description: "Here's COBOL sample program that explains that reading of VSAM files."
url: https://srinimf.com/2015/02/07/vsam-file-reading-in-cobol-program/
date: 2015-02-07
modified: 2026-10-10
author: "Srini"
image: https://i0.wp.com/srinimf.com/wp-content/uploads/2015/02/pexels-photo-288530.jpeg?fit=1733%2C1300&ssl=1
categories: ["COBOL", "VSAM"]
tags: ["COBOL Tips and Tricks", "VSAM FILE READ"]
type: post
lang: en
---

# COBOL VSAM Files READ with START Logic

Here’s sample COBOL program that shows [how to](https://srinimf.com/2015/10/13/file-open-should-be-input-or-i-o-in-cobol-start-statement/) use READ, WRITE and READ NEXT statements. The READ statement is to get record randomly. The READ NEXT to read [VSAM file](https://srinimf.com/2019/12/23/how-to-browse-vsam-file-in-cics/) till end of the file.

Advertisements

## Establish a Key

START statement positions the cursor. Once position establishes, you can use READ or READ NEXT statements. Below are the examples for that.

```
MOVE 'xxxxxx' TO key-value
START sample-file 
      KEY IS EQUAL TO key-value
END-START.
```

## READ Statement

The purpose of READ statement is to fetch a record randomly after establishing a key. Here is more on [How to Use READ in VSAM Complete Syntax](https://www.ibm.com/docs/en/cobol-zos/6.3?topic=statements-read-statement) .

```
READ sample_file RECORD INTO identifier 
KEY IS EQUAL TO key_value 
     INVALID KEY  do_this
     NOT INVALID KEY do_this
END-READ.
```

## READ NEXT Statement

READ Next fetches records sequentially till end of the input VSAM file. Here’s more on [VSAM-Basics-Usage.](https://click.linksynergy.com/deeplink?id=yYOcxCqEbGo&mid=39197&u1=srinimf&murl=https%3A%2F%2Fwww.udemy.com%2Fcourse%2Fvsam-basics-for-beginners%2F)

```
READ sample_file
    NEXT RECORD INTO identifier KEY IS sample-key
    AT END do_this
    NOT AT END do_this
END-READ.
```

**Note: **When you work with VSAM files, the logic READ and READ NEXT helpful to read records.

## Write a Record

```
WRITE record-name FROM identifier
INVALID KEY statement.
```

**Related Posts**

- [VSAM Program: How to Write Correctly](https://srinimf.com/2022/04/24/vsam-program-how-to-write-correctly/)DateApril 24, 2022
- [3 Top VSAM File Access Modes](https://srinimf.com/2016/03/16/3-ways-reading-vsam-files-with-start-and-read-next/)DateMarch 16, 2016
- [How to Read VSAM File Randomly in COBOL](https://srinimf.com/2020/03/29/7-quick-tips-on-mainframe-vsam-files/)DateMarch 29, 2020

### Share this:

-
- [Tweet](https://twitter.com/share)
- [![](https://i0.wp.com/assets.pinterest.com/images/pidgets/pinit_fg_en_rect_gray_20.png)](https://www.pinterest.com/pin/create/link/?url=https%3A%2F%2Fsrinimf.com%2F2015%2F02%2F07%2Fvsam-file-reading-in-cobol-program%2F&media=https%3A%2F%2Fi0.wp.com%2Fsrinimf.com%2Fwp-content%2Fuploads%2F2015%2F02%2Fpexels-photo-288530.jpeg%3Ffit%3D1200%252C900%26ssl%3D1&description=COBOL%20VSAM%20Files%20READ%20with%20START%20Logic)
-
- [Share on Tumblr](https://www.tumblr.com/share)
- [Share on WhatsApp (Opens in new window) WhatsApp](https://srinimf.com/2015/02/07/vsam-file-reading-in-cobol-program/?share=jetpack-whatsapp)
- [More](#)
-

- [Print (Opens in new window) Print](https://srinimf.com/2015/02/07/vsam-file-reading-in-cobol-program/?share=print)
- [Share on Reddit (Opens in new window) Reddit](https://srinimf.com/2015/02/07/vsam-file-reading-in-cobol-program/?share=reddit)
- [Share on Telegram (Opens in new window) Telegram](https://srinimf.com/2015/02/07/vsam-file-reading-in-cobol-program/?share=telegram)
- [Email a link to a friend (Opens in new window) Email](mailto:?subject=%5BShared%20Post%5D%20COBOL%20VSAM%20Files%20READ%20with%20START%20Logic&body=https%3A%2F%2Fsrinimf.com%2F2015%2F02%2F07%2Fvsam-file-reading-in-cobol-program%2F&share=email)
-

### Like this:

Like Loading…
