3

I have a module which has main procedure and sub procedures in it, the other scripts are using EXTPGM to call modules but few scripts are not using EXTPGM they are using CALLP, can anyone help me in understanding whether CALLP is dynamic call or static call in ILE RPG?

mrsorrted
  • 141
  • 1
  • 8
  • 1
    Cannot think of a good reason to use CALLP. I would convert the CALLP statements to PR defined procedure calls. Just to see it it breaks something. – RockBoro Apr 28 '21 at 03:26
  • 1
    @RockBoro that comment makes no sense. CALLP is [Call a Prototyped Procedure or Program](https://www.ibm.com/docs/en/i/7.4?topic=codes-callp-call-prototyped-procedure-program) – Charles Apr 28 '21 at 13:20
  • 1
    CALLP is used to call a procedure from fixed format RPG code. The C statement. In free format, a prototyped procedure is called by specifying the procedure name. There is no need in free format to use CALLP. I guess the question has to do with fixed format code. Also, thinking of CALLP as dynamic or static would confuse me. To understand CALLP, see it as an opcode added to RPG to support PR defined procedure or program calls from fixed format code. – RockBoro Apr 29 '21 at 12:57

1 Answers1

3

From the manual:

If the keyword EXTPGM is specified on the prototype, the call will be a dynamic external call; otherwise it will be a bound procedure call.

edit
resolution doesn't change. It's resolved during the first call. And not re-resolved as long as the program is active.

The exception to that rule is if EXTPGM() is used with a variable instead of a constant; and the value of the variable changes.

dcl-s pgmToCall varchar(21);
dcl-pr Mypgm extpgm(pgmToCall);
end-pr;

//SOMEPGM will be resolved twice
//  assuming the library list hasn't change
//  both will resolve to the same *PGM
pgmToCall = 'SOMEPGM';
Mypgm();
pgmToCall = '*LIBL/SOMEPGM';
Mypgm();

Note that this is nothing new. The CALL op-code in RPGIII and RPGIV worked the same way.

Charles
  • 21,637
  • 1
  • 20
  • 44
  • 1
    Thank you for your generous help @Charles I had one more related question to your point that will resolution come into play when EXTPGM is specified for prototype ? – mrsorrted Apr 28 '21 at 14:23