Show TOC

Interaction with Other AnnotationsLocate this document in the navigation structure

Get information about how to provide interaction between annotations.

In addition to UI annotation, you can use model-specific annotations that affect the desired client behavior. You can implement, for example, unit-currency-mappings, ID-text-mappings, or properties for field control that are represented by model-specific annotations. These model-specific annotations can be evaluated by the client and no additional UI annotations are required.

Figure 1: Example of interaction between CDS annotations
Example In the following example, the field CurrencyCode is marked with a @Semantics.currencyCode and is referenced by field GrossAmount. This means that the field GrossAmount is always displayed with the corresponding currency. The field CurrencyCode does not need to be exposed explicitly.

Futhermore the field GrossAmount is marked as being mandatory. This means that the field is treated accordingly by the client: The field is marked with an asterisk, and if users do not fill in a value for this property, an error is raised. The administrative fields such as CreatedAt and CreatedBy, are set in a back-end validation and must not be changed by the client. For this reason, these fields are marked as being read-only.

Sample Code
define view ZExample_SalesOrder as select from sepm_cds_sales_order as so  
  @UI.identification: [ { position: 10 } ]
  key so.sales_order_id as SalesOrder,

  @Semantics.currencyCode: true
  so.currency_code as CurrencyCode, 
  @Semantics.amount.currencyCode: 'CurrencyCode'
  @ObjectModel.mandatory: true
  @UI.identification: [ { position: '20' } ]
  so.gross_amount as GrossAmount, 


  @ObjectModel.readOnly: true
  @UI.identification: [ { position: '110' } ]
  so.created_at as CreatedAt,
  @ObjectModel.readOnly: true
  @UI.identification: [ { position: '120' } ]
  so.created_by as CreatedBy,
  @ObjectModel.readOnly: true
  @UI.identification: [ { position: '130' } ]
  so.changed_at as ChangedAt,
  @ObjectModel.readOnly: true
  @UI.identification: [ { position: '140' } ]
  so.changed_by as ChangedBy,