View previous topic :: View next topic
|
Author |
Message |
shilpa.khaire
New User
Joined: 21 Jul 2006 Posts: 39 Location: US
|
|
|
|
Hi all!
I want to mtch 2 files based on a certain field. Which is pretty easy if I sort the 2 files on a certain key field. But I have a selection criteria or a decision table which I need to use. The decision table looks like this:
Priority Field1 Field 2 Field3 Field4
1 A abc
2 B C def
3 B D ghi
Now Field 1 is present in the first file. So I need not match with the second file. For Field 2 and 3 are present in the second file, so I need to match file1 to file2 based on a key field. SO I was thinking of making this selection criteria dynamic by putting it into a file or an internal table? Is this possible?
Thanks! |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
Hello,
You wil get more useful replies if you take a bit more time and more completely describe what you are trying to do.
Show representative sample data from each input file and the output(s) you want when your process is run.
The rules you've posted may be all that is needed depending on the clarity of the inputs and output(s). |
|
Back to top |
|
|
dbzTHEdinosauer
Global Moderator
Joined: 20 Oct 2006 Posts: 6966 Location: porcelain throne
|
|
|
|
use bbcode, specifically code tags - they will preserve the horizontal spacing.
and this is a pile of dog-poop!
Quote: |
Priority Field1 Field 2 Field3 Field4
1 A abc
2 B C def
3 B D ghi |
How do you expect us to interpret that?
and you show a Field4 in your matrix, yet you mention nothing in your explanation. |
|
Back to top |
|
|
shilpa.khaire
New User
Joined: 21 Jul 2006 Posts: 39 Location: US
|
|
|
|
Code: |
Priority Field1 Field 2 Field3 Field4
1 A abc
2 B C def
3 B D ghi |
Now the first input file has Field 1 and the second input file has Field 2 and 3. And I expect to populate one field in the output file with Field 4.
E.g. 1 - If first file has Field 1 = A, then I need to populate one filed in the output as 'abc'.
E.g. 2. - If the first file does not have Field1 = A then I have to match file 1 and file 2 based ona key field and then if a match is found I have to look for Fields 2 and 3 in File 2. If Fields 2 and 3 in File2 are 'B' and 'C' respectively then I need to populate one filed in the output as 'def' .And so on. So I wanted to have this above decision table in a parm or a file and then lookup this decision table and populate the field in the output file with abd/def/ghi. Is this possible? What could be the differnt options instead of hardcoding as If-ELSE in the program?
Thanks!
|
|
Back to top |
|
|
Robert Sample
Global Moderator
Joined: 06 Jun 2008 Posts: 8696 Location: Dubuque, Iowa, USA
|
|
|
|
Considering how specific your example is, why would you NOT want to hard-code the IF statements? Do you really expect to have this set of conditions show up again sometime in the future?
If the files are indexed and keyed, you could do key look ups to do the matches; otherwise, the logic could get quite complex. You could code this up in a decision table, but the additional coding and complexity probably would negate any perceived benefit of using a decision table.
For example, what if the first file has Field1 = 'B' and file 1 and file 2 do not have a key match? Nothing you've posted yet indicates what is to be done in this case. So it does not appear at this point that you even have a decision table -- just part of one.
Furthermore, matching implies the files are sorted in the same sequence -- unless you want to do an unsorted match, which can drive I/O counts (and run times) extremely high with relatively small files. |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
Hello,
If you were to post something more "real" than alphabet soup, someone has probably already implemented what you are looking for.
If specifics are used to work thru a (this) topic, it might be made generic later.
An un-sorted file "match" should be limited to all files having no more than 10 records. . . It is possibly the poorest choice that can be made for combining data. |
|
Back to top |
|
|
|