Wednesday, March 3, 2010

Procedures within an ILE RPG program

procedure within RPGLE program,

Something more am trying to know about procedure,subprocedure,service program. While googling sample programs and I created one procedure in program. Iam not sure about the the other concepts now. Let me hack it later.
these procedures can be used like built-in functions:-)

http://publib.boulder.ibm.com/iseries/v5r2/ic2924/books/c092508410.htm


steps for creation:

(1)
A Prototype which specifies the name, return value if any, and parameters if any.

(2)
A Begin-Procedure specification (B in position 24 of a procedure specification)

(3)
A Procedure-Interface definition, which specifies the return value and parameters, if any. The procedure interface must match the corresponding prototype. The procedure-interface definition is optional if the subprocedure does not return a value and does not have any parameters that are passed to it.

(4)
Other definition specifications of variables, constants and prototypes needed by the subprocedure. These definitions are local definitions.

(5)
Any calculation specifications, standard or free-form, needed to perform the task of the procedure. The calculations may refer to both local and global definitions. Any subroutines included within the subprocedure are local. They cannot be used outside of the subprocedure. If the subprocedure returns a value, then the subprocedure must contain a RETURN operation.

(6)
An End-Procedure specification (E in position 24 of a procedure specification)

See sample program:



Rest of the code highlighted:


But default activation group(DFTACTGRP) as 'YES' throwing error while compiling, this can solveed giving as option 'NO'

not sure the reason for this ( need to investigate)
Activation group . . . . . . . . ACTGRP QILE




OUTPUT




See little about free format.... we can write direct statements separated by semicolon in between /free ...and /end-free

Please refer :

Code400.com