投影草稿业务对象数据模型
ABAP RESTful 应用程序编程模型 › 开发 › 开发应用程序 › 使用独占草稿功能开发事务应用 › 公开 UI 业务服务的草稿业务对象 › 预测草稿敞口的草稿业务对象 › 投影草稿业务对象数据模型
对于使用草稿的托管场景,为草稿业务对象实体创建和实施 CDS 映射视图和元数据扩展。
上下文和过程
为所有三个业务对象实体“差旅”、“预订”和“预订补充”创建映射视图的数据定义。在 ADT 中,使用基础 CDS 视图实体上的上下文菜单打开用于创建 CDS 数据定义的向导。
选择模板定义映射视图。
备注
ABAP 航班参考场景中的草稿场景使用后缀
_D。由于新的 CDS 投影视图表示具有草稿功能的 UI 服务,因此我们在后缀前使用标记_D将活动投影层与包含草稿的投影层区分开来。此外,映射视图带有前缀C_,因为它们代表使用层。有关详细信息,请参阅 开发对象的命名规则 。
为每个映射视图创建元数据扩展。在 ADT 中,右键单击数据定义以打开元数据扩展的创建向导。
备注
根据虚拟数据模型 (VDM) 指导原则,元数据扩展使用与相关 CDS 视图相同的名称。
有关映射视图中语法的详细信息,请参阅将视图实体定义为映射(ABAP 关键字文档)。
投影视图 /DMO/C_Travel_D_D
映射视图是 /DMO/R_Travel_D 上的投影。在投影视图中包含关键字 root。
使用基础业务对象差旅实体的所有元素。您不需要在投影视图中使用管理数据,表示 ETag 主数据的元素除外。
使用注释 @Metadata.allowExtension:true 启用元数据扩展。
使用实体标题和指定元素上的 @Search 注释为差旅实体启用搜索功能。有关详细信息,请参阅在 SAP Fiori 应用中启用文本和模糊搜索。
对于通过 Fiori 元素 UI 的草稿业务对象的 OData V4 使用,必须使用注释 @ObjectModel.semanticKey: ['SemanticIdentifier'] 确保实例上的草稿指示显示。
要检索标识元素的长文本,CustomerID、AgencyID 和 OverallStatus 将相关文本提供者视图中的文本元素非规范化到映射视图中。有关详细信息,请参阅获取映射视图中的语言相关文本。
定义元素 CustomerID、CurrencyCode、AgencyID 和 OverallStatus 的值帮助。有关详细信息,请参阅添加值帮助。
与 ETag 主字段(这是确保 OData 使用中的乐观并发控制所必需的)相比,您不需要将总计 ETag 字段包括在草稿业务服务映射中。只有内部草稿处理才需要总计 ETag。
业务对象的构成结构的所有映射视图可用后,将成分重定向到预订实体的映射视图。
展开以下代码示例以查看投影视图 /DMO/C_Travel_D_D 的源代码。
示例代码
@EndUserText.label: 'Travel Projection View with Draft'
@AccessControl.authorizationCheck: #NOT_REQUIRED
@Metadata.allowExtensions: true
@Search.searchable: true
@ObjectModel.semanticKey: ['TravelID']
define root view entity /DMO/C_Travel_D_D
provider contract transactional_query
as projection on /DMO/R_Travel_D
{
key TravelUUID,
@Search.defaultSearchElement: true
TravelID,
@Search.defaultSearchElement: true
@ObjectModel.text.element: ['AgencyName']
@Consumption.valueHelpDefinition: [{ entity : {name: '/DMO/I_Agency_StdVH', element: 'AgencyID' }, useForValidation: true }]
AgencyID,
_Agency.Name as AgencyName,
@Search.defaultSearchElement: true
@ObjectModel.text.element: ['CustomerName']
@Consumption.valueHelpDefinition: [{entity: {name: '/DMO/I_Customer_StdVH', element: 'CustomerID' }, useForValidation: true}]
CustomerID,
_Customer.LastName as CustomerName,
BeginDate,
EndDate,
BookingFee,
TotalPrice,
@Consumption.valueHelpDefinition: [{entity: {name: 'I_CurrencyStdVH', element: 'Currency' }, useForValidation: true }]
CurrencyCode,
Description,
@ObjectModel.text.element: ['OverallStatusText']
@Consumption.valueHelpDefinition: [{ entity : {name: '/DMO/I_Overall_Status_VH', element: 'OverallStatus' } }]
OverallStatus,
_OverallStatus._Text.Text as OverallStatusText: localized,
LocalLastChangedAt,
/* Associations */
_Agency,
_Booking : redirected to composition child /DMO/C_Booking_D_D,
_Currency,
_Customer,
_OverallStatus
}
元数据扩展 /DMO/C_Travel_D_D
将元数据扩展定义为 CDS 投影视图 /DMO/C_Travel_A_D 的扩展。
定义层 #CORE。
使用所有 @UI 注释为差旅应用设计用户界面。有关详细信息,请参阅定义元数据驱动 UI 的 CDS 注释。
展开以下代码示例以查看元数据扩展 /DMO/C_Travel_D_D 的源代码。
示例代码
@Metadata.layer: #CORE
@UI: { headerInfo: { typeName: 'Travel',
typeNamePlural: 'Travels',
title: { type: #STANDARD, value: 'TravelID' } },
presentationVariant: [{ sortOrder: [{ by: 'TravelID', direction: #DESC }], visualizations: [{type: #AS_LINEITEM}] }] }
annotate entity /DMO/C_Travel_D_D with
{
@UI.facet: [{ id: 'Travel',
purpose: #STANDARD,
type: #IDENTIFICATION_REFERENCE,
label: 'Travel',
position: 10 },
{ id: 'Booking',
purpose: #STANDARD,
type: #LINEITEM_REFERENCE,
label: 'Booking',
position: 20,
targetElement: '_Booking'}]
@UI.hidden: true
TravelUUID;
@UI: { lineItem: [ { position: 10, importance: #HIGH },
{ type: #FOR_ACTION, dataAction: 'acceptTravel', label: 'Accept Travel' },
{ type: #FOR_ACTION, dataAction: 'rejectTravel', label: 'Reject Travel' },
{ type: #FOR_ACTION, dataAction: 'deductDiscount', label: 'Deduct Discount', invocationGrouping: #CHANGE_SET } ],
identification: [ { position: 10, label: 'Travel ID' },
{ type: #FOR_ACTION, dataAction: 'acceptTravel', label: 'Accept Travel' },
{ type: #FOR_ACTION, dataAction: 'rejectTravel', label: 'Reject Travel' },
{ type: #FOR_ACTION, dataAction: 'deductDiscount', label: 'Deduct Discount' } ],
selectionField: [ { position: 10 } ] }
TravelID;
@UI: { lineItem: [ { position: 20, importance: #HIGH } ] ,
identification: [ { position: 20 } ],
selectionField: [ { position: 20 } ] }
AgencyID;
@UI: { lineItem: [ { position: 30, importance: #HIGH } ] ,
identification: [ { position: 30 } ],
selectionField: [ { position: 30 } ] }
CustomerID;
@UI: { lineItem: [ { position: 40, importance: #MEDIUM } ] ,
identification: [ { position: 40 } ] }
BeginDate;
@UI: { lineItem: [ { position: 50, importance: #MEDIUM } ] ,
identification: [ { position: 50 } ] }
EndDate;
@UI: { lineItem: [ { position: 60, importance: #MEDIUM } ] ,
identification: [ { position: 60 } ] }
BookingFee;
@UI: { lineItem: [ { position: 70, importance: #MEDIUM } ] ,
identification: [ { position: 70 } ] }
TotalPrice;
// CurrencyCode;
@UI: { lineItem: [ { position: 90, importance: #MEDIUM } ] ,
identification: [ { position: 90 } ] }
Description;
@UI: { lineItem: [ { position: 99, importance: #HIGH } ] ,
identification: [ { position: 99, label: 'Status' } ],
selectionField: [{ position: 40 }],
textArrangement: #TEXT_ONLY }
OverallStatus;
@UI.hidden: true
OverallStatusText;
@UI.hidden: true
LocalLastChangedAt;
}
投影视图 /DMO/C_Booking_D_D
映射视图是 /DMO/R_Booking_D 上的投影。
使用基础业务对象差旅实体的所有元素,尤其是表示 ETag 主数据的元素。
使用注释 @Metadata.allowExtension:true 启用元数据扩展。
使用 @Search 注释启用预订实体的搜索功能。有关详细信息,请参阅在 SAP Fiori 应用中启用文本和模糊搜索。
要检索标识元素 CustomerID 和 CarrierID 的长文本,请将相关文本提供者视图中的文本元素非规范化到映射视图中。有关详细信息,请参阅获取映射视图中的语言相关文本。
定义元素 CustomerID 、 ConnectionID 、 AirlineID 、 FlightDate 和 CurrencyCode 的值帮助。有关详细信息,请参阅添加值帮助。
业务对象构成结构的所有映射视图可用后,将构成重定向到子视图到预订实体的映射视图,并将根实体的关联重定向到相应的映射视图。
展开以下代码示例以查看投影视图 /DMO/C_Booking_D_D 的源代码。
示例代码
@EndUserText.label: 'Booking Proj View with Draft'
@AccessControl.authorizationCheck: #NOT_REQUIRED
@Metadata.allowExtensions: true
@Search.searchable: true
@ObjectModel.semanticKey: ['BookingID']
define view entity /DMO/C_Booking_D_D
as projection on /DMO/R_Booking_D
{
key BookingUUID,
TravelUUID,
@Search.defaultSearchElement: true
BookingID,
BookingDate,
@ObjectModel.text.element: ['CustomerName']
@Search.defaultSearchElement: true
@Consumption.valueHelpDefinition: [{entity: {name: '/DMO/I_Customer_StdVH', element: 'CustomerID' }, useForValidation: true}]
CustomerID,
_Customer.LastName as CustomerName,
@ObjectModel.text.element: ['CarrierName']
@Consumption.valueHelpDefinition: [
{ entity: {name: '/DMO/I_Flight_StdVH', element: 'AirlineID'},
additionalBinding: [ { localElement: 'FlightDate', element: 'FlightDate', usage: #RESULT},
{ localElement: 'ConnectionID', element: 'ConnectionID', usage: #RESULT},
{ localElement: 'FlightPrice', element: 'Price', usage: #RESULT},
{ localElement: 'CurrencyCode', element: 'CurrencyCode', usage: #RESULT } ],
qualifier: 'FlightVH1',
label: 'Flights' }
]
AirlineID,
_Carrier.Name as CarrierName,
@Consumption.valueHelpDefinition: [
{ entity: {name: '/DMO/I_Flight_StdVH', element: 'ConnectionID'},
additionalBinding: [ { localElement: 'FlightDate', element: 'FlightDate', usage: #RESULT},
{ localElement: 'AirlineID', element: 'AirlineID', usage: #FILTER_AND_RESULT},
{ localElement: 'FlightPrice', element: 'Price', usage: #RESULT},
{ localElement: 'CurrencyCode', element: 'CurrencyCode', usage: #RESULT } ],
qualifier: 'FlightVH2',
label: 'Flights' }
]
ConnectionID,
@Consumption.valueHelpDefinition: [
{ entity: {name: '/DMO/I_Flight_StdVH', element: 'FlightDate'},
additionalBinding: [ { localElement: 'AirlineID', element: 'AirlineID', usage: #FILTER_AND_RESULT},
{ localElement: 'ConnectionID', element: 'ConnectionID', usage: #FILTER_AND_RESULT},
{ localElement: 'FlightPrice', element: 'Price', usage: #RESULT},
{ localElement: 'CurrencyCode', element: 'CurrencyCode', usage: #RESULT } ],
label: 'Flights',
useForValidation: true }
]
FlightDate,
@Consumption.valueHelpDefinition: [
{ entity: {name: '/DMO/I_Flight_StdVH', element: 'Price'},
additionalBinding: [ { localElement: 'FlightDate', element: 'FlightDate', usage: #FILTER_AND_RESULT},
{ localElement: 'AirlineID', element: 'AirlineID', usage: #FILTER_AND_RESULT},
{ localElement: 'ConnectionID', element: 'ConnectionID', usage: #FILTER_AND_RESULT},
{ localElement: 'CurrencyCode', element: 'CurrencyCode', usage: #RESULT } ],
label: 'Flights',
useForValidation: true }
]
FlightPrice,
@Consumption.valueHelpDefinition: [{entity: {name: 'I_CurrencyStdVH', element: 'Currency' }, useForValidation: true }]
CurrencyCode,
@ObjectModel.text.element: ['BookingStatusText']
@Consumption.valueHelpDefinition: [{entity: {name: '/DMO/I_Booking_Status_VH', element: 'BookingStatus' }}]
BookingStatus,
_BookingStatus._Text.Text as BookingStatusText: localized,
LocalLastChangedAt,
/* Associations */
_BookingSupplement: redirected to composition child /DMO/C_BookingSupplement_D_D,
_BookingStatus,
_Carrier,
_Connection,
_Customer,
_Travel: redirected to parent /DMO/C_Travel_D_D
}
元数据扩展 /DMO/C_Booking_D_D
将元数据扩展定义为 CDS 投影视图 /DMO/C_Booking_D_D 的扩展。
定义层 #CORE。
使用所有 @UI 注释为差旅应用设计用户界面。有关详细信息,请参阅定义元数据驱动 UI 的 CDS 注释。
展开以下代码示例以查看元数据扩展视图 /DMO/C_Booking_D_D 的源代码。
示例代码
@Metadata.layer: #CORE
@UI: { headerInfo: { typeName: 'Booking',
typeNamePlural: 'Bookings',
title: { type: #STANDARD, value: 'BookingID' } } }
annotate entity /DMO/C_Booking_D_D with
{
@UI.facet: [ { id: 'Booking',
purpose: #STANDARD,
type: #IDENTIFICATION_REFERENCE,
label: 'Booking',
position: 10 },
{ id: 'BookingSupplement',
purpose: #STANDARD,
type: #LINEITEM_REFERENCE,
label: 'Booking Supplement',
position: 20,
targetElement: '_BookingSupplement'} ]
@UI.hidden: true
BookingUUID;
@UI.hidden: true
TravelUUID;
@UI: { lineItem: [ { position: 20, importance: #HIGH } ],
identification: [ { position: 20 } ] }
BookingID;
@UI: { lineItem: [ { position: 30, importance: #HIGH } ],
identification: [ { position: 30 } ] }
BookingDate;
@UI: { lineItem: [ { position: 40, importance: #HIGH } ],
identification: [ { position: 40 } ] }
CustomerID;
@UI: { lineItem: [ { position: 50, importance: #HIGH } ],
identification: [ { position: 50 } ] }
AirlineID;
@UI: { lineItem: [ { position: 60, importance: #HIGH } ],
identification: [ { position: 60 } ] }
ConnectionID;
@UI: { lineItem: [ { position: 70, importance: #HIGH } ],
identification: [ { position: 70 } ] }
FlightDate;
@UI: { lineItem: [ { position: 80, importance: #HIGH } ],
identification: [ { position: 80 } ] }
FlightPrice;
// CurrencyCode;
@UI: { lineItem: [ { position: 90, importance: #HIGH } ],
identification: [ { position: 90 } ],
textArrangement: #TEXT_ONLY }
BookingStatus;
@UI.hidden: true
BookingStatusText;
@UI.hidden: true
LocalLastChangedAt;
}
投影视图 /DMO/C_BookingSupplement_D_D
映射视图是 /DMO/R_BookingSupplement_D 上的投影。
使用基础业务对象差旅实体的所有元素,尤其是表示 ETag 主数据的元素。
使用注释 @Metadata.allowExtension:true 启用元数据扩展。
使用 @Search 注释启用差旅实体的搜索功能。有关详细信息,请参阅在 SAP Fiori 应用中启用文本和模糊搜索。
要检索标识元素 SupplementID 的长文本,请将相关文本提供者视图中的文本元素非规范化到映射视图中。有关详细信息,请参阅获取映射视图中的语言相关文本。
定义元素 SupplementID 和 CurrencyCode 的值帮助。有关详细信息,请参阅添加值帮助。
业务对象构成结构的所有映射视图可用后,将到父项的关联重定向到预订实体的映射视图,并将根实体的关联重定向到相应的映射视图。
展开以下代码示例以查看投影视图 /DMO/C_BookingSupplement_D_D 的源代码。
示例代码
@EndUserText.label: 'BookingSuppl Proj View for Draft RefScen'
@AccessControl.authorizationCheck: #NOT_REQUIRED
@Metadata.allowExtensions: true
@Search.searchable: true
@ObjectModel.semanticKey: ['BookingSupplementID']
define view entity /DMO/C_BookingSupplement_D_D
as projection on /DMO/R_BookingSupplement_D
{
key BookSupplUUID,
TravelUUID,
BookingUUID,
@Search.defaultSearchElement: true
BookingSupplementID,
@ObjectModel.text.element: ['SupplementDescription']
@Consumption.valueHelpDefinition: [
{ entity: {name: '/DMO/I_Supplement_StdVH', element: 'SupplementID' },
additionalBinding: [ { localElement: 'BookSupplPrice', element: 'Price', usage: #RESULT },
{ localElement: 'CurrencyCode', element: 'CurrencyCode', usage: #RESULT }],
useForValidation: true }
]
SupplementID,
_SupplementText.Description as SupplementDescription : localized,
BookSupplPrice,
@Consumption.valueHelpDefinition: [{entity: {name: 'I_CurrencyStdVH', element: 'Currency' }, useForValidation: true }]
CurrencyCode,
LocalLastChangedAt,
/* Associations */
_Booking : redirected to parent /DMO/C_Booking_D_D,
_Product,
_SupplementText,
_Travel : redirected to /DMO/C_Travel_D_D
}
元数据扩展 /DMO/C_BookingSupplement_D_D
将元数据扩展定义为 CDS 投影视图 /DMO/C_BookingSupplement_D_D 的扩展。
定义层 #CORE。
使用所有 @UI 注释为差旅应用设计用户界面。有关详细信息,请参阅定义元数据驱动 UI 的 CDS 注释。
展开以下代码示例以查看投影视图 /DMO/C_BookingSupplement_D_D 的源代码。
示例代码
@Metadata.layer: #CORE
@UI: { headerInfo: { typeName: 'Booking Supplement',
typeNamePlural: 'Booking Supplements',
title: { type: #STANDARD,
label: 'Booking Supplement',
value: 'BookingSupplementID' } } }
annotate entity /DMO/C_BookingSupplement_D_D
with
{
@UI.facet: [ { id: 'BookingSupplement',
purpose: #STANDARD,
type: #IDENTIFICATION_REFERENCE,
label: 'Booking Supplement',
position: 10 } ]
@UI.hidden:true
BookSupplUUID;
@UI.hidden:true
BookingUUID;
@UI.hidden:true
TravelUUID;
@UI: { lineItem: [ { position: 10, importance: #HIGH } ],
identification: [ { position: 10 } ] }
BookingSupplementID;
@UI: { lineItem: [ { position: 20, importance: #HIGH } ],
identification: [ { position: 20 } ] }
SupplementID;
@UI: { lineItem: [ { position: 30, importance: #HIGH } ],
identification: [ { position: 30 } ] }
BookSupplPrice;
// CurrencyCode;
@UI.hidden: true
LocalLastChangedAt;
}
来源:SAP Help Portal · 2025 FPS02 (Oct 2026) · 中文为 SAP 官方机器翻译
← 预测草稿敞口的草稿业务对象 · 预测草稿业务对象行为 →