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
 

 

Reading Last Record in KSDS VSAM File

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

New User


Joined: 25 Jul 2008
Posts: 15
Location: Chennai

PostPosted: Wed May 23, 2012 8:02 pm    Post subject: Reading Last Record in KSDS VSAM File
Reply with quote

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
View user's profile Send private message

dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6966
Location: porcelain throne

PostPosted: Wed May 23, 2012 8:07 pm    Post subject:
Reply with quote

maybe add a control record, 9 9 999, to the file?
Back to top
View user's profile Send private message
Bill O'Boyle

CICS Moderator


Joined: 14 Jan 2008
Posts: 2502
Location: Atlanta, Georgia, USA

PostPosted: Wed May 23, 2012 8:20 pm    Post subject: Reply to: Reading Last Record in KSDS VSAM File
Reply with quote

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
View user's profile Send private message
Thagun

New User


Joined: 25 Jul 2008
Posts: 15
Location: Chennai

PostPosted: Wed May 23, 2012 8:20 pm    Post subject: Reply to: Reading Last Record in KSDS VSAM File
Reply with quote

Its an existing file and cannot be changed to include header n trailer.
Back to top
View user's profile Send private message
Thagun

New User


Joined: 25 Jul 2008
Posts: 15
Location: Chennai

PostPosted: Wed May 23, 2012 8:24 pm    Post subject: Reply to: Reading Last Record in KSDS VSAM File
Reply with quote

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
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 7904
Location: Bellevue, IA

PostPosted: Wed May 23, 2012 8:46 pm    Post subject:
Reply with quote

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
View user's profile Send private message
Thagun

New User


Joined: 25 Jul 2008
Posts: 15
Location: Chennai

PostPosted: Thu May 24, 2012 10:22 am    Post subject: Reply to: Reading Last Record in KSDS VSAM File
Reply with quote

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
View user's profile Send private message
chandan.inst

Active User


Joined: 03 Nov 2005
Posts: 269
Location: Mumbai

PostPosted: Thu May 24, 2012 11:33 am    Post subject: Re: Reading Last Record in KSDS VSAM File
Reply with quote

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
View user's profile Send private message
Thagun

New User


Joined: 25 Jul 2008
Posts: 15
Location: Chennai

PostPosted: Thu May 24, 2012 1:14 pm    Post subject: Reply to: Reading Last Record in KSDS VSAM File
Reply with quote

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
View user's profile Send private message
Bill Woodger

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7223

PostPosted: Thu May 24, 2012 1:23 pm    Post subject: Reply to: Reading Last Record in KSDS VSAM File
Reply with quote

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
View user's profile Send private message
Peter cobolskolan

Active User


Joined: 06 Feb 2012
Posts: 104
Location: Sweden

PostPosted: Thu May 24, 2012 1:51 pm    Post subject: Reply to: Reading Last Record in KSDS VSAM File
Reply with quote

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
View user's profile Send private message
Bill Woodger

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7223

PostPosted: Thu May 24, 2012 2:05 pm    Post subject: Reply to: Reading Last Record in KSDS VSAM File
Reply with quote

To save TS some reading, what does starting the browse beyond the last recod on the file give, your way, Peter?
Back to top
View user's profile Send private message
Thagun

New User


Joined: 25 Jul 2008
Posts: 15
Location: Chennai

PostPosted: Thu May 24, 2012 2:13 pm    Post subject: Reply to: Reading Last Record in KSDS VSAM File
Reply with quote

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
View user's profile Send private message
Bill Woodger

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7223

PostPosted: Thu May 24, 2012 2:21 pm    Post subject: Reply to: Reading Last Record in KSDS VSAM File
Reply with quote

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
View user's profile Send private message
Thagun

New User


Joined: 25 Jul 2008
Posts: 15
Location: Chennai

PostPosted: Thu May 24, 2012 2:27 pm    Post subject: Reply to: Reading Last Record in KSDS VSAM File
Reply with quote

Sure Bill. Having clarity and all required details in the question is one of the things i have learnt today icon_biggrin.gif.
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 Add PD field from 2nd file to PD in 1st Sushant Garje DFSORT/ICETOOL 6 Thu Dec 01, 2016 4:32 pm
No new posts File Aid to File Manager conversion murali3955 IBM Tools 4 Thu Nov 24, 2016 3:41 pm
No new posts How to convert the VBM file to VB or... Sulabh Agrawal JCL & VSAM 4 Fri Nov 18, 2016 1:04 pm
No new posts CICS Roll back partially - Need to re... dwijadas CICS 4 Wed Nov 16, 2016 4:30 pm
No new posts Problem in writing Output file vickey_dw COBOL Programming 5 Mon Nov 14, 2016 11:14 pm


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