compare RECORDS from POSITION 1 to 5, of two VB flat files and write the matching records in 3rd file JCL

StackOverflow https://stackoverflow.com/questions/19839956

  •  29-07-2022
  •  | 
  •  

Question

 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
Was it helpful?

Solution

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top