Skip to main content

SAP S4HANA Embedded Real-time Analytics - 1/4 Semantic Model

ยท 7 min read
Tiven Wang

Embedded Analytics Introductionโ€‹

Metad Analytics Cloud is a powerful data analytics tool that can directly connect to the SAP S/4HANA system and utilize Transient Analytical Queries generated from CDS (Core Data Services) views for embedded real-time data analysis. By leveraging the in-memory computing capabilities of the SAP HANA database, it provides real-time data analysis and reporting functions, allowing users to gain insights directly during business operations.

This series introduces SAP S/4HANA embedded analytics functionality in three parts:

  1. Semantic Model: Explore how to enhance CDS models using the semantic model functionality of Metad Analytics Cloud, including defining calendar semantics and creating calculated measures using MDX statements, laying the groundwork for subsequent stories and metrics management.
  2. Story Dashboard: Learn how to create visual dashboards using enhanced CDS models to create a variety of stories and calculated measures.
  3. Metrics Management: Discuss how to define a series of metrics based on CDS models to form a systematic metrics management function, allowing managers within the enterprise to subscribe to and analyze metrics and monitor business data in real time.
SAP S/4HANA On-Premise Embedded Analytics
SAP S/4HANA On-Premise Embedded Analytics

This article will introduce how to enhance CDS models using the semantic model functionality of Metad Analytics Cloud, including calendar semantic definitions, calculated measures, and more.

Prerequisitesโ€‹

Before starting, make sure you have the following environment ready (choose one):

  • Public cloud SAP S/4HANA system with Metad Analytics Cloud.
  • On-Premise SAP S/4HANA system with a privately deployed Meta Analytics system.

The CDS views we will demonstrate belong to the standard views provided by the SD module of the S4 system. You can search for โ€œvdm_sdโ€ in ADT and add the VDM_SD_ANALYTICS package, which contains the standard content package for SAP sales analysis.

CDS views:

  • Analytical Catalog: 2CISDSLSANACUBE1 - Sales Volume and Open Sales
  • Query 2CISDSLSANACUBE1/2CCSDSLSANALYTICQ1 - Sales Volume and Open Sales
CDS Query
@Analytics.query: true
@AbapCatalog.sqlViewName: 'CSDSLSANALYTICQ1'
define view C_SalesAnalyticsQry_1
CDS Cube
@Analytics.dataCategory: #CUBE
@AbapCatalog.sqlViewName: 'ISDSLSANACUBE1'
define view I_SalesAnalyticsCube_1

The corresponding BW Query of the CDS View can be checked in transaction code RSRT (format 2C<CUBE_SQL_VIEW>/2C<QUERY_SQL_VIEW>), with results similar to 'Easy Query'.

SAP Query Monitor
SAP Query Monitor

Once the SAP S/4 system environment is ready, we will create a semantic model in Metad Analytics Cloud to enhance it.

Configuring the Analytical Environmentโ€‹

  1. Connect the S4HANA system as a data source.
  2. Create a semantic model as a workspace for model enhancement.

Based on Cubeโ€‹

Select the $INFOCUBE directory to create a semantic model, then find the multidimensional dataset named $2CISDSLSANACUBE1 in the source data table.

Based on Queryโ€‹

Select the 2CISDSLSANACUBE1 directory to create a semantic model, then find the query dataset named 2CISDSLSANACUBE1/2CCSDSLSANALYTICQ1 in the source data table.

Semantic Modelโ€‹

For the CDS Views model scenario of the SAP S/4HANA system embedded analysis, the basic model is already built in the CDS Views. The semantic model in Metad Analytics Cloud can enhance the CDS model, including defining dimension semantics, measure formats, and calculated measures.

Semantic Enhancementsโ€‹

In Metad Analytics Cloud, many features of data visualization and metrics management require defining the semantics of dimensions and measures, including calendar dimension formatting, geographic dimension properties, measure formatting methods, and more. Enhancing the CDS model with semantics in the semantic model facilitates subsequent display.

Calculated Membersโ€‹

In data analysis, calculated members are a powerful feature that allows you to define and create calculated measures based on existing data. These calculated members can be used in various analyses and reports, providing more flexible and dynamic data analysis capabilities. Semantic model calculated members can effectively replace formula-calculated measure fields in CDS views. Below is a detailed introduction.

