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 

File compare

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


Joined: 07 Apr 2005
Posts: 13
Topics: 5

PostPosted: Thu Apr 07, 2005 5:57 pm    Post subject: File compare Reply with quote

Hi,

I have 2 files, the requirement is to compare key fields in these two files and create an output file with matching records only from the first file. The first file can have duplicates.

File 1

Code:

Key

AAA  1234
AAA  5678
BBB  1234
CCC  1234
CCC  3456
 


File 2
Code:

Key

AAA  7777
CCC  8888


Output file
Code:

Key

AAA  1234
AAA  5678
CCC  1234
CCC  3456



We don't have DFSORT or Ezytrieve in our shop. Can we do this using Syncsort? All suggestions are welcome.

Thanks
Smith.
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12370
Topics: 75
Location: San Jose

PostPosted: Fri Apr 08, 2005 5:47 am    Post subject: Reply with quote

Smith,

If you have the latest version of syncsort , it supports the SPLICE operator. You can find the solution using splice here

http://www.mvsforums.com/helpboards/viewtopic.php?t=11&highlight=match

Hope this helps...

Cheers

Kolusu
_________________
Kolusu - DFSORT Development Team (IBM)
DFSORT is on the Web at:
www.ibm.com/storage/dfsort

www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Smith
Beginner


Joined: 07 Apr 2005
Posts: 13
Topics: 5

PostPosted: Fri Apr 08, 2005 10:23 am    Post subject: Reply with quote

Kolusu,

I tried splice but I'm getting only the first match from the first file. I'm not getting any subsequent matches. I tried to use WITHALL but it is still the same.

Output got
Code:

AAA  1234
CCC  1234


Desired output
Code:

AAA  1234
AAA  5678
CCC  1234
CCC  3456



Is this possible using sort? Please advice.

Thanks
Smith.
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12370
Topics: 75
Location: San Jose

PostPosted: Fri Apr 08, 2005 11:41 am    Post subject: Reply with quote

Smith,

Try this JCL

Code:

//STEP0100 EXEC PGM=SYNCTOOL                             
//TOOLMSG  DD SYSOUT=*                                   
//DFSMSG   DD SYSOUT=*                                   
//IN1      DD *                                         
AAA  1234                                               
AAA  5678                                               
BBB  1234                                               
CCC  1234                                               
CCC  3456                                               
//IN2      DD *                                         
AAA  7777                                               
CCC  8888                                               
//T1       DD DSN=&T1,DISP=(,PASS),SPACE=(CYL,(1,1),RLSE)
//T2       DD DSN=&T2,DISP=(,PASS),SPACE=(CYL,(1,1),RLSE)
//CON      DD DSN=*.T2,VOL=REF=*.T2,DISP=SHR             
//         DD DSN=*.T1,VOL=REF=*.T1,DISP=SHR             
//OUT      DD SYSOUT=*                                   
//TOOLIN   DD *                         
  COPY FROM(IN1) USING(CTL1)             
  SORT FROM(IN2) USING(CTL2)             
  SPLICE FROM(CON) TO(OUT) ON(1,3,CH) - 
    WITH(1,80) WITHALL USING(CTL3)       
//CTL1CNTL DD *                         
  OUTFIL FNAMES=T1,                     
  OUTREC=(1,80,3X)                       
//CTL2CNTL DD *                         
  SORT FIELDS=(1,3,CH,A)                 
  OUTFIL FNAMES=T2,                     
  OUTREC=(1,80,1,3)                     
//CTL3CNTL DD *                         
  OUTFIL FNAMES=OUT,                     
  OUTREC=(1,80)                         
/*


The output from this job is

Code:

AAA  1234     
AAA  5678     
CCC  1234     
CCC  3456     


Hope this helps...

Cheers

kolusu
_________________
Kolusu - DFSORT Development Team (IBM)
DFSORT is on the Web at:
www.ibm.com/storage/dfsort

www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Smith
Beginner


Joined: 07 Apr 2005
Posts: 13
Topics: 5

PostPosted: Fri Apr 08, 2005 2:36 pm    Post subject: Reply with quote

kolusu,

I just tried to run it with different input data.

File 1
Code:

AAA 1234
AAA 5678
BBB 1234
BBB 1234
BBB 1234
CCC 1234
CCC 1234
CCC 1234
CCC 1234
CCC 3456


File 2
Code:

AAA 7777
CCC 8888



The output I got is given below:

Output got
Code:

AAA 1234
AAA 5678
BBB 1234
BBB 1234
CCC 1234
CCC 1234
CCC 1234
CCC 1234
CCC 3456


The desired output was

Desired output
Code:

AAA 1234
AAA 5678
CCC 1234
CCC 1234
CCC 1234
CCC 1234
CCC 3456


I added an omit condition in CTL3CNTL to eliminate the BBB records.
OMIT=(81,2,CH,EQ,C' ')

Thank you very much for your help.

Smith.
Back to top
View user's profile Send private message
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