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.