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 Converting Variable block file to Fix... bhavana yalavarthi DFSORT/ICETOOL 10 Tue May 16, 2017 2:20 pm
No new posts Adding big TEXT lines to each record ... bshkris SYNCSORT 4 Sat May 06, 2017 1:40 am
No new posts Unable to create multiple files using... mbattu COBOL Programming 3 Fri May 05, 2017 5:35 pm
No new posts Getting error while opening a variabl... apandey1 COBOL Programming 5 Fri May 05, 2017 12:22 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


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