Re: RPG Service Program vs Include Source for Shared and SQL Calls
Niels Liisberg <nli-y1igGha7WhZnI0JKdf8LmQC/[email protected]> Mon, 23 Mar 2026 12:01:48 +0100
| Newsgroups | gmane.comp.lang.as400.rpg |
|---|---|
| Message-ID | <CADAk_-g_dbUoS9=JsiAcF5cpFcKqcK52vyDNukGwYt-bvN52Gg@mail.gmail.com> |
Hey Richard;
Thanx for your interest - I just carved this out for you;
Here is the prototype;
///
// Programs and procedures : Load service program procedure as procedure
pointer
//
//
// @param (input) Library where the ILE service program exists or *LIBL
// @param (input) Program name of the ILE service program
// @return procedure pointer or null and wrap it in a MONITOR
//
///
Dcl-PR json_LoadServiceProgramProc pointer(*proc) extproc(*CWIDEN :
'jx_loadServiceProgramProc');
library char(10) const;
program char(10) const;
procedure pointer value options(*string);
End-PR;
Example of usages:
dcl-proc callNameAndAge;
dcl-pr NameAndAge pointer extproc(pNameAndAge);
name char (10) const;
text char(200);
age packed(5:0);
end-pr;
dcl-s text char(200);
dcl-s age packed(5:0);
dcl-s msg char(50);
dcl-s pNameAndAge pointer (*PROC) static;
pNameAndAge = json_loadServiceProgramProc ( '*LIBL' : 'HELOSRVPGM' :
'NAMEAGE');
if pNameAndAge = *null;
json_joblog('Could not load program HELOSRVPGM');
return;
endif;
// Now we have an efficient dynamic procedure pointer to the service
program
// We can call it with the parameters we want,using prototype
// Note that text and age parameters are passed by reference, so we can
change them
text = 'Hello world from RPG';
age = 55;
NameAndAge ('Niels': text: age);
json_joblog ('Called HELOSRVPGM/NAMEAGE returns: "text": ' +
%trim(text) + ', "age": ' + %char(age));
end-proc;
You can find it here - where you also can see how it is implemented;
https://github.com/sitemule/noxDB/blob/master/headers/JSONPARSER.rpgle
Search for: json_LoadServiceProgramProc
This program examples/JSONPGM02B show how to use it:
https://github.com/sitemule/noxDB/blob/master/examples/JSONPGM02B.Call-ILE-service-program-procedure-by-proc-pointer.rpgle
On Sun, Mar 22, 2026 at 4:56 PM Richard Schoen <[email protected]>
wrote:
> Ooh I'll have to check out the dynamic loading in noxDb.
>
> Thanks for reminding me. I hadn't looked at that in a while.
>
> Regards,
> Richard Schoen
> Web: http://www.richardschoen.net
> Email: [email protected]
>
> ----------------------------------------------------------------------
>
> message: 1
> date: Sun, 22 Mar 2026 17:14:12 +0800
> from: Niels Liisberg <[email protected]>
> subject: Re: RPG Service Program vs Include Source for Shared
> Subprocedures and SQL Calls
>
> Hey Brian,
>
> We did it manually- so each ?breaking? version got its own version
> signature- and it worked fine. The problem occurred when you have hundreds
> of versions- and trying to keep track of each.. with hundreds of exports..
> the binder source exploded..
>
> So we went to a more pragmatic solution: only adding exports to the end -
> and if implementation is challenged- add that to the end and don?t touch
> the original so any client code will work in touched.
>
> .. but that is a convention, and conventions can easy be broken.
>
> That made me implement the dynamic procedure load and we use that in all
> our products and projects
>
> You can find ?the magic? in both noxDb and ILEastic and in our IceBreak.
>
>
> --
> This is the RPG programming on IBM i (RPG400-L) mailing list
> To post a message email: [email protected]
> To subscribe, unsubscribe, or change list options,
> visit: https://lists.midrange.com/mailman/listinfo/rpg400-l
> or email: [email protected]
> Before posting, please take a moment to review the archives
> at https://archive.midrange.com/rpg400-l.
>
> Please contact [email protected] for any subscription related
> questions.
>
>
--
This is the RPG programming on IBM i (RPG400-L) mailing list
To post a message email: [email protected]
To subscribe, unsubscribe, or change list options,
visit: https://lists.midrange.com/mailman/listinfo/rpg400-l
or email: [email protected]
Before posting, please take a moment to review the archives
at https://archive.midrange.com/rpg400-l.
Please contact [email protected] for any subscription related questions.