Include common executable code in functions
Include common declarations in Functions
A common set of code exists that needs to be executed from many functions.
SUBROUTINE NAME(SUB1)
*<<common set of code>>
ENDROUTINE
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.
One function calls another function, passing a working list. The working list needs to be defined exactly the same in both functions.
DEF_LIST NAME(#WRKLIST) FIELDS(<<fields needed>>) TYPE(*WORKING) ENTRYS(10)
INCLUDE PROCESS(*DIRECT) FUNCTION(FUNC1)
CALL PROCESS(*DIRECT) FUNCTION(FUNC3) PASS_LST(#WRKLIST)
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.