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
 

 

Merging files using SYNCSORT

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> JCL & VSAM
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    Post subject: Merging files using SYNCSORT
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: 1187
Location: Bangalore,India

PostPosted: Mon Mar 24, 2008 10:56 pm    Post subject:
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    Post subject:
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    Post subject:
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    Post subject:
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: 182
Location: hyderabad

PostPosted: Tue Mar 25, 2008 6:58 pm    Post subject:
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    IBMMAINFRAMES.com Support Forums -> JCL & VSAM All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts SYNCSORT SEQNUM and FI fields. nartcr SYNCSORT 5 Sat Jan 21, 2017 4:02 am
No new posts Syncsort Help to group fields sudhakarraju SYNCSORT 6 Thu Dec 29, 2016 1:38 am
No new posts syncsort: copy lines after the keyword shreya19 SYNCSORT 7 Fri Dec 02, 2016 9:47 am
No new posts High CPU consumption Job using IAM fi... aswinir JCL & VSAM 15 Thu Dec 01, 2016 8:28 pm
No new posts Match or compare two files in VB Format anatol DFSORT/ICETOOL 14 Thu Nov 03, 2016 7:41 pm


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