I have below requirement, which I want to fulfil using SORT.
I have two input files which has a field (7,5 i.e 5 bytes from position 7) which makes it unique. I want to match the key from 1st file to the key on the 2nd file. If key matches, I want to filter some fields from the 1st and 2nd file and write the new output file. The example in given below.
2nd File:
----+----1----+----2----+----3
F0001,B0001,G0001,H0001,I0001
F0002,B0002,G0002,H0002,I0002 Has matching key as 1st file.
F0003,B0003,G0003,H0003,I0003 Has matching key as 1st file.
F0004,B0004,G0004,H0004,I0004
F0005,B0005,G0005,H0005,I0005 Has matching key as 1st file.
F0006,B0006,G0006,H0006,I0006
F0007,B0007,G0007,H0007,I0007 Has matching key as 1st file.
F0008,B0008,G0008,H0008,I0008
F0009,B0009,G0009,H0009,I0009
Output file:
B0002,D0002,E0002,G0001,H0001 Fields are pulled from 2nd file.
B0003,D0003,E0003,G0003,H0003 Field are pulled from 2nd file.
B0005,D0005,E0005,G0005,H0005 Field are pulled from 2nd file.
B0007,D0007,E0007,G0007,H0007 Field are pulled from 2nd file.
Please let me know how can we acheive this and please provide me with sample sort card if have any. Would appriciate your help.
Yeah there was mistake in the output declaration. Thanks for you help. I had one document on DFSORT which i got it from IBM site but not finding it very useful to match the current criteria.
=============================================
I have below requirement, which I want to fulfil using SORT.
I have two input files which has a field (7,5 i.e 5 bytes from position 7) which makes it unique. I want to match the key from 1st file to the key on the 2nd file. If key matches, I want to filter some fields from the 1st and 2nd file and write the new output file. The example in given below.
2nd File:
----+----1----+----2----+----3
F0001,B0001,G0001,H0001,I0001
F0002,B0002,G0002,H0002,I0002 Has matching key as 1st file.
F0003,B0003,G0003,H0003,I0003 Has matching key as 1st file.
F0004,B0004,G0004,H0004,I0004
F0005,B0005,G0005,H0005,I0005 Has matching key as 1st file.
F0006,B0006,G0006,H0006,I0006
F0007,B0007,G0007,H0007,I0007 Has matching key as 1st file.
F0008,B0008,G0008,H0008,I0008
F0009,B0009,G0009,H0009,I0009
Output file:
B0002,D0002,E0002,G0002,H0002
B0002,D0002,E0002 Pulled from First File
G0002,H0002 Pulled from Second File
Simlar Output records..
B0003,D0003,E0003,G0003,H0003 Field are pulled from 2nd file.
B0005,D0005,E0005,G0005,H0005 Field are pulled from 2nd file.
B0007,D0007,E0007,G0007,H0007 Field are pulled from 2nd file.
Please let me know how can we acheive this and please provide me with sample sort card if have any. Would appriciate your help.
Please accept my sincere thanks to all of you for helping me out. The solution given by Frank Yaeger has worked and it is pretty fast. I will be keep checking this site for someone to whom i can help next time. Thanks once again.
Hi, I got some change in my requirment. The input file can have a duplicates in the key field. The below code SORT card will not work with duplicates. Please see the example.
No Frank Second fill not have duplicate. This was a requirement change and was not know to me before that the first input file may have duplicates in it. Sorry for the inconvenience caused.
Joined: 18 Nov 2006 Posts: 3156 Location: Tucson AZ
vijaypratapnayak wrote:
Could you please let me confirm my understanding. This could be a basic question. This is my first experience using ICETOOL.
As Frank would say:
Frank Yaeger wrote:
If you're not familiar with DFSORT and DFSORT's ICETOOL, I'd suggest reading through "z/OS DFSORT: Getting Started". It's an excellent tutorial, with lots of examples, that will show you how to use DFSORT, DFSORT's ICETOOL and DFSORT Symbols. You can access it online, along with all of the other DFSORT books, from:
and for some examples of using SPLICE for matching see the "Join fields from two files on a key" and "Join fields from two files record-by-record" Smart DFSORT Tricks at:
I have a similar requirement but I may have unmatched records in the File 1 . The above Sort will get all the matched records. What if I also want to write to output all those records in File 1 which do not have a match in File 2.
Joined: 15 Feb 2005 Posts: 7129 Location: San Jose, CA
achittu,
Please start a new Topic.
In your initial post, show an example of the records in each input file and what you expect for the output records. If input file1 can have duplicates within it, show that in the example. If input file2 can have duplicates within it, show that in the example. Also, give the RECFM and LRECL of the input files, and the starting position, length and format of the relevant fields in each input file.