on 2013 Oct 18 9:55 AM
Hi!
I have the following Problem and would like to know if there is an elegant solution to it!
I want to map the Output of a function block to an XML structure. So there is nothing so Special about it
The Problem is the following:
In the source structure there are 2 tables:
Table1:
Field 1, Field 2
xyz 001
abc 002
Table2:
Field 1, Field 2, Field 3
mno abc 001
abc xyz 001
xyz ako 002
A part of the target structure of the XML Looks like this:
<Tag1>
<Subtag 1>001</Subtag1>
--> Here All entries from Table 2 whose Field 3 corresponds to Field 2 of Table 1 should be placed!!
<Tag2>
<Subtag2>mno</Subtag2>
<Subtag3>abc</Subtag3>
</Tag2>
<Tag2>
<Subtag2>abc</Subtag2>
<Subtag3>xyz</Subtag3>
</Tag2>
<Subtag 1>002</Subtag1>
<Tag2>
<Subtag2>xyz</Subtag2>
<Subtag3>ako</Subtag3>
</Tag2>
</Tag1>
Is there a solution to this by a graphical mapping?
BR, EF
Request clarification before answering.
Hello Elmar,
This needs a UDF since Order_Suggestion contains two entries while Order_Suggestion_Option_Contains three entries in your example. You may use this mapping:
For Order_Suggestion:
For Suggested_Line/X_Feature_ID/Option/Sequential_No/
Now, for the Order_Suggestion_Option: There are two ways to map this
a. Use SplitByValue:ValueChanged
Cons of this is that you are not checking the input from Order_Suggestion-item-Suggested_Line
b. Via UDF
Cons, needs a user-defined function to work. UDF type is Context Type:
Arguments: inp1 type String[]
inp2 type String[]
for(int a=0;a<inp1.length;a++){
int c=0;
for(int b=0;b<inp2.length;b++){
if(inp1[a].equals(inp2[c])){
if(c+1<inp2.length){
if(inp1[a].equals(inp2[c+1])){
result.addValue(inp2[c]);
}
else if(!inp1[a].equals(inp2[c+1])){
result.addValue(inp2[c]);
result.addContextChange();
}
}
else{
result.addValue(inp2[c]);
}
}
c++;
}
}
Please forgive the unoptimized code.
Hope this helps
Mark
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello! I also tried Amit's solution, as you can see here ... but i still only get 1 entry for 100 and 200. What happens to the other entries? There should be 2 for 100 and 2 for 200 ...
Result: The order_suggestion_options for 1-2 and 2-2 are missing ... it seems that the logic only processes the first element for 100 and 200 and then quits ;(
Hi Amit!
I tried to Change the context of alle source fields, but i have three possibilites ... Standard was "item". I changed all source fields (Suggested_line, x_Feature_id, Option and sequence_no) to ORDER_SUGGESTION_OPTION. With NO success Then i tried the root node "Z_EXP_....", also with no success. Is there still something that i am doing wrong?
| User | Count |
|---|---|
| 15 | |
| 9 | |
| 6 | |
| 5 | |
| 4 | |
| 4 | |
| 3 | |
| 2 | |
| 2 | |
| 2 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.