View previous topic :: View next topic
|
Author |
Message |
Thagun
New User
Joined: 25 Jul 2008 Posts: 15 Location: Chennai
|
|
|
|
Hi,
I have data in the below format in a KSDS VSAM file,
Cust No Cust Dept Exp
1 1 322
1 1 412
1 1 721
2 2 233
I am using STARTBR option to point the record in above file (all 3 fields are key fields). I will be getting Cust No and Cust Dept as input, so I am passing 999 to Exp so that STARTBR will point to record 2 2 233.
I am then doing a READNEXT and then READPREV to read all matchung records.
I am facing problem for the below data setup,
Cust No Cust Dept Exp
1 1 322
1 1 412
1 1 721
The Key is 1 1 999, the STARTBR gives an EIBRESP 13, which is record not found, since no record greated than Exp 999 is found. After STARTBR if I do a READPREV it gives EIBRESP 16.
Is there a way to read in reverse direction for the above scenario?
Code: |
EXEC CICS STARTBR
DATASET (CUST-INFO)
RIDFLD (CUST-INFO-KEY)
KEYLENGTH (LENGTH OF CUST-INFO-KEY)
GTEQ
RESP (RESP-CODE)
END-EXEC
|
|
|
Back to top |
|
|
dbzTHEdinosauer
Global Moderator
Joined: 20 Oct 2006 Posts: 6966 Location: porcelain throne
|
|
|
|
maybe add a control record, 9 9 999, to the file? |
|
Back to top |
|
|
Bill O'Boyle
CICS Moderator
Joined: 14 Jan 2008 Posts: 2501 Location: Atlanta, Georgia, USA
|
|
|
|
Move all HIGH-VALUES to the Key (RIDFLD), issue a STARTBR then followed by single READPREV (maybe two, can't recall) and this will be the last record on the file. The RIDFLD will contain the last record's Key value.
You can test this using CECI, providing you have Authority. |
|
Back to top |
|
|
Thagun
New User
Joined: 25 Jul 2008 Posts: 15 Location: Chennai
|
|
|
|
Its an existing file and cannot be changed to include header n trailer. |
|
Back to top |
|
|
Thagun
New User
Joined: 25 Jul 2008 Posts: 15 Location: Chennai
|
|
|
|
Bill,
The file can have thousands of records and the records in which I am interested might be in the middle, so moving high values to Key fields will result in reading back from 1000th record, which is not desirable.
Thanks,
Senthil |
|
Back to top |
|
|
Robert Sample
Global Moderator
Joined: 06 Jun 2008 Posts: 8696 Location: Dubuque, Iowa, USA
|
|
|
|
I think you are EXTREMELY confused on what you want. The topic title "Reading Last Record in KSDS VSAM File" conflicts with the statement you just made:
Quote: |
The file can have thousands of records and the records in which I am interested might be in the middle |
The last record in a VSAM file will not be in the middle -- it will be the LAST RECORD.
So why don't you start all over, and attempt to explain what you have and what you want to achieve, and where your problem is? |
|
Back to top |
|
|
Thagun
New User
Joined: 25 Jul 2008 Posts: 15 Location: Chennai
|
|
|
|
Rob, apologies for the confusion. The problem statement is, if the records which are matching my keys are in middle of KSDS file I am able to read the records in reverse direction successfully by moving 999 to Exp.
But if the record that matches my key is the last record in my KSDS file, then moving 999 to Exp and doing a STARTBR gives EIBRESP 13. Hence not able to read it in reverse direction.
Hope it clarifies. |
|
Back to top |
|
|
chandan.inst
Active User
Joined: 03 Nov 2005 Posts: 275 Location: Mumbai
|
|
|
|
Hi Senthil,
Thagun wrote: |
I am then doing a READNEXT and then READPREV to read all matchung records.
|
What happens if you do READPREV and READPREV here?
Also if you need to read all records for a particular customer why you cant move '000' instead of '999' and start forward browsing ?
Regards,
Chandan |
|
Back to top |
|
|
Thagun
New User
Joined: 25 Jul 2008 Posts: 15 Location: Chennai
|
|
|
|
Hi Chandan,
When I do a READPREV it gives EIBRESP 16. Reading forward is the last option if reading backward isnt working.
Regards,
Senthil |
|
Back to top |
|
|
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
When you look at the documentation of the start browse, does that give you any clues?
If you can't get a "dummy" high-record as dbz suggested and you can't follow Mr Bill's suggestion...
Why is it so necessary to read backwards? |
|
Back to top |
|
|
Peter cobolskolan
Active User
Joined: 06 Feb 2012 Posts: 104 Location: Sweden
|
|
|
|
When you are using Browsing you should use partial key in your Startbr.
When you look for the last occurance of Cust/Dept 11, use keyvalue 11, keylength(2) GENERIC GT to position at the next available record which has a Cust/Dept greater than 11, any number of exp. Then your Readprev will get the previous Cust/Dept with the highest exp-value.
The last problem you mention, Eibresp=16, Invalid Request (?), indicates that the request is invalid! Perhaps no previous Startbr that has response normal. |
|
Back to top |
|
|
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
To save TS some reading, what does starting the browse beyond the last recod on the file give, your way, Peter? |
|
Back to top |
|
|
Thagun
New User
Joined: 25 Jul 2008 Posts: 15 Location: Chennai
|
|
|
|
Thanks Bill, I just wanted to get it confirmed in the forum that it cannot be done without a trailer record.
There is an existing code which says i reads the file in reverse direction, but when I tested it, it wasnt working for the scenario i had explained.
Thanks again for yor response. |
|
Back to top |
|
|
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
Good for being thorough.
Not so good for being unclear and lacking the full detail in the first place. It would have helpd. Next time, you'll give it all up front? |
|
Back to top |
|
|
Thagun
New User
Joined: 25 Jul 2008 Posts: 15 Location: Chennai
|
|
|
|
Sure Bill. Having clarity and all required details in the question is one of the things i have learnt today . |
|
Back to top |
|
|
|