Amount field decimal places display issue in Fiori Elements list report
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
- 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.
- Add the same CDS view I_Currency in your main data source CDS view as an association.
- Add a foreign key annotation for the above association to the currency field in the main CDS View.
- Do not forget the add the annotation @Semantics.amount.currencyCode: ‘waerk’ to your amount field.
- Last step would be to add the below annotation to your annotation file in your Business Application Studio List report project.
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.