ABAP Keyword Documentation → ABAP − Reference → ABAP RESTful Programming Model → Behavior Definitions → ABAP BDL - Example
Root entities example
Other versions:
7.31 | 7.40 | 7.54
Example
The CDS view /DMO/I_Travel represents the root node of the business object. The root node Travel is used to manage general flight booking data such as the trip ID, agency ID, customer number, start and end dates of a trip, booking fee, total price, currency, trip description, trip status, and date of last change.
The travel data is saved in the database table /DMO/TRAVEL.
@AbapCatalog.compiler.compareFilter: true
@AccessControl.authorizationCheck: #NOT_REQUIRED
@AbapCatalog.preserveKey: true
@EndUserText.label: 'Travel'
@Search.searchable: true
@ObjectModel.semanticKey: ['TravelID']
@ObjectModel.representativeKey: 'TravelID'
define root view /DMO/I_Travel
as select from /dmo/travel as Travel
composition [0..*] of /DMO/I_Booking as _Booking
association [1..1] to /DMO/I_Agency as _Agency on
$projection.AgencyID = _Agency.AgencyID
association [1..1] to /DMO/I_Customer as _Customer on
$projection.CustomerID = _Customer.CustomerID
association [0..*] to I_CurrencyText as _CurrencyText on
$projection.Currency_Code = _CurrencyText.Currency
association [0..*] to /DMO/I_Status_Text as _StatusText on
$projection.Status = _StatusText.Status
{
@Search.defaultSearchElement: true
@ObjectModel.readOnly: true
key Travel.travel_id as Travel_ID,
@Search.defaultSearchElement: true
@ObjectModel.text.association: '_Agency'
@Consumption.valueHelpDefinition: [{
entity: {name: '/DMO/I_Agency', element: 'Agency_ID' }}]
Travel.agency_id as Agency_ID,
@Search.defaultSearchElement: true
@Consumption.valueHelpDefinition: [{
entity: {name: '/DMO/I_Customer', element: 'CustomerID' }}]
@ObjectModel.text.association: '_Customer'
Travel.customer_id as Customer_ID,
Travel.begin_date as Begin_Date,
Travel.end_date as End_Date,
@Semantics.currencyCode: true
@ObjectModel.text.association: '_CurrencyText'
@Consumption.valueHelpDefinition: [{
entity: {name: 'I_CurrencyText', element: 'Currency' }}]
Travel.currency_code as Currency_Code,
@Semantics.amount.currencyCode: 'Currency_Code'
Travel.booking_fee as Booking_Fee,
@Semantics.amount.currencyCode: 'Currency_Code'
@ObjectModel.readOnly: true
Travel.total_price as Total_Price,
@Search.defaultSearchElement: true
@Search.fuzzinessThreshold: 0.86
Travel.description as Description,
@Consumption.valueHelpDefinition: [{
entity: {name: '/DMO/I_Status_Text', element: 'Status' }}]
@ObjectModel.text.association: '_StatusText'
@ObjectModel.readOnly: true
@UI: { lineItem: [ { position: 50, importance: #HIGH },
{ type: #FOR_ACTION,
dataAction: 'set_status_booked',
label: 'Set Status to Booked' } ]
,identification: [ { position: 80 } ]
,selectionField: [ { position: 60 }]
}
Travel.status as Status,
Travel.lastchangedat as LastChangedAt,
/* Associations */
@Search.defaultSearchElement: true
_Booking,
_Agency,
_Customer,
_StatusText,
_CurrencyText
}