cancel
Showing results for 
Search instead for 
Did you mean: 

Problem with Message-Mapping: Loop over Elements possible?

Former Member
0 Kudos

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

View Entire Topic
Former Member
0 Kudos

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

Former Member
0 Kudos

Hi,

In above UDF

change the

nsum = nsum + valueOf(sum(i));

to

nsum = nsum + Double.parseDouble.sum(i);

Regards

Chilla

Former Member
0 Kudos

Hey guys

Thanks for your help ... it could solve the problem

Best regards

Christopher