Upgrade RPG CALL statement to RPGLE Procedure call 

 January 7, 2016

By  NickLitten

Back in the olden days – RPG was this column based thing that looked magical and quite unlike any other programming language. But, it’s a new age and RPG has evolved, added a sprinkle of ILE pixie dust and now lets us code fully backwards compatible programm calls in a much neater format free’d from old column constraints.

It’s easy to refactor old CALL STATEMENTS and make them in to modern PROCEDURES. It looks nicer. It’s easier to read.

Lets see how to do it:

Old style program calls might look like this:

C           Call  'SY7020R01' 
C           Parm               ServiceOrder 
C           Parm               ScheduleCode 
C           Parm               s@Units 
C           Parm               s@AppDate 
C           Parm               s@DropDays 
C           Parm               s@ResultDate

So to make this into a PROCEDURE style call we would define the procedure like this:

dcl-pr addWorkDaystoDate extpgm('SY7020R01'); 
  *n char(9) const; // ServiceOrder 
  *n char(5) const; // ScheduleCode 
  *n zoned(5); // s@Units 
  *n packed(8); // s@AppDate 
  *n zoned(2); // s@DropDays 
  *n zoned(8); // s@ResultDate 

Note that I defined the size of each parameter and added a //comment to tell anyone what that parameter is.

Also note that I defined CONST against the first two parameters because in this case, those two are static (non-changing) values and its the S@* values that are being returned from the program that I’m calling.

I looked at the program being called pgm(SY7020R01) and found that it was a program for adding days to a business day for work orders. So, I decided to call my procedure ‘addWorkDaystoDate

Now to use this in my code I can replace that original RPG400 block of code with this RPGLE block of code:

addWorkDaystoDate( ServiceOrder : 
                   ScheduleCode : 
                   s@Units : 
                   s@AppDate : 
                   s@DropDays : 
                   s@ResultDate );


Modernizing old RPG code is fun.

Most recently I’ve been formatting my procedure calls like this:

addWorkDaystoDate( ServiceOrder  
                 : ScheduleCode  
                 : s@Units  
                 : s@AppDate  
                 : s@DropDays  
                 : s@ResultDate

I know code style is a personal thing but I like this layout because it draws my eye to each parameter and also let me easily copy/paste or re-order parms while in the IDE Editor.



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"}

Get In Touch

Iā€™m always looking for awesome input, feedback and critique!


Snug CBD

 20% Discount

I have partnered with SNUG CBD givING you Organic CBD
20% discount code "NL20"