View previous topic :: View next topic
|
Author |
Message |
neelesht
New User
Joined: 24 Jul 2006 Posts: 99 Location: Los Angeles
|
|
|
|
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 |
|
|
DavidatK
Active Member
Joined: 22 Nov 2005 Posts: 700 Location: Troy, Michigan USA
|
|
|
|
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 |
|
|
William Thompson
Global Moderator
Joined: 18 Nov 2006 Posts: 3156 Location: Tucson AZ
|
|
|
|
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 |
|
|
neelesht
New User
Joined: 24 Jul 2006 Posts: 99 Location: Los Angeles
|
|
|
|
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 |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
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 |
|
|
neelesht
New User
Joined: 24 Jul 2006 Posts: 99 Location: Los Angeles
|
|
|
|
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 |
|
|
William Thompson
Global Moderator
Joined: 18 Nov 2006 Posts: 3156 Location: Tucson AZ
|
|
|
|
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 |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
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 |
|
|
neelesht
New User
Joined: 24 Jul 2006 Posts: 99 Location: Los Angeles
|
|
|
|
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 |
|
|
|