Match records in two files



IBM's flagship sort product DFSORT for sorting, merging, copying, data manipulation and reporting. Includes ICETOOL and ICEGENER

Match records in two files

Postby Vineet » Wed Sep 07, 2011 6:39 pm

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.
Vineet
 
Posts: 86
Joined: Tue Jun 19, 2007 11:38 am
Has thanked: 0 time
Been thanked: 0 time

Re: Match records in two files

Postby skolusu » Wed Sep 07, 2011 8:52 pm

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                 
//*
Kolusu - DFSORT Development Team (IBM)
DFSORT is on the Web at:
www.ibm.com/storage/dfsort
skolusu
 
Posts: 586
Joined: Wed Apr 02, 2008 10:38 pm
Has thanked: 0 time
Been thanked: 39 times


Return to DFSORT/ICETOOL/ICEGENER

 


  • Related topics
    Replies
    Views
    Last post