Page 1 of 1

matched and unmatched records in diff outfile

PostPosted: Thu Sep 02, 2010 2:47 pm
by shyamsaravan
Hi;
How to write a matched records and unmatched records in a different file in SORT.
Both input files to be compared with each record and the matched records needs to be writtten in one out file,and remaining un matched records to aonther file
Input and output of two files are FB,LRECL 80
File A has
F2010-06-16125ESB46066361
F2010-06-16125ESB77777777
F2010-06-16125ESB12345678
F2010-06-16125ESB23456789
F2010-06-16125ESB98765432

File B has
F2010-06-16125ESB46066361
F2010-06-16125ESB98765432
F2010-06-16125ESB55555555
F2010-06-16125ESB23456789
F2010-06-16125ESB66666666
F2010-06-16125ESB12345678

Output should be
matched records outfile
F2010-06-16125ESB46066361
F2010-06-16125ESB12345678
F2010-06-16125ESB23456789
F2010-06-16125ESB98765432

un matched records outfile
F2010-06-16125ESB77777777
F2010-06-16125ESB55555555
F2010-06-16125ESB66666666


Please help!

Re: matched and unmatched records in diff outfile

PostPosted: Thu Sep 02, 2010 10:08 pm
by skolusu
shyamsaravan,

You need to take some time and explain the rules of matching. What is the KEY to match ? complete 80 bytes or just 25 bytes? Does any file have duplicates?

Assuming your matching key is the first 25 bytes and have duplicates on the key, here is a DFSORT job which will give you the desired results.

//STEP0100 EXEC PGM=SORT                                     
//SYSOUT   DD SYSOUT=*                                       
//INA      DD *                                               
F2010-06-16125ESB46066361                                     
F2010-06-16125ESB77777777                                     
F2010-06-16125ESB12345678                                     
F2010-06-16125ESB23456789                                     
F2010-06-16125ESB98765432                                     
//INB      DD *                                               
F2010-06-16125ESB46066361                                     
F2010-06-16125ESB98765432                                     
F2010-06-16125ESB55555555                                     
F2010-06-16125ESB23456789                                     
F2010-06-16125ESB66666666                                     
F2010-06-16125ESB12345678                                     
//MATCH    DD SYSOUT=*                                       
//UNMATCH  DD SYSOUT=*                                       
//SYSIN    DD *                                               
  OPTION COPY                                                 
  JOINKEYS F1=INA,FIELDS=(1,25,A)                             
  JOINKEYS F2=INB,FIELDS=(1,25,A)                             
  JOIN UNPAIRED                                               
  REFORMAT FIELDS=(?,F1:1,80,F2:1,80)                         
  OUTFIL FNAMES=MATCH,INCLUDE=(1,1,CH,EQ,C'B'),BUILD=(1,80)   
  OUTFIL FNAMES=UNMATCH,SAVE,                                 
  IFTHEN=(WHEN=(1,1,ZD,EQ,1),BUILD=(02,80)),                 
  IFTHEN=(WHEN=(1,1,ZD,EQ,2),BUILD=(82,80))                   
//*

Re: matched and unmatched records in diff outfile

PostPosted: Fri Sep 03, 2010 5:37 pm
by shyamsaravan
Hi;
Thank you,Sorry for the given short of info.The key is a complete 80 bytes, and it have duplicates also.So matched records need to move one outfile and remainig unmatched records from both input file need to move one another outfile.

When i am doing 'JJ' ,got the below messages
E1  8 DSS20011E  DD 'SORTIN' WAS NOT ALLOCATED.         
E2  8 DSS11051E  UNRECOGNIZED 'SORT' KEYWORD 'JOINKEYS'.
E3  8 DSS11051E  UNRECOGNIZED 'SORT' KEYWORD 'JOINKEYS'.
E4  8 DSS11051E  UNRECOGNIZED 'SORT' KEYWORD 'JOIN'.     
E5  8 DSS11051E  UNRECOGNIZED 'SORT' KEYWORD 'REFORMAT'.


Eventhough,When i ran the code and abendesand got the below message displayed in Sysout
1 SYNCSORT FOR Z/OS  1.3.2.1R    U.S. PATENTS: 4210961, 5117495
                                      ABCCOMPANY
  SYNCSORT LICENSED FOR CPU SERIAL NUMBER A0E5F, MODEL 2094 507
  SYSIN :                                                       
    OPTION COPY                                                 
    JOINKEYS F1=INA,FIELDS=(1,25,A)                             
             *                                                 
    JOINKEYS F2=INB,FIELDS=(1,25,A)                             
             *                                                 
    JOIN UNPAIRED                                               
    REFORMAT FIELDS=(?,F1:1,80,F2:1,80)                         
             *                                                 
    OUTFIL FNAMES=MATCH,INCLUDE=(1,1,CH,EQ,C'B'),BUILD=(1,80)   
    OUTFIL FNAMES=UNMATCH,SAVE,                                 
    IFTHEN=(WHEN=(1,1,ZD,EQ,1),BUILD=(02,80)),                 
      IFTHEN=(WHEN=(1,1,ZD,EQ,2),BUILD=(82,80))                 
  WER268A  JOINKEYS STATEMENT: SYNTAX ERROR                     
  WER268A  JOINKEYS STATEMENT: SYNTAX ERROR                     
  WER268A  REFORMAT STATEMENT: SYNTAX ERROR                     


I used the same code in my JCL what you suggested.

Re: matched and unmatched records in diff outfile

PostPosted: Fri Sep 03, 2010 6:16 pm
by NicC
You are using SYNCSORT not DFSORT. Frank and Kolusu will not be able to answer your question as they are DFSORT developers and SYNCSORT is a rival product. You should check the SYNCSORT manual to see if a) JOINKEYS is supposrted for the version you have and if it is, b) check the syntax. For some things there is a difference in syntax between DFSORT and SYNCSORT and what Kolusu gave you was the DFSORT syntax.

Re: matched and unmatched records in diff outfile

PostPosted: Sat Sep 04, 2010 1:18 am
by dick scherrer
Hello,

The version of Syncsort you have supports JOINing.

Try without the OPTION COPY. . .

Sugggest you refer to the examples in the documentation.

Re: matched and unmatched records in diff outfile

PostPosted: Sat Sep 04, 2010 1:28 am
by Alissa Margulies
This is a duplicate post. I am locking this thread. Please see syncsort-synctool/topic4173.html