Bryan's RPG IV Journal
Using CALLP with a Variable Program Name
Q. I understand how to prototype a program call, using EXTPGM and naming the program. But I want to allow the user to select an item from a subfile, then have the program use that selection to choose one from among several different possible programs to run. Is there a way to do this?
A. Yes. The EXTPGM value can be a character variable, as well as a literal or constant:
The called programs (AR101 and PR457) need not be coded with prototypes, even though the calling program will use prototyping and CALLP.
A. Yes. The EXTPGM value can be a character variable, as well as a literal or constant:
D Mypgm PR Extpgm(Pgmname)The parameter list must be consistent for any of the possible programs to be called; that is, AR101 and PR457 must accept the same parameters. But you can include the OPTIONS(*NOPASS) and/or OPTIONS(*OMIT) keywords to make some parameters optional or omissible.
D 5U 0 Const
D 35 Const
D Parm1 S 5U 0
D Parm2 S 35
D Pgmname S 10
/Free
Pgmname = 'AR101';
Mypgm(Parm1:Parm2); // Call AR101 (Implied Callp)
Pgmname = 'PR457';
Mypgm(Parm1:Parm2); // Call PR457 (Implied Callp)
/End-free
The called programs (AR101 and PR457) need not be coded with prototypes, even though the calling program will use prototyping and CALLP.
Log of Journal Entries |
|
Use this scrollable blog map to view other journal entries: |
|
| It is your responsibility to ensure procedures, techniques, and code used from this website are accurate and appropriate for your installation. No warranty or support is implied or expressed. |
![]() |
| Privacy and Email Policy |
| AS/400®, eServer, i5/OS, IBM i, Integrated Language Environment®, iSeries, OS/400®, RPG/400®, System i5, VisualAge®, and WebSphere® are trademarks of IBM Corporation. Note: IBM® System i is the latest member of the family of eServer iSeries. This site might refer to System i as System i5, iSeries, or AS/400. |
|
If you are having trouble navigating the menu at the top of this page, you may use the following scrollable site map instead: |
|
|











International visitors: