Repository navigation
Multi Module Programs
Daniel Long edited this page Sep 24, 2026
·
3 revisions
For larger applications, split code across modules:
mathlib.rpgle (module — no main):
**FREE
CTL-OPT NOMAIN;
DCL-PROC Add EXPORT;
DCL-PI *N INT(10);
a INT(10) VALUE;
b INT(10) VALUE;
END-PI;
RETURN a + b;
END-PROC;main.rpgle (main program):
**FREE
DCL-PR Add INT(10) EXTPROC('ADD');
a INT(10) VALUE;
b INT(10) VALUE;
END-PR;
DCL-S result INT(10);
result = Add(3 : 5);
DSPLY %CHAR(result);
RETURN;Build:
rpgc -c mathlib.rpgle # produces mathlib.o
rpgc main.rpgle mathlib.o -o myapp # compiles main and links with moduleThe
EXTPROCname is case-sensitive, and procedure names are exported upper-cased.DCL-PROC Add EXPORTexports the symbolADD, so the caller must sayEXTPROC('ADD')—EXTPROC('Add')compiles both sides cleanly and then fails at link time with an undefined symbol.
- Installation
- Quick Start
- CLI Reference
- Language Basics
- Data Types
- Variables and Constants
- Data Structures
- Arrays
- Varying-Dimension Arrays
- Control Flow
- Procedures
- Procedure Overloading
- Built-In Functions
- Error Handling
- Operation Extenders
- Enumerations
- Program Status Data Structure
- Data Areas
- SND-MSG
- Embedded SQL
- Record-Level Access
- Display Files (WORKSTN)
- Program-Described Files (I-Specs and O-Specs)
- DATA-INTO and DATA-GEN
- XML-INTO
- Fixed-Format Source
- Database Connections
- Multi-Module Programs
- Environment Variables
- Testing
- Complete Example: Employee Report
- IBM i Conformance Results
- IBM i Execution Results