Creating Modules, Bound RPG and ILE Programs

Back in the olden days of the AS400 we only had one way to compile RPG400 programs - a simple single RPG program which might contain subroutines. Any program would call any other program. This is called OPM (Original Program Model).

Then as we hit the late 1990's and the new IBM iSeries machine was launched, we were introduced to the concept of ILE (Integrated Language Environment) coding techniques.

I wrote a blog about the differences between OPM and ILE and you can read it here

How does Code for IBM i know the difference between Bound RPG programs, Modules and ILE Programs?

Quite simply, the file identifier of the source file tells it what it is.

something.pgm.rpgle

This will be a single bound RPG program. It contains RPG source code. It compiles using the CRTBNDRPG command.

something.rpgle

This will be compiled as an RPG Module using the CRTRPGMOD command. It contains RPG source code.

something.ilepgm

This is the CRTPGM command, embedded within the file. The file name doesn't have to match the something.rpgle for the module, but I would recommend keeping in the same for clarity.

Better Source Code Naming

I really like the BOB source code format of PGMNAME-program_description.rpgle

So, let's look at some examples of code and review the Rules.mk file which tells BOB how to do it's Better Object Building.

RPG as a bound RPG Program

HELLOWORLD-Simple_HelloWorld.pgm.rpgle
  • HELLOWORLD this will be the program name
  • the - says "the next string is the program description"
  • .pgm.rpgle says "compile this as a bound RPG program using CRTBNDRPG
HELLOWORLD-Simple_HelloWorld.pgm.rpgle

RPG as an RPG Module

HELLOADV-Advanced_HelloWorld.rpgle
  • HELLOADV this will be the module name
  • the - says "the next string is the program description"
  • .rpgle says "compile this as an RPG module using CRTRPGMOD
HELLOADV-Advanced_HelloWorld.rpgle

RPG as an RPG Module

HELLOADV-Advanced_HelloWorld.ILEPGM
  • HELLOADV this will be the ILE program name
  • the - says "the next string is the program description"
  • .ilepgm says "the compile command for this ILE program is defined within"
HELLOADV-Advanced_HelloWorld.ILEPGM

Rules.mk

The Rules.mk file define each source member:

HELLOADV.MODULE: HELLOADV-Advanced_HelloWorld.rpgle
HELLOWORLD.PGM: HELLOWORLD-Simple_HelloWorld.pgm.rpgle
HELLOADV.PGM: HELLOADV.MODULE

For example, if helloadv.pgm contained multiple modules they would be listed like this:

HELLOADV.MODULE: HELLOADV-Advanced_HelloWorld.rpgle
HELLOWORLD.PGM: HELLOWORLD-Simple_HelloWorld.pgm.rpgle
HELLOADV.PGM: HELLOADV.MODULE ANOTHER.MODULE AND1MORE.MODULE
{"email":"Email address invalid","url":"Website address invalid","required":"Required field missing"}
>