MVSFORUMS.com Forum Index MVSFORUMS.com
A Community of and for MVS Professionals
 
 FAQFAQ   SearchSearch   Quick Manuals   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Files comparing and copy unmatched records to output file

 
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Utilities
View previous topic :: View next topic  
Author Message
kirank
Beginner


Joined: 21 Apr 2004
Posts: 61
Topics: 33
Location: hyderabad

PostPosted: Thu Jan 24, 2008 5:50 am    Post subject: Files comparing and copy unmatched records to output file Reply with quote

I want to compare two files of different lengths. But both contains a common Id(suppose SSN).
Here i want to compare file2 with file1 and with the common Id(SSN) and if found, i want to omit that record and i want to copy all unmatched records to third output file.

For example:

First file:
ssn

1
2
3
4
5

Second file:
ssn

4
5

Third file:
ssn

1
2
3

Could you please let me know is it possible through syncsort.

Thanks
kirank
Back to top
View user's profile Send private message
vkphani
Intermediate


Joined: 05 Sep 2003
Posts: 483
Topics: 48

PostPosted: Thu Jan 24, 2008 6:06 am    Post subject: Reply with quote

kirank,

Check the below link.

http://www.mvsforums.com/helpboards/viewtopic.php?t=11&highlight=match
Back to top
View user's profile Send private message Send e-mail
Frank Yaeger
Sort Forum Moderator
Sort Forum Moderator


Joined: 02 Dec 2002
Posts: 1618
Topics: 31
Location: San Jose

PostPosted: Thu Jan 24, 2008 11:16 am    Post subject: Reply with quote

kirank,

For you example, where the ssns in file2 are a subset of the ssns in file1, you can use this simple DFSORT/ICETOOL job:

Code:

//S1    EXEC  PGM=ICETOOL
//TOOLMSG DD SYSOUT=*
//DFSMSG  DD SYSOUT=*
//IN DD DSN=...  input file1
//   DD DSN=...  input file2
//OUT DD DSN=...  output file
//TOOLIN DD *
SELECT FROM(IN) TO(OUT) ON(1,1,CH) NODUPS
/*


If your data is actually more complex than that, show a better example of the records in each input file (relevant fields only) and what you expect for output.

If you're not familiar with DFSORT and DFSORT's ICETOOL, I'd suggest reading through "z/OS DFSORT: Getting Started". It's an excellent tutorial, with lots of examples, that will show you how to use DFSORT, DFSORT's ICETOOL and DFSORT Symbols. You can access it online, along with all of the other DFSORT books, from:

www.ibm.com/servers/storage/support/software/sort/mvs/srtmpub.html
_________________
Frank Yaeger - DFSORT Development Team (IBM)
Specialties: JOINKEYS, FINDREP, WHEN=GROUP, ICETOOL, Symbols, Migration
DFSORT is on the Web at:
www.ibm.com/storage/dfsort
Back to top
View user's profile Send private message Send e-mail Visit poster's website
amargulies
Beginner


Joined: 10 Jan 2007
Posts: 123
Topics: 0

PostPosted: Thu Jan 24, 2008 12:43 pm    Post subject: Re: Files comparing and copy unmatched records to output fil Reply with quote

kirank wrote:
Could you please let me know is it possible through syncsort.

If you have SyncSort for z/OS 1.2 or later, you can try the following JCL:
Code:

//STEP1    EXEC PGM=SORT                                 
//SORTJNF1 DD DSN=FILE1                   
//SORTJNF2 DD DSN=FILE2                   
//SORTOUT  DD DSN=YOUR.DESIRED.OUTPUT
//SYSOUT   DD SYSOUT=*                                       
//SYSIN    DD *                                             
   JOINKEYS FILE=F1,FIELDS=(1,1,A)                             
   JOINKEYS FILE=F2,FIELDS=(1,1,A)                             
   JOIN UNPAIRED,F1,ONLY                                       
   SORT FIELDS=COPY                                           
   END                                                         
/*                                                           

Obviously, you will need to modify the JOINKEYS FIELDS based upon your actual data. Let me know if you require any further assistance.
_________________
Alissa Margulies
SyncSort Mainframe Product Services
201-930-8260
zos_tech@syncsort.com
Back to top
View user's profile Send private message Send e-mail
ranga_subham
Intermediate


Joined: 31 Jan 2006
Posts: 255
Topics: 72

PostPosted: Tue Jan 29, 2008 6:11 am    Post subject: I tried this Reply with quote

Hi,

I tried what you have suggested but found nothing in SYSOUT. Anything wrong?

Code:

//STEP1    EXEC PGM=SORT           
//SORTJNF1 DD *                   
 1                                 
 2                                 
 3                                 
 4                                 
 5                                 
//SORTJNF2 DD *                   
 1                                 
 2                                 
 3                                 
//SORTOUT  DD SYSOUT=*             
//SYSOUT   DD SYSOUT=*             
//SYSIN    DD *                   
   JOINKEYS FILE=F1,FIELDS=(1,1,A)
   JOINKEYS FILE=F2,FIELDS=(1,1,A)
   JOIN UNPAIRED,F1,ONLY           
   SORT FIELDS=COPY               
   END                             
/*     


Pls help.

Thanks.
_________________
Ranga
*****
None of us is as smart as all of us - Ken Blanchard
Back to top
View user's profile Send private message
amargulies
Beginner


Joined: 10 Jan 2007
Posts: 123
Topics: 0

PostPosted: Tue Jan 29, 2008 10:22 am    Post subject: Reply with quote

Looks like your data is not in column 1 but rather column 2... Try either moving your data or changing the JOINKEYS FIELDS to reflect (2,1,A).
_________________
Alissa Margulies
SyncSort Mainframe Product Services
201-930-8260
zos_tech@syncsort.com
Back to top
View user's profile Send private message Send e-mail
Display posts from previous:   
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Utilities All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


MVSFORUMS
Powered by phpBB © 2001, 2005 phpBB Group