Skip to main content

[archive] Copy statement - how does replacing work

  • September 26, 2009
  • 2 replies
  • 0 views

[Migrated content. Thread originally posted on 25 September 2009]

Hi,
I don't understand how the COPY/REPLACING works in ACUCOBOL (v6 and v8). I expected this to work :
demo.cob:
identification division.
program-id. demo.

working-storage section.
copy "demo.cpy" replacing ==abc== by ==def==.

procedure division.

main section.
display def-var1
display def-var2
stop run
.

demo.cpy:
01 abc-misc.
03 abc-var1 pic x(05).
03 abc-var2 pic x(50).

But I am getting compile errors (undef DEF-var1 etc.). Does anybody see what is wrong here ? Do I need a specific compiler switch or so ?

Many thanks,
- Peter -

2 replies

[Migrated content. Thread originally posted on 25 September 2009]

Hi,
I don't understand how the COPY/REPLACING works in ACUCOBOL (v6 and v8). I expected this to work :
demo.cob:
identification division.
program-id. demo.

working-storage section.
copy "demo.cpy" replacing ==abc== by ==def==.

procedure division.

main section.
display def-var1
display def-var2
stop run
.

demo.cpy:
01 abc-misc.
03 abc-var1 pic x(05).
03 abc-var2 pic x(50).

But I am getting compile errors (undef DEF-var1 etc.). Does anybody see what is wrong here ? Do I need a specific compiler switch or so ?

Many thanks,
- Peter -
try this code;

COPY "demo.cpy" replacing LEADING "abc" by "def".

[Migrated content. Thread originally posted on 25 September 2009]

Hi,
I don't understand how the COPY/REPLACING works in ACUCOBOL (v6 and v8). I expected this to work :
demo.cob:
identification division.
program-id. demo.

working-storage section.
copy "demo.cpy" replacing ==abc== by ==def==.

procedure division.

main section.
display def-var1
display def-var2
stop run
.

demo.cpy:
01 abc-misc.
03 abc-var1 pic x(05).
03 abc-var2 pic x(50).

But I am getting compile errors (undef DEF-var1 etc.). Does anybody see what is wrong here ? Do I need a specific compiler switch or so ?

Many thanks,
- Peter -
Unfortunately, that does not work using acucobol 6.
I'll try it out with acucobol 8.1 .... perhaps that will work.
Thanks,
- Peter -