The ILE RPG compiler supplies part of the logic for an RPG module. Depending on the type of module you choose, this supplied logic will control a large or small part of the control flow of your module. By default, an RPG module will include the full RPG Cycle, which begins with the *INIT phase and ends with the *TERM phase. The other two types of RPG modules do not include the full RPG Cycle; the only remnant of the RPG cycle is the module initialization, which is similar to the *INIT phase. The ILE RPG compiler supplies additional implicit logic that is separate from the RPG cycle; for example, the implicit opening and closing of local files in subprocedures.
All ILE RPG modules can have one or more procedures.
The three types of RPG modules are distinguished by the nature of the main procedure in the module.
A program or a service program can consist of multiple modules, each of which can have an RPG main procedure. If an RPG module is selected to be the program-entry module of a program, then you call the main procedure using a program call. If an RPG module is not the program-entry module of a program, or if it is a module in a service program, then you call its main procedure using a bound call. Calling a main procedure through a bound call is only available for cycle-main procedures; if a module contains a linear-main procedure and that module is not selected to be a program-entry module, than that procedure cannot be called.
This type of module cannot be the program-entry module of a program, since it has no main procedure.
See NOMAIN Module for more information.
Module Type | Keyword | Cycle Features Allowed | Main Procedure | Initialization of global variables, opening of files, and UDS data areas | Implicit closing of global files and unlocking of data areas |
---|---|---|---|---|---|
Cycle-main | Yes | Implicitly defined in the main source section |
|
When the main procedure ends with LR on, or ends abnormally. | |
Linear-main | MAIN | No | Explicitly defined with the MAIN keyword and Procedure specifications | When the main procedure is first called after the activation group is created, or if somehow a sub-procedure is called first. | Never |
No main | NOMAIN | No | None, indicated by the presence of the NOMAIN keyword | When the first procedure in the module is called after the activation group is created | Never |