IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

How to get last RRN in the RRDS file?


IBM Mainframe Forums -> JCL & VSAM
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
rajesh_mbt

New User


Joined: 27 Mar 2006
Posts: 97
Location: India

PostPosted: Fri Aug 12, 2011 6:00 pm
Reply with quote

I want to retrieve last RRN from a RRDS file, i tried move -1 to the value of RIDFIELD in the STARTBR statement. But it is not giving the correct RRN while reading the file thru READPREV.

05 WS-LAST-RRN PIC S9(8) COMP.
MOVE -1 To WS-LAST-RRN

Please help me to get to the last RRN of the record.
Back to top
View user's profile Send private message
Bill Woodger

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Fri Aug 12, 2011 6:09 pm
Reply with quote

Why do you want this?

If the RRDS behaves like other types of VSAM, there isn't really a last number. If you add records, serially, and the dataset gets another extent, the "last number" changes. I've used RRDS's, for a dateset with widely varying numbers of records. Can't say I actually know that multiple extents were used, but I'd be surprised if not.
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 8696
Location: Dubuque, Iowa, USA

PostPosted: Fri Aug 12, 2011 6:28 pm
Reply with quote

Quote:
But it is not giving the correct RRN while reading the file thru READPREV.
What does it give you? What would be the CORRECT RRN as opposed to what you are getting?
Back to top
View user's profile Send private message
Bill O'Boyle

CICS Moderator


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

PostPosted: Fri Aug 12, 2011 6:36 pm
Reply with quote

Perhaps the file needs to closed/opened (catalog update) beforehand to obtain the last RRN as this is a requirement to obtain the last RBA in an ESDS file.

Bill
Back to top
View user's profile Send private message
rajesh_mbt

New User


Joined: 27 Mar 2006
Posts: 97
Location: India

PostPosted: Fri Aug 12, 2011 7:14 pm
Reply with quote

Thanks for all your swift response. This file is being updated by some other program, am just want to read it from my program.
Let assume, the file is updated and contains 100 records. I want to read backward from 100th record.

In order to do so, I should get 100 as the last RRN number.
My question is how do point/get the the last record(which is 100) on the file.
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 8696
Location: Dubuque, Iowa, USA

PostPosted: Fri Aug 12, 2011 7:25 pm
Reply with quote

Quote:
Let assume, the file is updated and contains 100 records.
I don't know if you are being deliberately obtuse, or if you just don't understand RRDS.

Assuming you are dealing with a fixed-length RRDS (since variable length RRDS would make what you want to do pretty much impossible any way) -- an RRDS contains a fixed number of "slots" for records -- the number is set by the record size and the number of tracks / cylinders / etc allocated to the RRDS. Those "slots" may contain data or they may be empty -- but they ALWAYS exist.

So when you say "contains 100 records", do you mean:
1. the RRDS was allocated with 100 slots?
2. the RRDS was allocated with an unknown number of slots and the first 100 have data?
3. the RRDS was allocated with an unknown number of slots and there are 100 slots that are not empty scattered through the entire file -- which is quite possible?
4. something else entirely that you have not yet explained?
Back to top
View user's profile Send private message
rajesh_mbt

New User


Joined: 27 Mar 2006
Posts: 97
Location: India

PostPosted: Fri Aug 12, 2011 7:26 pm
Reply with quote

Robert Sample wrote:
Quote:
But it is not giving the correct RRN while reading the file thru READPREV.
What does it give you? What would be the CORRECT RRN as opposed to what you are getting?

I am getting constanly a same number though file is being added the records with next sequence RRN icon_sad.gif .
I am not sure how is it possible to get same RRN as last record!!!
Is my move statement -1 to RIDFIELD correct? I am thinking this should be something else to point last record. icon_confused.gif
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 8696
Location: Dubuque, Iowa, USA

PostPosted: Fri Aug 12, 2011 7:32 pm
Reply with quote

Quote:
I am not sure how is it possible to get same RRN as last record!!!
Okay, so you do NOT know how RRDS works. Records added to an RRDS MUST fit into one of the existing slots. You are getting back the same RRN for the last record because the last record number will not change -- an RRDS file will not extend itself like ESDS or KSDS when records are "added", since the file must be pre-allocated with a given number of slots.

