Return to the RPG Tips
Using copy members with SQLRPGLE source
Using /COPY and conditional compiler directives in your RPG IV programs lets you easily reuse RPG IV code. Some of you using /COPY extensively have run into problems, though, when using /COPY in SQLRPGLE members. When compiling SQLRPGLE members, the SQL precompiler first processes the SQL statements and then copies in the members specified in /COPY. The problem is that the SQL precompiler doesn't handle /EOF or nested /COPY members correctly. The precompiler adds in the /COPY member, including /EOF, which causes the compiler to ignore all lines following /EOF, causing the compile to fail.
To correct this problem, IBM has released the RPG IV /INCLUDE directive. /INCLUDE can be used interchangeably with /COPY, as they do exactly the same function with one exception: the SQL precompiler leaves the /INCLUDE in the source member, without reading the /INCLUDEd source member.
Because the SQL precompiler never processes an /INCLUDE source member, the /INCLUDEd member shouldn't contain embedded SQL or definitions relating to host variables. If you do need to include embedded SQL or definitions relating to host variables in an included member, you can still use /COPY -- just don't use /EOF in the included member.
You can obtain the /INCLUDE directive in V4R4 with PTF SF61918; /INCLUDE is included in V4R5. As of this writing, /INCLUDE hasn't made it into IBM's documentation. Also, PTF SF61918 doesn't affect SEU's syntax checker or CODE/400's program verifier, so both will flag /INCLUDE as an error.
[report a broken link by clicking here]