CDS Annotations

CDS: Semantic Annotations – Currency Unit and Measure Unit

Annotations enrich the CDS views but can be confusing as well. These series of blogs have my simplified explanation.

There are a lot of Semantic Annotations and proper use of Semantic Annotations can improve UI tremendously. They are also easy to use and understand. For example, if we need to show the “Amount” of any item or “Quantity” of any material – we can use the following Semantics to show the unit right beside the numeric value without using any separate column.

For Amount: We need to specify first which column has the currency code and then we need to specify which currency code to used for any particular amount. Example – PriceUnit is the currency code and Price has the amount. Now in Fiori App, the currency code will come beside the Price automatically.


 @Semantics.amount.currencyCode: 'PriceUnit'
    Price,
 @Semantics.currencyCode: true  
    PriceUnit,

Similarly for Quantity:


 @Semantics.unitOfMeasure: true
    Uom,
 @Semantics.quantity.unitOfMeasure: 'Uom'
    Quantity,

Please note, same unit can be used for multiple columns. Also one column can have more than one annotations.

Was this post helpful. Please let us know in the comment section. Please also let us know which annotations you want to understand better.

Leave a Reply

Your email address will not be published. Required fields are marked *

error

Enjoy this blog? Please spread the word :)

Follow by Email
Twitter
LinkedIn
LinkedIn
Share