READE – RPGLE

25 pts.
Tags:
READE
RPGLE
SETLL
When doing a.. SETLL (parm1:parm2:parm3) READE (parm1:parm2:parm3) IF %FOUND OCCASIONALLY IT COMES BACK AS FOUND WHEN THE RECORD IS CLEARLY NOT IN THE FILE. ANY IDEAS? THIS IS THE STRANGEST THING.

Software/Hardware used:
AS/400 RPGLE

Answer Wiki

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

Do not use %FOUND for READ statements use %EOF (or NOT %EOF) to be more accurate…. the %FOUND can be used for checking the CHAIN. %eqaul can be used for SETLL …. Also suggest always qualifing %eof, %found etc with (filename). Example %found(FILENAME)

======================================================

READE doesn’t set %FOUND().

The %FOUND() BIF was set *ON or *OFF by the earlier SETLL. However, %FOUND() <i>does not</i> mean that a record with the desired key was found; it means that a <i>lower limit</i> was “found”. (That’s what SETLL looks for — a lower limit, “LL”.)

So, SETLL finds a position within the file that satisfies the lower limit and %FOUND correctly returns *ON. Then READE tries to read a record with an equal key, but there is no match — it runs into the record that comes after the lower limit.

%FOUND remains unchanged from SETLL since READE doesn’t set it. %EOF should come on from the unsuccessful READE because the set of equal record keys is exhausted.

As noted by Finkpad, consider using %EQUAL with SETLL. That will tell if a record actually exists. And use %EOF with READE. CoderHal’s comment about qualification should also be your default style.

Tom

Discuss This Question: 1  Reply

 
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
  • Bix
    Thank you so much! That totally took care of my problem!
    25 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