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

Accessing Last Record of set


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

New User


Joined: 22 Feb 2010
Posts: 56
Location: Cochin

PostPosted: Sun Aug 09, 2015 4:19 am
Reply with quote

Hi experts,

I have a requirement for a record read as below.

I have a VSAM KSDS file defined with keys and non key area as shown.

Code:

Pharm    Subs      DOB(Key)      Mem       Claim(Non Key)
ID(Key)  ID(Key)             Name(NonKey)                     
                           
FASW   1234563   19870808   Kris Ramin   4767DD
FASW   1234563   19870808   Kris Ramin   HGHJS665
FASW   1234563   19870808   Kris Ramin   879234
FASW   7666668   19990101   Don Fisher   5346SDF
FASW   7666668   19990101   Don Fisher   2355
FASW   7666668   19990101   Don Fisher   3244


What would be the fastest way (In terms of computing/CPU time) to access the first record of the set with Keys starting with
"FASW 7666668", I mean basically I am trying to point to the record
Code:
"FASW   7666668   19990101   Don Fisher   5346SDF"
but I do not have information about the 3rd part of the key, i.e date of birth. Is there a way I can directly point to that record without sequentially going through the records ?

Please help.
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


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

PostPosted: Sun Aug 09, 2015 5:01 am
Reply with quote

You did not bother to mention if you are using CICS or batch, nor which programming language (if any) you are using.

Depending upon these details, USUALLY the easiest way would be to do a generic key read (which works in batch and CICS albeit a bit differently) on the Pharm ID and Subs ID. A generic key read starts from the first byte of the key but does NOT include the entire key -- it could include all but 1 byte of the key, or all but 6 bytes of the key or even just the first byte of the key -- but a generic key read MUST start with the first byte of the key (so if you wanted to pull records by Subs ID and DOB, a generic key read could not be used).

And in these days where tens to hundreds of millions of lines of code get executed per second of CPU time, the ONLY time to working about "computing/CPU time" is when you have discovered you have a performance issue -- such as batch work not being completed in the batch window. Most of the time, the code has to be executed millions to billions of times to identify any difference in CPU time between two methods.
Back to top
View user's profile Send private message
seahawk789

New User


Joined: 22 Feb 2010
Posts: 56
Location: Cochin

PostPosted: Sun Aug 09, 2015 5:10 am
Reply with quote

Thanks for the reply.

Sorry for not mentioning the details. I am using CICS and language is COBOL.

And I missed to mention an important point in my post. Basically I know only the subscriber ID of the first set of the record i.e 1234563. But I do not have any information about the 2nd subscriber ID to which I actually want to point to, i.e is the one with 7666668.

Please help.

Please let me know since this is slightly different from the requirement I mentioned originally, do i need to raise a new post ?
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


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

PostPosted: Sun Aug 09, 2015 5:13 am
Reply with quote

So do a generic key read on the Pharm ID -- which you DO know, right? Save the first Sub ID in WORKING-STORAGE. Keep reading records, comparing each Sub ID to your saved value. When they are not the same, you have found the second Sub ID.
Back to top
View user's profile Send private message
seahawk789

New User


Joined: 22 Feb 2010
Posts: 56
Location: Cochin

PostPosted: Sun Aug 09, 2015 5:19 am
Reply with quote

Thanks Again. But I also wanted to minimize the sequential read of the records. Here until I reach the second sub ID, I am reading the records one by one right ?

Something just came to my mind now. Instead of above, if I populate the PHARM ID as FASW and the SUB ID as 1234563 and then move high-values to rest of fields and do a GTEQ CICS read will it point me to the last record of the 1st set ? So If I do one more READNEXT will I reach the first record of FASW 7666668 set ?
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


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

PostPosted: Sun Aug 09, 2015 5:24 am
Reply with quote

Yes, you are reading records sequentially but presumably not nearly as many.

And using HIGH-VALUES with GTEQ will, generally, work -- but you'll need to ensure there's a group level to receive the HIGH-VALUES or none of the elementary variables are defined as numeric since HIGH-VALUES cannot be used with numeric variables.
Back to top
View user's profile Send private message
seahawk789

New User


Joined: 22 Feb 2010
Posts: 56
Location: Cochin

PostPosted: Sun Aug 09, 2015 5:25 am
Reply with quote

Thanks a lot Bob. Will try it out.
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 How to split large record length file... DFSORT/ICETOOL 10
No new posts SFTP Issue - destination file record ... All Other Mainframe Topics 2
No new posts FINDREP - Only first record from give... DFSORT/ICETOOL 3
No new posts To find whether record count are true... DFSORT/ICETOOL 6
No new posts Validating record count of a file is ... DFSORT/ICETOOL 13
Search our Forums:

Back to Top