SAP S/4HANA Embedded Analytics(嵌入式分析)是基于 SAP HANA 内存计算能力构建的实时分析方案。它允许企业在不脱离 S/4HANA 的情况下,直接对业务交易数据进行多维分析、报表展示和 KPI 监控,实现 OLTP 与 OLAP 的融合。
嵌入式分析的核心技术栈包括 ABAP CDS Views、OData 服务、SAP Fiori Elements、Analytical List Page 和 Smart Business KPI Tiles。
在嵌入式分析中,CDS View 扮演数据模型层的角色。根据用途不同,可分为以下几类:
| 类型 | 说明 | 典型用途 |
|---|---|---|
| Basic View | 基础视图,直接映射底层表 | 封装原始数据,提供统一语义 |
| Composite View | 组合视图,关联多个 Basic View | 构建业务对象视图 |
| Consumption View | 消费视图,暴露给 UI 或服务 | Fiori 应用、OData 服务 |
| Cube View | 分析立方体视图,带维度和度量 | 多维分析、KPI 计算 |
| Query View | 查询视图,最终面向用户 | Analytical List Page、报表 |
@AccessControl.authorizationCheck: #NOT_REQUIRED
@EndUserText.label: 'Sales Cube'
@Analytics.dataCategory: #CUBE
@VDM.viewType: #COMPOSITE
define view entity ZC_SalesCube
as select from zsales_item
association [0..1] to zproduct as _Product on $projection.product_id = _Product.product_id
association [0..1] to zcustomer as _Customer on $projection.customer_id = _Customer.customer_id
{
@ObjectModel.foreignKey.association: '_Product'
key product_id,
@ObjectModel.foreignKey.association: '_Customer'
key customer_id,
@Semantics.calendarYear: true
calendar_year,
@Semantics.currencyCode: true
currency_code,
@DefaultAggregation: #SUM
@Semantics.amount.currencyCode: 'currency_code'
net_amount,
@DefaultAggregation: #SUM
@Semantics.quantity.unitOfMeasure: 'unit_of_measure'
quantity,
unit_of_measure,
_Product,
_Customer
}
@EndUserText.label: 'Sales Query'
@Analytics.query: true
@VDM.viewType: #CONSUMPTION
define view entity ZC_SalesQuery
as select from ZC_SalesCube
{
@AnalyticsDetails.query.axis: #ROWS
@Consumption.filter: { selectionType: #INTERVAL, multipleSelections: true }
key calendar_year,
@AnalyticsDetails.query.axis: #ROWS
product_id,
@AnalyticsDetails.query.axis: #COLUMNS
@AnalyticsDetails.query.totals: #SHOW
@DefaultAggregation: #SUM
net_amount,
currency_code
}
将 CDS Query View 通过 Service Definition 暴露为 OData V2/V4 服务后,即可被 Fiori 应用消费:
define service ZUI_SALES_ANALYTICS {
expose ZC_SalesQuery as SalesQuery;
expose ZC_SalesCube as SalesCube;
}
Analytical List Page 是 Fiori Elements 提供的分析型页面模板,支持:
ALP 通常基于一个带分析注释的 CDS Query View 自动生成,开发工作量远小于传统 SAPUI5 freestyle 应用。
Smart Business KPI Tiles 允许将 CDS View 暴露的关键指标以磁贴形式展示在 Fiori Launchpad 上。其开发流程包括:
| 优化方向 | 具体措施 |
|---|---|
| 减少数据传输 | 仅暴露必要字段,使用参数化视图 |
| 利用 HANA 计算下推 | 避免在 ABAP 层进行大量聚合 |
| 合理使用索引 | 为高频过滤字段创建 HANA 索引 |
| 权限控制 | 使用 DCL 进行行级权限控制,避免全表扫描 |
| 缓存策略 | 对变化不频繁的 KPI 使用缓存或预计算 |
嵌入式分析适合 operational reporting 和实时 KPI 场景,而对于复杂的企业级数据仓库、跨系统整合和高级预测分析,仍建议结合 SAP Analytics Cloud (SAC)、SAP Datasphere 或 SAP BW/4HANA 使用。
SAP S/4HANA 嵌入式分析通过 CDS Views、OData 和 Fiori 技术栈,为企业提供了一种轻量、实时、原生的分析能力。掌握 Cube View、Query View、ALP 和 KPI Tiles 的开发方法,能够帮助企业在 S/4HANA 平台上快速构建可视化分析应用,支撑业务决策。
以下内容整理自 SAP 官方 ABAP 速查表(主题:CDS View Entities),作为本文的扩展补充资料。
Core data services (CDS) are an infrastructure for defining and consuming semantically rich data models on the standard database of an AS ABAP.
[!NOTE] - The executable example focuses on CDS view entities and covers a selection of features. - The sample CDS view entities are designed to demonstrate a selection of features with a limited number of artifacts. They are not intended to be role models for proper CDS view design. They focus on syntax options only. They are not intended to solve concrete programming tasks. You should always work out your own solution for each individual case. For more detailed information, refer to the links in the More Information section. - The ABAP Dictionary cheat sheet highlights that several CDS entities - apart from CDS view entities - represent structured types that are usable in ABAP.
The following links take you to the source code of the cheat sheet artifacts to get a glimpse on the syntax used. To explore the syntax in action, import the ABAP cheat sheet repository into your system.
[!NOTE] - The executable example covers the following topics: - Operands, expressions, built-in functions, and input parameters in CDS view entities - Selecting data from CDS view entities using ABAP SQLSELECTstatements - Joins - Note: A sample CDS view entity contains multiple joins. You can comment in/out code sections to see the effect. See the notes in the view. - Excursion: Joins in ABAP SQL - Associations - Defining views with associations - Exposing associations - Using exposed associations in ABAP statements - The example CDS view entities (zdemo_abap_cds_ve...) and the class contains comments in the code for more information. - The steps to import and run the code are outlined here. - Disclaimer
15_CDS_View_Entities.md。版权归原作者所有。