CRTRPGMOD (Create RPG Module) compiles RPGLE source into a module object, *MODULE. A module cannot run by itself. You bind it into a program with CRTPGM or into a service program with CRTSRVPGM. This page is the lookup for the command: what it creates, the parameters worth knowing, and the mistakes people make.
It does not teach the build from scratch. For that, read RPGLE Source Members, Compilers, and the Build Flow and Build an ILE RPG Service Program. For what the module types mean, see the RPGLE Modules and NOMAIN Reference, and for the packaging model in plain terms, IBM i Modules, Bound Programs, and Binding Directories Explained.
At a glance
| Question | Answer |
|---|---|
| What does it create? | A *MODULE object |
Can you CALL the result? | No. IBM says modules are created to be bound into programs |
| When do you use it? | When the module must be bound later: a NOMAIN module, a module for a service program, or one module of a multi-module program |
| When do you not use it? | When one source member should become a program directly. Use CRTBNDRPG |
| What comes next? | CRTPGM or CRTSRVPGM |
Parameters that matter
Defaults are those on the IBM i 7.5 command page.
| Parameter | Default | What it decides |
|---|---|---|
MODULE | *CTLSPEC | The module name and library. *CTLSPEC takes the name from the DFTNAME control specification keyword. If there is none and the source is a database file member, the member name is used. Otherwise the name is RPGMOD |
SRCFILE | QRPGLESRC | The source physical file. The library defaults to *LIBL |
SRCMBR | *MODULE | The source member. *MODULE means the member has the same name as the module |
SRCSTMF | none | A stream file as the source. See the note under common mistakes |
OPTION | none set | Compiler options in pairs such as *XREF and *NOXREF, *SRCSTMT and *NOSRCSTMT, *DEBUGIO and *NODEBUGIO |
DBGVIEW | *STMT | The debug views. *SOURCE gives a source view for source-level debugging, *LIST a listing view, *ALL listing, source and copy views, *NONE no debug data |
OPTIMIZE | *NONE | *NONE, *BASIC or *FULL. Higher levels can stop you changing variables in the debugger |
REPLACE | *YES | With *YES an existing module of the same name in the library is moved to QRPLOBJ and the new one takes its place |
TGTRLS | *CURRENT | The release the module must run on |
TEXT | *SRCMBRTXT | The description. The default copies the source member’s text |
OUTPUT | *PRINT | *PRINT produces a compiler listing in the spooled output |
DEFINE | *NONE | Condition names for /DEFINE-style conditional compilation |
DBGVIEW(*SOURCE) is the value to know. The default *STMT is enough to debug by statement number, but the source view is what lets you debug against your RPG text.
Example
CRTRPGMOD MODULE(MYLIB/REFUTIL) SRCFILE(MYLIB/QRPGLESRC) SRCMBR(REFUTIL) DBGVIEW(*SOURCE)
This compiles the member REFUTIL, a NOMAIN module that exports two procedures, into MYLIB/REFUTIL. The result is a *MODULE. To use it, bind it:
CRTSRVPGM SRVPGM(MYLIB/REFUTIL) MODULE(MYLIB/REFUTIL) EXPORT(*SRCFILE) SRCFILE(MYLIB/QSRVSRC) SRCMBR(REFUTIL) ACTGRP(*CALLER) DETAIL(*EXTENDED)
The module source and the binder source that goes with it are in the RPGLE Modules and NOMAIN Reference and the RPGLE Binder Language and Signatures Reference.
What you have afterwards
| Object | State |
|---|---|
MYLIB/REFUTIL type *MODULE | Created. It carries the compiled code, its exports and imports, and the debug data you asked for |
| Any program or service program | Not touched. A module that was already bound into one is copied into it at bind time, so recompiling the module does not change that object. See bind by copy and bind by reference |
Common mistakes
- Trying to
CALLthe module. It is not a program. Create a program withCRTPGMorCRTSRVPGMfirst. - Using
CRTRPGMODwhen one member should become a program. It works, but you then needCRTPGM.CRTBNDRPGdoes both steps for one member. - Recompiling a module and expecting bound objects to change. Run
CRTPGM,CRTSRVPGMorUPDSRVPGMagain. See UPDSRVPGM and DSPSRVPGM. - Relying on
SRCSTMFwithout testing it. On the PUB400 system used to check this site (IBM i V7R5M0), every compile withSRCSTMF(...)failed withRNS9339: Unable to open file, while the same source copied into a source file member compiled cleanly.SRCSTMFis a documented parameter and may work on your system. If it does not, copy the source into a member and useSRCFILEandSRCMBR. - Leaving
REPLACE(*YES)and forgetting the old module. The replaced module goes toQRPLOBJ, not away. - Expecting the module name to come from the member. With
MODULE(*CTLSPEC)the name comes fromDFTNAME, or the member name for a source file member. Name the module explicitly when you need to be sure.
Related commands
| Command | Relation |
|---|---|
| CRTBNDRPG | Compiles one source member straight into a program |
| CRTPGM | Binds modules into a program |
| CRTSRVPGM | Binds modules into a service program |
| UPDSRVPGM | Replaces modules in an existing service program |
For the activation group values that the later bind step sets, see the RPGLE Activation Groups Reference. For how the binder finds imports, see the RPGLE Binding Directories Reference.
FAQ
What does CRTRPGMOD create?
A module object, type *MODULE. It holds compiled code and cannot be run until it is bound into a program or service program.
What is the difference between CRTRPGMOD and CRTBNDRPG?
CRTRPGMOD stops at a module. CRTBNDRPG compiles one source member and creates a program from it in a single step.
Does a NOMAIN module need CRTRPGMOD?
Yes. CRTBNDRPG cannot create a program from NOMAIN source. On the test system it failed with RNF1304. Use CRTRPGMOD and then CRTPGM or CRTSRVPGM.
Which parameter gives me source-level debugging?
DBGVIEW(*SOURCE). The default is *STMT.
Summary
CRTRPGMODcompiles RPGLE source into a*MODULE, which cannot run on its own.- Name the module and member explicitly, and set
DBGVIEW(*SOURCE)when you debug. - A
NOMAINmodule must be created this way and bound withCRTPGMorCRTSRVPGM. - Recompiling a module does not change a program or service program that already copied it.
Sources: IBM i 7.5 CRTRPGMOD command (parameters, defaults, REPLACE, modules cannot run alone) and the IBM i 7.5 ILE RPG Reference. The CRTRPGMOD example, built from a source file member, compiled on IBM i V7R5M0 (PUB400, 2026-10-07; step B01). The parameter table and the statements about QRPLOBJ, TGTRLS and OUTPUT were checked against IBM documentation only and were not run.