|
Rank: Newbie
Joined: 11/8/2018 Posts: 7
|
Hi!
I'm creating an EDIFACT to flat file mapping and have encountered a problem I'm not really sure how to solve.
I would like to do a conditional mapping of address information from a "NAD"- segment. If "NAD" with qualifier "UC" exist, use address information from that, if not, use information from "NAD" with qualifier "CN" instead.
I have tried to use filters, if-else, and various boolean checks but it seems that all I have managed to create so far is a mess of arrows and boxes.
I've looked for examples that covers this but haven't been able to find any.
Thanks!
/Alex
|
|
Rank: Newbie
Joined: 11/8/2018 Posts: 7
|
NAD+UC comes after NAD+CN in the file if that simplifies things.
I have managed to create a solution that seems to work when debugging it but it doesn't when executing it. Information from NAD+CN is written to target elements and when NAD+UC is encountered it tries to overwrite the already stored information taken from NAD+CN. However, in the result, the information from NAD+CN is still used.
|
|
Rank: Newbie
Joined: 10/28/2002 Posts: 1,283 Location: AT
|
You will probably have to use two variables to hold the results of the different filters and then map the result of the variables to the output. If that doesn't help then attach your mapping and your input edi file
|
|
Rank: Newbie
Joined: 11/8/2018 Posts: 7
|
island wrote:You will probably have to use two variables to hold the results of the different filters and then map the result of the variables to the output. If that doesn't help then attach your mapping and your input edi file
Ok, so I have now tried to filter and map the source NADs to two similar complex variable blocks (holding all the address information). After the two variable blocks I will do an "empty"- check for the complex variable for NAD+UC and chain that with an if-else- block to decide if to use NAD+UC or NAD+CN variable. For some reason I get no result at all.
First thing; I'm not really sure how to filter the source. Can I filter the NAD- segments or do I have to filter each individual field in them? I tried to read up on "compute-when" but I'm still not sure if I should connect it to something and if so, to what?
Thanks!
|
|
Rank: Newbie
Joined: 11/8/2018 Posts: 7
|
Ok, so I managed to get the desired results. This is how i did it:
- Created two equals functions checking the qualifier for the NADs. One for NAD+CN and one for NAD+UC. - Then created two filters and connected the NAD- segment as node inputs. - Connected the output of the two equal functions as bool input to the two filters. - Created two complex variables. I mapped the filter outputs to "compute-when" for the two complex variables. - Connected all address details from the NAD fields to both complex variables inputs. - At the outside of the complex variable I created an "exists" functions checking the first element in the complex variables for NAD+UC. - Created one if-else statement for each field in the complex variables. - Connected the result from the exist function to each boolean input of every if-then- statement. - Connected each value from NAD+CN complex variable to the value-false input on each if-else- statement - Connected each value from NAD+UC complex variable to the value-true input on each if-else- statement - Connected result on each if-else statement to the corresponding target field in the flat text output structure.
Utterly complex and hard to follow for solving such an easy task. I'm not at all sure I did it in the smoothest and most efficient way? The mapping still feels like a mess but maybe that is how it usually turns up using the tool?
Thanks for your input!
/A
|
|
guest |