2017 Mar 02 3:04 AM
Hi Experts,
There is an existing table in ABAP DDIC . The table has a amount field for which the reference table is a structure and the field is from that structure.
Currently i'm creating a CDS view which this custom table and I need the amount field. In this case how can i give the currency key reference using semantics in the ABAP CDS.
Because the table doesnt have currency key field and reference table and refernce currency key field is from structure in ABAP DDIC.
Please advice
Regards Anand
2017 Mar 02 7:58 AM
2017 Mar 03 3:48 AM
Hi,
Thanks!!
Yes @semantics.currencyCode can be used for reference.
But my question is what if the table doesn't have currency key field. When I checked the table in SE11 the amount say in Table A was referred to a currency key field which is a field in a structure.
In such as case, how do I cater the same in ABAP CDS.
In another case the amount in Table A was referred to an currency key field in another table B, In such a case should I be writing a Join or association with Table A and table B for the currency reference
Regards Anand
2017 Mar 03 7:40 AM
In all examples, I'm aware of, the value specified after @Semantics.amount.currencyCode is an element of the same view. I'd say you have to add a currency code element to your view and annotate it with @Semantics.currencyCode.
2018 Mar 21 10:26 PM
I was searching SCN for the same issue and this is how I have managed to handle a table which doesn't have a currency field.
We created a default currency column in the view as follows:
@Semantics.currencyCode
cast ('USD' as abap.cuky) as CurrencyCode,
@Semantics.amount.currencyCode: 'CurrencyCode'
zsflight.price as price,
<br>
This will work if your organization is using single currency, the ideal fix would be to add currency code field to your Z table.
Thanks,
Sai