AS/400 RPGLE: Difference between readp and readpe opcodes

450 pts.
Tags:
AS 400
RPGLE
What is the difference between readp vs readpe opcodes
1

Answer Wiki

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

the short of it is one reads previous record regardless of conditions the other reads previous record equal to the key being used.

Discuss This Question: 2  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

    Similar to the difference between read and reade. Read/Reade process forward while Readp/Readpe process backward though the file.

    I might use read prior when by data is sorted by date and I want to process the data in my file in newest to oldest. I will use a setgt *end statement, then read prior or read prior equal.

    3,990 pointsBadges:
    report
  • GregManzo
    Another use - when adding a new line to an order. Assuming your Order Detail file is keyed by (Order, Line) and you want your new line number to be one greater than the last line, something like this:
    SETGT (Order) OrdDtl;
    READPE (Order) OrdDtl;
    If %eof();
      NewLine = 1;
    Else;
      NewLine = Line + 1;
    EndIf;

    Here the READPE will not get a record from outside the current Order, so if this is the first line being added you get %eof() {beginning really} and can set it to line 1. If you had used a READP you would have read the last line of the previous order - not helpful.
    2,905 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: