cancel
Showing results for 
Search instead for 
Did you mean: 

XI mapping: rounding failure during "abs" function

Former Member
0 Kudos

Hello XIGurus,

I've met following problem I'd like to discuss with you.

I have simple XI mapping, where source is XI message (from BPM) and destination is IDOC "SALESORDER_CREATEFROMDAT2". The XI message contains only "string type" fields (!).

Now the point is, that XML field "Qty" contains number, which has 3 decimal places and could be negative (e.g. -14598.235). Since destination system (SAP R/3) needs the possitive values only, there is the "ABS" function in the XI message mapping, understand between the box "QTY" and box "REQ_QTY" there is in/out arithmetic box "abs" ;).

So far all should work fine, the test is OK, everything else seems fine. The troubles come, when there is a message load on XI. In this case it sometimes happened that the result value is correctly positive, but the decimal places are rounded wrongly or even the places are cut off. The example for all - two parts of XMLs from XI monitoring (one node in monitoring): the first before mapping, the second the result IDOC:

(before mapping)

- <ITEMS>

- <ITEM>

<DATE>20060408</DATE>

<LOCPROFROLE>A11</LOCPROFROLE>

<QTY><b>119995.825</b></QTY>

<UNIT>MWH</UNIT>

</ITEM>

- <ITEM>

<DATE>20060409</DATE>

<LOCPROFROLE>A11</LOCPROFROLE>

<QTY><b>116719.337</b></QTY>

<UNIT>MWH</UNIT>

</ITEM>

- <ITEM>

<DATE>20060410</DATE>

<LOCPROFROLE>A11</LOCPROFROLE>

<QTY><b>131552.004</b></QTY>

<UNIT>MWH</UNIT>

</ITEM>

</ITEMS>

(after mapping)

- <E1BPSCHDL SEGMENT="">

<REQ_DATE>20060408</REQ_DATE>

<REQ_QTY><b>119995.83</b></REQ_QTY>

</E1BPSCHDL>

- <E1BPSCHDL SEGMENT="">

<REQ_DATE>20060409</REQ_DATE>

<REQ_QTY><b>116719.336</b></REQ_QTY>

</E1BPSCHDL>

- <E1BPSCHDL SEGMENT="">

<REQ_DATE>20060410</REQ_DATE>

<REQ_QTY><b>131552</b></REQ_QTY>

</E1BPSCHDL>

Remeber - I use the "ABS" function only, there is nothing about rounding in the mapping.

So what would you say. Could be the problem, that source value is in XI field which is type of string ??? I don't have any other idea. It seems to me like a bug anyway. I'll try to write my JAVA function in the message mapping.

Thx for your comments.

Regards

Tomas

Accepted Solutions (0)

Answers (1)

Answers (1)

Former Member
0 Kudos

Hi Tomas,

Please can you have a look at this

Regards

Vijaya

Former Member
0 Kudos

Thank you for the link .. 'haven't found it via SDN search engine.

Tomas

stefan_grube
Active Contributor
0 Kudos

Check out this blog as well:

/people/thorsten.nordholmsbirk/blog/2006/04/03/never-ever-use-xis-built-in-arithmetic-functions

Regards

Stefan

Former Member
0 Kudos

Also a good one ... thx.

Tom

Former Member
0 Kudos

Hello,

just only to close this thread properly, I created User-defined function according the weblog mentioned above. The code is like this:

BigDecimal bigA = new BigDecimal(a);
BigDecimal result  = bigA.abs();
return result.toString();

Note that java.math.BigDecimal has to be imported.

Regards

Tom