1) what is '?' in REFORMAT FIELDS=(F1:1,80,?,F2:45,5)
The ? indicates that DFSORT is to put a flag at that position (81 in this case) indicating where the record came from. In this case, the flag will be 'B' when the record was found in both files (F1/F2) or '1' when the record was only found in file1 (F1).
2) why are we comparing with column 81 and using 82 in overlay. Our File1 is only 80 length.
IFTHEN=(WHEN=(81,1,CH,EQ,C'B'),OVERLAY=(50:82,5))
The REFORMAT creates records like this:
|1-80 from F1|flag|45-49 from F2|
Len 80 1 5
For F1 only records, the REFORMAT records look like this:
|1-80 from F1|1| |
Len 80 1 5
For F1/F2 records, the REFORMAT records look like this:
|1-80 from F1|B|45-49 from F2|
Len 80 1 5
Here's what the IFTHEN does:
If the flag in 81 is '1' (F1 only), no change is needed. If the flag in 81 is 'B' (F1/F2), we overlay positions 50-54 with 82-86 (45-49 from F2).
The IFOUTLEN=80 sets the final output record length to 80.
3) Actually the value to be replaced is in column(50:5) in FIle1 with column(45:5) from File 2. The value in column(50:5) can be any name. Not necessary to start with B. So, how do we handle this?
The 'B' is a flag inserted by DFSORT, not a name starting with 'B'. 50:5 is replaced by 45:5 in the F1/F2 records.
This DFSORT job gives the output you requested.
For more information on DFSORT's JOINKEYS function, see:
http://www.ibm.com/support/docview.wss? ... g3T7000174