on 04-23-2007 2:57 PM
Hi all,
I want do create a Message-Mapping for an IDoc-to-File Scenario. In the Source Structure there are some Elements which can appear more than once (1..unbounded). I need a mechanism which loops over these elements and search for specified values. From the Element which contains an element with this specified value the mapping should write a value in the target structure.
Here a simple example (source structure) for better understanding:
<root>
<invoice>
<number> 10 </number>
<sum> 200.00 </sum>
</invoice>
<invoice>
<number> 20 </number>
<sum> 150.00 </sum>
</invoice>
<invoice>
<number> 30 </number>
<sum> 120.00 </sum>
</invoice>
</root>
Now the duty of the Mapping should be to search in the elements <invoice> for the number 30. And then the sum of the invoice with the number 30 should be written in a field of the target structure.
I tried it out with a constant togehter with an equalsS-function and an ifWithoutElse-function, but it is working only then, if the invoice with the number 30 has the first position in the root context.
Can anybody help me? Thanks
With kind regards
Christopher
Hi,
Write a UDF to sum the required values and map to target node.
See while writing the UDF select the type as queue.
number -- removecontext-UDF targetnode
sum----removecontext--/
number abd sum or the two inputs
in UDF
int nsum = 0;
for(int i;i < number.length;i++){
if number(i).equals("30") then
nsum = nsum + valueOf(sum(i));
}
result.addValue(nsum); // convert the nsum into string
Regsrds
Chilla
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
hi Christopher,
i think u hv to use UDF.
Try this :
number->Remove Context>UDF-->outputField
sum----->Remove Context>UDF
UDF :
double cnt = 0;
for(int i = 0 ; i<a.length ; i++)
{
if(a<b>[</b>i<b>]</b>.equals("30") )
{
cnt = cnt + Double.parseDouble(b<b>[</b>i<b>]</b>) ;
}
}
result.addValue(""+cnt);
Thanks,
Maheshwari.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Christopher,
This is possible without UDF.
First use IF-Without else to filter your source structure for number 30. And then you can play with the entire structure with keeping proper context in mind.
Regards,
Shri
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
thanks for your quick response,
I tried it with ifWithoutElse. I tried it in the following way:
I compare the number with the String "30" (Text-function "equalsS"). Then I do a ifWithoutElse-function with the input of the "equalsS-Output" and the sum. Then i write the result in the target-field.
What is wrong?
Thank you
User | Count |
---|---|
90 | |
10 | |
10 | |
10 | |
7 | |
7 | |
6 | |
5 | |
4 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.