Compare File1 header (position (7,6)) with File2 1st Record only (position (31,6)). If matching Max-RC should be 0, else throw Max-RC 16.
If return code is 0 then File2 will be merged with File1 in the next step.
Sample layout:
LRECL=95 for Both files
File1: With Header
----+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8
********************************* Top of Data **********************************
XXXXXX2024011620240131
AB387CDE **0001 9999 XY3849 Z 20240116170020240116230020240116170020240116170020
AB387CDE ND0001 9999 XY3849 Z 20240116170020240116230020240116170020240116170020
AB387CDE ZP0001 9999 XY3849 Z 20240116170020240116230020240116170020240116170020
File2 : Without header
----+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8
********************************* Top of Data **********************************
DE387CDE **0001 9999 WV3849 Z 20240116170020240116230020240116170020240116170020
DE387CDE WG0001 9999 WV3849 Z 20240116170020240116230020240116170020240116170020
DE387CDE DJ0001 9999 WV3849 Z 20240116170020240116230020240116170020240116170020
2. Stop your habits to assign stupid names to ANY OBJECT OF YOUR CODE, like STEP01, etc!!!
Also, instead of obsolete FILE=F1 try to use the format F1=meaningful_DD_name
3. Try to learn about //SYMNAMES option of SORT utility, to assign meaningful names to all used fields, instead of their absolute positions, and offsets.
4. Search and learn about extra processing statements //JFN1CNTL, and //JFN2CNTL, to pre-handle each of F1/F2 DD data before they are joined.
5. Likely, you need to (temporary) renumber each record of both F1/F2, and then use INCLUDE parameter in each of your JOINKEYS statement.
Please, try it yourself, before asking to provide you with the ready-to-use code.
Please use code tags ..
This has been discussed several times on this forum and simple search would get you to wha you want..
Try
ibmmainframes.com/about58174.html