IBM i e-Book
A Developer’s Guide to Mastering IBM i Concepts
IBM i Index
Integrated Language Environment
Signature
What is a Service Program Signature?
Every service program has at least one signature. The signature is generated by the system when a Create Service Program (CRTSRVPGM) command specifying Export(*ALL) or Export(*SRCFILE) is issued.
The signature value is generated by an algorithm that uses as input the names of all of the service programs “exports” and their sequence. Here, “exports” are nothing but external procedures and external variables, constants etc. that are exported so that those can be used/called in other programs.
In the above screenshot, a Service Program ‘CUSTSTUFF’ is created by binding 2 modules -Module1 and Module2.
What is the use of a Signature?
A signature is a value that provides a similar check for service programs that a level check does for files. It helps ensure that changes made to the service program are done in such a way that the programs using them can still function properly.
Where can we see the Signature of a Service Program?
You can see the current signature value for a service program by using the Display Service Program (DSPSRVPGM) command. The current signature appears on the first screen of the command output.
We can see the Signature of the Service Program ‘CUSTSTUFF’ in the last row.
If you continue to press Enter on each screen displayed by the command, screen 9 (of 10)
shows all the valid signatures, including any valid previous signatures.
In addition to these, we can also see the modules and the list of external procedures that are bound to the Service Program.
What causes Signature to Change?
A signature changes when the list of exports for the service program changes. The most common cause of a signature change is adding a new procedure to the service program.
By using ‘UPDSRVPGM’ we are updating the Service Program ‘CUSTSTUFF’ as a new external procedure is added in one of the modules.
In the above screenshot, we can see a new Export is added in the Service Program. That causes the change in Signature as in the below screenshot.
Note: A change in a procedures’ parameters doesn’t change the service program’s signature.
What happens when Signature changes?
When a program is called, it immediately checks the signature value of any service programs that it uses and produces a signature violation message if the signatures don’t match. This happens at program start up not when you call a service program procedure.
The program ‘CUSTPGM’ is created by binding the Service Program ‘CUSTSTUFF’ when it had only 4 external procedures.
As you can see, the Signature of ‘CUSTSTUFF’, the ‘CUSTPGM’ is referring to is the older one. (The command used to display this is DSPPGM against the program ‘CUSTPGM’.)
Now that the Signature of the Service Program is changed after the addition of a new Procedure, a call to ‘CUSTPGM’ results in an error.
When we see the job log, we realise it is a Signature Violation error.
How to correct a Signature violation?
Use the Update Program (UPDPGM) command. If any signatures have changed, it also updates the program’s signature values.
Note: You don’t need to specify the service program because the UPDPGM command automatically re-checks the signatures of any bound service programs.
As you can see, the Signature to which ‘CUSTPGM’ refers to is matching with the current Signature of ‘CUSTSTUFF’.
Now, a call to ‘CUSTPGM’ does not result in any error.
Conclusion
In our example, we have only one program that uses the Service Program ‘CUSTSTUFF’. What if there are some 20 programs that use a Service Program, and we have to find these 20 among 100 programs?.
In this case, to resolve the ‘Signature Violation’ error by, finding out which 20 are using the concerned Service Program –
- We must execute DSPPGM against 100s of programs.
- We can use SQL to qsys2.bound_module_info (v7r3 and above) or use APIs QBNLPGMI/QBNLSPGM to get the list of programs that use the service program.
to find out which 20 are actually using the concerned Service Program and And, do execute UPDPGM on those 20 programs manually.
Needless to say, it is a cumbersome process, unless, you have an appropriate change management tool which would do all the updates/recompilations automatically.
The solution to this problem is ‘Binder Language’.