Skip to Content
0

Currency reference in ABAP CDS

Mar 02, 2017 at 03:04 AM

1.1k

avatar image

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

10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

1 Answer

Horst Keller
Mar 02, 2017 at 07:58 AM
0

You use the @Semantics.currencyCode annotation for that.

Show 3 Share
10 |10000 characters needed characters left characters exceeded

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

0
Anand Krishnamurthi

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,

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,

Kabir

0

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