View previous topic :: View next topic
|
Author |
Message |
vinuseba
New User
Joined: 17 Feb 2014 Posts: 19 Location: India
|
|
|
|
HI
My copy book - RBABCC is as below.
01 RBH-RECORD.
03 RBH-ABC.
05 RBH-ITM-WH-TYP.
10 RBH-DEFT PIC X(9).
10 RBH-ASDF PIC 9(4).
10 RBH-WHAAAAA REDEFINES RBH-ASDF.
15 RBH-AAAAAAA PIC XX.
15 RBH-SSSSSSSS PIC XX.
I tried using the copy book in cobol program along with replacing option as below.
COPY RBABCC REPLACING == RBH-== BY == GW407OU-==
But the compilation is failing with the message GW407OU variables are not defined.
Please suggest me how i can use replacing option here correctly.
Thank you in advance |
|
Back to top |
|
|
sureshpathi10
Active User
Joined: 03 May 2010 Posts: 158 Location: Kuala Lumpur
|
|
Back to top |
|
|
vinuseba
New User
Joined: 17 Feb 2014 Posts: 19 Location: India
|
|
|
|
Thank you Suresh for your suggestion
i tried
COPY RBABCC REPLACING RBH- BY GW407OU-
but not working..... |
|
Back to top |
|
|
sureshpathi10
Active User
Joined: 03 May 2010 Posts: 158 Location: Kuala Lumpur
|
|
|
|
Can you provide the compilation error you're getting for this COPY statement? |
|
Back to top |
|
|
vinuseba
New User
Joined: 17 Feb 2014 Posts: 19 Location: India
|
|
|
|
errors are like
GW407OU-RECORD not defined . Its coming for all the GW407OU- variables using in the PGM... |
|
Back to top |
|
|
sureshpathi10
Active User
Joined: 03 May 2010 Posts: 158 Location: Kuala Lumpur
|
|
|
|
Could you post your compiler listening for this particular COPY statement?
how it is getting included in source? |
|
Back to top |
|
|
vinuseba
New User
Joined: 17 Feb 2014 Posts: 19 Location: India
|
|
|
|
it is including the RBABCC copy book variables only ....not replacing with GW407OU |
|
Back to top |
|
|
sureshpathi10
Active User
Joined: 03 May 2010 Posts: 158 Location: Kuala Lumpur
|
|
|
|
Here is what I found out.
You can't change the partial name without using a delimiter.
Change your copy book as follows
Code: |
01 :RBH:-RECORD.
03 :RBH:-ABC.
05 :RBH:-ITM-WH-TYP.
10 :RBH:-DEFT PIC X(9).
10 :RBH:-ASDF PIC 9(4).
10 :RBH:-WHAAAAA REDEFINES :RBH:-ASDF.
15 :RBH:-AAAAAAA PIC XX.
15 :RBH:-SSSSSSSS PIC XX. |
Then use this copy statement...
Code: |
COPY RBABCC REPLACING ==:RBH:== BY ==GW407OU==. |
|
|
Back to top |
|
|
vinuseba
New User
Joined: 17 Feb 2014 Posts: 19 Location: India
|
|
|
|
for that i need to modify the copy book also with colons( . I can't do that since the copy book is sharing with so many components.....
Thank you so much for that approach but it will be really great if there is some way to do that with out modifying copy book.... |
|
Back to top |
|
|
sureshpathi10
Active User
Joined: 03 May 2010 Posts: 158 Location: Kuala Lumpur
|
|
|
|
As I mentioned earlier, Partial name change can be done by using delimiter.
if you want to do this without changing the copybook, then you should use the "Example 2" in the link, I've given. (For this you may define all variables directly with whatever name you wish) |
|
Back to top |
|
|
Anuj Dhawan
Superior Member
Joined: 22 Apr 2006 Posts: 6248 Location: Mumbai, India
|
|
|
|
vinuseba wrote: |
COPY RBABCC REPLACING == RBH-== BY == GW407OU-==
But the compilation is failing with the message GW407OU variables are not defined. |
With this in mind and the restrictions you've posted so far - suggest you create a new copybook with essentially the same content but with delimiter as sureshpathi10 has mentioned. Put a note in this new copybook about why you mkae this change.
Second, copy the copybook in line with program and change the variable name to what you wish. Apart from these, with what you've posted nothing much can be done. |
|
Back to top |
|
|
dbzTHEdinosauer
Global Moderator
Joined: 20 Oct 2006 Posts: 6966 Location: porcelain throne
|
|
|
|
another approach:
COPY RBABCC replacing RBH-RECORD BY GW407OU-RECORD.
then just qualify all elements in your code with either
IN RBH-RECORD
or
IN GW407OU-RECORD
making a copy of a COPYBOOK is bad practice,
because you may not be around to supervise the changing of the copied version
in case the original is changed.
using my method, you only have to change the element names (or add or delete)
in the PROCEDURE DIVISION, which you would have to do anyway.
that way no one is screwed because of your shortcut. |
|
Back to top |
|
|
Robert Sample
Global Moderator
Joined: 06 Jun 2008 Posts: 8700 Location: Dubuque, Iowa, USA
|
|
|
|
You do not understand the REPLACING phrase in the COPY statement. From the Programming Reference manual:
Quote: |
8.1.7.2 REPLACING phrase
In the discussion that follows, each operand can consist of one of the following:
Pseudo-text
An identifier
A literal
A COBOL word (except the word COPY)
Function identifier
When the REPLACING phrase is specified, the library text is copied, and each properly matched occurrence of operand-1 within the library text is replaced by the associated operand-2.
pseudo-text A sequence of character-strings or separators, or both, bounded by, but not including, pseudo-text delimiters (==). Both characters of each pseudo-text delimiter must appear on one line; however, character-strings within pseudo-text can be continued. Individual character-strings within pseudo-text can be up to 322 characters long; they can be continued subject to the normal continuation rules for source code format. Keep in mind that a character-string must be delimited by separators. |
The last sentence in this quote tells you that ==RBH-== is NOT a valid pseudo-text as it is not surrounded by separators. Furthermore, it is not an identifier, nor literal, nor COBOL word, nor function identifier. In other words, your REPLACING phrase does not match any valid construct and hence the text is not replaced.
For what you have and what you want, Dick's suggestion is the ONLY way to do it. |
|
Back to top |
|
|
|