Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

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

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
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    Post subject: How to use same COPY BOOK for both input & output file?
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: 7913
Location: Bellevue, IA

PostPosted: Mon Feb 11, 2013 8:38 pm    Post subject:
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    Post subject: How to use same COPY BOOK for both input & output file?
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    Post subject:
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    Post subject: How to use same COPY BOOK for both input & output file?
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    Post subject:
Reply with quote

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

Senior Member


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

PostPosted: Tue Feb 12, 2013 4:30 pm    Post subject:
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    IBMMAINFRAMES.com Support Forums -> COBOL Programming All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Performing arithmetic on input field zh_lad DFSORT/ICETOOL 24 Tue Dec 06, 2016 8:04 pm
No new posts syncsort: copy lines after the keyword shreya19 SYNCSORT 7 Fri Dec 02, 2016 9:47 am
No new posts High CPU consumption Job using IAM fi... aswinir JCL & VSAM 8 Thu Dec 01, 2016 8:28 pm
No new posts Add PD field from 2nd file to PD in 1st Sushant Garje DFSORT/ICETOOL 6 Thu Dec 01, 2016 4:32 pm
No new posts File Aid to File Manager conversion murali3955 IBM Tools 4 Thu Nov 24, 2016 3:41 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us