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.