Page 1 of 1

Match records in two files

PostPosted: Wed Sep 07, 2011 6:39 pm
by Vineet
I have 2 Sequential Files (File A & File B), LRECL = 500 & RECFM = FB. My Requirement is, If a Record is Present in File B & Not present in File A then Record Should Be written to Output File. If Record is Present in File A but Not in File B Should Not Written To Oupt Put File. If Record is Present in Both Files Record should not be written to Ouptput File.
Below is Example.

File A.
ABCD|12345|ABCD123|XYZ
ABCD|12345|HIJKL123|XYZ
ABCD|12345|OPQR123|XYZ
ABCD|12345|AAAA123|XYZ
ABCD|12345|BBBBB23|XYZ
ABCD|12345|DDDDD3|XYZ ---> This Record is Not present in File B. Should Not written to O/P File.

File B.
ABCD|12345|DDDD123|XYZ ---> Should Get Written To O/P File
ABCD|12345|KKKKK23|XYZ ----> Should Get Written To O/P File
ABCD|12345|OPQR123|XYZ ----> Should Not written to O/P File.
ABCD|12345|AAAA123|XYZ ----> Should Not written to O/P File.
ABCD|12345|BBBBBB23|XYZ ----> Should Not written to O/P File.

Sort Criteria is SORT=(1,500,CH,A).

Thanks
Kind Rgds

Vineet Anand.

Re: Match records in two files

PostPosted: Wed Sep 07, 2011 8:52 pm
by skolusu
vineet,

use the following DFSORT JCL which will give you the desired results

//STEP0100 EXEC PGM=SORT           
//SYSOUT   DD SYSOUT=*             
//INA      DD DSN=Your input file A,DISP=SHR
//INB      DD DSN=Your input file B,DISP=SHR
//SORTOUT  DD SYSOUT=*                   
//SYSIN    DD *                         
  OPTION COPY                           
  JOINKEYS F1=INA,FIELDS=(1,500,A)       
  JOINKEYS F2=INB,FIELDS=(1,500,A)       
  JOIN UNPAIRED,F2,ONLY                 
//*