.st0{fill:#FFFFFF;}

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 ---
EndIF;

and Code (hint this code is correct!):

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

And why would you use one over the other?

Answer:

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

NickLitten


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:

Swap Homes and Travel the World – Join Home Exchange
Surf the Web Securely with OPEN DNS
IBM i Software Change Management – CMS vs ALM – What’s in a Name?
Want to learn CL Programming?
  • {"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!

    >

    Snug CBD

     20% Discount

    I have partnered with SNUG CBD givING you Organic CBD
    20% discount code "NL20"