Page 1 of 1

Random Access for a KSDS file

PostPosted: Wed Mar 07, 2012 11:28 am
by ashwin1990
while accessing a KSDS file using random access method, do we have to re initialize the pointer back to the starting position evrytime if i am accessing more than 1 record.

Re: Random Access for a KSDS file

PostPosted: Wed Mar 07, 2012 12:53 pm
by BillyBoyo
I'm going to guess "no", because I can't think of anything like that using VSAM from Cobol.

However, it is a guess because I don't really know what you are talking about.

Try not doing anything except READing. If that doesn't work for you, post your code, SELECT, FD and I/O statements, please.

Re: Random Access for a KSDS file

PostPosted: Wed Mar 07, 2012 1:48 pm
by mongan
I think your terminology is not correct. Are you talking about a read using a key, or are you talking about a start and read next scenario?

Re: Random Access for a KSDS file

PostPosted: Wed Mar 07, 2012 5:37 pm
by Robert Sample
As has been mentioned, it is difficult to tell what you are asking since your terminology is so vague.

However, since you do not have to initialize any pointer to do a random read of a KSDS file (you merely have to ensure the key contains the value you want), I'm guessing the answer is probably not.

On the other hand, if you're thinking of dynamic processing (where you randomly read a record, then use sequential processing to read the next record(s)), then you would not want to change the key since that would affect your sequential processing.

Re: Random Access for a KSDS file

PostPosted: Sun Mar 11, 2012 5:58 pm
by ashwin1990
my question was that suppose i am reading a record (eg 10th record) from a KSDS file using random access method for the first time. now the second time i want to read 5th record. So in this case do we have to re initialize the pointer back to the first record again???

Re: Random Access for a KSDS file

PostPosted: Sun Mar 11, 2012 6:09 pm
by Robert Sample
It is STILL not clear what you want to know. Since you do NOT have to initialize anything to read a KSDS randomly, why would you think you do? On the other hand, if what you are doing is working then why are you posting on this forum? And if you are talking about a KSDS, why are you using terms like "10th record" and "5th record" since a KSDS is read by key value not record number -- terms that are used with RRDS files in VSAM?

If what you are doing is working, then go with it -- even if it is not the most efficient way, at least it is working. If what you are doing is not working, you're going to need to post the LISTCAT for the file (so we can see if you want KSDS or RRDS), as well as the code you are using to read the file, in order for us to help you.

Re: Random Access for a KSDS file

PostPosted: Sun Mar 11, 2012 6:51 pm
by BillyBoyo
You are talking about a VSAM KSDS on a Mainframe, we assume. We also assume you are using Cobol.

You establish a file a being a KSDS with RANDOM access.

You open the file.

You populate a key field and issue a READ for that key. You can tell that you were able to read with that key, or that you weren't.

You cannot tell which record, as far as relative sequence in the file, you read.

To read another record with a lower key, all you need to do is set up the key and issue the read. Same for a record with a higher key.

There is nothing you can set or reset relating to the KSDS (or any VSAM file).

This is why we cannot make good sense of your question.

Although you can do RANDOM access with keys in any order, where possible you should do it in key order, as the program will run better (there will be no occasion where a buffer is filled, discarded because of a lower key, and then the same data is again accessed later, so ends up being physically read again).

Re: Random Access for a KSDS file

PostPosted: Mon Mar 12, 2012 9:18 pm
by ashwin1990
thnks guys for ur help............. really appreciate it........