The COPY and REPLACE statements can be used to extend and/or modify a source text with texts stored in a library. These two statements, which are effective in the source text manipulation phase can be used either independently or together.
A COPY statement extends an existing source text with COBOL text lines taken from a library element. The compiler then treats the inserted text as part of the compilation unit. The REPLACING phrase offers the additional possibility of replacing each occurrence of a literals, an identifier, a word or a group of words with another text.
The REPLACE statement causes parts of the source text to be replaced with new texts. With a REPLACE statement, compilation units written by the programmer in his self-defined notation can be converted at compile time into syntactically correct phrases, clauses and statements.
The compiler does not check the source text until execution of all COPY and REPLACE statements has been completed.