I have tried the following in spark-scala.
Logic:
If Code in Data1 = Code in Data2 the record has to be written to the output file. so based on this condition