Comparing two files using SORT



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

Comparing two files using SORT

Postby jvinoth » Tue May 08, 2012 6:21 pm

Hi,
I have two files and need to compare master file with the another file and i need to
remove the reocrds from the second file which are present in master file how to achive this.

both files are FB and same length.

File A(Master file)
-------------------
0000490
0000490
0000432
0000490
0000490
0000490
0000450
0000444
0000490
0000445

File B
-------
0000490
0000490
0000432
0000490
0000411
0000412
0000450
0000444
0000413
0000445

Output file
-----------
0000411
0000412
0000413

please tel me how to do
jvinoth
 
Posts: 132
Joined: Fri Nov 18, 2011 3:13 pm
Has thanked: 0 time
Been thanked: 1 time

Re: Comparing two files using SORT

 

Re: Comparing two files using sort

Postby BillyBoyo » Tue May 08, 2012 6:59 pm

Joinkeys with JOIN ONLY for the non-matched file.

What is your record-length? Up to 4080 (I think it is) you can specify as a single key. Beyond 4080 it'll be "more tricky" :-)
BillyBoyo
Global moderator
 
Posts: 3804
Joined: Tue Jan 25, 2011 12:02 am
Has thanked: 22 times
Been thanked: 264 times

Re: Comparing two files using sort

Postby skolusu » Wed May 09, 2012 12:50 am

Use the following DFSORT JCL which will give you the desired results
//STEP0100 EXEC PGM=SORT                       
//SYSOUT   DD SYSOUT=*                         
//INA      DD *                                 
0000490                                         
0000490                                         
0000432                                         
0000490                                         
0000490                                         
0000490                                         
0000450                                         
0000444                                         
0000490                                         
0000445                                         
//INB      DD *                                 
----+----1----+----2----+----3----+----4----+---
0000490                                         
0000490                                         
0000432                                         
0000490                                         
0000411                                         
0000412                                         
0000450                                         
0000444                                         
0000413                                         
0000445                                         
//SORTOUT  DD SYSOUT=*                         
//SYSIN    DD *                                 
  OPTION COPY                                   
  JOINKEYS F1=INA,FIELDS=(1,7,A)               
  JOINKEYS F2=INB,FIELDS=(1,7,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

Re: Comparing two files using sort

Postby jvinoth » Wed May 09, 2012 2:15 pm

thank you so much skolusu.
jvinoth
 
Posts: 132
Joined: Fri Nov 18, 2011 3:13 pm
Has thanked: 0 time
Been thanked: 1 time

Re: Comparing two files using sort

Postby jvinoth » Wed May 09, 2012 4:56 pm

suppose if i have two files which contain different records and i need to remove the records which are present in both fileA and fileB.
can we do using sort.

File A(Master file)
-------------------
0000490
0000432
0000450
0000444
0000490
0000445

File B
-------
0000490
0000490
0000432
0000411
0000490
0000415
0000444
0000413


File c
-------
0000490
0000432
0000450
0000444
0000490
0000445
0000490
0000455
0000432
0000411
0000466
0000415
0000444
0000413

ouput file
----------
0000466
0000455

thanks
jvinoth
 
Posts: 132
Joined: Fri Nov 18, 2011 3:13 pm
Has thanked: 0 time
Been thanked: 1 time

Re: Comparing two files using sort

Postby jvinoth » Wed May 09, 2012 5:05 pm

i have used f3 only but its showing errors says that
 VALUE 'F3' SHOULD HAVE BEEN F1 OR F2.
jvinoth
 
Posts: 132
Joined: Fri Nov 18, 2011 3:13 pm
Has thanked: 0 time
Been thanked: 1 time

Re: Comparing two files using sort

Postby BillyBoyo » Wed May 09, 2012 5:26 pm

There are only two files in JOINKEYS.

You can concatenate two files, possibly, if treating two files as one to match against the first would give you your answers.
BillyBoyo
Global moderator
 
Posts: 3804
Joined: Tue Jan 25, 2011 12:02 am
Has thanked: 22 times
Been thanked: 264 times

Re: Comparing two files using sort

Postby jvinoth » Wed May 09, 2012 5:27 pm

thanks billy.
jvinoth
 
Posts: 132
Joined: Fri Nov 18, 2011 3:13 pm
Has thanked: 0 time
Been thanked: 1 time


Return to DFSORT/ICETOOL/ICEGENER

 


  • Related topics
    Replies
    Views
    Last post