What is INVALID key in VSAM?

Virtual Storage Access method - ESDS, KSDS, RRDS & LDS. Basic direct access method, Basic sequential -, Queued sequential -, Basic partitioned -, Indexed sequential -, Object - access method.
Post Reply
riathane
New Member
Posts: 2
Joined: Sun Sep 27, 2015 6:57 pm

What is INVALID key in VSAM?

Post by riathane »

What is INVALID key in VSAM? And when do we need it?

In one of my programs, I've this:

Code: Select all

READ IN-ILEA 
INTO IN-RECORD 
INVALID KEY 
MOVE 'pass' TO WS-OUT 
In above code, IN-FILE is a KSDS file, ORGANIZATION IS INDEXED and ACCESS IS RANDOM. With this code, when INVALID KEY will execute and what does INVALID KEY do here?
William Collins
Global Moderator
Global Moderator
Posts: 490
Joined: Sun Aug 25, 2013 7:24 pm

Re: What is INVALID key in VSAM?

Post by William Collins »

When the key is not found on the file. You also need to use END-READ, unless you have a very old COBOL, when you'd use a full-stop/period.

To my mind it is much better to use the FILE STATUS clause on the SELECT, and an 88 on the file-status field you define (one per file). "23" is "record not found".
User avatar
Robert Sample
Global Moderator
Global Moderator
Posts: 1891
Joined: Fri Jun 28, 2013 1:22 am
Location: Dubuque Iowa
United States of America

Re: What is INVALID key in VSAM?

Post by Robert Sample »

To my mind it is much better to use the FILE STATUS clause on the SELECT
And Enterprise COBOL supports extended file status bytes for VSAM which give you plenty of helpful information if your program doesn't run correctly.
Post Reply

Create an account or sign in to join the discussion

You need to be a member in order to post a reply

Create an account

Not a member? register to join our community
Members can start their own topics & subscribe to topics
It’s free and only takes a minute

Register

Sign in

Return to “SMS & VSAM and BDAM, BSAM, QSAM, BPAM, ISAM, OAM.”