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

Merging files using SYNCSORT


IBM Mainframe Forums -> JCL & VSAM
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
abin

Active User


Joined: 14 Aug 2006
Posts: 198

PostPosted: Mon Mar 24, 2008 10:06 pm
Reply with quote

Hi,

I'm using SYNCSORT FOR Z/OS 1.2.2.2R. My requirement is as follows.

I have two files. First file is sorted under Key1. Second file is sorted under Key2.
I need to merge the two files under Key3.

So if input is as follows.

File#1:
111aaa
222bbb
333ccc

File#2:
111x111
111x222
333y555

The output should come as
111aaa
111x111
111x222
222bbb
333ccc
333y555

Could some body please help me on this.

regards,
Abin davis Peter.
Back to top
View user's profile Send private message
guptae

Moderator


Joined: 14 Oct 2005
Posts: 1208
Location: Bangalore,India

PostPosted: Mon Mar 24, 2008 10:56 pm
Reply with quote

Hi Abin,

Would you please lets us know what do u mean by key3 ?
Back to top
View user's profile Send private message
abin

Active User


Joined: 14 Aug 2006
Posts: 198

PostPosted: Mon Mar 24, 2008 11:01 pm
Reply with quote

Sorry,

I missed to mention one important point. In output the records from file#1 should be in the order of its appearance in the input and records from file#2 shich matches with records in file#1 in key#3(here it is 1:3) should appear right after the matching file#1 record in the original order.
Back to top
View user's profile Send private message
Sundar V

New User


Joined: 25 Apr 2006
Posts: 5

PostPosted: Tue Mar 25, 2008 1:25 pm
Reply with quote

Hi abin

Pls try as below, I hope it may help you.

//EXAMP JOB A492,PROGRAMMER
//MERGE EXEC PGM=SORT
//SYSOUT DD SYSOUT=A
//SORTIN01 DD DSN=A123456.MASTER,DISP=SHR (Your Input file: 1)
//SORTIN02 DD DSN=A123456.NEW,DISP=SHR (Your Input File: 2)
//SORTOUT DD DSN=A123456.SORT.SAMPOUT,DISP=OLD (Resultant File: File 3)
//SYSIN DD *
MERGE FIELDS=(1,6,CH,A,1,7,CH,A)
/*

All, please correct me if my suggestion is wrong.

Thanks and Regards
Sundar
Back to top
View user's profile Send private message
abin

Active User


Joined: 14 Aug 2006
Posts: 198

PostPosted: Tue Mar 25, 2008 1:54 pm
Reply with quote

Hi Sundar,

If we use merge operator files should be in the sorted order of merge fields. But my input files are in different sorted order. That is File#1 is in sorted order of Ke#1 and File#2 on Key#2. And Key#1 != Key#2. I need to retain the input order in the output also.
Back to top
View user's profile Send private message
sril.krishy

Active User


Joined: 30 Jul 2005
Posts: 183
Location: hyderabad

PostPosted: Tue Mar 25, 2008 6:58 pm
Reply with quote

Hi Abin,
Please chek the below code.

Code:


//PS020    EXEC PGM=SORT                   
//SYSOUT   DD  SYSOUT=*                     
//TOOLMSG  DD  SYSOUT=*                     
//DFSMSG   DD  SYSOUT=*                     
//SORTIN   DD  DSN=your First FILE,DISP=SHR     
//         DD  DSN=your Secnd FILE,DISP=SHR     
//SORTOUT  DD SYSOUT=*                     
//SYSIN    DD  *                           
   SORT FIELDS=(1,3,CH,A),EQUALS           


Code:


OUTOUT (SORTOUT):
111aaa 
111x111
111x222
222bbb 
333ccc 
333y555




Thanks
Krishy
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 -> JCL & VSAM

 


Similar Topics
Topic Forum Replies
No new posts Compare 2 files and retrive records f... DFSORT/ICETOOL 3
No new posts Compare 2 files(F1 & F2) and writ... JCL & VSAM 8
No new posts Write line by line from two files DFSORT/ICETOOL 7
No new posts Compare only first records of the fil... SYNCSORT 7
No new posts Merge two VSAM KSDS files into third ... JCL & VSAM 6
Search our Forums:

Back to Top