Module/Sub Procedure Call by RPG3/RPG III

110 pts.
Tags:
AS/400
RPG
Is it possible to call a module/sub procedure from RPG 3/ RPG III code program?


Software/Hardware used:
AS400
1

Answer Wiki

Thanks. We'll let you know when a new response is added.

Big Yes. You compile the module (*MODULE), build it into a service program (*SRVPGM), add the serv pgm to a binding directory (WRKBNDDIR), and nominate the binding directory either on the H-spec or the CRTxxx command of the calling program.

And if you’re smart you will have the prototypes of the function(s) in the same module src member with conditional compile directives. Something like:
/IF DEFINED(Module)
H Nomain etc.
F-specs, etc.
/ENDIF
D-specs for prototype (PR)
/IF DEFINED(Module)
/EOF
/ENDIF
code function implementation here.
Then DEFINE(Module) as you compile the module itself. Any pgm wanting to use the functions can just /include the src and will only see the PR specs.

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.
  • ToddN2000
    Yes. Are you having problems? If so post any errors and you command code and we will take a look.
    132,840 pointsBadges:
    report
  • TheRealRaven
    No. Not directly.

    RPGIII can only call a *PGM. If a module or procedure is needed, you must create a RPGIV-based program that can call into the module/procedure (i.e., a "wrapper"), and call the RPGIV *PGM from RPGIII. Parms may be passed including returned/output parm values.
    35,130 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: