Making the move to RPG IV with modules and procedures isn't as difficult as you might expect. There is some mystery surrounding the idea of using modules and procedures instead of traditional programs, but the concept--and the implementation of it--is not really that complex.
With traditional RPG III on AS/400, you had source members that, when compiled, created program objects (*PGM). Pretty straightforward; edit "the program" with SEU, compile "the program" with PDM option 14, and (assuming no syntax errors) you end up with a *PGM object.
When you need to jump from one program to another, a simple CALL operation is performed. The CALL interface between programs is notoriously slow, but the overall performance of the CALL operation has improved over the years with new, faster chips.
With modules and procedures, you still end up with a program, but sometimes a couple of additional steps are required to get to the program object. The reason for this is that programs are actually made up of modules. If a program is created from a single source member, that program contains one module. If a program is created from the compilation of several source members, each source member yields a module. Consequently, the program is made up of multiple modules.
A module is an object very much like the old program object created with RPG III. The primary difference is that module (*MODULE) objects are not called. Instead, modules contain routines that are called from other routines. These routines are referred to as "procedures." These procedures can be called by other procedures. Although technically it is possible to call a module, it does not make sense to do so and is rarely practiced. Today, best practice is to call procedures, which are the routines stored in a module.
Procedures are the code that is run within a module object. Procedures are created using source code written with any ILE language, such as C, C++, RPG IV, COBOL, and even CL. A procedure has a starting point and an exit point. Procedures may accept parameters if required, and they support local variables. This allows the programmer to create a procedure that has its own variables--variables that are not visible and therefore do not conflict or interfere with other areas of the eventual program in which they will be stored.
One advantage of using procedures is that the modules in which they are contained are created from a single source member, yet multiple modules are used to create programs. So procedures may be stored in any number of individual source members. Since modules may contain any number of procedures and calling between procedures within the same program is simple, you are encouraged create several small source members in which to store your procedures. Then, when maintenance is required, you need only worry about modifying the small source member and not the 3,000- to 7,000-line, all-in-one source program you previously managed.
This I just a quick look at modules and procedures. You should consider replacing all new code with RPG IV and modules and procedures, and you should strongly consider allowing developers to use this technology with their maintenance assignments. It helps give them the skills to write better applications for your shops, and it will also help reduce the overall amount of time required to make a change to an application.
LATEST COMMENTS
MC Press Online