The manual states using -1 for RIDFLD will return the last slot number -- but again, that will be a fixed value that does not change until the file is deleted and redefined with a different number of tracks or cylinders in it. You cannot use the last RRN of an RRDS file to find the last record "added" since that will depend upon which slot the record was placed in.
Back to top
View user's profile Send private message
rajesh_mbt

New User


Joined: 27 Mar 2006
Posts: 97
Location: India

PostPosted: Fri Aug 12, 2011 7:35 pm
Reply with quote

Robert Sample wrote:
Quote:
Let assume, the file is updated and contains 100 records.
I don't know if you are being deliberately obtuse, or if you just don't understand RRDS.

Assuming you are dealing with a fixed-length RRDS (since variable length RRDS would make what you want to do pretty much impossible any way) -- an RRDS contains a fixed number of "slots" for records -- the number is set by the record size and the number of tracks / cylinders / etc allocated to the RRDS. Those "slots" may contain data or they may be empty -- but they ALWAYS exist.

So when you say "contains 100 records", do you mean:
1. the RRDS was allocated with 100 slots?
2. the RRDS was allocated with an unknown number of slots and the first 100 have data?
3. the RRDS was allocated with an unknown number of slots and there are 100 slots that are not empty scattered through the entire file -- which is quite possible?
4. something else entirely that you have not yet explained?


That 100 records i mentioned for an example. The file is already running for many years, so i've no idea on it. Also, I am not sure why you took that much complicated.
In general, how do you achiecve to get last RRN? Thanks for your response..
Back to top
View user's profile Send private message
rajesh_mbt

New User


Joined: 27 Mar 2006
Posts: 97
Location: India

PostPosted: Fri Aug 12, 2011 7:37 pm
Reply with quote

Robert Sample wrote:
Quote:
I am not sure how is it possible to get same RRN as last record!!!
Okay, so you do NOT know how RRDS works. Records added to an RRDS MUST fit into one of the existing slots. You are getting back the same RRN for the last record because the last record number will not change -- an RRDS file will not extend itself like ESDS or KSDS when records are "added", since the file must be pre-allocated with a given number of slots.

The manual states using -1 for RIDFLD will return the last slot number -- but again, that will be a fixed value that does not change until the file is deleted and redefined with a different number of tracks or cylinders in it. You cannot use the last RRN of an RRDS file to find the last record "added" since that will depend upon which slot the record was placed in.


Thanks Robert for your reply. Actully, am not familiar with RRDS thats why got confused.
Let me check at my end here too
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 8696
Location: Dubuque, Iowa, USA

PostPosted: Fri Aug 12, 2011 7:43 pm
Reply with quote

I took the time to explain all that because your problem is NOT how to get the last record of an RRDS in CICS -- that's easy; move -1 to the RIDFLD and do the READ. However, that record is NOT what you are wanting; you want the last updated record and that is a very big can of worms -- depending upon how the file is set up and used, the FIRST record (RRN zero) could have been updated last.

Without more information, and a LOT more understanding of RRDS files and the application on your part, what you are wanting cannot be done -- at least based on what you've given us so far.
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


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

PostPosted: Fri Aug 12, 2011 7:50 pm
Reply with quote

we always had a simplistic approach to rrds files.
the first slot always contained a field, the value of which was the next available.

no one can 'just add records to a rrds' without sometype of control.

as the TS said, "he don't know nothing".

this is a site specific thing, and should be handled by the TS asking someone there!
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 8696
Location: Dubuque, Iowa, USA

PostPosted: Fri Aug 12, 2011 7:55 pm
Reply with quote

Dick -- actually, this is not even a site-specific issue; it is an issue specific to that particular application at that site. I've known applications to use the first slot for control data, and I've known applications using the LAST slot for control data. But, as you said, records are not "added" to an RRDS -- a given slot is updated either from empty to containing data, or from containing data to containing other data.
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> JCL & VSAM

 


Similar Topics
Topic Forum Replies
No new posts Extract the file name from another fi... DFSORT/ICETOOL 6
No new posts How to split large record length file... DFSORT/ICETOOL 10
No new posts Extracting Variable decimal numbers f... DFSORT/ICETOOL 17
No new posts SFTP Issue - destination file record ... All Other Mainframe Topics 2
No new posts Access to non cataloged VSAM file JCL & VSAM 18
Search our Forums:

Back to Top