procedures and sub procedure

115
Procedures and Subprocedures ============================= A procedure is a routine that is called using a bound call. You can create two kinds of procedures in RPG: a main procedure and a subprocedure. A main procedure uses the RPG cycle. It is specified in the main source section. You do not need to code anything special to define the main procedure; it consists of everything before the first Procedure specification. The parameters for the main procedure can be coded using a prototype and procedure interface in the global Definition specifications, or using a *ENTRY PLIST in the main procedure's calculations. Any procedure interface found in the global definitions is assumed to be the procedure interface for the main procedure. The name is required for the procedure interface for the main procedure, and the prototype with the matching name must precede the procedure interface in the source. The name of the main procedure must be the same as the name of the module being created. You can either use this name for the prototype and procedure interface, or specify this name in the EXTPROC keyword of the prototype. In the following example, module CheckFile is created. The main procedure has three parameters: A file name (input) A library name (input) An indicator indicating whether the file was found (output) /COPY file CHECKFILEC with the prototype for the main procedure: D CheckFile PR D file 10a const D library 10a const D found 1N Module CheckFile: /COPY CHECKFILEC D CheckFile PI D file 10a const D library 10a const D found 1N C ... code using parameters file, library and found Using a *ENTRY PLIST, you would define the parameters this way: D file S 10a const D library S 10a const D found S 1N C *ENTRY PLIST C PARM file

Upload: meenakshi-gupta

Post on 22-Oct-2014

124 views

Category:

Documents


10 download

TRANSCRIPT

' + C 'Hello World!' + C '