Joined: 05 Jun 2005 Posts: 165 Location: Bangalore
DCLGEN members need to be expanded during the Pre-Compilation as the variables declared in those members are placed in the COBOL code before the compilation. DCLGEN members are not used with the COPY option as the COPY expands the members during the Compile time.
If COPY is used instead of INCLUDE with the DCLGEN variables then syntactically there is no issue with it. The DCLGEN will get expanded during the compilation time if used with COPY like normal copybooks. In case of INCLUDE, it would have expanded during pre-compilation itself. I got to know the following fact from this very forum that during pre-compilation process the pre-compiler performs a basic syntax checking on the embedded SQL queries in the COBOL pgm wherein the columns name of the tables used in the program are matched with the DCLGEN. If we notice a DCLGEN there is a query placed at the top of it which is used for generating the DCLGEN. This query has all the column names listed for the table of whose DCLGEN is being created. The pre-compiler checks the column name of the tables used in the program with the query used for generating the DCLGEN of that table. Infact that is the precise reason why pre-compiler doesn't need DB2 to be up for its operation.
Having said that now if there is a misspeled column name being used in the program, if we are using COPY for DCLGEN this syntax catch will be missed. No doubt, it will get caught during BIND operation. However, if INCLUDE has been used with DCLGEN this bug will be caught in pre-compilation itself.