CRTSRVPGM Command Reference

CRTSRVPGM (Create Service Program) binds one or more modules into a service program, *SRVPGM: a set of exported procedures and data that other programs call. This page is the lookup for the command’s parameters and defaults. It owns the command. The service program as an object, and why you would build one, are in the RPGLE Service Programs Reference.

For a step-by-step build, read Build an ILE RPG Service Program.

At a glance

QuestionAnswer
What does it create?A *SRVPGM with no entry point of its own
What does it need?One or more modules, usually NOMAIN, made with CRTRPGMOD
What decides the public interface?The EXPORT parameter, normally with binder source
What decides the activation group?ACTGRP, which is *CALLER by default. *NEW is not a value for a service program
Rebuild it later?Run CRTSRVPGM again with REPLACE(*YES), or use UPDSRVPGM to replace modules

Parameters that matter

Defaults are those on the IBM i 7.5 command page.

ParameterDefaultWhat it decides
SRVPGMrequiredThe service program name and library
MODULE*SRVPGMThe modules copied and bound together, up to 300. *SRVPGM means one module with the same name as the service program
EXPORT*SRCFILE*SRCFILE reads EXPORT statements from binder source in the file and member named by SRCFILE and SRCMBR, or in SRCSTMF. *ALL exports everything the modules export
SRCFILEQSRVSRCThe source file that holds the binder source
SRCMBR*SRVPGMThe binder source member. *SRVPGM means the member has the service program’s name
SRCSTMFnoneBinder source in a stream file
BNDSRVPGM*NONEService programs whose exports are examined to resolve imports, each with *IMMED or *DEFER activation, up to 300
BNDDIR*NONEBinding directories searched to resolve imports, up to 300
ACTGRP*CALLER*CALLER or a group name. IBM does not list *NEW for a service program
OPTIONnone setBinder options such as *DUPPROC and *NODUPPROC, *WARN and *NOWARN, *RSLVREF and *UNRSLVREF
DETAIL*NONEThe binder listing: *BASIC, *EXTENDED or *FULL
ALWUPD*YESWhether the service program may be updated later
ALWLIBUPD*NOWhether the library of a bound service program may be changed on update
USRPRF*USER*USER runs with the caller’s authority. *OWNER adds the owner’s authority
REPLACE*YESReplace an existing service program of the same name
AUT*LIBCRTAUTPublic authority of the new object
TEXT*BLANKThe description. *EXPORTSRC and *MODULE copy text from the binder source or module
TGTRLS*CURRENTThe release the service program must run on
STGMDL*SNGLVLThe storage model

EXPORT: binder source or everything

ValuePublic interfaceSignatureUse when
*SRCFILEOnly the symbols named in the binder sourceYou control it with SIGNATURE and PGMLVLThe service program has callers you cannot rebuild, and the interface has to stay compatible
*ALLEvery procedure and data item the modules exportGenerated from the exportsA private service program with callers you rebuild, or while you are experimenting

Binder source, signatures and PGMLVL(*PRV) blocks are in the RPGLE Binder Language and Signatures Reference.

Example

CRTSRVPGM SRVPGM(MYLIB/REFUTIL) MODULE(MYLIB/REFUTIL) EXPORT(*SRCFILE) SRCFILE(MYLIB/QSRVSRC) SRCMBR(REFUTIL) ACTGRP(*CALLER) DETAIL(*EXTENDED)

The binder source member REFUTIL holds:

STRPGMEXP PGMLVL(*CURRENT) SIGNATURE('REFUTIL_VERSION1')
  EXPORT SYMBOL('REFDOUBLE')
  EXPORT SYMBOL('REFLABEL')
ENDPGMEXP

Result: a *SRVPGM named REFUTIL that exports REFDOUBLE and REFLABEL under one signature, and runs in the caller’s activation group. DSPSRVPGM SRVPGM(MYLIB/REFUTIL) DETAIL(*PROCEXP) lists the two procedures. A caller binds to it with BNDSRVPGM on CRTPGM or through a binding directory, as in the RPGLE Binding Directories Reference.

Common mistakes

  • Ignoring the EXPORT default. The default is *SRCFILE, so the command expects binder source in QSRVSRC with the service program’s name. If yours is elsewhere, name the file and member, or use EXPORT(*ALL).
  • Using *ALL for a public service program. Any procedure you export later changes the signature, and callers bound to the old one fail. See the signature error in CRTPGM.
  • Changing the order of EXPORT statements. IBM says that for a compatible change you add new exports at the end and keep the old signature in a *PRV block.
  • Choosing ACTGRP(*NEW). It is not a value for a service program. Use *CALLER, or a named group when the service program holds state of its own. See the RPGLE Activation Groups Reference.
  • Rebuilding with CRTSRVPGM and expecting callers to follow. A new signature does not reach programs that were bound to the old one unless the old signature is kept.
  • Relying on SRCSTMF for the binder source without testing it. The PUB400 problem was recorded for RPG compiles. Binder source was copied into a source file member and used with SRCFILE.

Related commands

CommandRelation
CRTRPGMODCreates the modules to bind
CRTPGMBinds a program to the service program
UPDSRVPGM and DSPSRVPGMReplace modules in it, and inspect it
CRTBNDDIR, ADDBNDDIREMake the service program findable at bind time. See the RPGLE Binding Directories Reference

FAQ

What does CRTSRVPGM create?

A service program object, *SRVPGM, bound from modules. It has no entry point of its own, so you call its exported procedures from other ILE programs.

What is the difference between EXPORT(SRCFILE) and EXPORT(ALL)?

*SRCFILE exports only what binder source names. *ALL exports everything the modules export.

Can a service program run in a new activation group?

IBM does not list *NEW as a value for a service program. Use *CALLER or a named group.

How do I change a service program without breaking callers?

Keep the old signature in a PGMLVL(*PRV) block, add new exports at the end, and replace the modules with UPDSRVPGM or rebuild with CRTSRVPGM.

Summary

  • CRTSRVPGM binds modules into a *SRVPGM that other programs call.
  • EXPORT(*SRCFILE), the default, uses binder source. EXPORT(*ALL) exports everything the modules export.
  • ACTGRP defaults to *CALLER. *NEW is not a service program value.
  • Signature control is what keeps old callers working.

Sources: IBM i 7.5 CRTSRVPGM command (parameters, defaults, EXPORT, ACTGRP) and IBM i 7.5 ILE Concepts. On IBM i V7R5M0 (PUB400, 2026-10-07) the example built REFUTIL from binder source and DSPSRVPGM listed the procedures and signature (steps B02 to B04). The EXPORT(*ALL) behaviour, the parameter table and the statements about export order were checked against IBM documentation only and were not run.

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top