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

Write the header part,detail part and the trailer part


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

New User


Joined: 14 Mar 2007
Posts: 60
Location: Thiruvananthapuram

PostPosted: Fri Jul 06, 2007 6:19 pm
Reply with quote

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

Active User


Joined: 11 May 2005
Posts: 344
Location: Spain

PostPosted: Fri Jul 06, 2007 6:29 pm
Reply with quote

what about posting an example?
Back to top
View user's profile Send private message
lekshmi_ci

New User


Joined: 14 Mar 2007
Posts: 60
Location: Thiruvananthapuram

PostPosted: Fri Jul 06, 2007 6:42 pm
Reply with quote

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

Active Member


Joined: 13 Jun 2007
Posts: 826
Location: Wilmington, DE

PostPosted: Fri Jul 06, 2007 7:09 pm
Reply with quote

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. icon_wink.gif
Back to top
View user's profile Send private message
mmwife

Super Moderator


Joined: 30 May 2003
Posts: 1592

PostPosted: Fri Jul 06, 2007 8:28 pm
Reply with quote

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. icon_wink.gif
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


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

PostPosted: Fri Jul 06, 2007 9:56 pm
Reply with quote

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

CICS Moderator


Joined: 07 Nov 2005
Posts: 1104
Location: The Netherlands at Hole 19

PostPosted: Sat Jul 07, 2007 12:15 am
Reply with quote

As I see it you have only one output area. Header, detail and trailer redefine at the same 01 level.
Back to top
View user's profile Send private message
mmwife

Super Moderator


Joined: 30 May 2003
Posts: 1592

PostPosted: Sat Jul 07, 2007 10:30 pm
Reply with quote

The 2 "== REDEFINES HEADER-REC== BY ==== " I mentioned above will remove the redefines and give you 3 output areas.
Back to top
View user's profile Send private message
Bitneuker

CICS Moderator


Joined: 07 Nov 2005
Posts: 1104
Location: The Netherlands at Hole 19

PostPosted: Sun Jul 08, 2007 4:02 am
Reply with quote

But then again Jack, did I see it right or not? Ages ago I wrote cobol...
Back to top
View user's profile Send private message
Sandy Zimmer

Active Member


Joined: 13 Jun 2007
Posts: 826
Location: Wilmington, DE

PostPosted: Sun Jul 08, 2007 4:15 am
Reply with quote

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

Super Moderator


Joined: 30 May 2003
Posts: 1592

PostPosted: Sun Jul 08, 2007 6:13 am
Reply with quote

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

CICS Moderator


Joined: 07 Nov 2005
Posts: 1104
Location: The Netherlands at Hole 19

PostPosted: Mon Jul 09, 2007 1:08 am
Reply with quote

Uhhhhh, this doesn't solve my question icon_wink.gif IMHO this program could never congatinate the header/trailer/detail into one single outputrecord.
Back to top
View user's profile Send private message
Craq Giegerich

Senior Member


Joined: 19 May 2007
Posts: 1512
Location: Virginia, USA

PostPosted: Mon Jul 09, 2007 7:18 am
Reply with quote

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. icon_sad.gif
Back to top
View user's profile Send private message
mmwife

Super Moderator


Joined: 30 May 2003
Posts: 1592

PostPosted: Mon Jul 09, 2007 7:43 am
Reply with quote

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

Moderator Emeritus


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

PostPosted: Mon Jul 09, 2007 8:30 am
Reply with quote

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
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 SORT on detail record, then repeat he... DFSORT/ICETOOL 3
No new posts batch SFTP job using AOPBATCH unable ... All Other Mainframe Topics 7
No new posts Compare 2 files and write Matched/Unm... JCL & VSAM 8
No new posts Write line by line from two files DFSORT/ICETOOL 7
No new posts Insert header record with record coun... DFSORT/ICETOOL 14
Search our Forums:

Back to Top