Should we /copy or /Include our copybooks?

For general purposes, there's no difference between /COPY or /INCLUDE. General means what? For simple RPGLE type programs. However, for SQLRPGLE programs these things matter (And only for SQLRPGLE type programs).

Idea is that you can not use nested /COPY directive in SQLRPGLE programs. That's you define a copybook which again defines some copybook.

In that case you may get the following errors

  • The SQL preprocessor does not allow nested /COPY commands.
  • The SQL preprocessor does not always handle conditional compilation directives correctly.

What I did when I received such error is that I used /INCLUDE directive in the main SQLRPGLE source file. However, IBM recommends to use /COPY directive in the main file and use /INCLUDE in the copybooks.

In my case since all the copybooks were already defined, changing each of them was not possible so I tried with /INCLUDE in the main SQLRPGLE source and it worked! For further reading on ILE RPG please refer the IBM documentation.

Now that we have discussed entire COPYBOOK concept, let's see the FAQ's of COPYBOOKS.