RPG Evolution, Modernization and Refactoring – Step 3 of 4 – Paroling RPG4

IBM i

Sep 13

Upgrade RPG4 to use free-friendly code standards

If we were using Rational Developer/i software we could do this automatically. But as a manual process its simple, if a little tedious. Basically when we are going to skim through the code and replace all indicators with the modern and preferred %FOUND BIF technique:
 H debug
 *****************************************************************
 * 
 * system name: fix slp06 
 * 
 * program desc: fix the records on slp06 
 * 
 * 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)
 D lda e ds extname(lda)
 D pstat esds extname(psds)
 C *dtaara    define *lda lda
 C            in     lda
 C l#cono     setll   acsummar
 C l#cono     reade   acsummar
 C            dow     not %eof(acsummar)
 C cusn06     chain   efp01l01
 C            if      %found(efp01l01)
 C            eval    bodv06 = amount
 C            else
 C            eval    bodv06 = 0
 C            endif
 C            update  slr06
 C l#cono     reade   acsummar
 C            enddo
 C            eval    *inlr = *on
 C            out     lda
  *****************************************************************
  * standard error handling routine.
  /Copy qgpl/qrpglesrc,pssr
Not that all indicators have been removed and I would also change Z-ADD, MOVE and MOVEL statements into EVAL’s. I switch the code into lowercase, a personal preference, because I like it that way.

At this point I added some commenting, cause thats the kind of guy I am.

Last but not least is the conversion to RPG /FREE

  1. Take the code and upgrade it to RPG/4
  2. Tidy the Code
  3. Do some Refactoring and make it smile
  4. Evolve to RPG4 and make it awesome
Follow

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.