file 1 : AAAAA1234
AAA111ZZZ
BBBB111ZZ
file2 : KAAAA1234
AAA111ZZZ
BBBB111ZZ
FILES WILL BE COMPARED FOR FIRST 5 LETTERS AND HENCE 3RD FILE WILL WRITE
FILE 3 : AAA111ZZZ
BBBB111ZZ
JOINKEYS FILE=F1,FIELDS=(1,5,A)
JOINKEYS FILE=F2,FIELDS=(1,5,A)
REFORMAT FIELDS=(F1:1,9)
SORT FIELDS=COPY
This will match the two files, only process matches (mismatches will be ignored) and create a record for the Main Task of the JOINKEYS which is the input record from F1. The Main Task will just copy its input to its output. The output will be on SORTOUT. Inputs are SRTJFNF1 and SRTJNF2.
If this is related to your earlier question, depending on which SORT product you have, which level of that product, and whether you have a "patch" or not, you could put any INCLUDE/OMIT processing in a JNFnCTNL file (where n is 1 or 2 depending on which input file). Saves you a whole step. You could also INCLUDE/OMIT in the Main Task of the JOINKEYS, but why SORT more than you need to.
If your File 1 is already in sort order, you can add ,SORTED
to the JOINKEYS for that file. If so and you have DFSORT (please let us know that on the previous question) you can also put ,NOSEQCHK
.