How can we help you?

We have hundreds of highly-qualified, experienced experts working in 70+ technologies.

IBM i e-Book

A Developer’s Guide to Mastering IBM i Concepts

Integrated Language Environment

Bind By Reference

The BNDSRVPGM parameter’s service programs are bound by reference. A service program is bound by reference if it is named in a binding directory and provides an export for an unresolved import. When a service program is bound in this way, no new imports are added.

Signature Violation

The signature violation error occurs when the signature IDs of a program and its associated service program don’t match.

Signature IDs

A signature ID is a special identification associated with a program or service program in the context of service programs. It guarantees that the interfaces of the caller and the callee are compatible. When a program calls for a procedure through a service program, the system verifies if the signature IDs match. A signature violation error happens if they don’t.

Common Causes

Service Program Changes: A service program’s signature ID changes when it is modified, such as when new modules are added.

Existing Callers: It’s possible that older signature IDs are still cached in programs that refers the service program.

Example:

MODULECALL1:

**Free

 Dcl-Pr Addition Zoned(5:0);
 Num1 Zoned(2:0);
 Num2 Zoned(2:0);
 End-Pr;


 Dcl-S Number1 Zoned(2:0) Inz(60);
 Dcl-S Number2 Zoned(2:0) Inz(20);
 Dcl-S Output Zoned(5:0);

 Output = Addition(Number1:Number2);
 Dsply Output;

 *Inlr = *On;

MODULE1:

**Free

Dcl-Proc Addition Export;
Dcl-Pi Addition Zoned(5:0);
Num1 Zoned(2:0);
Num2 Zoned(2:0);
End-Pi;

Dcl-S Result Zoned(5:0);

Result = Num1 + Num2;
Return Result;

*Inlr = *On;
End-Proc;

  • Create Module MODULECALL1, MODULE1
    CRTRPGMOD MODULE(DEMOLIB/MODULECALL) SRCFILE(DEMOLIB/QRPGLESRC)
    CRTRPGMOD MODULE(DEMOLIB/MODULE1) SRCFILE(DEMOLIB/QRPGLESRC)
    
  • To create a service program SRVPGM1, use the CRTSRVPGM command.
     CRTSRVPGM SRVPGM(DEMOLIB/SRVPGM1) MODULE(DEMOLIB/MODULE1) EXPORT(*ALL)
    
  • Now bind the service program SRVPGM1 to the calling program CALLPGM1 and call the CALLPGM1 program.
    CRTPGM PGM(DEMOLIB/CALLPGM1) MODULE(DEMOLIB/MODULECALL)
    BNDSRVPGM((DEMOLIB/SRVPGM1))

    Result:

  • Now adding the SUBTRACTION procedure to MODULE1 module and updating the SRVPGM1 service program using UPDSRVPGM command. Signature ID of associated service program will change.
  • After updating the SRVPGM1 service program and calling the CALLPGM1 program it will get the Program signature violation error.

Avoiding Signature Violation error

Rebind Programs: Rebind all programs that refer the modified service program. By doing this, you can be sure that their signature IDs have been updated with the new program signature.

Manage Signatures: As an alternative, you can manage service program signatures by creating binder language, which is used during program compilation. By doing this, you can manage the handling of signature IDs without having to recompile every caller.

Binder Language

A service program’s exports are defined by a small set of nonrunnable commands known as the binder language. When a BND source type is specified, the binder language allows the source entry utility (SEU) syntax checker to prompt and verify the input.

The binder language consists of a list of the following commands:

  • Start Program Export (STRPGMEXP) command, which identifies the beginning of a list of exports from a service program
  • Export Symbol (EXPORT) commands, each of which identifies a symbol name available to be exported from a service program
  • End Program Export (ENDPGMEXP) command, which identifies the end of a list of exports from a service program

The public interface to a service program is defined by the symbols found between a pair of STRPGMEXP PGMLVL(*CURRENT) and ENDPGMEXP symbols. A signature serves as a representation of that public interface. A value known as a signature identifies the interface that a service program supports.

You can add new exports to the end of the list of exports, so your binder language source only needs one export block if you choose to specify an explicit signature.

If you choose not to specify an explicit signature, the binder generates a signature from the list of procedure and data item names to be exported and from the order in which they are specified.

Each time you add a new export to your service program, you have to create a new export block in your binder source.

The first entry in a list of exports from a service program is indicated by the Start Program Export (STRPGMEXP) command. A service program’s list of exports can be ended with the End Program Export (ENDPGMEXP) command.
Multiple signatures are produced when a source file contains multiple STRPGMEXP and ENDPGMEXP pairs. There is no significance to the order in which the STRPGMEXP and ENDPGMEXP pairs occur.

PGMLVL(*CURRENT) can only be specified by one STRPGMEXP command, though it need not be the first one. A source file’s other STRPGMEXP commands must all include PGMLVL(*PRV). PGMLVL(*CURRENT)-specified STRPGMEXP commands are represented by the current signature.

You can explicitly specify a signature for a service program using the signature (SIGNATURE) parameter.
A character string or a hexadecimal string can be used as the explicit signature.

The binder generates a signature from exported symbols when the signature parameter’s default value, *GEN is used.

The STRPGMEXP command’s level check (LVLCHK) parameter indicates whether the binder will automatically check a service program’s public interface.

A symbol name that can be exported from a service program is identified by the Export Symbol (EXPORT) command.

Example:
  • You can create binder source file using STRSEU command with BND type.
  • Exported the procedure ADDITION by Export symbol (EXPORT) command.
  • Create service program using CRTSRVPGM command and export the BNDSRC binding source file.
  • See the Signature ID of recently created service program SRVPGM2.
  • After binding the SRVPGM2 service program to the CALLPGM2 and call the CALLPGM2.
  • Specify another STRPGMEXP and ENDPGMEXP pair with PGLVAL(*CURRENT) parameter. And exported the new procedure SUBTRACTION.
  • Updating the existing service program SRVPGM2 with BNDSRC source file. Also, one more signature will be added with old signature.
  • Call the CALLPGM2 program and this time you will not get signature violation error.

How can we help you?

We have hundreds of highly-qualified, experienced experts working in 70+ technologies.

X

Awards and Certifications

company-logo
company-logo
company-logo
company-logo
company-logo
company-logo
company-logo
company-logo
company-logo
company-logo