Advantages of Calculated Membersโ€‹

  1. Flexibility: Calculated members allow users to define complex measures at the semantic model level without modifying the underlying CDS views. This flexibility enables users to quickly adjust and create new calculated measures based on their needs without involving changes to the underlying database or data model.

  2. Dynamic Nature: Calculated members can dynamically calculate results based on user interactions and data filters. For example, they can calculate specific measures based on different time ranges, geographic areas, or product categories, which might require complex formulas and conditions in CDS views.

  3. Ease of Use: Through the semantic model interface, users can use simple drag-and-drop operations and an intuitive formula editor to create calculated members without deeply understanding SQL or CDS view syntax. This significantly lowers the threshold for creating and managing calculated measures, allowing more business users to participate in data analysis.

  4. Simplified Maintenance: Calculated members are centrally managed in the semantic model, making maintenance and updates more convenient. Users can view and modify all calculated measures in one place instead of searching and updating formulas in multiple CDS views.

  5. Enhanced Calculation Capabilities: The semantic model supports more complex calculation logic and functions, such as MDX (Multidimensional Expressions) statements, enabling advanced calculation capabilities that are difficult to achieve in CDS views. These features include complex time series analysis, cumulative and moving average calculations, etc.

Calculated Members
Calculated Members in Semantic Model

Replacing Formula Calculated Measure Fields in CDS Viewsโ€‹

Formula-calculated measure fields in CDS views are often used to define the calculation logic of key business metrics (such as sales amount, profit margin, etc.). These formulas are fixed when the view is defined, lacking flexibility and dynamic adjustment capabilities. Below are the steps on how to use calculated members in the semantic model to replace these functions:

  1. Creating Calculated Members: In the semantic model, select the dimensions or measures to be enhanced, and use the calculated member function to define new measures. For example, define a calculated member to calculate the annual sales growth rate:

    [Measures].[Annual Sales Growth] =
    ([Measures].[Sales Amount], [Time].[Year].CurrentMember) -
    ([Measures].[Sales Amount], [Time].[Year].CurrentMember.PrevMember)
  2. Applying Dynamic Calculations: According to analytical needs, calculated members can dynamically calculate based on different dimensions and filter conditions selected by users. For example, calculate the sales growth rate based on different time ranges (such as quarters, months) without modifying the underlying data model.

  3. Integrating Existing Measures: Calculated members can be extended and calculated based on existing measures. For example, calculate the profit margin based on existing sales and cost measures:

    [Measures].[Profit Margin] =
    ([Measures].[Sales Amount] - [Measures].[Cost Amount]) /
    [Measures].[Sales Amount]
  4. Optimizing Performance: Calculated members in the semantic model usually perform calculations at the analysis layer, utilizing in-memory computing technology and optimized query engines to improve calculation performance and reduce the load on the database.

AI-Generated Calculated Formulasโ€‹

With the widespread application of AI (Artificial Intelligence) technology, the calculated formula command (/calculated) in the Metad Analytics Cloud Copilot utilizes AI technology to provide an intelligent calculated formula generation function, helping users create calculated measures and metrics more quickly and accurately. Users can click the AI generation button in the calculated member toolbar, enter a natural language description of the desired calculated formula, and get a calculated member in the semantic model, significantly speeding up the creation of calculated formulas in CDS Views.

Data Previewโ€‹

After the model is created, you can preview the model data in the preview interface.

Data Preview
Data Preview in Semantic Model

CDS Parametersโ€‹

For CDS Views with input parameters like the following:

CDS View with parameters
define view C_SalesAnalyticsQry_1 
with parameters
@Consumption.defaultValue: 'M'
P_ExchangeRateType : kurst,
P_DisplayCurrency : vdm_v_display_currency

as select from I_SalesAnalyticsCube_1(P_ExchangeRateType:$parameters.P_ExchangeRateType, P_DisplayCurrency: $parameters.P_DisplayCurrency) as SAC
{

In the preview interface, parameters with default values

will be automatically filled in, and required parameters without default values need to be manually selected or entered.

Model Query Statementsโ€‹

You can also use MDX query statements (or AI-assisted generated query statements) in the query interface for more flexible data queries and export the query results.

Summaryโ€‹

This article introduces how to enhance and optimize CDS views using the semantic model functionality of Metad Analytics Cloud, achieving more flexible and efficient data analysis. In the next article, we will introduce how to create visual dashboards using the enhanced CDS models, creating a variety of stories and calculated measures.