Copybooks in a Library

If the copybooks used in a Cobol program are in a library, and the library is referenced in a COPY statement with the format COPY text-name IN library-name or COPY text-name OF library-name, the parser looks first for a copybook named library-name.text-name, and if it does not exist, for a copybook named text-name. If text-name does not exist, the parser reports library-name.text-name as an unresolved reference.

It is your responsibility to prefix library member names with library names or filepaths and dot (.) separators: dir1.dir2.member.cpy represents the copybook dir1/dir2/member, for example. When the parser encounters a reference to a member, it first searches for the longest possible name, dir1.dir2.member.cpy, and if not found, then the shorter versions, dir2.member.cpy and member.cpy.

Note: Unresolved references to library members are always reported with the longest name. This means that if you subsequently register a missing copybook with a short name, the referencing source file will not be invalidated. It’s up to you to remember that the referencing source needs to be reverified.