Last three records from physical file using RPGLE

10 pts.
Tags:
AS 400
RPGLE
How to retrieve last three records from a physical file using RPGLE

Answer Wiki

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

It can be done depending on how the file is defined in the program. If it has a key, use the SETGT to point to the end of file using the highest key value then do a READP in a DO loop for 3 repetitions.


For files with no key you can try one of these other options
*LOVAL, *HIVAL, *START, *END or we can use RRN VALUE

Discuss This Question: 4  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.
  • azohawk
    I was going to post the same as Toad did, he just got here first.
    3,455 pointsBadges:
    report
  • ToddN2000
    @Azohawk: Toad? How did you know my nickname from elementary school?...lol brought back memories...
    102,460 pointsBadges:
    report
  • azohawk
    Sorry that was typo, but funny coincidence.
    3,455 pointsBadges:
    report
  • TheRealRaven
    The methods are different and dependent upon the meaning of "last" as well as on the full definition of the physical file.

    Do you want the "last" three records that were physically added to the file? Do you want the "last" three records from a key sequence? Do you want the "last" three records from the physical end of the file? All three will require different logic.
    24,375 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.

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

Following

Share this item with your network: