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

 September 13, 2009

By  NickLitten

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.



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"}
__CONFIG_colors_palette__{"active_palette":0,"config":{"colors":{"cff50":{"name":"Main Accent","parent":-1},"a344d":{"name":"Accent Transparent","parent":"cff50"}},"gradients":[]},"palettes":[{"name":"Default","value":{"colors":{"cff50":{"val":"var(--tcb-skin-color-0)"},"a344d":{"val":"rgba(46, 138, 229, 0.85)","hsl_parent_dependency":{"h":210,"l":0.54,"s":0.78}}},"gradients":[]},"original":{"colors":{"cff50":{"val":"rgb(0, 178, 255)","hsl":{"h":198,"s":1,"l":0.5}},"a344d":{"val":"rgba(0, 178, 255, 0.85)","hsl_parent_dependency":{"h":198,"s":1,"l":0.5}}},"gradients":[]}}]}__CONFIG_colors_palette__

Get In Touch

I’m always looking for awesome input, feedback and critique!