How to tell if a specific record comes before or after another specific record?

5 pts.
Tags:
RPG ILE
RPGLE
In RPG ILE, I have an externally described file. I am chaining out to the logical file with a key & find the first record. Now, I want to know if the second record I'm looking for is before or after the first record in the file.

Answer Wiki

Thanks. We'll let you know when a new response is added.

Stckrb

Here is a good site:

http://publib.boulder.ibm.com/iseries/v5r2/ic2924/books/c092508378.htm

The file Information data structure contains this info

FMYFILE IF E DISK INFDS(DBFBK)

DDBFBK DS
D DB_RRN 397 400I 0 * Relative-rcd-num

This should give you the physical file relative record number.

Discuss This Question: 9  Replies

 
There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy
  • Obierun
    I am sure you have a good reason for asking this, but I am not sure why this is necessary. Would you not be better off abandoning the chain, which the last time I looked did not guarantee to retrieve the first or last or any record identified by the key, but instead do a setll (or setgt) on the file and reade (or readpe) to get the records you are really after?
    60 pointsBadges:
    report
  • philpl1jb
    I was guessing that even though the program access the records through a logical with chains or a read loop the programmer needs to know which record arrived in the physical file first. Obviously a timestamp field would be ideal.
    50,860 pointsBadges:
    report
  • WoodEngineer
    The following is true ONLY if your file does not reuse deleted records and has never been re-organized. When a file contains multiple records with exactly the same key, your chain will return the record with the lowest record number first. A subsequent READE operation will return a record with a higher record number, same key. You can prove this by inspecting the RRN returned in the file info data structure. It is not necessary to do a SETLL and READE instead of a chain. Same results either way. We had this discussion in our shop a last year and ran a test. Once your file has been re-organized, this techinque will not work because there is not guarantee that the lowest record number in the original file will still be the lowest in the re-org'ed file. The keys will be just fine - no worries there.
    6,765 pointsBadges:
    report
  • philpl1jb
    WoodEngineer is right. If the entire key is the same - not just the fields used for this access. Otherwise it's get the RRN. But It's a shame we haven't gotten feedback from Stckrb
    50,860 pointsBadges:
    report
  • TomLiotta
    I want to know if the second record I'm looking for is before or after the first record in the file. Please define "before" and "after". If you are using CHAIN, are you CHAINing by a key value or by relative record number? If you are CHAINing by key, the only rational meaning of "before" and "after" is "lower key" and "higher key". Is the file defined in RPG as 'K'eyed? Or are you expecting to get the second record from a different open data path? Does the file have a FIFO or LIFO attribute? Is it opened as SEQONLY(*YES)? How are you expecting to get the second record? How will you recognize the second record? Overall, the question doesn't seem to make any sense. More explanation is clearly required. A lot of questions can be asked to try to come up with a meaningful answer. Tom
    125,585 pointsBadges:
    report
  • DanTheDane
    Jun an SQL against your physicl file. The SQL shall be something like this
    SELECT myfield1, RRN(myfile) 
    FROM myfile 
    WHERE myfield1 IN (mydata1, mydata2)
    
    I hope it helps. DanF
    2,555 pointsBadges:
    report
  • philpl1jb
    You guys .. . But It’s a shame we haven’t gotten feedback from Stckrb October 31, 2008 But in September 2010 you act like you can elicit a response. Phil
    50,860 pointsBadges:
    report
  • carlosdl
    "But in September 2010 you act like you can elicit a response." :-) :-) :-)
    70,200 pointsBadges:
    report
  • TomLiotta
    A discussion doesn't require a response from the OP. Although it can be necessary in order to give an appropriate answer to a question, technical details around the issue can be even more valuable for the "Wiki". Besides, I haven't seen a huge differences in getting responses from 2008 and from 2010! :-) Tom
    125,585 pointsBadges:
    report

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

To follow this tag...

There was an error processing your information. Please try again later.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Thanks! We'll email you when relevant content is added and updated.

Following