Skip to content

Multi Module Programs

danlong005 edited this page Aug 30, 2026 · 3 revisions

Multi-Module Programs

For larger applications, split code across modules:

mathlib.rpgle (module — no main):

**FREE
CTL-OPT NOMAIN;

DCL-PROC Add EXPORT;
  DCL-PI 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 module

Clone this wiki locally