Page 1 of 1

VSAM file status 02.

PostPosted: Thu Oct 31, 2013 2:52 am
by sandeepjanar
Hi all,

I have a doubt in VSAM. It would be really helpful if some one can help me with that.

I got a VSAM file (say A) with first 48 characters as key. There is an alternate path created for this VSAM (say B) with fields 33-42 (10 digit field as key) as key.
I am writing a program where I must use path B as I have to query on that 10 digit field. (I can directly use VSAM file A but it is going to take lot of time to process all records). That 10 digit field has alphanumeric values WITH DUPLICATES.
In my program, I have a input value. I need to read this path B with 10 digit key >= Input-key.. My intention is to retrieve multiple records from VSAM satisfying the criteria.. Please let me know how to do it.. Not sure if it is possible to do also..

Thanks,
Sandeep.

Re: VSAM file status 02.

PostPosted: Thu Oct 31, 2013 3:18 am
by Robert Sample
You did not specify the language your program is written in. I am assuming COBOL; other languages would use similar methodss. Use
START <file name> KEY IS <alt-key-name>
followed by READ NEXT to retrieve the data in alternate index sequence.

Re: VSAM file status 02.

PostPosted: Thu Oct 31, 2013 3:52 am
by sandeepjanar
I am sorry about that.. yes it is COBOL..
I tried giving START FILE B KEY IS FILE B KEY..
Then I did a READ NEXT... it is giving RC=02 (duplicate)..
Thanks for your reply..

Re: VSAM file status 02.

PostPosted: Thu Oct 31, 2013 4:18 am
by BillyBoyo
There is more than one record with that same alternate key value. What problem does that give you?

Re: VSAM file status 02.

PostPosted: Thu Oct 31, 2013 5:43 am
by Robert Sample
A file status code of 02 is NOT an error -- so your code should ignore it and continue.

Re: VSAM file status 02.

PostPosted: Thu Oct 31, 2013 10:53 am
by sandeepjanar
Thanks for the help. It did work. I am able to make it work after adding further processing under IF condition IF STATUS-CODE = '02'.

Re: VSAM file status 02.

PostPosted: Thu Oct 31, 2013 9:51 pm
by dick scherrer
Hello,

You need to make sure you understand why you changed the code . . .

Re: VSAM file status 02.

PostPosted: Thu Oct 31, 2013 10:03 pm
by sandeepjanar
Yes. I did understand. Initially I was assuming STATUS-CODE shouldn't be '02' when we use START & READNEXT. Now I am clear that when we read sequentially from a particular point in this case, status '02' is a valid possible code that comes because of duplicate keys. So, we can read all records next using status code '00' or '02'. Let me know if I have understood anything wrong.

Re: VSAM file status 02.

PostPosted: Thu Oct 31, 2013 10:17 pm
by Robert Sample
It is worth noting that the first digit of the file status code being a zero means that the operation was successful, even though the second digit can be 0, 2, 4, 5, or 7 to denote various conditions that did not prevent the operation but could impact the results.

Re: VSAM file status 02.

PostPosted: Thu Oct 31, 2013 10:24 pm
by sandeepjanar
Robert, I never knew this. Thanks for sharing. This will help me.