Forums >> Programming >> RPG Programming >>
Using Our First RPG ILE Service Program


Using Our First RPG ILE Service Program

Using Our First RPG ILE Service Program

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:


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:


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:

                          Display Program Information 
                                                                 Display 3 of 7 
 Program  . . . . . . . :   MATHTEST      Library  . . . . . . . :   ILESAMPLE  
 Owner  . . . . . . . . :   BVSTONE    
 Program attribute  . . :   RPGLE      
 Detail . . . . . . . . :   *MODULE    

 Type options, press Enter. 
   5=Display description   6=Print description 

                                          Creation  Optimization  Debug 
 Opt  Module      Library     Attribute   Date         Level      Data 
      MATHTEST    ILESAMPLE   RPGLE       04/13/15  *NONE         *NO      

Now, if we view the *SRVPGM information we see that we have bound (by reference, not copy) the F.MATH service program:

                          Display Program Information 
                                                                 Display 4 of 7 
 Program  . . . . . . . :   MATHTEST      Library  . . . . . . . :   ILESAMPLE  
 Owner  . . . . . . . . :   BVSTONE    
 Program attribute  . . :   RPGLE      
 Detail . . . . . . . . :   *SRVPGM    

 Type options, press Enter. 

 Opt  Program     Library     Signature 
      F.MATH      ILESAMPLE   A5F14BF0404040404040404040404040 
      QRNXIE      QSYS        D8D9D5E7C9C540404040404040404040 
      QLEAWI      QSYS        44F70FABA08585397BDF0CF195F82EC1 

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.

Last edited 04/13/2015 at 14:41:27


Copyright 1983-2017 BVSTools
GreenBoard(v3) Powered by the eRPG SDK, MAILTOOL Plus!, GreenTools for Google Apps, jQuery, jQuery UI, BlockUI, CKEditor and running on the IBM i (AKA AS/400, iSeries, System i).