I tried the following: Even though the VB length is 32576, the maximum length of the record is 4000. So I used JOINKEYS, but the problem is that all the matching records are getting written to SORTOUT and so the return code is never set to 4.
I need to set the return code to 4 only when there is even one record mis-match. If all the records match, then I want the RC to be set to 0.
Instead of using JOIN UNPAIRED,F2 (Right outer Join) go with UNPAIRED,F1,F2,ONLY to get only unpaired records from both the input files and SET RC=4 if you get any records in the SORTOUT. Remove the NULLOUT and pass the below parm to set RC4 when you get any unpaired record.
STEP01 EXEC PGM=SORT,PARM='NOTMTOUT=RC4'
you included OMIT to remove Header, Trailer for File1 only. Add for F2 also.