0
 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
Bill Woodger
  • 12,968
  • 4
  • 38
  • 47
Agent Mahone
  • 307
  • 3
  • 15
  • 26

1 Answers1

2
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.

Bill Woodger
  • 12,968
  • 4
  • 38
  • 47
  • the files are not sorted before this step of JOINKEYS, this output will be used in other sort step which is previous/actually-next question. – Agent Mahone Nov 08 '13 at 06:29
  • OK. The code shown should suffice. You need to tag this question, and your others on SORT. Just one of SyncSort or DFSORT. Depends on the messages in the sysout for the step. ICE = DFSORT, WER = SyncSort. – Bill Woodger Nov 08 '13 at 07:46