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 and Split two files using ICETOOL

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


Joined: 13 Mar 2007
Posts: 15
Topics: 5

PostPosted: Wed May 09, 2007 5:53 am    Post subject: Compare and Split two files using ICETOOL Reply with quote

Hi,

Can we do a record vise comparison in two files using ICETOOL,

In this case, there are two files, Field1 is comon in both the files,

1. If there is a match of the Field1, Field2 and Field3 in both the files then nothing is to be done
2. If Field1 of File A is not present in File B then populate that record to File 1
3. If Field1 of File B is not present in File A then populate that record to File 2
4. If Field1 of File A matches with Field1 of File B but the other fields(Field2 or Field3) are not the same then populate that record to File3



File A
Code:

Field1   Field2  Field3
100      aa0     bb0
101      aa1     cc0
102      aa2     bb2
103      aa3     bb3

File B
Code:

Field1   Field2  Field3
101      aa1     bb1
102      aa2     bb2
103      aa3     cc1
104      aa4     bb4

Output Files:

File 1:
Code:

Field1   Field2  Field3
100      aa0     bb0

File 2:
Code:

Field1   Field2  Field3
104      aa4     bb4

File 3:
Code:

Field1   Field2  Field3
101      aa1     cc0
103      aa3     cc1
Back to top
View user's profile Send private message
Frank Yaeger
Sort Forum Moderator
Sort Forum Moderator


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

PostPosted: Wed May 09, 2007 11:56 am    Post subject: Reply with quote

Quote:
4. If Field1 of File A matches with Field1 of File B but the other fields(Field2 or Field3) are not the same then populate that record to File3


You show the following output for File3:


Code:

Field1   Field2  Field3
101      aa1     cc0       from FileA
103      aa3     cc1       from FileB


I assumed you really wanted the File A records for this situation, so your output records for File3 should be:

Code:

Field1   Field2  Field3
101      aa1     cc0       from FileA
103      aa3     bb3       from FileA


If you really want the 103 record from File B rather than from File A, you need to explain the rules for that.

Here's a DFSORT/ICETOOL job that will do what you asked for. I assumed your input files have RECFM=FB and LRECL=20, but the job can be changed appropriately.

Code:

//S1    EXEC  PGM=ICETOOL
//TOOLMSG DD SYSOUT=*
//DFSMSG  DD SYSOUT=*
//IN1 DD DSN=... input file1 (FB/20)
//IN2 DD DSN=... input file2 (FB/20)
//T1 DD DSN=&&T1,UNIT=SYSDA,SPACE=(CYL,(5,5)),DISP=(MOD,PASS)
//OUT1 DD DSN=...  output file1 (FB/20)
//OUT2 DD DSN=...  output file2 (FB/20)
//OUT3 DD DSN=...  output file3 (FB/20)
//TOOLIN   DD    *
COPY FROM(IN1) TO(T1) USING(CTL1)
COPY FROM(IN2) TO(T1) USING(CTL2)
SPLICE FROM(T1) TO(OUT1) ON(1,3,CH) KEEPNODUPS -
  WITH(21,21) USING(CTL3)
/*
//CTL1CNTL DD *
  INREC BUILD=(1,20,41:C'BB')
/*
//CTL2CNTL DD *
  INREC BUILD=(1,3,21:1,20,41:C'VV')
/*
//CTL3CNTL DD *
  OUTFIL FNAMES=OUT1,INCLUDE=(41,2,CH,EQ,C'BB'),
     BUILD=(1,20)
  OUTFIL FNAMES=OUT2,INCLUDE=(41,2,CH,EQ,C'VV'),
     BUILD=(21,20)
  OUTFIL FNAMES=OUT3,INCLUDE=(41,2,CH,EQ,C'VB',AND,
       (10,3,CH,NE,30,3,CH,OR,18,3,CH,NE,38,3,CH)),
     BUILD=(1,20)
/*

_________________
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
aruna_space
Beginner


Joined: 13 Mar 2007
Posts: 15
Topics: 5

PostPosted: Sun May 13, 2007 10:32 pm    Post subject: Reply with quote

Hi Frank,
[code:1:b12a144ce1]
//S1 EXEC PGM=ICETOOL
//TOOLMSG DD SYSOUT=*
//DFSMSG DD SYSOUT=*
//IN1 DD DSN=... input file1 (FB/11)
//IN2 DD DSN=... input file2 (FB/11)
//TEMP DD DSN=&&TEMP1,DISP=(MOD,PASS),

//TEMP1 DD DSN=&&TEMP2,DISP=(MOD,PASS),

//T1 DD DSN=&&TEMP3,DISP=(MOD,PASS),

//T2 DD DSN=&&TEMP4,DISP=(MOD,PASS),

//T3 DD DSN=&&TEMP5,DISP=(MOD,PASS),

//T4 DD DSN=
Back to top
View user's profile Send private message
Nic Clouston
Advanced


Joined: 01 Feb 2007
Posts: 1075
Topics: 7
Location: At Home

PostPosted: Mon May 14, 2007 2:58 am    Post subject: Reply with quote

Run them both and compare the timings - quicker than waiting for someone else to do it for you.
_________________
Utility and Program control cards are NOT, repeat NOT, JCL.
Back to top
View user's profile Send private message
aruna_space
Beginner


Joined: 13 Mar 2007
Posts: 15
Topics: 5

PostPosted: Tue May 15, 2007 7:07 am    Post subject: Reply with quote

In the T1 file we dont get the condition 'VB' at all, we either get 'BB' or 'VV' then why do we have this check on 'VB'

OUTFIL FNAMES=OUT3,INCLUDE=(41,2,CH,EQ,C'VB',AND,
(10,3,CH,NE,30,3,CH,OR,18,3,CH,NE,38,3,CH)),
BUILD=(1,20)
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


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

PostPosted: Tue May 15, 2007 8:10 am    Post subject: Reply with quote

Quote:

In the T1 file we dont get the condition 'VB' at all, we either get 'BB' or 'VV' then why do we have this check on 'VB'

aruna_space,

If you had ran Frank's job as is you would have found 'VB' records. For every matching record in both files you will have a 'VB' record.

Kolusu
_________________
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