RPG Evolution, Modernization and Refactoring – Finally some modern RPG FREE FORMAT

Convert it to RPG FREE FORMAT -- RPG Evolution 2017 style

That's right -- this is step five of four.

Much like RPG evolution, the modern day free-form RPG code is way more advanced than earlier neanderthal column based RPG.

The original code blog was way back in 2009, but RPG has quietly been improving all the time since then. IBM release new opcodes, built in functions, source snippets all the time. Most recently, we had a quite big update which gets rid of H, F and D specs and allows us RPG Nerd to code in almost entirely freeformat.

// system name: fix slp06
// program desc: fix the records on slp06 showing RPG EVOLUTION
// program no: ef001
// date: 2017.07.12
// author: nick@nicklitten.com

ctl-opt datfmt(*iso) timfmt(*iso) option(*nodebugio) debug;

dcl-f EFP01L01 keyed infsr(*pssr);
dcl-f ACSUMMAR keyed usage(*update) infsr(*pssr);

// Externally defined file defn's for *LDA and *PSDS
dcl-ds lda extname('LDA') dtaara(*lda) end-ds;
dcl-ds pstat ext PSDS extname('PSDS') end-ds;

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;
    bodv06 = 0;
  update slr06; // Update Account Balances new Order Total
  reade l#cono acsummar;

// --- Program Termination ---
out lda;
*inlr = *on;

//standard error handling routine.
/include qgpl/qrpglesrc,pssr

This is the same old 2009 program in RPG Free Format -- aka RPG4 -- AKA RPGLE /Free.

I really enjoy coding in the latest /freestyle format of RPG. It makes coding easy, very readable and much easier to maintain. No more lining up screens of code, easy formatting and creation of code snippets (using code editing tools like RDi) and the look and feel of RPG has finally caught up with other modern languages.

As I said in the earlier blogs " 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?
{"email":"Email address invalid","url":"Website address invalid","required":"Required field missing"}