Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

Copy book replace, compilation is failing

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
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    Post subject: Copy book replace, compilation is failing
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    Post subject:
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    Post subject:
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    Post subject:
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    Post subject:
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    Post subject:
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    Post subject:
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    Post subject:
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    Post subject:
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    Post subject:
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

Senior Member


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

PostPosted: Thu Feb 20, 2014 5:38 pm    Post subject: Re: Copy book replace
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    Post subject:
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: 7904
Location: Bellevue, IA

PostPosted: Fri Feb 21, 2014 2:04 am    Post subject:
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    IBMMAINFRAMES.com Support Forums -> COBOL Programming All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts syncsort: copy lines after the keyword shreya19 SYNCSORT 1 Fri Dec 02, 2016 9:47 am
No new posts Replace repeated JCL with looping REXX prino CLIST & REXX 3 Thu Oct 13, 2016 5:30 am
No new posts Single COPY CICS TS datasets and when... Kyle Carroll CICS 2 Tue Oct 11, 2016 9:47 pm
This topic is locked: you cannot edit posts or make replies. Sort card to replace text using cross... Susanta SYNCSORT 32 Tue Sep 13, 2016 4:17 pm
No new posts Replace function abdulrafi COBOL Programming 13 Mon Sep 12, 2016 10:12 am


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us