View previous topic :: View next topic
|
Author |
Message |
lekshmi_ci
New User
Joined: 14 Mar 2007 Posts: 60 Location: Thiruvananthapuram
|
|
|
|
Hi,
I have a copybook layout for a file.
The copybook has a header part,detail part(redefines the header) and a trailer part(redefines the header).
The header and the trailer parts are messages which is already populated.
The detail part is handled in the program.
When i write the record as a whole, only the setail record will be written.
I need to write the header part,detail part and th etrailer part.
How do i do that. Please provide a solution.
LC |
|
Back to top |
|
|
acevedo
Active User
Joined: 11 May 2005 Posts: 344 Location: Spain
|
|
|
|
what about posting an example? |
|
Back to top |
|
|
lekshmi_ci
New User
Joined: 14 Mar 2007 Posts: 60 Location: Thiruvananthapuram
|
|
|
|
Hi
This is an example
01 Header-rec
05 header-msg.
10 hello-msg pic x(10) value 'hello '.
10 filler pic x(20) value spaces.
01 detail-rec redefines header-rec.
05 detail-rec.
10 ws-name pic x(10) value spaces.
10 ws-age pic 9(02) value zero.
01 trailer-rec redefines header-rec
05 trailer-msg.
10 end-msg pic x(10) value 'the end '.
10 filler pic x(20) value spaces.
I have this copy book in my program.
i am moving values to the detail rec.
i need to write the entire thing (header,detail,trailer) |
|
Back to top |
|
|
Sandy Zimmer
Active Member
Joined: 13 Jun 2007 Posts: 826 Location: Wilmington, DE
|
|
|
|
You do have the copy in working storage not in the FD - correct? How many write statements do you have? Can we see your write statement(s)? I am assuming that you just do a write - not a write from. Try this "write file-record from header-rec" or move header-rec to file-record - then write.
Since your area is redefined - whatever you did last is still in the buffer. |
|
Back to top |
|
|
mmwife
Super Moderator
Joined: 30 May 2003 Posts: 1592
|
|
|
|
Hi LC,
You could try this:
Code: |
WS
COPY TSTCB REPLACING == REDEFINES HEADER-REC== BY ====
== REDEFINES HEADER-REC== BY ====.
PD
WRITE OP-REC FROM HEADER-REC
PERFORM WRITE-DETAIL-RTN UNTIL NO-MORE-DATA
WRITE OP-REC FROM TRAILER-REC
yada yada
.
WRITE-DETAIL-RTN.
yada yada
WRITE OP-REC FROM DETAIL-REC
yada yada
. |
The REPLACING prevents overlaying the REC areas. |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19243 Location: Inside the Matrix
|
|
|
|
Hello,
You should not have multiple initial values in fields that are redefined.
If you put your copybook in WS and remove the redefines, you will be then able to use the initial values and would then "write from" as Sandy suggested before. |
|
Back to top |
|
|
Bitneuker
CICS Moderator
Joined: 07 Nov 2005 Posts: 1104 Location: The Netherlands at Hole 19
|
|
|
|
As I see it you have only one output area. Header, detail and trailer redefine at the same 01 level. |
|
Back to top |
|
|
mmwife
Super Moderator
Joined: 30 May 2003 Posts: 1592
|
|
|
|
The 2 "== REDEFINES HEADER-REC== BY ==== " I mentioned above will remove the redefines and give you 3 output areas. |
|
Back to top |
|
|
Bitneuker
CICS Moderator
Joined: 07 Nov 2005 Posts: 1104 Location: The Netherlands at Hole 19
|
|
|
|
But then again Jack, did I see it right or not? Ages ago I wrote cobol... |
|
Back to top |
|
|
Sandy Zimmer
Active Member
Joined: 13 Jun 2007 Posts: 826 Location: Wilmington, DE
|
|
|
|
The really simple answer is to get rid of the copybook or it at least comment it out, define the 3 record types without the redefines and go from there - test. Once the problem is solved - and it should be very quickly - if standards insist on that copybook, put it back in. |
|
Back to top |
|
|
mmwife
Super Moderator
Joined: 30 May 2003 Posts: 1592
|
|
|
|
Hi LC,
I assumed the hdr/trlr recs were FILE hdr/trlr recs. If they are RECORD hdr/trlr recs, the code would simply be the 3 WRITE FROMs:
Code: |
WRITE-DETAIL-RTN.
yada yada
WRITE OP-REC FROM HEADER-REC
WRITE OP-REC FROM DETAIL-REC
WRITE OP-REC FROM TRAILER-REC
|
But the copybook stmt would remain the same. |
|
Back to top |
|
|
Bitneuker
CICS Moderator
Joined: 07 Nov 2005 Posts: 1104 Location: The Netherlands at Hole 19
|
|
|
|
Uhhhhh, this doesn't solve my question IMHO this program could never congatinate the header/trailer/detail into one single outputrecord. |
|
Back to top |
|
|
Craq Giegerich
Senior Member
Joined: 19 May 2007 Posts: 1512 Location: Virginia, USA
|
|
|
|
It seems to me that if the OP had looked at the compile errors (warnings)in his program he would have had at least some warning of a problem with the copy book as it was set up. |
|
Back to top |
|
|
mmwife
Super Moderator
Joined: 30 May 2003 Posts: 1592
|
|
|
|
Typically detail records with headers and trailers are usually written separately (and in multples) between the other two. But re-reading LC's orig post it looks like he wants to concat the 3 recs, but then again, why does he call them -recs?? Oh well, never mind.
If he wants to concat them use the copy/replace shown above, define a 72 byte pic x field - combined-rec and:
Code: |
string header-rec
detail-rec
trailer-rec delimited by size
into combined-rec
write op-rec from combined-rec |
|
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19243 Location: Inside the Matrix
|
|
|
|
Hello,
LC - please post a few sample input records and what you want the output to contain when these input records are processed.
Looking over the several suggestions posted, i am not sure that the group has a unified understanding your requirement. If we can see your data and the output you need, your requirement will be more clear and we can offer suggestions. |
|
Back to top |
|
|
|