Include common executable code in functions
Include common declarations in Functions
Include common executable code in functions
A common set of code exists that needs to be executed from many functions.
FUNCA RDML
SUBROUTINE NAME(SUB1)
*<<common set of code>>
ENDROUTINE
FUNCB RDML
EXECUTE SUBROUTINE(SUB1)
INCLUDE PROCESS(PROCA) FUNCTION(FUNCA)
As an alternative, you could place the common code in its own function and call it where it is needed, or copy it in to each function that needs it. Using the INCLUDE command is the recommended approach.
Include common declarations in Functions
One function calls another function, passing a working list. The working list needs to be defined exactly the same in both functions.
FUNC1 RDML
DEF_LIST NAME(#WRKLIST) FIELDS(<<fields needed>>) TYPE(*WORKING) ENTRYS(10)
FUNC2 RDML
INCLUDE PROCESS(*DIRECT) FUNCTION(FUNC1)
CALL PROCESS(*DIRECT) FUNCTION(FUNC3) PASS_LST(#WRKLIST)
FUNC3 RDML
FUNCTION OPTIONS(*DIRECT) RCV_LIST(#WRKLIST)
INCLUDE PROCESS(*DIRECT) FUNCTION(FUNC1)
Alternatives would be either to define the working list in one function then copy it into the other function that needs it, or to include it in the functions that need it.