RPGLE %eof, %equal, %found – whats the difference? 

 October 7, 2009

By  NickLitten

ILE RPG – has wonderful built in functions to replace the smelly old *indicator techniques in old RPG3. The modern generation of RPGLE %eof, %equal, %found %BIFS let us accurately and clearly handle native file IO.

The trouble is; using the wrong built in function can be easy to do and sometimes not easy to spot an obvious error. It’s not as annoying as coding an indicator on the wrong column in old style RPG3 or RPG400, but it’s still thoroughly frustrating when you stare at a CHAIN statement and cant figure out why its not working. Only to realise that you should have checked for %FOUND rather than %EOF  šŸ™‚

RPGLE %eof, %equal, %found

So whats the difference between (hint this code is wrong!):

Chain (keyfields) filename;
If Not %eof( filename );
--- do something ---

and Code (hint this code is correct!):

Chain (keyfields) filename;
If %Found( filename )
--- do something ---

And why would you use one over the other?


if you are using CHAIN then use %FOUND if your using READ then use %EOF

  • Chain – %Found
  • Check – %Found
  • CheckR – %Found
  • Delete – %Found
  • LookUp – %Equal, %Found
  • Read – %Eof
  • ReadC – %Eof
  • ReadE – %Eof
  • ReadP – %Eof
  • ReadPE – %Eof
  • Scan – %Found
  • SetGT – %Found
  • SetLL – %Equal, %Found
  • Write (subfile only) – %Eof

and there you have it

If you want to see a code example have a look here

snug cbd discount coupon 15% off

20% Off with Coupon: NICKLITTEN

I highly recommend the SNUG CBD Tincture to help keep you in the zone when programming!

In Partnership with SNUG CBD - American readers get 20% off


IBM i Software Developer, Digital Dad, AS400 Anarchist, RPG Modernizer, Shameless Trekkie, Belligerent Nerd, Englishman Abroad and Passionate Eater of Cheese and Biscuits. Nick Litten Dot Com is a mixture of blog posts that can be sometimes serious, frequently playful and probably down-right pointless all in the space of a day. Enjoy your stay, feel free to comment and remember: If at first you don't succeed then skydiving probably isn't a hobby you should look into.

Nick Litten

related posts:

  • {"email":"Email address invalid","url":"Website address invalid","required":"Required field missing"}

    Get In Touch

    Iā€™m always looking for awesome input, feedback and critique!