Page 1 of 1

Comparing two files using SORT

PostPosted: Tue May 08, 2012 6:21 pm
by jvinoth
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

Re: Comparing two files using sort

PostPosted: Tue May 08, 2012 6:59 pm
by BillyBoyo
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" :-)

Re: Comparing two files using sort

PostPosted: Wed May 09, 2012 12:50 am
by skolusu
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                         
//*

Re: Comparing two files using sort

PostPosted: Wed May 09, 2012 2:15 pm
by jvinoth
thank you so much skolusu.

Re: Comparing two files using sort

PostPosted: Wed May 09, 2012 4:56 pm
by jvinoth
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

Re: Comparing two files using sort

PostPosted: Wed May 09, 2012 5:05 pm
by jvinoth
i have used f3 only but its showing errors says that
 VALUE 'F3' SHOULD HAVE BEEN F1 OR F2.

Re: Comparing two files using sort

PostPosted: Wed May 09, 2012 5:26 pm
by BillyBoyo
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.

Re: Comparing two files using sort

PostPosted: Wed May 09, 2012 5:27 pm
by jvinoth
thanks billy.