Technology Blogs by Members
Explore a vibrant mix of technical expertise, industry insights, and tech buzz in member blogs covering SAP products, technology, and events. Get in the mix!
cancel
Showing results for 
Search instead for 
Did you mean: 
asimchandra
Explorer
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.
8 Comments
Labels in this area