When IBM introduced RPG IV (RPGLE) back in the mid 90’s, most of the RPG III opcodes were converted into built in functions. This makes for more readable code and efficient programming. The built in functions each do a particular function just like any opcode would have done. Since the built in functions are provided by the system itself, all the error handling etc is done by the system itself and you are given just the errors.
When we learn RPGLE procedures, we will see that the built in functions are very similar to procedures. Within the %BIF itself, ‘arguments’ (the important bits defining what the BIF is doing) are denoted by a colon. Here is an example:
// Look on a file called 'SOMEFILE" and if that key 'CompanyCode' is found then do something... Chain CompanyCode SOMEFILE If %Found(SOMEFILE)
Of course, we can get complex and use %BIFS for some really neat functions. All in one line of code this operation is saying – take the value #STRDATE which is *MDY format and convert it to *CYMD then make that date variable into a 7 long alpha character field before finally turning it into a 7,0 numeric value (which is how the dates are stored on the files in this program).
// convert screen dates from MMDDYY to 7,0 numeric in CYYMMDD format =%dec(%char(%date(#StrDate:*mdy):*cymd0):7:0);
Some important built in functions are given in the list below.
RPGIV Built-in fucntion Action Performed
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.
Updating Numeric DTAARA in RPGLE
Going the (Levenshtein) Distance in RPG Free
Which %BIF for Chain, Read and other naughty native file IO
Convert RPG Datefield %DATE into a signed numeric
When the RPGLE %EOF BIF is not the End of File
How to Install IBM Access Client Solutions (ACS)
IBM i Data Obfuscation – Making Data Foggy Murky and Squinty
How to rename Fresche (BCD) Presto Library – XL_PRESTO
What is AS400 modernization?