1. Exported Procedures should not be in the same member as a linear or cyclic main procedure.
2. Exported Procedures should be bound into a Service Program
3. The service program should be bound to the program.
The easiest way is to register the Service Program in a Binding Directory and then specifying the binding directory in the compile command or even better register in the H-Specs/CTL-OPT keyword BINDDIR

Mit freundlichen Grüßen / Best regards

Birgitta Hauser
Modernization – Education – Consulting on IBM i
Database and Software Architect
IBM Champion since 2020

"Shoot for the moon, even if you miss, you'll land among the stars." (Les Brown)
"If you think education is expensive, try ignorance." (Derek Bok)
"What is worse than training your staff and losing them? Not training them and keeping them!"
"Train people well enough so they can leave, treat them well enough so they don't want to. " (Richard Branson)
"Learning is experience … everything else is only information!" (Albert Einstein)

-----Original Message-----
From: RPG400-L <rpg400-l-bounces@xxxxxxxxxxxxxxxxxx> On Behalf Of Brian Parkins
Sent: Wednesday, 15 May 2024 10:24
To: RPG programming on the IBM i (AS/400 and iSeries) <rpg400-l@xxxxxxxxxxxxxxxxxx>
Subject: EXPORTing subprocedures

OK, here is something I have never quite understood. Can anyone explain why subprocedures within a Linear Main *MODULE have to be EXPORTed - even when only referenced within the same *MODULE?

Example: A single source member follows, (please be gentle with my
coding.) CRTBNDRPG used with this particular example.
**Free
// Linear Main *MODULE with subprocedure // Subprocedure MSG requires EXPORT keyword - why???
Ctl-Opt DftActGrp(*No) Main(MainProc);
Dcl-PR MainProc ExtPgm('PGM2_PROC1');
End-PR;
Dcl-Proc MainProc;
Dcl-PI MainProc;
End-PI;
Dcl-PR Msg;
End-PR;
Dcl-S UserId Char(10) Inz(*USER);
Dsply 'In MainProc' UserId;
Msg();
Return;
End-Proc;

Dcl-Proc Msg Export;
Dcl-PI Msg;
End-PI;
Dcl-S UserId Char(10) Inz(*USER);
Dsply 'In Msg Proc' UserId;
Return;
End-Proc;

If I rewrite the above as a Cycle Main *MODULE, the EXPORT keyword is not required on the subprocedure. The RPG Reference states:
"If the EXPORT keyword is not specified, the procedure can only be called from within the module."
So why is EXPORT needed in the above example? (If it is removed, a bind error occurs.)

Thx for any insight.
Brian.
--
This is the RPG programming on IBM i (RPG400-L) mailing list To post a message email: RPG400-L@xxxxxxxxxxxxxxxxxx To subscribe, unsubscribe, or change list options,
visit: https://lists.midrange.com/mailman/listinfo/rpg400-l
or email: RPG400-L-request@xxxxxxxxxxxxxxxxxx
Before posting, please take a moment to review the archives at https://archive.midrange.com/rpg400-l.

Please contact support@xxxxxxxxxxxxxxxxxxxx for any subscription related questions.



As an Amazon Associate we earn from qualifying purchases.

This thread ...

Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.