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
 

 

Write the header part,detail part and the trailer part

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
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    Post subject: Write the header part,detail part and the trailer part
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    Post subject:
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    Post subject: Writing records
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    Post subject:
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    Post subject:
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

Site Director


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

PostPosted: Fri Jul 06, 2007 9:56 pm    Post subject:
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: 1105
Location: The Netherlands at Hole 19

PostPosted: Sat Jul 07, 2007 12:15 am    Post subject:
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    Post subject:
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: 1105
Location: The Netherlands at Hole 19

PostPosted: Sun Jul 08, 2007 4:02 am    Post subject:
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    Post subject:
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    Post subject:
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: 1105
Location: The Netherlands at Hole 19

PostPosted: Mon Jul 09, 2007 1:08 am    Post subject:
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    Post subject:
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    Post subject:
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

Site Director


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

PostPosted: Mon Jul 09, 2007 8:30 am    Post subject:
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    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 RMM: scratching a volume that RMM thi... Hervey Martinez IBM Tools 0 Mon May 15, 2017 8:51 pm
No new posts Check if any Detail records and extra... V S Amarendra Reddy SYNCSORT 19 Mon May 08, 2017 8:54 pm
This topic is locked: you cannot edit posts or make replies. Merge two files and update Trailer re... Yashashri JCL & VSAM 1 Thu May 04, 2017 12:54 pm
No new posts Validating file with multiple header/... mohitsaini DFSORT/ICETOOL 6 Thu Apr 13, 2017 1:53 am
No new posts Write R1 and R2 to OP1 and R1 to OP2 bhaskar_kanteti DFSORT/ICETOOL 10 Fri Mar 03, 2017 11:18 am


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