IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

Reading a KSDS sequentially with alternate key


IBM Mainframe Forums -> JCL & VSAM
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
meen

New User


Joined: 23 Jun 2008
Posts: 15
Location: bangalore

PostPosted: Wed Aug 12, 2009 9:53 pm
Reply with quote

Hi

I have a KSDS file with alternate key ALT-KEY (21 bytes) as:
ALtkey-part1 x(5)
ALtkey-part2 X(4)
ALtkey-part3 x(12)

Now on screen user can enter :
First three digits of ALtkey-part1 and ALtkey-part2

Suppose user has entered ABC__ and DEFG
And In file we have records e.g ABC__DEFG09864754765, ABCXYZDEFG09864754875, ABCMNODEFG09864754765 etc...

Currently I am passing
ABC to ALTKEY-PART1(1:3)
SPaces to ALTKEY-PART1(4:2)
DEFG to ALtkey-Part2

I am browsing as:

EXEC CICS
STARTBR FILE('file name')
RIDFLD(ALT-KEY)
GTEQ
RESP(WS-RESP)
END-EXEC.
and Read Next until ALTKEY-PART1(1:3) or ALtkey-Part2 changes
EXEC CICS READNEXT
DATASET (file name')
INTO (file-RECORD)
RIDFLD (ALT-KEY)
RESP (WS-RESP)
END-EXEC.

But using this command I am getting only those records e.g ABC__DEFG09864754765 and not ABCMNODEFG09864754765.

Pls suggest how to browse and read the file so that i get all the records whose first three digits of ALtKey part 1 + ALtkey-Part2 are matching... the last two digits of ALtkey part1 in fetched records can be anything spaces or some value.!
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 8696
Location: Dubuque, Iowa, USA

PostPosted: Wed Aug 12, 2009 10:31 pm
Reply with quote

You are getting exactly what you asked for. The records that match ABC<space><space> in your ALTKEY-PART1 are the only ones to be retrieved with your browse. If you want all matches, you'll need to do a generic key read on just the first 3 bytes of the key, then look at the ALTKEY-PART2 for matching fields. CICS does not allow wild card matching so there's no other way to find all matching ALTKEY-PART1 records.
Back to top
View user's profile Send private message
expat

Global Moderator


Joined: 14 Mar 2007
Posts: 8797
Location: Welsh Wales

PostPosted: Thu Aug 13, 2009 11:30 am
Reply with quote

So I'm picky this morning ..............

How can you read the file sequentially using an alternate key, surely to read it sequentially you would use the primary key as the records are stored in the order of the primary key.
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> JCL & VSAM

 


Similar Topics
Topic Forum Replies
No new posts Merge two VSAM KSDS files into third ... JCL & VSAM 6
No new posts Reading dataset in Python - New Line ... All Other Mainframe Topics 22
No new posts Find the size of a PS file before rea... COBOL Programming 13
No new posts Rexx program reading a DSN then write... CLIST & REXX 4
No new posts VSAM KSDS CREATION AND LOAD WITH RAND... JCL & VSAM 1
Search our Forums:

Back to Top