Annotations
Semantic Annotations
Field Labels
Change label of a field
@EndUserText.label: 'Custom label'@EndUserText.quickInfo: 'Quick Info'
For ABAP datatypes, CDS select a longest text whose length is maximum 20 characters.
Units
@Semantics.unitOfMeasure: trueOrderQuantityUnit,@Semantics.quantity.unitOfMeasure: 'OrderQuantityUnit'OrderQuantity,@Semantics.amount.currencyCode: 'TransactionCurrency'NetAmount,@Semantics.currencyCode: trueTransactionCurrency,
Default Aggregation
@DefaultAggregation: #SUMOrderQuantity,@DefaultAggregation: #SUMNetAmount,@DefaultAggregation: #NONENetPriceAmount,
Text Field
@Semantics.languagekey spras as Language,@Semantics.text: truecast(landx50 as fis_landx50 preserving type ) as CountryName,
Foreign Keys
define view I_ProfitCenter as select distinct from cepcassociation[0..1] to I_Country as _Countryon $projection.Country = _Country.Countryassociation[0..1] to I_Region as _Regionon $projection.Country = _Region.Country and$projection.Region = _Region.Region{...@ObjectModel.foreignKey.association: '_Country'land1 as Country,@ObjectModel.foreignKey.association: '_Region'regio as Region,...}
Mark representative keys in target views:
@ObjectModel.representativeKey: 'Region'define view I_Region as select from t005sassociation [1..1] to I_Country as _Countryon $projection.Country = _Country.Country{@ObjectModel.foreignKey.association: '_Country' key t005s.land1 as Country,key t005s.bland as Region,...}
Foreign Text Keys
Mark text tables with @ObjectModel.dataCategory: #TEXT
define view I_Country as select from t005association [0..*] to I_CountryText as _Texton $projection.Country = _Text.Country{@ObjectModel.text.association: '_Text'key cast(land1 as land1_gp preserving type ) as Country,...}@ObjectModel.dataCategory: #TEXT@ObjectModel.representativeKey: 'Country'define view I_CountryText as select from t005t{key land1 as Country,@Semantics.language: truekey spras as Language,@Semantics.text: truecast(landx50 as fis_landx50 preserving type ) as CountryName,}
Composition Relations
Mark with @ObjectModel.association.type
alternative values: #TO_COMPOSITION_PARENT, #TO_COMPOSITION_CHILD, #TO_COMPOSITION_ROOT
define view I_SalesOrderItem ...association [1..1] to I_SalesOrder as _SalesOrderon $projection.SalesOrder = _SalesOrder.SalesOrderassociation [0..*] to I_SalesOrderScheduleLine as _ScheduleLineon $projection.SalesOrder = _ScheduleLine.SalesOrderand $projection.SalesOrderItem = _ScheduleLine.SalesOrderItem{...@ObjectModel.association.type: [#TO_COMPOSITION_PARENT, #TO_COMPOSITION_ROOT]_SalesOrder,@ObjectModel.association.type: [#TO_COMPOSITION_CHILD]_ScheduleLine,...}