The procedure specification is used to isolate the first and last statement of an RPG subprocedure. The procedure specification simply blocks the starting and ending source statements of the subprocedure and, optionally, identifies the procedure as being available to other procedures. The procedure specification ruler is shown in Figure 2.18.
.....PProcName+++++++..B...................Functions++++++++++++++++++++++++++++
A procedure definition is made up of three parts:
Procedure prototype (specified with the definition specification).
Procedure identification (specified with the procedure specification).
Procedure interface (specified with the definition specification).
With only two exceptions, the procedure prototype and the procedure interface are similar interfaces. First, the type of definition specification is PR (for the procedure prototype) and PI (for the procedure interface). Second, the parameter names specified on the procedure interface are accessible by the procedure. The names specified on the procedure prototype, however, are optional and are used for documentation purposes only. They are not accessible by the calling procedure.
A procedure prototype is required within any program that calls the subprocedure and by the subprocedure itself. Procedure prototypes can be stored in a separate source file, and are included at compile time through the /COPY compiler directive. This allows the prototype to be inserted into any source file that requires it.
Table 2.21 summarizes the procedure specification.
Column | Title | Values | Description |
---|---|---|---|
6 | Form type | P | Identifies this statement as a procedure specification. |
7 – 21 | Procedure name | Name | Name of the procedure being defined. |
24 | B | This procedure specification identifies the beginning of the subprocedure named in positions 7 to 21. | |
E | This procedure specification identifies the ending of the subprocedure named in positions 7 to 21. | ||
44 – 80 | Functions | Keywords | Any valid procedure specification keyword can be specified. Currently, the EXPORT keyword is the only procedure keyword. |
Table 2.22 summarizes the keyword for the procedure specification.
Keyword | Parameters | Description |
---|---|---|
EXPORT | ['Exported procedure name'] | The procedure is exported and made available to other "external" modules. The exported procedure name is optional and, if specified, indicates the name of the procedure as it is exported. This exported name is the name used by other modules to import this procedure. Exported names specified on this keyword are enclosed in quotes and are exported case sensitive. |