The <a href="http://publib.boulder.ibm.com/infocenter/iseries/v5r4/index.jsp?topic=/books/c092507602.htm">ILE RPG Programmers Guide</a>does a pretty good job of describing how to build a *SRVPGM.
The essentials are that you build one or more modules such as:
<pre>
h NoMain
dDisplay pr extproc('Display')
d InputNbr 10i 0
pDisplay b export
dDisplay pi
d InputNbr 10i 0
/free
dsply InputNbr;
return;
/end-free
pDisplay e
</pre>
and
<pre>
h NoMain
dAlter pr extproc('Alter')
d InputNbr 10i 0
pAlter b export
dAlter pi
d InputNbr 10i 0
/free
dsply InputNbr ' ' InputNbr;
return;
/end-free
pAlter e
</pre>
compiled with
<pre>
crtrpgmod display
crtrpgmod alter
</pre>
create your *SRVPGM with
<pre>
CRTSRVPGM SRVPGM(SAMPLE) MODULE(ALTER DISPLAY) EXPORT(*ALL)
</pre>
assuming you want to export both function Display and Alter. You don't have to.
You now have a *SRVPGM.
One way to use the *SRVPGM is to now:
<pre>
CRTBNDDIR BNDDIR(SAMPLE)
ADDBNDDIRE BNDDIR(SAMPLE) OBJ((SAMPLE))
</pre>
Write a *PGM such as:
<pre>
h dftactgrp(*no) bnddir('SAMPLE')
dAlter pr extproc('Alter')
d InputNbr 10i 0
dDisplay pr extproc('Display')
d InputNbr 10i 0
dNumber s 10i 0 inz(13)
/free
Display(Number);
Alter(Number);
Display(Number);
*inlr = *on;
return;
/end-free
</pre>
compile with CRTBNDRPG USESAMPLE
and then CALL USESAMPLE
You should see a prompt of 'DSPLY 13' from function Display
followed by a prompt 'DSPLY 13 13' from function Alter
type in 14, hit Enter, and you should see a prompt of 'DSPLY 14' from the second call to Display.
Bruce Vining
<a href="http://www.brucevining.com/">http://www.brucevining.com/</a>
Last Wiki Answer Submitted: February 7, 2008 1:31 pm by bvining6,055 pts.
If you live outside the United States, by submitting your email address you consent to having your personal data transferred to and processed in the United States.