Now that we have taken the step of creating a service program from the F.MATH module, let's "bind" it to our MATHTEST program.
The first step is the same as if we were binding the F.MATH module. We create the MATHTEST module:
CRTRPGMOD MODULE(ILESAMPLE/MATHTEST) SRCFILE(ILESAMPLE/QRPGLESRC)
Next, we use the Create Program (CRTPGM) command again, but this time instead of specifying the F.MATH module, we specify the F.MATH service program created in the previous section:
CRTPGM PGM(ILESAMPLE/MATHTEST) MODULE(ILESAMPLE/MATHTEST) BNDSRVPGM(ILESAMPLE/F.MATH)
We now have a program named MATHTEST that is created from one module, and will reference our F.MATH service program instead of attaching a physical copy of it to the program.
Lets verify that using the following command:
When we get to the *MODULE detail of the program object, we see that yes, just the MATHTEST module is bound to this program:
Now, if we view the *SRVPGM information we see that we have bound (by reference, not copy) the F.MATH service program:
Another thing to notice is that next to the F.MATH service program we show a signature. This signature needs to match the signature of the actual F.MATH service program object or the program will crash hard, similar to if you were using a file and there was a level check.
You're probably thinking at this point "but I like just using option 14 to compile... isn't there an easier way?"
There is an easier way! And that is by using Binding Directories which will be covered next.