In IBM i, copybooks are typically stored in a source physical file (such as a member of a source file) but can also be stored in the modern preferred IFS locations. These snippets of reuseable code can be used in CL programs by copying the contents of the copybook into the program.

This is done using the INCLUDE command, which tells the compiler to include the contents of the copybook in the program

Here is very simple example:

copybook - include.clleinc

DCL VAR(&MSG) TYPE(*CHAR) LEN(100)
copybook - include.clleinc

CL Program- CLBNDPGM.PGM.CLLE

Here is a very simple CL program sucking in the declare statement from the copybook:

PGM PARM(&MSG)
  INCLUDE SRCSTMF('include.clleinc')
  SNDPGMMSG MSG(&MSG) TOPGMQ(*EXT) TOMSGQ(*TOPGMQ) MSGTYPE(*COMP)
ENDPGM
CL Program- CLBNDPGM.PGM.CLLE

Remember, we don't need to add the folder prefix so the copybook location because CODE4IBMI/BOB knows where it lives by the include paths defined in the Project Explorer.

include paths defined in the Project Explorer
{"email":"Email address invalid","url":"Website address invalid","required":"Required field missing"}
>