Author: Arun Raj
Posted: Fri Mar 31, 2017 5:55 pm (GMT 5.5)
ameetmund,
The idea here is to include only the actual key fields in your JOINKEYS (exclude the amount field), and then extract ONLY matching records from both the files, then work with the amount comparison later on.
Instead of JOIN UNPAIRED,F2,ONLY you probably need to remove the JOIN statement altogether which would give you matching key-records from both the input files.
JOIN UNPAIRED,F2,ONLY - would write ONLY non-matching records from F2.
Then use an OUTREC IFTHEN WHEN condition to check if the amount fields from both the files are different, then OVERLAY the calculated difference amount to the output record.
Something similar to this, if I modify the control statements from your original post:
And remember this would NOT write non-matching records from either of the inputs, if you need non matching records too (I don't see that mentioned in your posts), you would have to modify this as per your requirements. Also I have assumed your amount field to be PD as shown in your control statements.
_________________
Arun
----------------------------------------------------------------------------------------------------
Love is like an hourglass, with the heart filling up as the brain empties. -Jules Renard
Posted: Fri Mar 31, 2017 5:55 pm (GMT 5.5)
ameetmund wrote: |
Forgot to mention that the joinkeys in Sort card have the amount field as well along with few other fields. So it's a combination that's checked |
The idea here is to include only the actual key fields in your JOINKEYS (exclude the amount field), and then extract ONLY matching records from both the files, then work with the amount comparison later on.
Instead of JOIN UNPAIRED,F2,ONLY you probably need to remove the JOIN statement altogether which would give you matching key-records from both the input files.
JOIN UNPAIRED,F2,ONLY - would write ONLY non-matching records from F2.
Then use an OUTREC IFTHEN WHEN condition to check if the amount fields from both the files are different, then OVERLAY the calculated difference amount to the output record.
Something similar to this, if I modify the control statements from your original post:
Code: |
//SYSIN DD * SORT FIELDS=COPY JOINKEYS F1=IN1,FIELDS=(1,4,A) JOINKEYS F2=IN2,FIELDS=(1,4,A) REFORMAT FIELDS=(F2:1,125,F1:75,8) OUTREC IFOUTLEN=125, IFTHEN=(WHEN=(75,8,PD,NE,126,8,PD), OVERLAY=(75:126,8,PD,SUB,75,8,PD,TO=PD,LENGTH=8)) |
_________________
Arun
----------------------------------------------------------------------------------------------------
Love is like an hourglass, with the heart filling up as the brain empties. -Jules Renard