4,990 pts.
 AS400: copybook or module? …or…other?
I'm on V6R1, using WDSCi 7 to program in RPG IV.  I've accumulated a number of functions that I use in quite a few of my programs, and I was thinking it might be a good idea to go ahead and place them as subroutines (may be wrong terminology) in a copybook.  But, having done some research, there are downsides to using a copybook. So, what should I use?  I've never done this kind of thing on the AS400 before, so I'd like to do it right the first time.  :) I also read about modules, but they seem very unwieldy to use since you appear to have to use a different compile command and I don't even begin to understand how the syntax-checking could work... And then there is the whole service-program idea.  My head still hurts after the hoops I had to jump through to make the last one work. Maybe I have a lot of misinformation and there really is a simple way to do what I want to do.  Please help me make the right choice!  Thanks for your help!!

Software/Hardware used:
AS400 V6R1 RPG IV
ASKED: September 11, 2009  12:35 PM
UPDATED: September 14, 2009  8:08 PM

Answer Wiki:
I believe creating a *SRVPGM with multiple procedures is what you want to do. It is a different concept, that needs to be learned. Like anything else, the unknown is hard, and once you have the answer, it seems simple. Send me an email at charliebrowne99@gmail.com and I will try to send you some samples. There are some great books out there that you should pick up to help you learn. To make lit easier for yourself, you can create PDM options to do your complies.
Last Wiki Answer Submitted:  September 11, 2009  2:15 pm  by  CharlieBrowne   32,825 pts.
All Answer Wiki Contributors:  CharlieBrowne   32,825 pts.
To see all answers submitted to the Answer Wiki: View Answer History.


Discuss This Question:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _


 

Instead of subroutines, I meant to say that I was wanting to make subprocedures out of these commonly used functions (which are already subroutines, but I have to currently copy/paste them into each pgm).

 4,990 pts.

 

Subprocedures would be the “ILE” way.
Sometimes it’s more practical to make a callable program. Mainly depends on likelyhood that this subprocedure will be modified later. If so, a subprocedure would need to be re-linked to each using program while a callable program needs no re-link.
The cost of a callable routine is in performance.

 1,565 pts.

 

If you package the common procedures into a service program, nothing needs to be relinked if any of the logic in the the procedures has to be changed later on. It is only when their interfaces / signatures change, i.e, the number or type of parameters being sent or returned, that you would need to recompile the calling modules. And using binder language, you can even have the service program be backwards compatible by maintaining as many previous signatures as you want to support. This way, existing modules don’t have to be recompiled as long as they don’t need to send the new parameters, or don’t need to use the new procedures that may be added into the service program over time.

This is one of the ways in which ILE is a more powerful and flexibile development methodology than the OPM (original program model).

 4,275 pts.

 

Thanks for the ideas! I think I will go the route of having a service program to handle these functions for me! I appreciate all the help from everyone! ^_^

 4,990 pts.