View previous topic :: View next topic
|
Author |
Message |
mrdinesh
New User
Joined: 23 Sep 2006 Posts: 24 Location: India
|
|
|
|
Hi,
I have two files which are Variable length files. I am trying to combine the two files and in the process I want to replace the matching keys with the key in the secong file. For example
File 1 Contains the followin records
1000...ABCD
1001...DCDE
1002...EFGH
1003...WXYZ
1004...NOPQ
1005...RSTU
File 2 Contains the following records
1000...WXYZ
1001...ABCD
My output file should consist like
1000...WXYZ
1001...ABCD
1002...EFGH
1003...WXYZ
1004...NOPQ
1005...RSTU
The Key for both the files is the first 4 bytes.
Thanks,
Dinesh |
|
Back to top |
|
|
THINKSRINIII Warnings : 1 New User
Joined: 09 Jan 2009 Posts: 88 Location: India
|
|
|
|
Hi Dinesh,
Your requirement is still not clear.
Can you explain how you need your output? |
|
Back to top |
|
|
enrico-sorichetti
Superior Member
Joined: 14 Mar 2007 Posts: 10873 Location: italy
|
|
|
|
there is a little miswording,
Quote: |
I want to replace the matching keys with the key in the secong file. |
but nothing that prevents understanding the requirement
for matching keys ( the first 4 bytes ) use the data from file 2 |
|
Back to top |
|
|
Frank Yaeger
DFSORT Developer
Joined: 15 Feb 2005 Posts: 7129 Location: San Jose, CA
|
|
|
|
Dinsesh,
We really do need more information.
What is the LRECL of each input file?
Since the files are VB, the key (first field) starts in position 5 (after the RDW). Where does the second field start (after the RDW)? Is there more data after the second field? Is it variable in length?
Does file1 have any keys that don't have a match in file2?
Does file2 have any keys that don't have a match in file1?
If there can be mismatches, then show an example of that with the expected output.
You seem to be referring to both the first field and second field as "key" whereas really you should only refer to the first field as "key" since that's the one you're matching on. The second field is just data. |
|
Back to top |
|
|
mrdinesh
New User
Joined: 23 Sep 2006 Posts: 24 Location: India
|
|
|
|
Frank, Here is a much detailed information on the files
Both the files are in VB and has a LRECL of 1000.The first file consists of a set of records which are accumulated from the start of the year. The second file consists of the records that are updated/newly added records on a day. At the end of the day the second file needs to be merged with the file 1.
The key to both the files is the first 25 characters in it.
When the key from file 1 matches with the key in file 2 the record from file 2 need to be written in output file ignoring the file 1 record.
When the key from file 1 does not matches with the key from file 2 both the file 1 and file 2 records need to be written to the output file.
For example consider the following example
File 1 Key File 1 data
1000... ABCD
1001... EFGH
1002... HIJK
1003... LMNO
1004... PQRS
1005... UVWX
File 2 Key File 2 data
1000... UPDATED ABCD
1006... NEWLY ADDED YZAB
The output should be like this
1000... UPDATED ABCD
1001... EFGH
1002... HIJK
1003... LMNO
1004... PQRS
1005... UVWX
1006... NEWLY ADDED YZAB
Please let me know if it is still not clear.
Thanks,
Dinesh |
|
Back to top |
|
|
Frank Yaeger
DFSORT Developer
Joined: 15 Feb 2005 Posts: 7129 Location: San Jose, CA
|
|
|
|
Since you don't have any duplicates within each file, you can use a DFSORT/ICETOOL job like the following. Be sure that file2 is first in the concatenation.
Code: |
//S1 EXEC PGM=ICETOOL
//TOOLMSG DD SYSOUT=*
//DFSMSG DD SYSOUT=*
//SYSUDUMP DD SYSOUT=*
//CON DD DSN=... input file2 (VB/1000)
// DD DSN=... input file1 (VB/1000)
//OUT DD DSN=... output file (VB/1000)
//TOOLIN DD *
SELECT FROM(CON) TO(OUT) ON(5,25,CH) FIRST
/*
|
|
|
Back to top |
|
|
|