A procedure is a collection of statements that can be called and run.
There are three kinds of procedures in RPG: regular subprocedures, linear-main procedures and cycle-main procedures. RPG source programs can be compiled into one of three kinds of modules depending on the types of procedures present, and as indicated by the presence of the NOMAIN or MAIN keyword on the Control specification: Cycle, Nomain, or Linear-main modules.
The term "subprocedure" is used to denote both regular subprocedures and linear-main procedures.
An RPG source program can be divided into these sections which contain procedures:
A cycle module may be designed without sub-procedures, and thus have no separate Procedure section.
The linear-main procedure is indicated by the use of the MAIN keyword on a Control specification, making it a special kind of sub-procedure.