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 can 2 copybooks write in the same file ?

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
View previous topic :: :: View next topic  
Author Message
neelesht

New User


Joined: 24 Jul 2006
Posts: 99
Location: Los Angeles

PostPosted: Wed Feb 14, 2007 2:18 am    Post subject: how can 2 copybooks write in the same file ?
Reply with quote

Hi All,

I have a prog which writes a report into a file from A COPYBOOK layout.

I need to add another copybook B in the program and want prog to write into report the contents of COPYBOOK A + COPYBOOK B

How do I write the WRITE statement for 2 copybooks together.

I hope I haven't confused you guys.

Thanks alot
Neelesh
Back to top
View user's profile Send private message

DavidatK

Active Member


Joined: 22 Nov 2005
Posts: 700
Location: Troy, Michigan USA

PostPosted: Wed Feb 14, 2007 2:42 am    Post subject: Re: how can 2 copybooks write in the same file ?
Reply with quote

neelesht,

Let Me understand,

You have two copybooks, copybook 'A' length 120 and copybook 'B' length 120. You now want to change the output write from writing copybook 'A' length 120 to copybook 'A' + 'B' length 240?
Back to top
View user's profile Send private message
William Thompson

Global Moderator


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

PostPosted: Wed Feb 14, 2007 2:45 am    Post subject: Re: how can 2 copybooks write in the same file ?
Reply with quote

neelesht wrote:
I have a prog which writes a report into a file from A COPYBOOK layout.
Need info...Does this copybook represent to 01 level of the output record?
Quote:
I need to add another copybook B in the program and want prog to write into report the contents of COPYBOOK A + COPYBOOK B
Does copybook B represent the 01 level of the output record too? Or does it represent an extension on the end of copybook A?
Quote:
I hope I haven't confused you guys.
That will not be a problem if you can answer a few questions.
Could you also cut-and-paste the pertinent parts of both copybooks (first couple lines, last couple lines) after cutting out all the unrelated, unnecessary fields?
Back to top
View user's profile Send private message
neelesht

New User


Joined: 24 Jul 2006
Posts: 99
Location: Los Angeles

PostPosted: Wed Feb 14, 2007 2:46 am    Post subject: Re: how can 2 copybooks write in the same file ?
Reply with quote

Yes David,

I have a program which writes into a report from 1 copybook (a) layout.
now say I dont want to make changes in the existing copybook so I am adding another copybook(b).

But the new report should contain the data of both copybook(a) and copybook(b). (the length of new report as per your example should be 240)

whatever you understood is correct david.

I dont know how will I write the WRITE statement in this case.

Hope I am clear now.
Back to top
View user's profile Send private message
dick scherrer

Site Director


Joined: 23 Nov 2006
Posts: 19270
Location: Inside the Matrix

PostPosted: Wed Feb 14, 2007 3:58 am    Post subject:
Reply with quote

Hello,

There are multiple ways you can accomplish what i believe is your goal.

One way is to define your output report as
Code:

FD  your-report
01  report-rec.
     05 the-first  copy copybooka
     05 the-second copy copybookb


another is
Code:

FD  your-report
01  report-rec.
     05 the-first   pic x(120).
     05 the-second  pic x(120).
.
Working-storage section.
01  the-first-ws     copy copybooka.
01  the-second-ws    copy copybookb.


In both cases move the appropriate data fields to the fields named in the copybooks. In the latter example (after the fields have been moved)
Code:
move the-first-ws to the-first
move the second-ws to the-second


If i misunderstood what you need to do, please advise.
Back to top
View user's profile Send private message
neelesht

New User


Joined: 24 Jul 2006
Posts: 99
Location: Los Angeles

PostPosted: Wed Feb 14, 2007 11:11 pm    Post subject:
Reply with quote

Thanks a lot Dick.

My copybooks are :
A. 01 TRM310G2.
10 AUK-KEY-2.

B. 01 TRM310GT.
10 AUK-KEY.

Both of them starts at 01 level then will it be possible to use the ways you have suggested.

i.e can I code like :


FD your-report
01 report-rec.
05 the-first copy copybooka (this starts at 01 level)
05 the-second copy copybookb (this also starts at 01 level)

Thanks for the help buddy.
Back to top
View user's profile Send private message
William Thompson

Global Moderator


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

PostPosted: Thu Feb 15, 2007 12:10 am    Post subject:
Reply with quote

Quote:
FD your-report
01 report-rec.
05 the-first copy copybooka (this starts at 01 level)
05 the-second copy copybookb (this also starts at 01 level)
You are going to have to eliminate the 01 level number in the copybooks to use them like above.

Generally, the first level number in a record defining copybook should not be a 01, but a slightly higher number.

If the copybooks truly do contain the 01
Quote:
01 TRM310G2.
10 AUK-KEY-2.

01 TRM310GT.
10 AUK-KEY.
and you are unable to change them then you will have to go to something more like Dick's second example.

Let us know how you are faring,

Bill
Back to top
View user's profile Send private message
dick scherrer

Site Director


Joined: 23 Nov 2006
Posts: 19270
Location: Inside the Matrix

PostPosted: Thu Feb 15, 2007 12:31 am    Post subject:
Reply with quote

You're welcome.

If your copybooks start with an 01 level, you will have better luck using the second method. It is ok to move an 01 to an 05, but if your 05 contains an 01 it may present problems. Best case is that it won't compile. Worst case it that it compiles but doesn't work.

If you put the copybooks containing an 01 in WS and then move them to the fields in the output record, you should have no problems.

If you can change the copybooks to be other than 01, doing the COPY in the FD would work - i'm just cautious about the embedded 01's.

Good luck and let us know how it goes.
Back to top
View user's profile Send private message
neelesht

New User


Joined: 24 Jul 2006
Posts: 99
Location: Los Angeles

PostPosted: Thu Feb 15, 2007 10:16 pm    Post subject:
Reply with quote

Hi All,

Thanks alot for the help.

I did that, taking everyone's input.

Created new copybook and defined a rec in Working Storage.

01 ws-res
05 ws-rec1 pic(Length of COPYBOOKA)
05 ws-rec2 pic(Length of COPYBOOKB)

Moved Copybook a to ws-rec1 and copybook b to ws-rec2 adn then wrote in the file the WS-REC.

Once again thanks a lot for all the help.

Neelesh
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 SORTJOIN - Copy Matched and Unmatched... Steve Ironmonger DFSORT/ICETOOL 5 Tue Jan 17, 2017 4:26 pm
No new posts Copy RECFM =VB TO FB file with RECL =... sahil41352 DFSORT/ICETOOL 3 Wed Dec 28, 2016 11:29 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
No new posts How to convert the VBM file to VB or... Sulabh Agrawal JCL & VSAM 4 Fri Nov 18, 2016 1:04 pm


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