2024 Oct 02 7:05 AM
Facing issue with currency conversion.
in JPY , decimal should be before 2 digits only to be correct as the value saved in table has 2 decimal places, but it isn't showing correctly in Fiori app.
I've following annotations in my cds view.
// @Semantics.currencyCode: true
@ObjectModel.foreignKey.association: '_currency'
waers as Waers,I guess, the annotation @Semantics.currencyCode: true is the culprit, as it isn't usable anymore. what is the way around?
Any help is appreciated.
Thanks.
2024 Oct 02 8:00 AM
Hi @dukejib5 Hmmm... I don't think you have understood SAP currency conversion.
JPY does not have 2 digits following the decimal place. You are correct that it is being stored with 2 decimal places - as is standard - and the displayed correctly in the localized format - i.e. WITHOUT the decimal places. As you have you shown in your screenshots. This is CORRECT as per SAP currency conversion.
SAP currency conversion maps formats that are NOT the standard 2 digits to the appropriate localization format. That is the difference between how the data is stored and how it is interpreted. This affects a small but significant number of currencies including JPY, KRW, VND etc.
This blog might be helpful for you
Currency Decimal issue - JPY, KRW, VND | Localization | Rollout - Japan, Korea, Vietnam
2024 Oct 02 9:28 AM
Thanks for the reply. I want to show the correct value , for $ Fiori shows 5 digits after decimal. I want to show correct value with only 2 digits after decimal.
2024 Oct 02 10:35 AM - edited 2024 Oct 02 10:38 AM
Have you created a custom currency code type definition in table TCURC ? E.g. using the configuration menu in transaction SPRO.
Manipulating decimal places on the front-end only in this way is very risky. When you change the decimal places you change the meaning of the value. That affects everywhere that value is used, e.g. when converting from local to foreign currency.
Retail customers often use 4 decimal place currencies like this - and for that you need a custom currency code type definition. Then all the currency conversions will work reliably system wide.
From what I understand of your approach this is really ABAP fundamentals and actually nothing to do with SAP Fiori - SAP Fiori is applying the conversion correctly (its actually just reflecting what the ABAP currency conversion is automatically doing via the CDS View) . You might want to ask your question using the ABAP tag.
2024 Oct 02 11:24 AM - edited 2024 Oct 02 11:30 AM
I think I am unable to clearly state my requirement. For JPY, I want to show correct value, using annotations. How to do it? guess i'm using wrong annotation.
Value Stored JPY : 15494732.37
Value Shown : 1549473.237
Value should be shown : 1549473237 ( if without decimal val currency).
Yes TCURC/TCURX has custom values for custom currencies.
And again, thanks for your reply and link to blog 🙂
2024 Oct 02 12:04 PM
Ok so I see your issue now. Thank you for the clarification!
Recommend you first double-check your custom currency code is working correctly by running report RCURTEST in GUI to check. See SAP Note 2561100 - Currency Conversion in CDS Queries - Could not determine valid conversion rate for value(s) ...
Assuming this is ok... then as explained in the ABAP CDS keyword documentation for amounts https://help.sap.com/doc/abapdocu_758_index_htm/7.58/en-US/index.htm?file=abencds_amount_field.htm yes you do need to apply the mandatory annotation @Semantics.amount.currencyCode : true to the currency code field
I'm not sure why you think it's unusable though? It's just commented out... You should un-comment the line and reactivate the CDS View.
That should solve it. Remember you can have multiple annotations before a field.