I’ve recently been writing all my new programs in RPG Free format. Attending RPGWORLD earlier this year, gave me the impetus to finally commit myself to the new and improved style of RPG coding.
I’m currently in contract at a shop that still has twenty year old programs running in production, the developers still write in RPG3 and shun any development techniques that have been introduced this century. “I havent got time to learn all that newfangled business” is the war cry. “Thats why your code is unreadable, the system runs like a dog, change management is out of control and there are so many bugs” is my silently worded response.
As an RPG programmer I am amazed that other programmers are simply not interested in learning the benefits of the latest generations of RPG. There are lots of flavours and any programmer worth his salt should be proficient in all of them: RPG2, RPG3, RPG400, RPGILE, RPG4, RPG/Freeformat
I wish IBM had simply named it RPG1-2-3-4-5 but in true befuddling IBM style the Report Program Generators language naming structure is nearly as poor as the naming standards for the System i itself.
Anyway, I digress, my task yesterday was to write a bunch of little utility programs adding up various elements of the JBA System21 Accounts Receivable database to compare values with what was stored in the accounts hierarchy.
For example, “Does the total value of orders actually match all the orders added together?” and “How many invoices and how are outstanding this year by month” relatively simple to write and the first program was already written.
This first program was, quite amazingly, written in 2008! Some programmers are frozen in the land of the 1980’s and refuses to move up from RPG3. The old style code works, dont get me wrong, but can be easily upgraded to a twenty year newer version which is vastly more readable, efficient and easy to maintain – in a few simple steps.
So here’s the code:
H 1 * program to fix SLP06 records FEFP01L01IF E K DISK KINFSR *PSSR FACSUMMARUF E K DISK KINFSR *PSSR ILDA E DSLDA IPSTAT ESDSPSDS C *NAMVAR DEFN *LDA LDA C IN LDA C K01 KLIST C KFLD CUSN06 C L#CONO SETLL ACSUMMAR C L#CONO READE ACSUMMAR 06 C *IN06 DOWEQ *OFF C K01 CHAINE FP01L01 02 C *IN02 IFEQ *OFF C Z-ADD AMOUNT BODV06 C ELSE C Z-ADD 0 BODV06 C END C UPDAT SLR06 C L#CONO READE ACSUMMAR 06 C END C SETON LR C OUT LDA /COPY OSLCOPYSRC/QRPGSRC,PSSR
Notice there are no comments, not even an author name.
I decided to take this program and upgrade it to RPG/FREE so I can show him the thought process between versions and hopefully entice him to write newer code: RPG Free Format is neater, easier to read and more efficient.
So, I’ve broken it into 4 very simple steps
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.
RPG Evolution, Modernization and Refactoring – Step 5 of 4 – RPG FREE FORMAT 2017
Dirty RPG programmers need to write Clean RPG Code
IBM i create JOBLOG from RPGLE /FREE – a QMHSNDPM code example
Write to joblog messages from RPGLE /FREE – easy code example using Qp0zLprintf
RPG example: Talk to a Webservice and store reply XML or JSON in IFS
Write RPG joblog messages – simple code example
How to add the Turnover V100 Perspective to WDSC7
Example RPGLE web service program [SOAP]
DSPF Function Keys and the Hex AID Byte from the INFDS