cancel
Showing results for 
Search instead for 
Did you mean: 

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

nimiprave
Advisor
Advisor
0 Kudos

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}"/>

Accepted Solutions (0)

Answers (1)

Answers (1)

former_member228602
Contributor
0 Kudos

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

junwu
Active Contributor
0 Kudos

I don't think it will help any.

former_member228602
Contributor
0 Kudos

Hello,

Do you find any specific reason why it wont work. I found it working Sample Code . Basically there are many ways to override the locale . I checked the internal formatting functions in SAPUI5 and prepared the above code snippet.

Thanks and Regards,

Veera

junwu
Active Contributor
0 Kudos

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.

0 Kudos

Thanks for the reply.

What "parts : []" is doing?

If I put only 1 value or same property like actual amount ( see image below ), my value (price) is not formatted as currency.

Can anyone explain or send documentation URL where path : [] is explained?