Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

Accessing Last Record of set

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> JCL & VSAM
View previous topic :: :: View next topic  
Author Message
seahawk789

New User


Joined: 22 Feb 2010
Posts: 47
Location: Cochin

PostPosted: Sun Aug 09, 2015 4:19 am    Post subject: Accessing Last Record of set
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: 7914
Location: Bellevue, IA

PostPosted: Sun Aug 09, 2015 5:01 am    Post subject:
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: 47
Location: Cochin

PostPosted: Sun Aug 09, 2015 5:10 am    Post subject:
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: 7914
Location: Bellevue, IA

PostPosted: Sun Aug 09, 2015 5:13 am    Post subject:
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: 47
Location: Cochin

PostPosted: Sun Aug 09, 2015 5:19 am    Post subject:
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: 7914
Location: Bellevue, IA

PostPosted: Sun Aug 09, 2015 5:24 am    Post subject:
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: 47
Location: Cochin

PostPosted: Sun Aug 09, 2015 5:25 am    Post subject:
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    IBMMAINFRAMES.com Support Forums -> JCL & VSAM All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts How to update a portion of text in a ... Bill Woodger DFSORT/ICETOOL 25 Wed Nov 09, 2016 9:41 pm
No new posts Access SQLCA fields inside a stored p... gangapd DB2 4 Thu Oct 27, 2016 10:20 am
No new posts sort with previous record anatol DFSORT/ICETOOL 9 Thu Oct 06, 2016 2:36 am
No new posts Get Record count in summary record fo... Atul Banke DFSORT/ICETOOL 21 Fri Sep 23, 2016 4:17 pm
No new posts Change date (DD/MM/YY) in 2nd record ... uday kiran DFSORT/ICETOOL 12 Wed Sep 07, 2016 10:57 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us