Portal | IBM Manuals | Downloads | Products | Refer | Info | Programs | JCLs | Forum Rules*| Site Map | Mainframe CD 
IBMMAINFRAMES.com - IBM Mainframe Support Forums Index
 
Register
 
IBMMAINFRAMES.com - IBM Mainframe Support Forums Index FAQ Search Memberlist Usergroups Profile Log in to check your private messages Log in
 
Need information about COPY verb in Cobol?

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> Mainframe COBOL
Author Message
sivasaras

New User


Joined: 29 Sep 2007
Posts: 17
Location: chenna/i-

PostPosted: Fri Feb 05, 2010 8:59 am    Post subject: Need information about COPY verb in Cobol?
Reply with quote

Hi,

I have 3 copybooks and i want to add 2 new fields to one of the copybook and i want to use it in one of the program,but that copybook is used by many programs, how can we use COPY verb in this case?

Thanks in Advance

Regards,
Siva
Back to top
View user's profile Send private message
References
CICS Guy

Senior Member


Joined: 18 Jul 2007
Posts: 1741
Location: At my desk

PostPosted: Fri Feb 05, 2010 9:37 am    Post subject:
Reply with quote

Will the adding of the two fields change the displacement of any other fields?
Will the adding of the two fields change the length of the copybooks?
Back to top
View user's profile Send private message
Anuj Dhawan

Global Moderator


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

PostPosted: Fri Feb 05, 2010 2:44 pm    Post subject: Reply to: Need information about COPY verb in Cobol?
Reply with quote

Quote:
I have 3 copybooks and i want to add 2 new fields to one of the copybook...
and the other questions are

- why there is a reference for "3 copybooks" while in the very same sentence you talk about changing only one copybook?

- Have you used the "existing" FILLERs from the "existing" copybook, for the new fields?
Back to top
View user's profile Send private message
Aaru

Senior Member


Joined: 03 Jul 2007
Posts: 1322
Location: Chennai - India

PostPosted: Mon Feb 08, 2010 5:40 pm    Post subject: Reply to: Need information about COPY verb in Cobol?
Reply with quote

siva,

Quote:
how can we use COPY verb in this case?

This is confusing.

When you make changes to your copybook, it can be one among the following cases

1) When the length of the copybook changes - In this case you will have to recompile all the programs using the copybook (COPY verb should be ussed to include the copybok)

2) When the length doesn't change and the new field is added in the FILLER space. - In this case you will have to compile the program only if the field is used.

In all these cases "COPY" verb needs to be used in the programs to include the copybook.
Back to top
View user's profile Send private message
sivasaras

New User


Joined: 29 Sep 2007
Posts: 17
Location: chenna/i-

PostPosted: Tue Feb 09, 2010 8:58 am    Post subject: Reply to: Need information about COPY verb in Cobol?
Reply with quote

Hi,

Let me clear my question.

There is only 1 copybook which can be used by many programs,now i want to add 2 fields to that copybook and has to be used in one of the program,whether it is possible?

If we add 2 fields means we cannot use that copybook for many programs right because only one program needs changes?

Regards,
Siva
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 4194
Location: Atlanta, GA

PostPosted: Tue Feb 09, 2010 9:11 am    Post subject:
Reply with quote

The answer to your questions is ... it depends. If the fields are added to the end of the copy book, and the copy book is not defining a file layout or CICS COMMAREA (just a WORKING-STORAGE layout), then you can add the fields to the copy book. As programs that invoke the copy book are recompiled, they will pick up the two new fields but there's no reason to go back and recompile them just for the new data.

If you are not adding the fields to the end of the copy book, or the copy book is used for a file record layout (or CICS COMMAREA layout), then you probably want to recompile every program using the copy book to ensure they are consistent. Or, you can create a new version of the copy book with a new name for just the programs that need the new fields. What is done usually depends to some degree upon site standards.
Back to top
View user's profile Send private message
enrico-sorichetti

Global Moderator


Joined: 14 Mar 2007
Posts: 5385
Location: italy

PostPosted: Tue Feb 09, 2010 11:32 am    Post subject: Reply to: Need information about COPY verb in Cobol?
Reply with quote

