RPG Evolution, Modernization and Refactoring – Step 4 of 4 – Setting RPG Free


Sep 13

Setting RPG Free

Convert RPG from Column to free format

So, if we take the code and actually upgrade it to be the current style of RPG/Free we can see all the mainline specs are now written in freeform code style and it looks yummy:

h datfmt(*iso) timfmt(*iso) option(*nodebugio) debug
 // system name: fix slp06
 // program desc: fix the records on slp06 - Setting RPG Free
 // program no: ef001
‚Äč // date: 09/09/09 (sadly not at 9:09)
 // author: nick@nicklitten.com
 Fefp01l01 if e k disk infsr(*pssr)
 Facsummar uf e k disk infsr(*pssr)
 // Externally defined file defn's for *LDA and *PSDS
 D lda e ds extname(lda) dtaara(*LDA)
 D pstat esds extname(psds)
 in lda;

setll l#cono acsummar; reade l#cono acsummar; dow not %eof(acsummar); // get customer order total from work file (efp01) which // is generated by accumulating OEP65 invoices chain cusn06 efp01l01; if %found(efp01l01); bodv06 = amount; else; bodv06 = 0; endif; update slr06; // Update Account Balances new Order Total reade l#cono acsummar; enddo; // --- Program Termination --- out lda;

*inlr = *on; //standard error handling routine. /include qgpl/qrpglesrc,pssr /end-free
Setting RPG Free

‚ÄčThis is the same program in RPG Free Format.

As you can see, I’ve spaced the code out to make it more readable, added comments, Key Lists are now listed by field and Eval statements are not required and generally kicked it around a bit.

I think it’s a huge improvement in readability.

Easier code to read means easier to maintain means saving time means saving money!

What do you think?

Want to read an IBM primer on coding with the RPG language?

JULY 2017 UPDATE: It’s been a long time since I wrote this blog. Here is the code in RPG4 /FREE format that was released as a further enhancement to RPG earlier this year.


About the Author

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.

%d bloggers like this: