IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

How to use same COPY BOOK for both input & output file?


IBM Mainframe Forums -> COBOL Programming
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
satyapn9

New User


Joined: 08 Oct 2010
Posts: 27
Location: India

PostPosted: Mon Feb 11, 2013 7:59 pm
Reply with quote

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
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 8696
Location: Dubuque, Iowa, USA

PostPosted: Mon Feb 11, 2013 8:38 pm
Reply with quote

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
View user's profile Send private message
satyapn9

New User


Joined: 08 Oct 2010
Posts: 27
Location: India

PostPosted: Mon Feb 11, 2013 9:29 pm
Reply with quote

Thank you Robert. I would try this and get back to you if any issues.
Back to top
View user's profile Send private message
Gary McDowell

Active User


Joined: 15 Oct 2012
Posts: 139
Location: USA

PostPosted: Mon Feb 11, 2013 9:53 pm
Reply with quote

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
View user's profile Send private message
satyapn9

New User


Joined: 08 Oct 2010
Posts: 27
Location: India

PostPosted: Mon Feb 11, 2013 11:11 pm
Reply with quote

Thank you so much Gary,

I am exactly looking fo this.

<><>
Back to top
View user's profile Send private message
Gary McDowell

Active User


Joined: 15 Oct 2012
Posts: 139
Location: USA

PostPosted: Mon Feb 11, 2013 11:21 pm
Reply with quote

You are welcome Satyapn9. Good luck.
Back to top
View user's profile Send private message
Anuj Dhawan

Superior Member


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

PostPosted: Tue Feb 12, 2013 4:30 pm
Reply with quote

...I hope you've some ==:PREFIX:== already in your copybook?
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> COBOL Programming

 


Similar Topics
Topic Forum Replies
No new posts TRIM everything from input, output co... DFSORT/ICETOOL 1
No new posts FTP VB File from Mainframe retaining ... JCL & VSAM 4
No new posts Extract the file name from another fi... DFSORT/ICETOOL 6
No new posts How to split large record length file... DFSORT/ICETOOL 10
No new posts Extracting Variable decimal numbers f... DFSORT/ICETOOL 17
Search our Forums:

Back to Top