File compare using SORT



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

File compare using SORT

Postby vkumarg3 » Wed Jul 16, 2014 4:33 pm

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.
vkumarg3
 
Posts: 29
Joined: Fri Jan 06, 2012 9:29 am
Has thanked: 10 times
Been thanked: 0 time

Re: File compare using SORT

 

Re: File compare using SORT

Postby BillyBoyo » Wed Jul 16, 2014 5:19 pm

Can you post the sysout from a SORT step, so we can see what software and version you have?
BillyBoyo
Global moderator
 
Posts: 3804
Joined: Tue Jan 25, 2011 12:02 am
Has thanked: 22 times
Been thanked: 264 times

Re: File compare using SORT

Postby vkumarg3 » Wed Jul 16, 2014 7:19 pm

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
vkumarg3
 
Posts: 29
Joined: Fri Jan 06, 2012 9:29 am
Has thanked: 10 times
Been thanked: 0 time

Re: File compare using SORT

Postby BillyBoyo » Wed Jul 16, 2014 8:08 pm

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.
BillyBoyo
Global moderator
 
Posts: 3804
Joined: Tue Jan 25, 2011 12:02 am
Has thanked: 22 times
Been thanked: 264 times

Re: File compare using SORT

Postby vkumarg3 » Thu Jul 17, 2014 11:41 am

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.
vkumarg3
 
Posts: 29
Joined: Fri Jan 06, 2012 9:29 am
Has thanked: 10 times
Been thanked: 0 time

Re: File compare using SORT

Postby BillyBoyo » Thu Jul 17, 2014 12:44 pm

  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.

These users thanked the author BillyBoyo for the post:
vkumarg3 (Tue Jul 22, 2014 12:46 pm)
BillyBoyo
Global moderator
 
Posts: 3804
Joined: Tue Jan 25, 2011 12:02 am
Has thanked: 22 times
Been thanked: 264 times

Re: File compare using SORT

Postby Magesh23586 » Thu Jul 17, 2014 1:09 pm

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

These users thanked the author Magesh23586 for the post:
vkumarg3 (Tue Jul 22, 2014 12:47 pm)
Magesh23586
 
Posts: 35
Joined: Sat Jul 05, 2014 5:36 pm
Has thanked: 1 time
Been thanked: 3 times

Re: File compare using SORT

Postby BillyBoyo » Thu Jul 17, 2014 1:34 pm

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 :-)
BillyBoyo
Global moderator
 
Posts: 3804
Joined: Tue Jan 25, 2011 12:02 am
Has thanked: 22 times
Been thanked: 264 times


Return to DFSORT/ICETOOL/ICEGENER

 


  • Related topics
    Replies
    Views
    Last post