Quote:
but that copybook is used by many programs, how can we use COPY verb in this case?


the COPY directive is transparent to the copybook content...
it will simply expand ONE <thing> to many lines of COBOL coding.

You need to carry on the <so called> impact analysis,
it means verify how the change will affect all the other programs using the copybook.

if the copybook describes ONLY woking storage thing the impact might be small or nonexistent,
if the copybook describes a RECORD layout quite a bit of investigation has to be carried on
Back to top
View user's profile Send private message
William Thompson

Global Moderator


Joined: 18 Nov 2006
Posts: 3134
Location: Tucson AZ

PostPosted: Tue Feb 09, 2010 1:52 pm    Post subject: Re: Reply to: Need information about COPY verb in Cobol?
Reply with quote

sivasaras wrote:
If we add 2 fields means we cannot use that copybook for many programs right because only one program needs changes?
For starters, answer CICS Guy's question.....
Back to top
View user's profile Send private message
Chirantan Banerjee

New User


Joined: 08 Oct 2009
Posts: 14
Location: Kolkata, India

PostPosted: Thu Feb 11, 2010 3:02 pm    Post subject:
Reply with quote

Well, not sure what you are exactly looking for, but if the problem is like -
I want to add two new fields at the end of a group variable that has been defined in a copybook and want to use it in only one of the programs out of a total of n programs which uses the cooybook, Then you may try this out -

COPY COPYBOOK.
05 NEW-VARIABLE01 PIC X.
05 NEW-VARIABLE02 PIC X.

Assuming that the content of the copybook is something like this -

01 GROUP-VARIABLE-NAME.
05 VAR1 PIC X.
05 VAR2 PIC X.
05 VAR3 PIC X.
.........

And so on.


You may also declare the 2 new variables in a new copybook and use it as -

COPY COPYBOOK.
COPY NEWCOPY.
where newcopy is the name of the new copybook. This should work.


But if you want to add the new fields somewhere in the middle, then this won't work and maybe having a separate copybook for this one program that you need to change will be a better idea.
Back to top
View user's profile Send private message
sivasaras

New User


Joined: 29 Sep 2007
Posts: 17
Location: chenna/i-

PostPosted: Thu Feb 11, 2010 5:18 pm    Post subject: Reply to: Need information about COPY verb in Cobol?
Reply with quote

Hi all,

Thanks for all your replies.

Regards,
Siva
Back to top
View user's profile Send private message
kailas girase

New User


Joined: 20 Nov 2008
Posts: 7
Location: New Bombay

PostPosted: Thu Feb 11, 2010 5:54 pm    Post subject: Replacing with phrase in cobol for copybook
Reply with quote

If we want to use same copybook multiple times in same program then we can use REPLACING keyword.
Back to top
View user's profile Send private message
Anuj Dhawan

Global Moderator


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

PostPosted: Thu Feb 11, 2010 6:01 pm    Post subject:
Reply with quote

Just being little picky - what if there is 'nothing' to be "replaced" in copybook (to be used multiple times)? icon_smile.gif
Back to top
View user's profile Send private message
Chirantan Banerjee

New User


Joined: 08 Oct 2009
Posts: 14
Location: Kolkata, India

PostPosted: Fri Feb 12, 2010 10:18 am    Post subject:
Reply with quote

Anuj Dhawan wrote:
Just being little picky - what if there is 'nothing' to be "replaced" in copybook (to be used multiple times)? icon_smile.gif


Don't replace anything !!! Just use separate group variable names for each time you are reusing the copybook in the same program and have the member variables declared in the copybook.

Of course COBOL allows the same variable name to be used under different group variables in the same program and they are allocated as different variables. You can reference them in your program as -

VARIABLE1 OF/IN GROUP-VARIABLE1
VARIABLE1 OF/IN GROUP-VARIABLE2
and so on

Of course this post might not be very useful to the members of this forum 'coz i suppose this is something very fundamental even for a schholboy learning COBOL but I just thought of putting this up in case a new programmer is looking for something like this and just bumps into this post from a google search result icon_razz.gif
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> Mainframe COBOL All times are GMT + 6 Hours
Page 1 of 1