RPGIV @ Work

A unique site for RPG and System i Lovers


Hi, this site will provide all what you need in System i and RPG developments.

My Name is Chamara Withanachchi, System i Expert and RPG Developer. And in the field for last 11 years.

I hope you will find lot of valuable information from this site

Comparing the RPG IV CALL Operations Print E-mail
User Rating: / 0
Written by Chamara Withanachchi   

By : Vincent Goldsby


Over time, realize that many people don't understand the various forms of RPG IV CALL operation codes available. Here, I hope to shed some light on them.



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.



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.



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).

<Previous   Next>