View previous topic :: View next topic
|
Author |
Message |
satyapn9
New User
Joined: 08 Oct 2010 Posts: 27 Location: India
|
|
|
|
Hi, I would like to use same copy book for both input & output files while writing a COBOL program.
I know that if i use that it would throw an error and I heard that some way is there to make use of same copy book for both files.
Can anyone help me ?? |
|
Back to top |
|
|
Robert Sample
Global Moderator
Joined: 06 Jun 2008 Posts: 8700 Location: Dubuque, Iowa, USA
|
|
|
|
Quote: |
I know that if i use that it would throw an error |
1. Mainframes do NOT "throw" errors. The program may ABEND, or the program may get a non-zero return code, but there is no "throwing" on mainframes.
2. What you know is wrong. It is perfectly legal to use the same copy book for multiple files.
3. The restriction on copy books is that IF THE COPY BOOK STARTS WITH AN 01 LEVEL, IT CAN OCCUR ONLY ONE TIME IN THE PROGRAM. If the copy book does not contain an 01 level, you can place it in different spots in the program -- as long as the 01 names are unique, you can then qualify your program statement as
Code: |
MOVE <COPY BOOK VARIABLE> OF 01-LEVEL-NAME TO ... |
and so forth. COBOL requires you to be able to uniquely identify a variable; as long as you can do that, there's no restriction on copy book usae. |
|
Back to top |
|
|
satyapn9
New User
Joined: 08 Oct 2010 Posts: 27 Location: India
|
|
|
|
Thank you Robert. I would try this and get back to you if any issues. |
|
Back to top |
|
|
Gary McDowell
Active User
Joined: 15 Oct 2012 Posts: 139 Location: USA
|
|
|
|
COPY REPLACING is another alternative. You can of course add ":PREFIX:" to the other COPY level field names.
Code: |
COPY COPYNAME.
01 :PREFIX:FIELDS.
COPY COPYNAME
REPLACING ==:PREFIX:==
BY ==INPUT-==.
01 INPUT-FIELDS.
COPY COPYNAME
REPLACING ==:PREFIX:==
BY ==OUTPUT-==.
01 OUTPUT-FIELDS. |
|
|
Back to top |
|
|
satyapn9
New User
Joined: 08 Oct 2010 Posts: 27 Location: India
|
|
|
|
Thank you so much Gary,
I am exactly looking fo this.
<><> |
|
Back to top |
|
|
Gary McDowell
Active User
Joined: 15 Oct 2012 Posts: 139 Location: USA
|
|
|
|
You are welcome Satyapn9. Good luck. |
|
Back to top |
|
|
Anuj Dhawan
Superior Member
Joined: 22 Apr 2006 Posts: 6248 Location: Mumbai, India
|
|
|
|
...I hope you've some ==:PREFIX:== already in your copybook? |
|
Back to top |
|
|
|