I always forget the differences between %EOF, %EQUAL and Not %Found when writing native file I/O in RPG ILE Programs. Sometimes a file record is %found and sometimes its not. Even after all these years I still scratch my head about which one is which.
I know, I know – I should be using SQL right? SQL does things differently so these problems don’t bite us – but us crusty old time RPG chaps still have a secret soft-spot for good old fashioned chains don’t we?
I tend to copy blocks of code when writing source, it’s all too easy to copy a block of logic doing a subfile readc and change it to a chain without changing the %EOF to a %found. Which is exactly what I’ve been doing today. Of course, this ends up with chains looking for %EOF which compiles just fine. Grrrrr.
Since chain doesn’t necessarily set the file pointer to “end of file” sometimes I execute the NOT %eof( ) logic. Bloody annoying and not easy to spot a simply typo like this.
So, here is a quick little cheat sheet of which built in function to use with which command:
One further note – SETLL checking for %found means it positioned before the key but %EQUAL means it found the exact key.
IBM i Software Developer, Digital Dad, AS400 Anarchist, RPG Modernizer, Alpha Nerd 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 in the words of the most interesting man in the world: Stay thirsty my friend.
Convert RPG Datefield %DATE into a signed numeric
When the RPGLE %EOF BIF is not the End of File
RPG Built-In Functions %BIF
What is IBM i Email and SPF?
Updating Numeric DTAARA in RPGLE
How to capture IBM-i job info for submitted jobs
Register license key in SOFTLANDING SOFTMENU
Going the (Levenshtein) Distance in RPG Free
Don’t hardcode library names in your TURNOVER SQL source #youbigsilly