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

Merge two files keeping last record of first file intact.


IBM Mainframe Forums -> DFSORT/ICETOOL
Post new topic   Reply to topic
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
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 Developer


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

PostPosted: Thu Sep 15, 2011 4:48 am
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
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 View Bookmarks
All times are GMT + 6 Hours
Forum Index -> DFSORT/ICETOOL

 


Similar Topics
Topic Forum Replies
No new posts Compare 2 files(F1 & F2) and writ... JCL & VSAM 5
No new posts FTP VB File from Mainframe retaining ... JCL & VSAM 8
No new posts Extract the file name from another fi... DFSORT/ICETOOL 6
No new posts How to split large record length file... DFSORT/ICETOOL 10
No new posts Extracting Variable decimal numbers f... DFSORT/ICETOOL 17
Search our Forums:

Back to Top