What is a Service Program on the IBM i System?

An IBM-i Service Program is a collection of reusable procedures and data items that can be accessed by other Integrated Language Environment (ILE) programs or service programs on the IBM i (AS400/iSERIES) system.

Here are some key points about service programs:

  • Modularity: Service programs allow you to encapsulate commonly used procedures and data, promoting code reuse and modularity
  • Binding: Unlike standalone programs, service programs are bound to the calling program at runtime. This means they are not physically copied into the calling program but are linked dynamically
  • Exporting Procedures: Only the procedures and data items explicitly exported from the service program are accessible to other programs. This allows for a controlled interface
  • Binder Language: The binder language is used to define the list of procedures and data items that can be exported. This helps manage changes and maintain compatibility with existing programs
  • Updating: Service programs can be updated without needing to recompile the programs that use them, as long as the interface remains compatible

Here's a simple example of creating a service program:

// Module with procedures
DCL-PROC AddNumbers;
 DCL-PI *N INT(10);
  NUM1 INT(10);
  NUM2 INT(10);
 END-PI;
 RETURN NUM1 + NUM2;
END-PROC;

DCL-PROC SubtractNumbers;
 DCL-PI *N INT(10);
  NUM1 INT(10);
  NUM2 INT(10);
 END-PI;
 RETURN NUM1 - NUM2;
END-PROC;

We would create this using the CRTSRVPGM command:

// Create the service program
CRTSRVPGM SRVPGM(MYLIB/MYSRVPGM) MODULE(MYLIB/MYMODULE) EXPORT(*ALL)

In this example, 'AddNumbers' and 'SubtractNumbers' are procedures within a module that are included in a service program. The 'CRTSRVPGM' command creates the service program and specifies that all procedures in the module should be exported.

{"email":"Email address invalid","url":"Website address invalid","required":"Required field missing"}
>