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
RPG as an RPG Module
HELLOADV-Advanced_HelloWorld.rpgle
RPG as an RPG Module
HELLOADV-Advanced_HelloWorld.ILEPGM
Rules.mk
The Rules.mk file define each source member:
For example, if helloadv.pgm contained multiple modules they would be listed like this: