cancel
Showing results for 
Search instead for 
Did you mean: 

Summation of Tax amount field in message mapping

Former Member
0 Kudos


Hi All,

Requirement is PI has to sum up the amount value in message mapping

E1EDP01 ->E1EDP04 ->MWSKZ-SD--> MWSBT(amount value).

E1EDP04 SD occurs 5 times in one line item and during summation 3rd one in sequence should be ignored and rest all 4 should be summed up.

Invoice Idoc may have multiple line items.Please let me know how to achieve this in java code.

Regards,

Karthiga

Accepted Solutions (0)

Answers (2)

Answers (2)

juan_vasquez2
Active Participant
0 Kudos

Try function sum

you need to change context of source element, to an up level

if you don't change context, then only get first value, like you say

former_member184720
Active Contributor
0 Kudos

If you are sure that it always occurs 5 times and you always have to ignore the third occurrence.

Try below graphical mapping

Your input should be at lineitem level (instead of using remove context, right click and choose the context)

if you expect some without any sd, then you might want to try this

Message was edited by: Hareesh Gampa

Former Member
0 Kudos


Hi Hareesh,

I guess this sum function loses the decimal values and thats why I have chosen java udf.

double taxvalue = 0;

NumberFormat formatter = new DecimalFormat("#0.00");
for(int i=0;i<tax.length;i++)
{

if (tax[i].equals(ResultList.CC))
{
result.addValue(formatter.format(sum));
sum=0;
taxvalue=0;

}
else
{
if( (! (tax[i].equals("") ) ) && (tax[i]!=null))
{
taxvalue=Double.valueOf(tax[i]).doubleValue();

sum=sum+taxvalue;

}
}

}
result.addValue(formatter.format(sum));

But not sure how to skip the third value from each context.

Regards,

Karthiga

former_member184720
Active Contributor
0 Kudos

>>> But not sure how to skip the third value from each context.

Do you always receive the 5 values from source? if so you can simply access the third value like this


- tax[2] in your UDF.

I just realized copy value doesn't work for you as you may have multiple items.

Try below if you need decimals.

RaghuVamseedhar
Active Contributor
0 Kudos

Karthiga,

'sum' does not ignore decimal numbers. You can also try below UDF (Context change input field by right clicking on it. Add 'FormatNum' if needed).