Skip to Content
avatar image
Former Member

How is currency formatted in the sap.m.ObjectNumber API

We use the sap.m.ObjectNumber to display the number formatted based on the currency key as shown below. I have issues with formatting of the USD vs EUR. The decimal and thousand separator shows the same as shown below. For EUR, I except ',' as decimal seperator and '.' as thousand separator. For USD, I except the opposite. My understanding is that it is formatted based on the regional settings of your computer. However, when I tried to change it , it does not reflect in the UI. Anybody ,please explain how is this thing working.

<ObjectNumber class="sapUiSmallMarginBottom" binding="{/ProductCollection/0}"
number="{ parts:[{path:'Price'},{path:'CurrencyCode'}], type: 'sap.ui.model.type.Currency', formatOptions: {showMeasure: false} }"
unit="{CurrencyCode}" numberUnit="{CurrencyCode}"/>
currency.png (10.1 kB)
Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

1 Answer

  • Jan 27, 2017 at 07:41 PM

    Hello Nirmal,

    There are mutiple ways to handle this . One of the ways is

    <ObjectNumber binding="{/}" number="{ parts:[{path:'Price'},{path:'CurrencyCode'}], type: 'sap.ui.model.type.Currency', formatOptions: {showMeasure: false,decimalSeparator : ',', groupingSeparator : '.'} }" unit="{CurrencyCode}" numberUnit="{CurrencyCode}" />

    There are other ways as mentioned here

    https://help.sap.com/saphelp_uiaddon10/helpdata/en/91/f2f2866f4d1014b6dd926db0e91070/content.htm

    Thanks and Regards,

    Veera

    Add comment
    10|10000 characters needed characters exceeded

    • Jun Wu Veeraraghavan Narasimhan

      your code works, but you are doing hardcoding and won't satisfy his expectation.

      he expects "," as decimal point for EURO and "." for USD. he wants this to happen automatically.