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
 

 

Merge two files keeping last record of first file intact.

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL
View previous topic :: :: View next topic  
Author Message
ksouren007

New User


Joined: 30 Jun 2010
Posts: 85
Location: Toronto, ON

PostPosted: Thu Sep 15, 2011 4:34 am    Post subject: Merge two files keeping last record of first file intact.
Reply with quote

Hi,

I have two sequential files both having FB LRECL=975.

The first file contains record in this format:
The Header record always starts with ##H and Trailer with ##T. There would be no other records in both the files having ## in the first 2 positions other than the header and the trailer record.

##H <Header Record>
data1
:
:
data1
##T <Trailer Record>

And the second file just have data; no header or trailer records.

Now, I want to merge both the files as below keeping the trailer position as it is:

##H <Header Record>
data1
:
:
data1
data2 --data from second file
:
:
data2
##T <Trailer Record>

Could somebody please advise me if there are any sort cards to achieve the same?
Back to top
View user's profile Send private message

Frank Yaeger

DFSORT Moderator


Joined: 15 Feb 2005
Posts: 7130
Location: San Jose, CA

PostPosted: Thu Sep 15, 2011 4:48 am    Post subject:
Reply with quote

I think you mean "concatenate" rather than "merge" (MERGE would imply that the records in each file are in order by a specific key which I don't think is the case here).

At any rate, here's a DFSORT job that will do what you asked for:

Code:

//S1 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//SORTIN DD DSN=...  input file1 (FB/975)
//       DD DSN=...  input file2 (FB/975)
//SORTOUT DD DSN=...  output file (FB/975)
//SYSIN DD *
  OPTION EQUALS
  INREC IFTHEN=(WHEN=INIT,OVERLAY=(976:C'##I')),
        IFTHEN=(WHEN=(1,2,CH,EQ,C'##'),OVERLAY=(976:1,3))
  SORT FIELDS=(976,3,CH,A)
  OUTREC BUILD=(1,975)
/*

Back to top
View user's profile Send private message
ksouren007

New User


Joined: 30 Jun 2010
Posts: 85
Location: Toronto, ON

PostPosted: Thu Sep 15, 2011 8:25 pm    Post subject:
Reply with quote

It worked great!! Thank You Frank.
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 -> DFSORT/ICETOOL All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Changing of LRECL of a file abdulrafi DFSORT/ICETOOL 2 Fri Mar 24, 2017 3:25 pm
No new posts splitting a file abdulrafi DFSORT/ICETOOL 4 Fri Mar 24, 2017 11:51 am
No new posts Record Not found in AlX but record re... mukun264 COBOL Programming 7 Fri Mar 24, 2017 9:28 am
No new posts Count the length of the record & ... sreekusr DFSORT/ICETOOL 4 Thu Mar 23, 2017 7:52 pm
No new posts Receive a file using PCOMM macro Harald.v.K IBM Tools 0 Thu Mar 23, 2017 6:50 pm


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