Skip to Content
Technical Articles
Author's profile photo Asim Chandra

Amount field decimal places display issue in Fiori Elements list report

Background:

SAP generally stores all the amount values with two decimal places in tables like VBRP, VBAP and so on. This is because most of the currencies have 2 decimal places by default. But there are a lot of currencies that have decimal places no equal to two. Mostly for large currency markets, the default number of decimal places for the currency is not 2.

For example, for VND (Vietnamese Dong), the default number of decimal places is 0 and this is stored in the table TCURX.

For example, a billing invoice (with currency VND) has net value with 0 decimal places, but it is stored with 2 decimal places in SAP Table VBRP because SAP shifts the decimal place in tables so as to not change the data type of the amount and maintain a standard throughout SAP.

This invoice has no decimal places for VND but below shows how it is stored in SAP table.

Moreover, when we display this amount in a Fiori elements list report through a CDS view or normally it displays with 3 decimal places by default.

 

Issue: Display the amount according to the correct decimal places as maintained in TCURX table in the list report 

 

Solution:

  1. Create an extra entity in your OData service (CDS data source). The data source exposed should be I_CURRENCY, an SAP standard CDS View.

          This CDS view has the number of decimal places for currencies maintained in TCURX table.

       

  1. Add the same CDS view I_Currency in your main data source CDS view as an association.
  2. Add a foreign key annotation for the above association to the currency field in the main CDS View.
  3. Do not forget the add the annotation  @Semantics.amount.currencyCode: ‘waerk’ to your amount field.

 

  1. Last step would be to add the below annotation to your annotation file in your Business Application Studio List report project.
<Annotation Term=”com.sap.vocabularies.CodeList.v1.CurrencyCodes”>
                    <Record>
                        <PropertyValue Property=”Url” String=”./$metadata”/>
                        <PropertyValue Property=”CollectionPath” String=”I_CurrencyType”/>
                    </Record>
                </Annotation>
                <Annotations Target=”ZOTD_VIETNAM_CUSTOMS_REP_SRV.I_CurrencyType/Currency”>
                <Annotation Term=”Common.UnitSpecificScale” Path=”Decimals”/>
                <Annotation Term=”Common.Text” Path=”Currency_Text”/>
            </Annotations>

The list report will now show the appropriate number of decimal places in the Amount field along with the Currency.

For example, it shows 0 decimal places for VND now.

Assigned Tags

      8 Comments
      You must be Logged on to comment or reply to a post.
      Author's profile photo Jun Wu
      Jun Wu

      I don't remember you have to do that much extra work.

      as long as the currency annotation is there, sap is handling all for you.

      Author's profile photo Asim Chandra
      Asim Chandra
      Blog Post Author

      Hi Jun Wu,

      As far as Fiori Elements report is concerned, just the currency annotation does not take care of the decimal places for different currencies. The default number of decimal places is 2, which is ok for a lot of currencies but not for the currency which have different number of decimals maintained in TCURX table.

       

      Do let me know if you have been able to achieve the same end result without using an extra TUCRX entity in your service, as mentioned in my blog.

      Thanks

      Author's profile photo Jun Wu
      Jun Wu

      normally that entry is in the table.

      Author's profile photo Asim Chandra
      Asim Chandra
      Blog Post Author

      The entry for number of decimal places?

      Author's profile photo Jun Wu
      Jun Wu

      yes

      Author's profile photo Asim Chandra
      Asim Chandra
      Blog Post Author

      I do not think it is available in those data tables. It is a customising data entry maintained for particular currencies like JPY or VND etc ( for instance large currency markets) . May be you try it once and check.

      Author's profile photo Jun Wu
      Jun Wu

      you didn't get my point.

      it is not likely that until you develop a fiori screen you realize you need that entry. I believe other business require that entry way before your fiori use case. that's why I say normally the entry is already there.

      Author's profile photo Asim Chandra
      Asim Chandra
      Blog Post Author
      • Ok got your point, yes we realised it later, as we were dealing with Vietnamese Dong in particular and it has no decimals in display. So this was done to achieve that  but in the end it works perfectly for all currencies using this. May be the ones you used had that entity from the beginning due to particular business case.