ABAP Keyword Documentation → ABAP − Reference → ABAP RESTful Programming Model → Behavior Definitions → ABAP BDL - Example
Other entity examples
Other versions:
7.31 | 7.40 | 7.54
Example
CDS entity Agency
The CDS view /DMO/I_Agency represents travel agency data, for example, the address and contact information. The relevant agency data is saved in the database table /DMO/AGENCY. The flight data scenario defines a 1:n cardinality between the entities Agency and Travel.
@AbapCatalog.compiler.compareFilter: true
@AbapCatalog.preserveKey: true
@AccessControl.authorizationCheck: #NOT_REQUIRED
@EndUserText.label: 'Agency - CDS Data Model'
define view /DMO/I_Agency
as select from /dmo/agency as Agency
association [0..1] to I_Country as _Country on
$projection.CountryCode = _Country.Country
{
key Agency.agency_id as AgencyID,
@Semantics.text: true
Agency.name as Name,
Agency.street as Street,
Agency.postal_code as PostalCode,
Agency.city as City,
Agency.country_code as CountryCode,
Agency.phone_number as PhoneNumber,
Agency.email_address as EMailAddress,
Agency.web_address as WebAddress,
/* Associations */
_Country
}
CDS entity Customer
The CDS view /DMO/I_Customer represents the data model for managing passengers, for example, the name, address, and contact information. The relevant data is saved in the database table /DMO/CUSTOMER. The flight data scenario defines a 1:n cardinality between the entities Customer and Travel.
@AbapCatalog.compiler.compareFilter: true
@AbapCatalog.preserveKey: true
@AccessControl.authorizationCheck: #NOT_REQUIRED
@EndUserText.label: 'Customer - CDS Data Model'
define view /DMO/I_Customer
as select from /dmo/customer as Customer
association [0..1] to I_Country as _Country on
$projection.CountryCode = _Country.Country
{
key Customer.customer_id as CustomerID,
Customer.first_name as FirstName,
@Semantics.text: true
Customer.last_name as LastName,
Customer.title as Title,
Customer.street as Street,
Customer.postal_code as PostalCode,
Customer.city as City,
Customer.country_code as CountryCode,
Customer.phone_number as PhoneNumber,
Customer.email_address as EMailAddress,
/* Associations */
_Country
}
CDS entity Carrier
The CDS view /DMO/I_Carrier represents the data model for managing airline data, for example, the carrier ID and name. The relevant data is saved in the database table /DMO/CARRIER. The flight data scenario defines a 1:n cardinality between the entities Carrier and Connection.
@AbapCatalog.compiler.compareFilter: true
@AccessControl.authorizationCheck: #NOT_REQUIRED
@EndUserText.label: 'Carrier - CDS Data Model'
@Search.searchable: true
define view /DMO/I_Carrier
as select from /dmo/carrier as Carrier
{
key Carrier.carrier_id as CarrierID,
@Semantics.text: true
@Search.defaultSearchElement: true
@Search.fuzzinessThreshold: 0.86
Carrier.name as Name,
@Semantics.currencyCode: true
Carrier.currency_code as CurrencyCode
}
CDS entity Connection
The CDS view /DMO/I_Connection represents the data model for managing flight connection data, for example, the departure airport and arrival airport. The relevant data is saved in the database table /DMO/CONNECTION. The flight data scenario defines a 1:n cardinality between the entities Connection and Carrier.
@AbapCatalog.compiler.compareFilter: true
@AccessControl.authorizationCheck: #NOT_REQUIRED
@ObjectModel.dataCategory: #TEXT
@EndUserText.label: 'Connection - CDS Data Model'
define view /DMO/I_Connection
as select from /dmo/connection as Connection
{
@ObjectModel.text.element: ['Description']
key Connection.carrier_id as CarrierID,
key Connection.connection_id as ConnectionID,
airport_from_id as Departure,
airport_to_id as DestinationAirport,
departure_time as DepartureTime,
arrival_time as ArrialTime,
@Semantics.quantity.unitOfMeasure: 'DistanceUnit'
distance as Distance,
@Semantics.unitOfMeasure: true
distance_unit as DistanceUnit,
}
CDS entity Status
The CDS view /DMO/I_Status_Text represents the data model for managing the status of a trip, for example, new and booked.
@AbapCatalog.compiler.compareFilter: true
@AccessControl.authorizationCheck: #CHECK
@EndUserText.label: 'Status - CDS Data Model'
define view /DMO/I_Status_Text
as select from dd07t as dd
{
key cast ( substring( dd.domvalue_l, 1, 1 )
as /dmo/travel_status ) as Status,
@Semantics.language: true
key dd.ddlanguage as language,
@Semantics.text: true
dd.ddtext as StatusText
}
where dd.domname = '/DMO/STATUS'
and dd.as4local = 'A'