Difference between EXTPGM and EXTPROC

335 pts.
Tags:
AS/400
EXTPGM
EXTPROC
RPGLE
Could someone please let me know what is the difference between EXTPGM and EXTPROC? In which scenario EXTPGM is used and in which scenario EXTPROC is used? What are the limitations of EXTPGM over EXTPROC? If possible could you please let me know the difference with a sample program as an example. Thanks in advance

Software/Hardware used:
iseries

Answer Wiki

Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.

Discuss This Question: 2  Replies

 
There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.
  • TomLiotta
    The difference is that one references an external program and the other references an external procedure. . CALLP is "Call with Prototype". A prototype can reference an external *PGM by using the EXTPGM() keyword. That makes it essentially an enhanced version of the CALL op-code. Or a prototype can reference a procedure exported from another *MODULE that is bound into the calling program by using the EXTPROC() keyword. That makes it essentially an enhanced version of the CALLB op-code. (The exported procedure could be from a *MODULE of a bound *SRVPGM.) . So, additional differences are all of the differences between calling programs and calling procedures. A major example of a difference there is that procedure parameters can be passed by value, while programs can only receive parameters by reference (i.e., by address). . Prototypes for other procedures that are in the same *MODULE do not need EXTPGM() nor EXTPROC(). . Tom
    125,585 pointsBadges:
    report
  • anandx
    An extProc() is a static procedural call and an extPGM() is a dynamic program call. That is the only difference between the two.
    Because static calls are designed differently from dynamic calls, inevitably, there exits operational and procedural differences between them. Aside from those differences both, in essence, do the same thing, namely, do something for which it is called upon to do, and faithfully return the result to the caller. In that sense, in most occasions, they are interchangeable, if efficiency is not a concern. Now, let's take a macro view of how modules work in an ILE environment.
    A *module is an object which is compiled but not runnable. A *pgm is an object which evolves from *module and is executable. CRTRPGMOD creates an unrunnable *module CRTPGM and CRTSRVPGM create a runnable *pgm. A *pgm can tie together one or more modules either at compile time or at run time. Tying modules together is 'binding'. A module encompasses one or more procedures. When a piece of code can be executed only when it is called upon and not on its own, then that piece is a procedure (save main procedure). When a module of a procedure is bound to a caller, either at compile time or at run time, and when that procedure is called, then that process is called a static procedural call. Why static? because it is statically bound. Why procedural? because a procedure is called not a pgm. Until the caller terminates, the binding persists, which means after the initial activation the called remains active in the memory even when caller calls called again and again. This is different with a dynamic pgm call. First, there is no binding between the caller and called. In fact, caller will not even been aware whether at all a called *pgm object exits even at run time, until it is really called.
    Unlike a static call, in dynamic pgm call the caller and caller are two separate entities. When two separate callers call a same procedure, there is only one copy of called in memory, whereas, in a similar scenario under a pgm call there exists as many copies of called pgm as there are callers. In dynamic pgm calls, the called need to do many tasks before responding to caller and that happens every time it is called, not just at the first time. As a result of those two primary reasons, dynamic pgm calls are (theoretically) slower than static procedural calls. Theoretically, because the difference would manifest only when called thousands of times and will not be perceivable in small number of iterations.
    Hence, extProc() is a static procedural call and extPGM() is a dynamic program call. That is the root cause of the difference between the two. All other differences arise out of that and are operational differences.
    Some examples to illustrate the concept will follow, but later
    Thanks.

    435 pointsBadges:
    report

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

To follow this tag...

There was an error processing your information. Please try again later.

Thanks! We'll email you when relevant content is added and updated.

Following

Share this item with your network: