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 

Compare two files field by field

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


Joined: 29 May 2007
Posts: 165
Topics: 77

PostPosted: Thu Nov 25, 2010 7:53 am    Post subject: Compare two files field by field Reply with quote

Hi,


I need to compare two files field by field and both are Fixed blocked with lrecl 80.

File01
Code:

SIVA     15585 30000       
JAYANTH  20010 15000
NAVEEN S 25100 15000
SUPRIYO  23234 30000


File02
Code:

SIVA     15585 30100       
JAYANTH  20010 15000
NAVEEN   25100 15000
SUPRIYO  23234 30100




Output file should contain only the differnce records
Code:

SIVA     15585 30100
NAVEEN   25100 15000
SUPRIYO  23234 30100


Thanks,
Siva
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


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

PostPosted: Thu Nov 25, 2010 11:05 am    Post subject: Reply with quote

sivafdms,

Isn't it a simple task of using joinkeys with UNPAIRED,F2,ONLY? Here is an Untested DFSORT JCL which would give you the desired results

Code:

//STEP0100 EXEC PGM=SORT
//SYSOUT   DD SYSOUT=*
//SORTJNF1 DD *
----+----1----+----2
SIVA     15585 30000       
JAYANTH  20010 15000
NAVEEN S 25100 15000
SUPRIYO  23234 30000
//SORTJNF2 DD *
----+----1----+----2
SIVA     15585 30100       
JAYANTH  20010 15000
NAVEEN   25100 15000
SUPRIYO  23234 30100
//SORTOUT DD SYSOUT=*
//SYSIN DD *
  JOINKEYS FILE=F1,FIELDS=(01,08,A,10,5,A,16,5,A)
  JOINKEYS FILE=F2,FIELDS=(01,08,A,10,5,A,16,5,A)
  JOIN UNPAIRED,F2,ONLY
  SORT FIELDS=COPY
//*

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


Joined: 10 Sep 2004
Posts: 384
Topics: 79

PostPosted: Fri Nov 26, 2010 7:13 am    Post subject: Reply with quote

you can also try ICETOOL

Quote:

