Page 1 of 1

SUM FIELDS = NONE in JOINKEY Operation

PostPosted: Fri Jun 22, 2012 4:16 pm
by fornanthakumar
Hi,

Good Day.

My objective is to compare two files and get the unpaired F2 data. (if F2 does have duplicates or the content are in both files duplicates then it should be removed) . I am using DFSORT and using JOINKEY operations. Please find my code below.
JOINKEYS FILES=F1,FIELDS=(23,18,A,42,9,A,63,17,A)
JOINKEYS FILES=F2,FIELDS=(23,18,A,42,9,A,63,17,A)
JOIN UNPAIRED,F2,ONLY
REFORMAT FIELDS(F2:1,186)
SUM FIELDS=NONE
OPTION COPY

My second input file does contain duplicates also contains the records which is there in first input file. when i am using the above code, duplicates are not eliminated from the file.

Could some one please help..

can i use some code to elimate in JNF2CNTL ...

Re: SUM FIELDS = NONE in JOINKEY Operation

PostPosted: Fri Jun 22, 2012 11:31 pm
by skolusu
fornanthakumar,

Your Main task is using a COPY operation so the SUM FIELDS=NONE statement is ignored. If you want to remove duplicates move the SUM FIELDS=NONE to JNF2CNTL DD like shown below
//SYSIN    DD *                                       
  OPTION COPY                                         
  JOINKEYS FILES=F1,FIELDS=(23,18,A,42,9,A,63,17,A)   
  JOINKEYS FILES=F2,FIELDS=(23,18,A,42,9,A,63,17,A)   
  JOIN UNPAIRED,F2,ONLY                               
//*                 
//JNF2CNTL DD *     
  SUM FIELDS=NONE   
//*

Re: SUM FIELDS = NONE in JOINKEY Operation

PostPosted: Thu Jun 28, 2012 2:03 pm
by fornanthakumar
Hi,

Thanks for the above reply, i have got some kick from your points ,

I have some questions as well,

1. In the ABOVE case , where/how the key fields for file2 will picked from ? will it from the SYSIN ?
2. I am just confused on having sum fields without SORT fields. Should i mentined SORT FIELDS=(23,18,CH,A,42,9,CH,A,63,17,CH,A) SUM FIELDS- NONE in JNF2CNTL.
3. Instead of option copy in SYSIN statement, can we have the SORT fields there ?

Re: SUM FIELDS = NONE in JOINKEY Operation

PostPosted: Thu Jun 28, 2012 8:07 pm
by BillyBoyo
fornanthakumar wrote:Hi,

Thanks for the above reply, i have got some kick from your points ,

I have some questions as well,

1. In the ABOVE case , where/how the key fields for file2 will picked from ? will it from the SYSIN ?
2. I am just confused on having sum fields without SORT fields. Should i mentined SORT FIELDS=(23,18,CH,A,42,9,CH,A,63,17,CH,A) SUM FIELDS- NONE in JNF2CNTL.
3. Instead of option copy in SYSIN statement, can we have the SORT fields there ?


When you have doubts like this, the manual is a good source of information.

JOINKEYS, unless told not to, does a SORT on the keys specified for the join (else it won't work, except by fluke, or if files already in order, in which case you tell that to the JOINKEYS).
So, by default, you have your full SORT key for the joinkeys and that is what it will do the SUM on.

You could sort in the main task of the JOINKEYS but since the reformat file will be in that order anyway it will be something of a waste. Plus you will have had more data going into the JOINKEYS than necessary. If getting rid of stuff, best to do it as early as possibible, for clarity with a performance bonus.

Re: SUM FIELDS = NONE in JOINKEY Operation

PostPosted: Thu Jun 28, 2012 10:23 pm
by skolusu
fornanthakumar,

Check this link which will answer all your queries.

http://publibz.boulder.ibm.com/cgi-bin/ ... E1CA60/4.0