Page 1 of 1

File compare using SORT

PostPosted: Wed Jul 16, 2014 4:33 pm
by vkumarg3
Hi All,

Is it possible to compare two file using SORT or ICETOOL and set RC accordingly??


My requirement is, Need to compare file A and B.
A and B will have same layout.

A- New file uploaded.
B- Backup file last uploaded.

I need to compare those two files A and B. If file differs, I need to upload A using program. If files are same, I must skip uploading.
Need suggestions.


Thanks in advance.

Re: File compare using SORT

PostPosted: Wed Jul 16, 2014 5:19 pm
by BillyBoyo
Can you post the sysout from a SORT step, so we can see what software and version you have?

Re: File compare using SORT

PostPosted: Wed Jul 16, 2014 7:19 pm
by vkumarg3
Hi Billy,
Please find the version which we are using.

ICE000I 1 - CONTROL STATEMENTS FOR 5694-A01, Z/OS DFSORT V1R12 - 14:34 ON SAT JUN 21, 2014 -
             OPTION COPY

Re: File compare using SORT

PostPosted: Wed Jul 16, 2014 8:08 pm
by BillyBoyo
OK. LRECL and RECFM are...? Is there some key? Are the files in order on that key?

You'll use a JOINKEYS and either NULLOUT (empty SORTOUT) or NULLOFL (empty particular OUTFIL). Specifying the output as a DD DUMMY (output not needed) you can set RC=4 for no records written. Exact match would get CC=4 from the step, so you can then decide not to run the update step.

Re: File compare using SORT

PostPosted: Thu Jul 17, 2014 11:41 am
by vkumarg3
Hi Billy,
Yes we have key field - 14 to 22
LRECL - 1400
RECFM - FB.

Can you please give me the SORT CARD to achieve this??

Thanks in advance.

Re: File compare using SORT

PostPosted: Thu Jul 17, 2014 12:44 pm
by BillyBoyo
  OPTION COPY,NULLOUT=RC4

  JOINKEYS FILE=F1,FIELDS=(start1,length1,A)                           
  JOINKEYS FILE=F2,FIELDS=(start2,length2,A)                           
  JOIN UNPAIRED                                       
  REFORMAT FIELDS=(F1:1,1400,F2:1,1400)
  INREC IFTHEN=(WHEN=(1,1400,CH,NE,1401,1400),
                   BUILD=(C'Y')),
          IFTHEN=(WHEN=NONE,BUILD=(C'N'))
  OUTFIL INCLUDE=(1,1,CH,EQ,C'Y')
   


Try something along those lines. Written quickly, untested.

Re: File compare using SORT

PostPosted: Thu Jul 17, 2014 1:09 pm
by Magesh23586
Bill,

How about this... ? why we need INREC... ?

//S1   EXEC  PGM=SORT       
//SYSOUT DD SYSOUT=*       
//SORTJNF1 DD  DSN=INPUT1 file             
//SORTJNF2 DD  DSN=INPUT2 file       
//SORTOUT DD DUMMY
//SYSIN    DD *                     
  OPTION COPY,NULLOUT=RC4           
  JOINKEYS FILE=F1,FIELDS=(1,1400,A)   
  JOINKEYS FILE=F2,FIELDS=(1,1400,A)   
  JOIN UNPAIRED,F1,ONLY             
  REFORMAT FIELDS=(F1:1,1400)         


In the example I am comparing both the file fully... i.e from 1 to 1400 ?
If key is sufficient to compare then
  JOINKEYS FILE=F1,FIELDS=(14,9,A)   
  JOINKEYS FILE=F2,FIELDS=(14,9,A)   


I have made the output as dummy... if you need this data for uploading... give the dataset name in sortout
Regards,
Magesh

Re: File compare using SORT

PostPosted: Thu Jul 17, 2014 1:34 pm
by BillyBoyo
DUMMY definitely for the output.

Files have a key, if in key order, don't need to be SORTed, which will save considerably on resources.

If, for instance, the key started at position 1, it would be better to do it this way. You'd not need 1400 bytes on the REFORMAT either, because all that is required is "is there a complete match".

I think you'd want UNPAIRED,ONLY. Otherwise you'll miss differences which are on F2, not on F1. Still rushed... so no time to concentrate :-)