IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

Copy book replace, compilation is failing


IBM Mainframe Forums -> COBOL Programming
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
vinuseba

New User


Joined: 17 Feb 2014
Posts: 19
Location: India

PostPosted: Thu Feb 20, 2014 3:40 pm
Reply with quote

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
View user's profile Send private message
sureshpathi10

Active User


Joined: 03 May 2010
Posts: 154
Location: Kuala Lumpur

PostPosted: Thu Feb 20, 2014 4:34 pm
Reply with quote

Can you try without '=' symbol?

Code:
COPY RBABCC REPLACING RBH- BY GW407OU-


Please refer http://pic.dhe.ibm.com/infocenter/ratdevz/v9r0/index.jsp?topic=%2Fcom.ibm.etools.cbl.win.doc%2Ftopics%2Frlcdscop.htm for more information.
Back to top
View user's profile Send private message
vinuseba

New User


Joined: 17 Feb 2014
Posts: 19
Location: India

PostPosted: Thu Feb 20, 2014 4:39 pm
Reply with quote

Thank you Suresh for your suggestion

i tried

COPY RBABCC REPLACING RBH- BY GW407OU-

but not working.....
Back to top
View user's profile Send private message
sureshpathi10

Active User


Joined: 03 May 2010
Posts: 154
Location: Kuala Lumpur

PostPosted: Thu Feb 20, 2014 4:40 pm
Reply with quote

Can you provide the compilation error you're getting for this COPY statement?
Back to top
View user's profile Send private message
vinuseba

New User


Joined: 17 Feb 2014
Posts: 19
Location: India

PostPosted: Thu Feb 20, 2014 4:43 pm
Reply with quote

errors are like

GW407OU-RECORD not defined . Its coming for all the GW407OU- variables using in the PGM...
Back to top
View user's profile Send private message
sureshpathi10

Active User


Joined: 03 May 2010
Posts: 154
Location: Kuala Lumpur

PostPosted: Thu Feb 20, 2014 4:45 pm
Reply with quote

Could you post your compiler listening for this particular COPY statement?

how it is getting included in source?
Back to top
View user's profile Send private message
vinuseba

New User


Joined: 17 Feb 2014
Posts: 19
Location: India

PostPosted: Thu Feb 20, 2014 4:49 pm
Reply with quote

it is including the RBABCC copy book variables only ....not replacing with GW407OU
Back to top
View user's profile Send private message
sureshpathi10

Active User


Joined: 03 May 2010
Posts: 154
Location: Kuala Lumpur

PostPosted: Thu Feb 20, 2014 5:01 pm
Reply with quote

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
View user's profile Send private message
vinuseba

New User


Joined: 17 Feb 2014
Posts: 19
Location: India

PostPosted: Thu Feb 20, 2014 5:05 pm
Reply with quote

for that i need to modify the copy book also with colons(icon_smile.gif . 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
View user's profile Send private message
sureshpathi10

Active User


Joined: 03 May 2010
Posts: 154
Location: Kuala Lumpur

PostPosted: Thu Feb 20, 2014 5:08 pm
Reply with quote

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
View user's profile Send private message
Anuj Dhawan

Superior Member


Joined: 22 Apr 2006
Posts: 6250
Location: Mumbai, India

PostPosted: Thu Feb 20, 2014 5:38 pm
Reply with quote

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
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6966
Location: porcelain throne

PostPosted: Thu Feb 20, 2014 11:37 pm
Reply with quote

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
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 8696
Location: Dubuque, Iowa, USA

PostPosted: Fri Feb 21, 2014 2:04 am
Reply with quote

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
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> COBOL Programming

 


Similar Topics
Topic Forum Replies
No new posts Replace each space in cobol string wi... COBOL Programming 3
No new posts Replace Multiple Field values to Othe... DFSORT/ICETOOL 12
No new posts VB to VB copy - Full length reached SYNCSORT 8
No new posts replace word 'MONTH' with current mon... SYNCSORT 11
No new posts Need COBOL COPY Help in MVS Environment COBOL Programming 4
Search our Forums:

Back to Top