You haven't given enough information for anyone to do that.
Please show an example of the records in each input file (relevant fields only) and what you expect for output. Explain the "rules" for getting from input to output. Give the starting position, length and format of each relevant field. Give the RECFM and LRECL of the input files. If file1 can have duplicates within it, show that in your example. If file2 can have duplicates within it, show that in your example.
Also, run this job and show the //SYSOUT messages you receive, so I can see what level you're at:
It would really have helped if you'd given all of the information I asked for including an example of input and output. Since you didn't, I can only guess what your files look like.
both R1 and R2 have duplicate values.
Assuming you mean that there are dups within file1, and dups within file2, you can use a DFSORT/ICETOOL job like the following (of course, I don't know if your files really look like this but it should give you the idea):