|
|
| Author |
Message |
sivasaras
New User
Joined: 29 Sep 2007 Posts: 17 Location: chenna/i-
|
|
|
|
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 |
|
 |
References
|
|
 |
CICS Guy
Senior Member
Joined: 18 Jul 2007 Posts: 1741 Location: At my desk
|
|
|
|
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 |
|
 |
Anuj Dhawan
Global Moderator
Joined: 22 Apr 2006 Posts: 4037 Location: Mumbai, India
|
|
|
|
| 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 |
|
 |
Aaru
Senior Member
Joined: 03 Jul 2007 Posts: 1322 Location: Chennai - India
|
|
|
|
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 |
|
 |
sivasaras
New User
Joined: 29 Sep 2007 Posts: 17 Location: chenna/i-
|
|
|
|
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 |
|
 |
Robert Sample
Global Moderator
Joined: 06 Jun 2008 Posts: 4194 Location: Atlanta, GA
|
|
|
|
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 |
|
 |
enrico-sorichetti
Global Moderator
Joined: 14 Mar 2007 Posts: 5385 Location: italy
|
|
|
|
| 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 |
|
 |
William Thompson
Global Moderator
Joined: 18 Nov 2006 Posts: 3134 Location: Tucson AZ
|
|
|
|
| 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 |
|
 |
Chirantan Banerjee
New User
Joined: 08 Oct 2009 Posts: 14 Location: Kolkata, India
|
|
|
|
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 |
|
 |
sivasaras
New User
Joined: 29 Sep 2007 Posts: 17 Location: chenna/i-
|
|
|
|
Hi all,
Thanks for all your replies.
Regards,
Siva |
|
| Back to top |
|
 |
kailas girase
New User
Joined: 20 Nov 2008 Posts: 7 Location: New Bombay
|
|
|
|
| If we want to use same copybook multiple times in same program then we can use REPLACING keyword. |
|
| Back to top |
|
 |
Anuj Dhawan
Global Moderator
Joined: 22 Apr 2006 Posts: 4037 Location: Mumbai, India
|
|
|
|
Just being little picky - what if there is 'nothing' to be "replaced" in copybook (to be used multiple times)?  |
|
| Back to top |
|
 |
Chirantan Banerjee
New User
Joined: 08 Oct 2009 Posts: 14 Location: Kolkata, India
|
|
|
|
| Anuj Dhawan wrote: |
Just being little picky - what if there is 'nothing' to be "replaced" in copybook (to be used multiple times)?  |
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  |
|
| Back to top |
|
 |
|
|