I have two flat files of same record length and same file layout. I need to create an output file with records of the first file whose key(position 81-100 byte) is not found in the second file. In other words, I should create an output file by removing the records from the first file whose key is available in the second file. The second file may contain duplicate keys. The key is in the same byte location (81-100) in both the files. Is there any simple way using JCL SORT to do this?
Joined: 15 Feb 2005 Posts: 7129 Location: San Jose, CA
Karthik,
If you need more specific help than that DFSORT Trick provides, show an example of the records in each input file (relevant fields only) and what you expect for output. Also, give the RECFM and LRECL of each input file.
I have created the sample Input files and the output file that is needed for me. It will be great if you could assist me in getting this done through JCL SORT. Please find the details below. Thanks for your time and assistance.
Thanks,
Karthik Raman
All files are of LRECL=300 and RECFM=FB. The key(20 byte) is available in the byte position (81 ? 100) in all the files. The first input file does not contain duplicate key but the second input file may or may not contain duplicate keys. (Only keys may be duplicate in the second file but the records wont be duplicate). The output file should contain records as it is from the first file by removing the record keys found in second file.
The second column in the following example case is the 20 byte key.
Input File 1
20060101 01CE2006VIPSNM567893 DATA...
20050425 01FH2005VIPSNM876561 DATA...
20050317 01GT2005VIPSNM089334 DATA...
20050205 01FH2005VIPSNM847244 DATA... Key Match 1 .Do not copy
20060521 01PS2006VIPSNM524357 DATA...
20050511 01VB2005VIPSNM083424 DATA... Key Match 2 .Do not copy
Output File
Output File contain records from Input File 1 without any matched keys in Input File 2.(i.e.,) All matched key records are removed from File 1 and written to output file. In this example case, the fourth and sixth records of input file 1 has matching key in input file 2. So, those two records are removed from the input file 1 and written to output file.
I was able to solve my trouble by looking at one of your reply to another query. Here is the sample code that I tried with a sample file attribute and it ran fine.
Just let me know if I need to remember any important point in this code.