Problem:
How to code a COPY REPLACING statement?
Resolution:
This is a useful and widely exploited feature within COBOL. However, the syntax can often cause problems and it is hoped the following will give some much needed clarification.
The attached demo illustrates one particular use for COPY REPLACING -- the reuse of a file status copybook. If we look at the FSTAT-WS.CPY we see:
01 (tag)-fstat.
03 (tag)-fs-values.
05 (tag)-fs-key1 pic x(1).
05 (tag)-fs-key2 pic x(1).
05 (tag)-fs-key2-bin redefines
(tag)-fs-key2 pic 9(2) comp-x.
03 (tag)-fs-error redefines
(tag)-fs-values pic x(2).
This source code will not compile "as is" due to the (tag) on each line. This is known as the substitution marker and indicates the text we want to replace during compilation.
Our sample program (PROG01.CBL) brings in the copybook via a COPY statement. We also indicate on the COPY statement that anywhere (tag) is foundit should be replaced by the text in the following double equal signs.
We suggest you download the Net Express project, compile the program and animate to see the full effect.



