Reading a VSAM KSDS sequentially with the OPSVSAM function
search cancel

Reading a VSAM KSDS sequentially with the OPSVSAM function

book

Article ID: 247310

calendar_today

Updated On:

Products

OPS/MVS Event Management & Automation

Issue/Introduction

I am trying to read multiple records from a VSAM KSDS file sequentially.

This is a KSDS DB with a 36 character key, the key contains the job/application/job#/time/date:

SRTJOB  SRTJBAPP  110 10.00.26062222

I have OPSVSAM reading the first record, but don't see how to advance to the next record.  I've tried the 3 following formats and can display the RBA, but still don't see how to advance to the next record.

record = OPSVSAM('READ','JOBFILE',,,KGE)         
record = OPSVSAM('POINT','JOBFILE',JOBKEY,,KGE)
record = OPSVSAM('READ','JOBFILE',JOBKEY)      

 

 

 

Environment

Release : 14.0

Component : OPS/MVS

Resolution

The syntax of the OPSVSAM READ function is as follows:

var = OPSVSAM('READ',ddname,[key[,keylength[,criterion]] ])

In order to sequentially read through a VSAM KSDS file by retrieving the next record on each OPSVSAM READ call, all that is needed is the ddname. For instance, if the ddname is OPSDDN, the the call should be coded as:

RECORD = OPSVSAM('READ',OPSDDN)

Each invocation of the above call will read the next record sequentially into the variable "RECORD" from the VSAM file associated with the ddname OPSDDN.

 

From the OPSVSAM Function documentation located here:

OPSVSAM Function

under "Usage Notes" the following is stated:

KSDS (Key Sequenced Data Set)
 
A KSDS VSAM file can be positioned sequentially to the next record by not specifying a key, or directly to a specific record that matches (partially) the specified key (and 
keylength).