Joined: 17 Oct 2006 Posts: 2481 Location: @my desk
I read this thread several times, and I have been thinking why would we need a JOIN UNPAIRED when we are not at all interested in UNPAIRED records from F2 where a JOIN UNPAIRED,F1,ONLY would suffice the requirement. And the TS himself has posted the below "JOIN UNPAIRED F1 ONLY" solution in the Page1 of this thread and had complained saying he gets records in output even if both the input files are same.
Code:
//SYSIN DD *
SORT FIELDS=COPY
JOINKEYS FILE=F1,FIELDS=(1,250,CH,A)
JOINKEYS FILE=F2,FIELDS=(1,250,CH,A)
JOIN UNPAIRED F1 ONLY
REFORMAT FIELDS=(F1:1,250,F2:1,250)
OMIT COND=((1,6,CH,EQ,C'HEADER'),OR,(1,7,CH,EQ,C'TRAILER'),OR,
(1,250,CH,EQ,C' '))
/*
In the above card, comma is missed after UNPAIRED and after F1, and hence the portion after UNPAIRED was treated as comments. JOIN UNPAIRED has a totally different meaning - it tells sort to extract all the records - matched records + unmatched records from file1 + unmatched records from file2.
Again an UNPAIRED,F1,ONLY does not need a REFORMAT statement since the output record is generated by fields from a single file.ie., F1.
I would have preferred something like this.
This will give
RC0 - unpaired data records from file1 alone in output
RC4 - empty output since both the files are matching byte-by-byte
RC4 - empty output since file1 is empty
RC4 - empty output since both file1 and file2 are empty
RC4 - empty output since all data records are matching, but header or trailer records do not match
If the TS is particular about RC4 only when file1 is not empty, he could have it checked beforehand and skip this comparison step itself.
However the header or trailer mismatch alone could lead to RC4. He could very well analyse on the possibility of occurrence of each scenario and take an appropriate decision.
Joined: 17 Oct 2006 Posts: 2481 Location: @my desk
tecnokrat,
Did you pay attention to the questions raised by Gerry? You have just stated what you need, but it does not look like you are doing the same in your posted code.