CRTRPGMOD Command Reference

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

QuestionAnswer
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.

ParameterDefaultWhat it decides
MODULE*CTLSPECThe 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
SRCFILEQRPGLESRCThe source physical file. The library defaults to *LIBL
SRCMBR*MODULEThe source member. *MODULE means the member has the same name as the module
SRCSTMFnoneA stream file as the source. See the note under common mistakes
OPTIONnone setCompiler options in pairs such as *XREF and *NOXREF, *SRCSTMT and *NOSRCSTMT, *DEBUGIO and *NODEBUGIO
DBGVIEW*STMTThe 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*YESWith *YES an existing module of the same name in the library is moved to QRPLOBJ and the new one takes its place
TGTRLS*CURRENTThe release the module must run on
TEXT*SRCMBRTXTThe description. The default copies the source member’s text
OUTPUT*PRINT*PRINT produces a compiler listing in the spooled output
DEFINE*NONECondition 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

ObjectState
MYLIB/REFUTIL type *MODULECreated. It carries the compiled code, its exports and imports, and the debug data you asked for
Any program or service programNot 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 CALL the module. It is not a program. Create a program with CRTPGM or CRTSRVPGM first.
  • Using CRTRPGMOD when one member should become a program. It works, but you then need CRTPGM. CRTBNDRPG does both steps for one member.
  • Recompiling a module and expecting bound objects to change. Run CRTPGM, CRTSRVPGM or UPDSRVPGM again. See UPDSRVPGM and DSPSRVPGM.
  • Relying on SRCSTMF without testing it. On the PUB400 system used to check this site (IBM i V7R5M0), every compile with SRCSTMF(...) failed with RNS9339: Unable to open file, while the same source copied into a source file member compiled cleanly. SRCSTMF is a documented parameter and may work on your system. If it does not, copy the source into a member and use SRCFILE and SRCMBR.
  • Leaving REPLACE(*YES) and forgetting the old module. The replaced module goes to QRPLOBJ, not away.
  • Expecting the module name to come from the member. With MODULE(*CTLSPEC) the name comes from DFTNAME, or the member name for a source file member. Name the module explicitly when you need to be sure.

Related commands

CommandRelation
CRTBNDRPGCompiles one source member straight into a program
CRTPGMBinds modules into a program
CRTSRVPGMBinds modules into a service program
UPDSRVPGMReplaces 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

  • CRTRPGMOD compiles 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 NOMAIN module must be created this way and bound with CRTPGM or CRTSRVPGM.
  • 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.

Leave a Comment

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

Scroll to Top