CALL an Old Friend
The first and easiest of the opcodes is the CALL. This is the one every RPG programmer is familiar with, probably more than we should be nowadays. A CALL is a direct evocation of a *PGM object type. I generally refer to this opcode as the "evil CALL" because it has all of the guilt and none of the pleasure of the other CALLs. It is very simple and produces simple results, including additional overhead of resources for each CALL that is executed. Not exactly the most efficient way of operating.
Why Won't You CALLB?
The CALLB, a CALL to a Bound procedure is superior to a CALL in that it evokes a procedure that is already bound along with the calling routine. One of the recurring themes in the questions I've received suggests that there is some confusion about whether a module and a procedure are one and the same. They are not. Let me share a couple of hints that should keep you off the road of confusion. First, omit the word "procedure" in the definition of CALLB. Next, think of CALLB as a CALL to a Bound object, which at least for the present, would be those of type *MODULE.
Take note that *MODULE objects can exist on their own or as part of a service program (object type *SRVPGM) but CALLB does not call service programs. CALLB calls the *MODULE objects within a service program.
CALLP Confused!
The last opcode is the CALLP. CALLP can be understandably confusing because it is actually two commands in one. Depending on what you've read and where you've read it, CALLP could stand for CALL to a Prototyped Procedure or CALL to a Prototyped Program.
When CALLP is used for a prototyped program procedure, it is always in conjunction with the EXTPGM keyword. Remember that! The only way an external program can be evoked without prototyping is by utilizing a CALL. This is something I would not advise you to do. To properly call an external program in today's land of RPG IV, prototype the program!
When CALLP is used for an internally defined procedure prototype, no keywords are used. This is the case many times when you create a prototype for yourself. If the procedure is externally defined, such as a C language function like atoi( ), use the EXTPROC keyword on the prototype.
Think of EXTPROC and EXTPGM as the parameters for procedure prototype aliases and nothing more than that. This will simplify your understanding of how they work. The target of the EXTPGM procedure prototype keyword is the program that will be invoked by the procedure call (CALLP). The target of the EXTPROC procedure prototype keyword is the subprocedure that will be invoked by the procedure call (again, a CALLP).
So, Who You Gonna CALL?
I hope this clarifies some potential misconceptions about the various CALLs available within RPG IV. I would suggest making CALLP your best friend in today's world of coding with CALLB being the second most likely CALL to use. With the power inherent in today's RPG IV language, whether you are using free-format or not, I would hope to never again need to see a CALL of the old variety in any new RPG code! Learn the new opcodes if you haven't already! Use them when needed. And by all means if you have questions, ask your favorite RPG guru or refer to your favorite RPG IV text!
--Vincent B. Goldsby
LATEST COMMENTS
MC Press Online