01 - SAP Analytics - US-USI-MX Knowledge Series - Modeling With CDS Views Day 1
01 - SAP Analytics - US-USI-MX Knowledge Series - Modeling With CDS Views Day 1
Analytics
Day 1
Abhishek Agrawal &
Vikas Kr. Pandey
Agenda
Annotations Overview
Q&A
SAP S/4HANA is the suit of applications with Enterprise Management at its core,
S/4HANA is built natively and optimally to run only on the SAP HANA platform.
11 Yrs
12 Yrs
13 Yrs
S/4 HANA
FIORI
V6
Finance
Logistics V4 V5
Production
V1 V2 V3
Physical Tables
Set of analytical features integrated in SAP S/4 HANA that enable users to perform real time
operational analytics on transactional data.
Embedded Analytics
OLAP + OLTP
No aggregated data
Data Modeling
V3
V1 V2
S/4HANA Embedded
Analytics
BI Tools
S/4HANA Embedded
Analytics
S/4 HANA Analytics is built on Virtual Data Models (VDM) based on CDS views.
BI Suite
Fiori UI BI tools (on-premise)
WebI SAP Analytics Cloud
KPI Modeler APF
Crystal Reports Tableau
consume CDS models via
Query Browser Analytic Apps Analytical Engine
Analysis for Office Power BI
BI Analytical
@OData.publish: true oData Services @Analytics.query: true
Engine
Gateway
Application
Server Standard CDS Custom CDS
(ABAP) Extension
Content Content
Database sever
Physical Tables
(SAP HANA)
S/4 HANA Analytics is built on Virtual Data Models (VDM) based on CDS views.
BI Suite
Fiori UI
WebI SAP Analytics Cloud
KPI Modeler APF
Crystal Reports Tableau
Query Browser Analytic Apps
Analysis for Office Power BI
Gateway
InfoCube
Application Embedded
MultiProvider
Server CDS Views
Standard CDS Custom CDSBW
(ABAP) Composite Provider
Content
Content
Database sever
Physical Tables Calculation Views
(SAP HANA)
S/4 HANA Analytics is built on Virtual Data Models (VDM) based on CDS views.
BI Suite
Fiori UI
WebI SAP Analytics Cloud
KPI Modeler APF
Crystal Reports Tableau
Query Browser Analytic Apps
Analysis for Office Power BI
Gateway
InfoCube
Application Embedded
MultiProvider
Server CDS Views
Standard CDS Custom CDSBW
(ABAP) Composite Provider
Content
Content
Database sever
Physical Tables Calculation Views
(SAP HANA)
S/4HANA Embedded
Formatted Analytics Dashboards
Header
Annotation at header level (applicable to entire CDS View)
Annotations
Element /Field
Annotation at field/element level (only applicable to field on which it is applied)
Annotations
Input Parameters to create parametrized CDS views (e.g. language parameter to select
Parameters
Correct language key based on User)
Types of Annotations:-
Analytic manager
Mandatory and interprets individual
denotes the entities.
SE11 view Possible values are:
name @Analytics.dataCategory:
Evaluation #DIMENSION, #CUBE,
using CDS DCL The view can be used #FACT, #AGGREGATION
views as target for foreign key LEVEL
associations if this value
is there
@objectmodel.foreignkey.association
Definition in view
Additional Attributes
View in backend available as part of
transaction association
@objectmodel.text.association
Definition in view
#TEXT view
Lookup Entity- View Name to get So in above statement, we are telling the system to filter on all the
values to filter dataset “Country”(result) which it will get based on passing
Result element – Field whose data the value P_USER(value) to field “UserID”(target) from the view
has to be fetched ZCCD_CX_USR_CNTRY.
TargetElement- Field whose value is During runtime, we will not see country in selection, but it will be
being passed from view automatically filtered with all the relevant countries
For your user ID based on the LookupEntity specified.
This also gives us the flexibility to dynamically apply filter to the data.
• Associations are preferred in CDS since it’s a better way to code reusable joins.
• They can be used inside the view using path expressions or can be used to assign master data
to annotated element in the Select List.
• Associations always behave as LEFT OUTER JOIN in select list. However, you can influence
this behavior.
• Cardinality needs to be specified which applies only to the target. Eg. [0..1], [1..1], [min .. max]
• You can build complex models with relative ease using propagated annotations.
Syntax:
association [<cardinality>] to <target_data_source> as <_alias>
on <target_data_source>.<element_name> = <_alias>.<target_element_name>
Examples:
assoc3 [1] Like assoc1, this association has no or one target instance;
the default for min is 0
assoc6 [] Like assoc4, [] is short for [0..*] (the association has no,
one, or multiple target instances)
CDS Query
(to be created …)
Let us consider a scenario where the user wants to see the amount and count of the Accounting Documents posted per
Fiscal Period for a given company code. The data will be fetched from the ACDOCA Table. The user also wants to be
able to drilldown/filter on Document Type field.
The first step to creating this report would be to find out if there is any existing standard CDS View that can be utilized
as the source for our Cube or would we to create one from scratch. To do this, refer the table DD26I and search for the
existing views on the ACDOCA Table by filtering on the views with TABNAME = ‘ACDOCA’.
Of the CDS Views available, we find P_ACDOCA_COM (View Name PFIACDOCACOM) to be most suitable to our
requirements, in terms of the fields required for the report and selections filters applied in the view.
As for the ability to drilldown/filter on Accounting Document Type, we need to find out if there is a suitable view present
on the master data table (Table T003). Let us assume that such a view is currently not present in the system, so we can
create a Text and Master Data View for Accounting Document Type.
It is important to include the header annotation, Similar to the Text View, using the @Analytics.dataCategory annotation
‘@ObjectModel.dataCategory: #TEXT’. This along with Semantic tells the system that this is a Master Data Dimension and not a regular view. And
annotation on the Language field SPRAS, enables the language to be association with the Text View ensures that we have Text available with the
Attribute master data when this is used with CDS Cube.
picked up dynamically in certain scenarios.
Also, the annotation @ObjectModel.representative key has been used to mark the field DocumentType as the most relevant key for both the Text
View and Dimension View
Now that we have found the view to used as the source, we can build for our Cube.
We start by declaring the appropriate header annotations, giving the source as P_ACDOCA_COM and listing the fields that we would
need from the source view to be part of our Transactional Data Cube.
Since we might need input help on Company Code, Cost Center, Controlling Area and Document Type for the selection screen or
filtering in the report, we would have to establish the Foreign Key relationship for these fields with the appropriate master data.
Firstly, we would have to create association with the appropriate Master Data views, as shown below.
@AbapCatalog.sqlViewName: 'ZCCAAACDOCA'
@AbapCatalog.compiler.compareFilter: true
@AccessControl.authorizationCheck: #NOT_ALLOWED
@EndUserText.label: 'Year'
acdoca.gjahr,
acdoca.rbukrs,
acdoca.awref,
acdoca.hsl
CDS View (Queries & Cubes) are automatically exposed and available in Query Browser Fiori
App
SAP has provided a lot of standard CDS Views (Queries) as part of Standard delivered content
as of S/4 HANA
Customers can extend SAP delivered CDS Objects based on requirements using Extend Views
https://consulting.deloitteresources.com/sandd/resources/snet/applications/Pages/
sap.aspx
Install ABAP Tools in HANA Studio using website (note link may change based on Ecclipse
version):
https://tools.hana.ondemand.com/photon