//STEP04 EXEC PGM=ICETOOL
//TOOLMSG DD SYSOUT=*
//DFSMSG DD SYSOUT=*
//INPUT DD DSN=file1
// DISP=SHR
// DD DSN=file2
// DISP=SHR
//DIFFILE DD DSN=new file
// DISP=(NEW,CATLG,CATLG),
// SPACE=(CYL,(01,10),RLSE)
//* RECFM=FB,LRECL=80,
//TOOLIN DD *
SELECT FROM(INPUT) TO(DIFFILE) ON(10,11,CH) NODUPS
/*
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


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

PostPosted: Fri Nov 26, 2010 11:03 am    Post subject: Reply with quote

vak255 wrote:
you can also try ICETOOL


vak255,

Did you test the job you posted? Try to understand the question and then post the answer by testing out your code.

OP wanted to compare 3 fields. You are comparing 10 byte from position 10 ignoring the first 9 bytes. (look at the 3rd record Naveen S ...)

NODUPS will pick the values from both files where as OP wanted only unmatched records from file 2.
_________________
Kolusu
www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
vak255
Intermediate


Joined: 10 Sep 2004
Posts: 384
Topics: 79

PostPosted: Mon Nov 29, 2010 2:50 am    Post subject: Reply with quote

I apologize, my mistake. I should have tested it.
Back to top
View user's profile Send private message
sivafdms
Intermediate


Joined: 29 May 2007
Posts: 165
Topics: 77

PostPosted: Tue Nov 30, 2010 9:16 am    Post subject: Reply with quote

Thanks Kolusu..
Back to top
View user's profile Send private message
computer
Beginner


Joined: 12 Jun 2007
Posts: 64
Topics: 17
Location: Hyderabad

PostPosted: Tue Dec 07, 2010 8:10 am    Post subject: Reply with quote

I have another solution with ICETOOL, but do not know whether this will be an efficeint solution or not....Please suggest
Code:

//STEP04  EXEC PGM=ICETOOL
//TOOLMSG DD SYSOUT=*
//DFSMSG  DD SYSOUT=*
//INPUT1  DD DSN=file1,DISP=SHR
//INPUT2  DD DSN=file2,DISP=SHR
//DIFFILE DD DSN=new file
//        DISP=(NEW,CATLG,CATLG),
.
.
//T1     DD DSn=&&TEMP
//TOOLIN DD *
SORT FROM(INPUT1) TO(T1) USING(CTL1)
SORT FROM(INPUT2) TO(T1) USING(CTL2)
SORT FROM(T1) TO(DIFFILE) USING(CTL3)
/*
//CNTLCTL1
SORT FIELDS = (1,80, CH, A)
SUM FIELDS = NONE
OUTREC FIELDS = (1:1,80,C'01')
/*
//CNTLCTL2
SORT FIELDS = (1,80, CH, A)
SUM FIELDS = NONE
OUTREC FIELDS = (1:1,80,C'02')
/*
//CNTLCTL3
SORT FIELDS = (1, 82, CH, A)
SUM FIELDS = (81,2,ZD)
INCLUDE COND= (81,CH,EQ,C'02')
/*


Thanks,
Computer
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


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

PostPosted: Tue Dec 07, 2010 9:41 am    Post subject: Reply with quote

computer wrote:
I have another solution with ICETOOL, but do not know whether this will be an efficeint solution or not....Please suggest


Computer,

The proposed solution is NOT an optimal solution as it involves 3 SORTS with SUM. If you are not interested in Joinkeys solution , there are better ways to get the desired results in 1 or 2 passes of the data
_________________
Kolusu
www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
computer
Beginner


Joined: 12 Jun 2007
Posts: 64
Topics: 17
Location: Hyderabad

PostPosted: Thu Dec 09, 2010 11:31 am    Post subject: Reply with quote

Hi,

Can you please share the solution... Very Happy

Thanks,
Computer
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


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

PostPosted: Thu Dec 09, 2010 11:44 am    Post subject: Reply with quote

computer wrote:
Hi,Can you please share the solution... Very Happy


Computer,

Assuming the input is FB and Lrecl of 80 we can have a dummy header record before each file which will be used to generate the file id number using WHEN=GROUP and get the non matching records like shown below

Code:

//STEP0100 EXEC PGM=SORT                                           
//SYSOUT   DD SYSOUT=*                                             
//SORTIN   DD *                                                     
$$$                                                                 
//         DD *                                                     
SIVA     15585 30000                                               
JAYANTH  20010 15000                                               
NAVEEN S 25100 15000                                               
SUPRIYO  23234 30000                                               
//         DD *                                                     
$$$                                                                 
//         DD *                                                     
SIVA     15585 30100                                               
JAYANTH  20010 15000                                               
NAVEEN   25100 15000                                               
SUPRIYO  23234 30100                                               
//*                                                                 
//SORTOUT  DD SYSOUT=*                                             
//SYSIN    DD *                                                     
  INREC IFTHEN=(WHEN=GROUP,BEGIN=(1,3,CH,EQ,C'$$$'),PUSH=(81:ID=1))
  SORT FIELDS=(1,8,CH,A,10,5,CH,A,16,5,CH,A),EQUALS                 
  SUM FIELDS=(81,1,ZD)                                             
  OUTFIL BUILD=(1,80),INCLUDE=(81,1,ZD,EQ,2)                       
//*


or

Code:

//STEP0100 EXEC PGM=ICETOOL                                         
//TOOLMSG  DD SYSOUT=*                                             
//DFSMSG   DD SYSOUT=*                                             
//IN       DD *                                                     
$$$                                                                 
//         DD *                                                     
SIVA     15585 30000                                               
JAYANTH  20010 15000                                               
NAVEEN S 25100 15000                                               
SUPRIYO  23234 30000                                               
//         DD *                                                     
$$$                                                                 
//         DD *                                                     
SIVA     15585 30100                                               
JAYANTH  20010 15000                                               
NAVEEN   25100 15000                                               
SUPRIYO  23234 30100                                               
//*                                                                 
//OUT      DD SYSOUT=*                                             
//TOOLIN   DD *                                                     
  SELECT FROM(IN) TO(OUT) ON(1,8,CH) ON(10,5,CH) ON(16,5,CH) -     
  FIRST USING(CTL1)                                                 
//*                                                                 
//CTL1CNTL DD *                                                     
  INREC IFTHEN=(WHEN=GROUP,BEGIN=(1,3,CH,EQ,C'$$$'),PUSH=(81:ID=1))
  OUTFIL FNAMES=OUT,BUILD=(1,80),INCLUDE=(81,1,ZD,EQ,2)             
//*

_________________
Kolusu
www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
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