View previous topic :: View next topic
|
Author |
Message |
erhan
New User
Joined: 27 Sep 2007 Posts: 5 Location: rotterdam
|
|
|
|
Hi
I want replace the records in a file according another file:
file1: contains all records
file2: contains only changed records
Example:
file1:
aaaa1111bb
aaaa2222cc
aaaa3333bb
aaaa4444bb
aaaa5555bb
file2:
eeee1111xx
kkkk3333xx
output should be come into file1:
eeee1111xx
aaaa2222cc
kkkk3333xx
aaaa4444bb
aaaa5555bb
I want not change the fields that are changed but replace the record with new one. Keys are the numbers in the file. |
|
Back to top |
|
|
Frank Yaeger
DFSORT Developer
Joined: 15 Feb 2005 Posts: 7129 Location: San Jose, CA
|
|
|
|
You can use a DFSORT job like the one below to do what you asked for. I assumed there were no duplicates within file1, and no duplicates within file2, as in your example. Be sure to concatenate the file with the changed records before the file with all records.
Code: |
//S1 EXEC PGM=ICETOOL
//TOOLMSG DD SYSOUT=*
//DFSMSG DD SYSOUT=*
//CON DD * input file2
eeee1111xx
kkkk3333xx
/*
// DD * input file1
aaaa1111bb
aaaa2222cc
aaaa3333bb
aaaa4444bb
aaaa5555bb
/*
//OUT DD SYSOUT=*
//TOOLIN DD *
SELECT FROM(CON) TO(OUT) ON(5,4,CH) FIRST
/*
|
|
|
Back to top |
|
|
erhan
New User
Joined: 27 Sep 2007 Posts: 5 Location: rotterdam
|
|
|
|
but how can i put the records from file2 to file1 and overwrite if exists? |
|
Back to top |
|
|
Frank Yaeger
DFSORT Developer
Joined: 15 Feb 2005 Posts: 7129 Location: San Jose, CA
|
|
|
|
Huh? I gave you a DFSORT job that does what you asked for in your first post. I stated my assumptions.
Did you try the job? If not, try it.
If you did try the job and it didn't do what you want, then you didn't explain what you want correctly or my assumptions were wrong because you didn't give enough information. You need to explain exactly what you want if you expect anyone to help you. Show a good example of the records in your input files and what you want for output, and explain the "rules" for getting from input to output. If either input file has duplicates within it, show that in your example. Give the RECFM and LRECL of the input files. Give the starting position, length and format of each relevant field. |
|
Back to top |
|
|
erhan
New User
Joined: 27 Sep 2007 Posts: 5 Location: rotterdam
|
|
|
|
Sorry Frank. I will explain what i want to do:
FileA and FileB: both FB with 354 reclen. Key is first 17 characters.
In positions 23 thru 29 are the accountnumbers in packed decimal format.
File B has the updated records which should be applied in File A.
FileA:
<key1>.... <accountnbr1><data1>
<key2>.... <accountnbr2><data2>
<key3>.... <accountnbr3><data3>
<key4>.... <accountnbr4><data4>
....
FileB:
<key2>.... <accountnbr2><data2chg>
<key3>.... <accountnbr3><data3chg>
Output should be come into File A:
FileA:
<key1>.... <accountnbr1><data1>
<key2>.... <accountnbr2><data2chg>
<key3>.... <accountnbr3><data3chg>
<key4>.... <accountnbr4><data4>
.... |
|
Back to top |
|
|
Frank Yaeger
DFSORT Developer
Joined: 15 Feb 2005 Posts: 7129 Location: San Jose, CA
|
|
|
|
You haven't said which fields you want to match on: Key only? Account number only? Key and Account number? I'm going to assume it's the key and account number.
Here's a DFSORT/ICETOOL job that will do what you asked for. Be sure to concatenate FileB before FileA.
Code: |
//S1 EXEC PGM=ICETOOL
//TOOLMSG DD SYSOUT=*
//DFSMSG DD SYSOUT=*
//CON DD DSN=... input fileB (FB/354)
// DD DSN=... input fileA (FB/354)
//OUT DD DSN=... output file (FB/354)
//TOOLIN DD *
SELECT FROM(CON) TO(OUT) ON(1,17,CH) ON(23,7,PD) FIRST
/*
|
Again, this does what you want for the cases you described. If there are other cases for which it doesn't do what you want, you need to tell me what those cases are with an example of the input and expected output records. |
|
Back to top |
|
|
|