MVSFORUMS.com Forum Index MVSFORUMS.com
A Community of and for MVS Professionals
 
 FAQFAQ   SearchSearch   Quick Manuals   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Copy Statement in COBOL

 
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Application Programming
View previous topic :: View next topic  
Author Message
haqshaik
Beginner


Joined: 11 May 2005
Posts: 49
Topics: 19

PostPosted: Thu Jun 01, 2006 10:30 am    Post subject: Copy Statement in COBOL Reply with quote

Hi All.

I am using COPY statement with replacing option in the working storage.
While I complie, the replace statement is not working. if i simply say copy the copy book is getting expanded properly in the complialtion listing.

Here is my copy statement.

I have tried the following three variations
Variaition1: COPY FNLREQCP REPLACING "CPY" BY "INP"
Varaition2: COPY FNLREQCP REPLACING 'CPY' BY 'INP'
Third varaition is using the pseudo text.
Variation3:COPY FNLREQCP REPLACING ==CPY== BY ==INP==

I am pasting down the copy book for reference.

01 CPY-ADDRESS-REQ-DATA.

05 CPY-ADDRESS-REQ.
10 CPY-ADDRESS-LINE1 PIC X(30).
10 CPY-ADDRESS-LINE2 PIC X(30).
10 CPY-CITY-ST-LINE PIC X(17).
10 CPY-ZIP-CD PIC X(05).
10 CPY-ZIP-EXT PIC X(04).

I have searched throuh the forum and found good info about copy statement. But I could not resolve what the problem is.
Do we need to specify some compiler option for the replace to be effective?
Am I missing something here? Please guide me.

Thanks,
Salauddin
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12366
Topics: 75
Location: San Jose

PostPosted: Thu Jun 01, 2006 11:25 am    Post subject: Reply with quote

haqshaik,

The COPY statement with REPLACING phrase can be used to replace parts of words only by inserting a dummy operand delimited by colons into the variable names.

if your copy book was follows

Code:

01 :CPY:-ADDRESS-REQ-DATA.             
   05 :CPY:-ADDRESS-REQ.               
      10 :CPY:-ADDRESS-LINE1 PIC X(30).
      10 :CPY:-ADDRESS-LINE2 PIC X(30).
      10 :CPY:-CITY-ST-LINE PIC X(17). 
      10 :CPY:-ZIP-CD      PIC X(05).   
      10 :CPY:-ZIP-EXT     PIC X(04).   


Then you can use
Code:

COPY cpybookname REPLACING ==:CPY:== BY ==INP==.

which will translate the copybook to

Code:

01  INP-ADDRESS-REQ-DATA.             
    05 INP-ADDRESS-REQ.                 
       10 INP-ADDRESS-LINE1 PIC X(30). 
       10 INP-ADDRESS-LINE2 PIC X(30). 
       10 INP-CITY-ST-LINE  PIC X(17).   
       10 INP-ZIP-CD        PIC X(05).   
       10 INP-ZIP-EXT       PIC X(04).   
                                       


Hope this helps...

Cheers

Kolusu
_________________
Kolusu - DFSORT Development Team (IBM)
DFSORT is on the Web at:
www.ibm.com/storage/dfsort

www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
haqshaik
Beginner


Joined: 11 May 2005
Posts: 49
Topics: 19

PostPosted: Thu Jun 01, 2006 1:06 pm    Post subject: Reply with quote

Thanks Kolusu,
its working now. Thanks for your help.

Thanks,
Salauddin
Back to top
View user's profile Send private message
neilxt
Beginner


Joined: 01 Mar 2004
Posts: 23
Topics: 1

PostPosted: Tue Sep 19, 2006 3:54 pm    Post subject: Reply with quote

kolusu wrote:
haqshaik,

The COPY statement with REPLACING phrase can be used to replace parts of words only by inserting a dummy operand delimited by colons into the variable names.


This works however the statement is not exactly true as stated. For clarity the COPY REPLACING statement only replaces words. In order to make it work as required you have to trick the compiler into seeing a word (or words) in the REPLACING field and have the BY field replace it in such a way as to remove the delimiter that broke the field name into two.

Surrounding the replaceable part with colons is a good way, but any special character at the end of the replaceable part will work.

e.g.
Code:
COPY MYREC REPLACING ==PREFIX@== BY ==ABC==


Code:

01 PREFIX@-MYFIELD PIC XXX.

Becomes

Code:

01 ABC-MYFIELD PIC XXX.


N.
Back to top
View user's profile Send private message Send e-mail
Display posts from previous:   
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Application Programming All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


MVSFORUMS
Powered by phpBB © 2001, 2005 phpBB Group