Forums >> Programming >> RPG Programming >>
Service Program Binder Language Part 2 - Signatures




Posted:
bvstone

Service Program Binder Language Part 2 - Signatures

 
Service Program Binder Language Part 2 - Signatures

Up until this point we've stayed away from the topic of Service Program Signatures mainly because it is something that can get confusing and interfere with learning the basics of programming with ILE.

But, before we go any further it is best we cover this subject.  If you choose the route of using Service Programs in place of or along with modules, it will be something you will want to understand.

When you create a service program that service program gets what is called a Signature.  A signature is a unique identifier of a service program that is created based upon the procedures that are exported from a module.

When you create a program that uses a Service Program that program will take the most current signature from the service program and store it in the program description.  That way when it goes to call a procedure from that service program it can do a check on the signature. 

Signatures can either be generated by the system, or you can provide your own signatures in your Binder Language on the STRPGMEXP label.

When you use the CRTSRVPGM command and specify EXPORT(*ALL) (which we won't do in production, right?) or leave the STRPGMEXP label blank without any other keywords the system will generate a signature for our service program.

If we edit our F.MATH binder language and prompt the STRPGMEXP label we will see the following keywords or parameters are available:

                      Start Program Export List (STRPGMEXP)    
           
 Type choices, press Enter. 
   
                                                  
                            Additional Parameters                               
  
 Program level  . . . . . . . . .   *CURRENT      *CURRENT, *PRV
 Signature level check  . . . . .   *YES          *YES, *NO
 Signature  . . . . . . . . . . .   *GEN

 Comment  . . . . . . . . . . . . 

First we see the Program Level (PGMLVL) keyword which defaults to *CURRENT.  This means that when we create this service program that this particular grouping of exports will be the "current" list.

Next we see the Signature Level Check (LVLCHK).  This is similar to a level check we're all probably familiar with when it comes to files.  This is used so that when a program uses a service program it checks the signature it was assigned when it was created to make sure it matches one of the signatures of the service program.  If not, it will throw an error.

The third option is the Signature (SIGNATURE).  This allows us to specify our own signature or the special value of *GEN which will let the system generate the signature.  I've actually found that specifying my own signatures in the form of versions (ie, v1.0, v1.1, v2.2) as the signature tends to work well and be a little more descriptive.  But, it's your choice as to how you want to do this.

Lets now take a look at the signature of our F.MATH service program and how it's referenced in our MATHTEST program.

DSPSRVPGM SRVPGM(ILESAMPLE/F.MATH) OUTPUT(*) DETAIL(*SIGNATURE)

When we execute this command we will be shown the signature(s) of our service program:

                     Display Service Program Information 
                                                                Display 1 of 1 
Service program  . . . . . . . . . . . . :   F.MATH     
  Library  . . . . . . . . . . . . . . . :     ILESAMPLE  
Owner  . . . . . . . . . . . . . . . . . :   BVSTONE    
Service program attribute  . . . . . . . :   RPGLE      
Detail . . . . . . . . . . . . . . . . . :   *SIGNATURE 

                                 Signatures: 

00E3D5C9D4E4E2E3C5C76DC8E3C1D47B 

The signature we see here is actually a hex representation of a characters signature.  We can also use the F11 function key to display the "text" version of our signature.

                     Display Service Program Information 
                                                                Display 1 of 1 
Service program  . . . . . . . . . . . . :   F.MATH     
  Library  . . . . . . . . . . . . . . . :     ILESAMPLE  
Owner  . . . . . . . . . . . . . . . . . :   BVSTONE    
Service program attribute  . . . . . . . :   RPGLE      
Detail . . . . . . . . . . . . . . . . . :   *SIGNATURE 

                                 Signatures: 

 TNIMUSTEG_HTAM# 

Interestingly in this case the signature is the single procedure name exported from the module, only backwards.

Let's go back into our F.MATH Binder Language source now and actually specify our own signature:

             STRPGMEXP  SIGNATURE('v1.0')                
             EXPORT     SYMBOL(#math_getSumInt)          
             ENDPGMEXP                                   

The signature in this case will be more descriptive and tell us that this is version 1 of our service program.

We now can recreate the service program:

CRTSRVPGM SRVPGM(ILESAMPLE/F.MATH) MODULE(ILESAMPLE/F.MATH)

And then again, view the signatures for our service program:

DSPSRVPGM SRVPGM(ILESAMPLE/F.MATH) OUTPUT(*) DETAIL(*SIGNATURE)

We now see the signature value:

                     Display Service Program Information 
                                                                Display 1 of 1
Service program  . . . . . . . . . . . . :   F.MATH     
  Library  . . . . . . . . . . . . . . . :     ILESAMPLE  
Owner  . . . . . . . . . . . . . . . . . :   BVSTONE    
Service program attribute  . . . . . . . :   RPGLE      
Detail . . . . . . . . . . . . . . . . . :   *SIGNATURE 

                                 Signatures: 

A5F14BF0404040404040404040404040 

If we press the F11 function key we will see the text representation of our new signature:

                     Display Service Program Information 
                                                                Display 1 of 1 
Service program  . . . . . . . . . . . . :   F.MATH     
  Library  . . . . . . . . . . . . . . . :     ILESAMPLE  
Owner  . . . . . . . . . . . . . . . . . :   BVSTONE    
Service program attribute  . . . . . . . :   RPGLE      
Detail . . . . . . . . . . . . . . . . . :   *SIGNATURE 

                                 Signatures: 

v1.0             

Next, we will update our program to use the F.MATH service program and Bind By Reference in place of the F.MATH module using Bind By Copy.


Last edited 04/07/2015 at 14:47:28


Reply




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).