Page 1 of 1

Remove Duplicates + Original Record

PostPosted: Fri Nov 12, 2010 10:07 pm
by Eagle
Is there a way to use Syncsort to produce the following? All records with unique keys go to Output file 1 and all duplicate records plus the respective original record go to Output file 2.

Example:
Input
0001
0002
0002
0003
0004
0005
0005


Output file 1:
0001
0003
0004


Output file 2:
0002
0002
0005
0005

Re: Remove Duplicates + Original Record

PostPosted: Sat Nov 13, 2010 12:08 am
by Alissa Margulies
Here is a SyncSort for z/OS 1.3 job that will produce the requested output:
//STEP1 EXEC PGM=SORT                           
//SORTIN  DD *                                   
0001                                             
0002                                             
0002                                             
0003                                             
0004                                             
0005                                             
0005                                             
//SORTXDUP DD DSN=&&XDUP,DISP=(NEW,PASS)     
//SORTOF01 DD DSN=&&OUT1,DISP=(NEW,PASS)         
//SORTOF02 DD DSN=UNIQUE.RECORDS
//SYSOUT   DD SYSOUT=*                           
//SYSIN    DD *                                 
   INREC OVERLAY=(81:X'F1')                     
   SORT FIELDS=(1,5,CH,A)                       
   DUPKEYS SUM=(81,1,ZD),XDUP                   
   OUTFIL FILES=01,INCLUDE=(81,1,ZD,GT,1)       
   OUTFIL FILES=02,INCLUDE=(81,1,ZD,EQ,1),BUILD=(1,80)       
/*                                               
//STEP2  EXEC PGM=SORT                           
//SORTIN01 DD DSN=&&XDUP,DISP=SHR                 
//SORTIN02 DD DSN=&&OUT1,DISP=SHR                 
//SORTOUT  DD DSN=ALLDUPS     
//SYSOUT   DD SYSOUT=*                           
//SYSIN    DD *                                   
   INREC BUILD=(1,80)                             
   MERGE FIELDS=(1,5,CH,A)                       
/*                                               

Re: Remove Duplicates + Original Record

PostPosted: Sat Nov 13, 2010 12:19 am
by Eagle
Thanks, again!

Is there a manual for Synctool? Using Synctool, I found the following example on another forum:

//S1    EXEC  PGM=SYNCTOOL                           
//TOOLMSG DD SYSOUT=*                                 
//DFSMSG  DD SYSOUT=*                                 
//IN DD DSN=TEST.XSUM.INPUT,DISP=SHR         
//OUT1 DD DSN=TEST.XSUM.OUTPUT.UNIQUE,DISP=SHR
//OUT2 DD DSN=TEST.XSUM.OUTPUT.DUPS,DISP=SHR
//TOOLIN DD *                                         
SELECT FROM(IN) TO(OUT1) ON(1,04,CH) NODUPS           
SELECT FROM(IN) TO(OUT2) ON(1,04,CH) ALLDUPS         
/*

Re: Remove Duplicates + Original Record

PostPosted: Sat Nov 13, 2010 12:27 am
by Alissa Margulies
Eagle,

Please see the email I sent you offline.

Regards,