20 pts.
 READE – RPGLE
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
ASKED: February 18, 2010  8:59 PM
UPDATED: May 20, 2011  10:48 AM

Answer Wiki:
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
Last Wiki Answer Submitted:  February 19, 2010  3:07 am  by  CoderHal   350 pts.
All Answer Wiki Contributors:  CoderHal   350 pts. , Finkpad   60 pts.
To see all answers submitted to the Answer Wiki: View Answer History.


Discuss This Question:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _


 

Thank you so much! That totally took care of my problem!

 20 pts.