Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

Currency reference in ABAP CDS

former_member192842
Participant

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

4 REPLIES 4

horst_keller
Product and Topic Expert
Product and Topic Expert

You use the @Semantics.currencyCode annotation for that.

0 Kudos

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

horst_keller
Product and Topic Expert
Product and Topic Expert
0 Kudos

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.

0 Kudos

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