0% found this document useful (0 votes)
142 views60 pages

01 - SAP Analytics - US-USI-MX Knowledge Series - Modeling With CDS Views Day 1

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
142 views60 pages

01 - SAP Analytics - US-USI-MX Knowledge Series - Modeling With CDS Views Day 1

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 60

SAP S/4 HANA

Analytics
Day 1
Abhishek Agrawal &
Vikas Kr. Pandey
Agenda

SAP S/4HANA Overview

SAP S/4HANA Embedded Analytics Overview

SAP S/4HANA Embedded Analytics - Components

SAP S/4HANA Data Modeling Options

Core Data Services(CDS) Overview

Annotations Overview

View Level Annotation & Field Level Annotation

Association, Joins & Cardinality in CDS Views

CDS Modelling – Master/Transaction Views

Q&A

Copyright © 2017 Deloitte Development LLC. All rights reserved. 2


SAP S/4HANA Overview

Copyright © 2017 Deloitte Development LLC. All rights reserved.


S/4 HANA Overview

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.

ERP Evolution SAP HANA Evolution

11 Yrs
12 Yrs
13 Yrs

4 Copyright © 2014 Deloitte Development LLC. All rights reserved.


S/4 HANA Architecture Overview

S/4 HANA

FIORI

Business Transactions Analytics

V6

Finance
Logistics V4 V5

Production
V1 V2 V3

Physical Tables

SAP HANA Database

5 Copyright © 2014 Deloitte Development LLC. All rights reserved.


Poll Question -1

6 Copyright © 2014 Deloitte Development LLC. All rights reserved.


SAP S/4HANA Embedded
Analytics

Copyright © 2017 Deloitte Development LLC. All rights reserved.


S/4 HANA Embedded Analytics

Traditional Operational Analytics


 Multiple copies
of data
 Reporting on old
data
 ETL & batch
processing
efforts and cost

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

 No ETL and batch


process
 Real time analytics

8 Copyright © 2014 Deloitte Development LLC. All rights reserved.


Poll Question -2

9 Copyright © 2014 Deloitte Development LLC. All rights reserved.


System Demo

Access S/4HANA system using GUI & Eclipse

10 Copyright © 2014 Deloitte Development LLC. All rights reserved.


SAP S/4HANA Embedded
Analytics: Components

Copyright © 2017 Deloitte Development LLC. All rights reserved.


S/4HANA Embedded Analytics: Components

Data Modeling

V3

V1 V2

S/4HANA Embedded
Analytics
BI Tools

Copyright © 2017 Deloitte Development LLC. All rights reserved. 12


S/4HANA Embedded Analytics: Data Modeling Options

Data Modeling using CDS Data Modeling using


Views Embedded BW

S/4HANA Embedded
Analytics

Data Modeling using


Calculation Views

Copyright © 2017 Deloitte Development LLC. All rights reserved. 13


Data Modeling: CDS Views

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

SAP S/4 HANA

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)

14 Copyright © 2014 Deloitte Development LLC. All rights reserved.


System Demo

Demonstrate CDS view modeling in system

15 Copyright © 2014 Deloitte Development LLC. All rights reserved.


Data Modeling: Embedded BW

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

SAP S/4 HANA

oData Services Bex Queries

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)

16 Copyright © 2014 Deloitte Development LLC. All rights reserved.


System Demo

Demonstrate BW modeling in system

17 Copyright © 2014 Deloitte Development LLC. All rights reserved.


Data Modeling: Embedded BW

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

SAP S/4 HANA

oData Services Bex Queries

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)

18 Copyright © 2014 Deloitte Development LLC. All rights reserved.


System Demo

Demonstrate HANA view modeling in system

19 Copyright © 2014 Deloitte Development LLC. All rights reserved.


Poll Question -3

20 Copyright © 2014 Deloitte Development LLC. All rights reserved.


S/4HANA Embedded Analytics: BI Tool Options

Out of Box Slice & Dice

KPI Modeler, APF, Query Browser, Analysis for Office


Analytical Apps

S/4HANA Embedded
Formatted Analytics Dashboards

Copyright © 2017 Deloitte Development LLC. All rights reserved. 21


Poll Question -4

22 Copyright © 2014 Deloitte Development LLC. All rights reserved.


SAP S/4HANA Core Data
Services

Copyright © 2017 Deloitte Development LLC. All rights reserved.


Core Data Services (CDS) – Major components

Annotations Enriches data models with additional metadata/information.

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

Associations connect data models with other views/tables


Associations
(Analytics Point of View –It is primarily used to connect data models with master data)

Source Single or Multiple tables/views combined using Join Conditions/Union

Name of View that is generated at the backend


SQL View Name
(This must be different from CDS view name)

Input Parameters to create parametrized CDS views (e.g. language parameter to select
Parameters
Correct language key based on User)

24 Copyright © 2014 Deloitte Development LLC. All rights reserved.


Annotations

• The term annotations implies attaching data to another piece of data.


• In Simple words, you can enhance your model with additional information.
• You can specify properties which helps system to understand your model.

Types of Annotations:-

View Level Annotation Field Level Annotation

25 Copyright © 2014 Deloitte Development LLC. All rights reserved.


Basic Example

• View Level Annotations have global scope in the CDS View.


• Field Level Annotations have their scope limited to the field in the CDS
view.
• Annotation “@AbapCatalog.sqlViewName” is mandatory for the definition of
a Core Data Services (CDS) view
View Level Annotations

@AbapCatalog.sqlViewName- Determines name of SE11


@AccessControl.authorizationCheck
@Analytics.query: true – Interpreted as an analytical query
@ObjectModel.representativeKey
@Analytics.dataCategory – Analytic Queries can be defined on top of CDS views using this
annotation
@Objectmodel.datacategory - #TEXT , #HIERARCHY

27 Copyright © 2014 Deloitte Development LLC. All rights reserved.


View Annotations- Details

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

This notation specifies that the


view is a query and thus needs
special handling and field
annotations to display rows
and columns in UI

28 Copyright © 2014 Deloitte Development LLC. All rights reserved.


View Annotations- Details

#TEXT denotes this view is a text


view which gives text for CostCenter
Name

29 Copyright © 2014 Deloitte Development LLC. All rights reserved.


View Annotations- Details

#HIERARCHY denotes this view is a Hierarchy


view which creates parent child relationship using
@hierarchy.parentchild association
Poll Question - 5

31 Copyright © 2014 Deloitte Development LLC. All rights reserved.


Field Level Annotations – Examples

@EndUserText.label - Translatable short text of the element


@objectmodel.foreignkey.association – Associate Field to another view.
@objectmodel.text.association – Associate Field to a #TEXT view
@consumption.derivation- Dynamically derive parameter/filter value
@consumption.filter – Enables fields as variables in UI layer
@analyticsdetails.query.axis – Determines field axis
ROWS/COLUMNS/FREE
@defaultaggregation- Specify behavior of the Measure(KPI). Missing this
can lead to values going under “Not Included” and thus giving errors. Needed
For KPI’s in CUBE. Can specify formulas also.

32 Copyright © 2014 Deloitte Development LLC. All rights reserved.


Field Annotations- Details

@objectmodel.foreignkey.association

Definition in view

Additional Attributes
View in backend available as part of
transaction association

33 Copyright © 2014 Deloitte Development LLC. All rights reserved.


Field Annotations- Details

@objectmodel.text.association

Definition in view
#TEXT view

Notice how we just have


name(text) field and no
other fields
View in backend
transaction

34 Copyright © 2014 Deloitte Development LLC. All rights reserved.


Poll Question - 6

35 Copyright © 2014 Deloitte Development LLC. All rights reserved.


Field Annotations- Details

@consumption.filter and @consumption.derivation

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.

36 Copyright © 2014 Deloitte Development LLC. All rights reserved.


Field Annotations- Details

@analyticsdetails.query.formula and @DefaultAggregation

When we specify @default.aggregation as #FORMULA , then we can


use @analyticsdetails.query.formula to specify the details of the field.
In the above eg. We have calculated a SLACompliant flat based on
two fields of the model.

help.sap url for CDS annotations:


https://help.sap.com/viewer/cc0c305d2fab47bd808adcad3ca7ee9d/7.5.9/en-
US/630ce9b386b84e80bfade96779fbaeec.html
37 Copyright © 2014 Deloitte Development LLC. All rights reserved.
Poll Question - 7

38 Copyright © 2014 Deloitte Development LLC. All rights reserved.


Associations

• 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>

39 Copyright © 2014 Deloitte Development LLC. All rights reserved.


Accessing Associations – Local or Propagated
• Associations can be local or propagated, consider a case when you are reading data from LFB1 and you need to
access master data for a given vendor from LFA1.
• We can have an approach where
Select from LFB1DIM
..association[1..1] to LFA1DIM as _LFA1
..
But what if LFB1DIM already has an association _LFA1 inside it. You will be able to access it using _LFA1.<field>
instead of writing the statement again.

• This is how you propagate the associations in select list

• Accessing elements from association in outer view.

• Accessing elements from propagated associations of I_SUPPLIER.

40 Copyright © 2014 Deloitte Development LLC. All rights reserved.


Joins in Associations
• As mentioned, by default, associations work as left outer join unless specified to work as inner join using below
syntax

[ [1:] [INNER|{LEFT OUTER} [WHERE]] [cond_expr] ]

Examples:

In these eg. we have overwritten the left outer and


explicitly mentioned inner using where condition too.

41 Copyright © 2014 Deloitte Development LLC. All rights reserved.


Cardinality in Associations

Association Cardinality Syntax Examples

Association Cardinality Explanation


assoc1 [0..1] The association has no or one target instance
assoc2 Like assoc1, this association has no or one target instance
and uses the default [0..1]

assoc3 [1] Like assoc1, this association has no or one target instance;
the default for min is 0

assoc4 [1..1] The association has one target instance


assoc5 [0..*] The association has no, one, or multiple target instances

assoc6 [] Like assoc4, [] is short for [0..*] (the association has no,
one, or multiple target instances)

42 Copyright © 2014 Deloitte Development LLC. All rights reserved.


Poll Question - 8

43 Copyright © 2014 Deloitte Development LLC. All rights reserved.


Poll Question - 9

44 Copyright © 2014 Deloitte Development LLC. All rights reserved.


CDS Modeling – Data Flow

CDS Query
(to be created …)

CDS Dimension View


I_COMPANYCODE
CDS Cube

CDS Dimension View


I_CONTROLLINGAREA
CDS Dimension View
Accounting Document Type

CDS Dimension View Standard CDS View


I_COSTCENTER P_ACDOCA_COM
CDS Text View
Accounting Document Type

Table Table Table


ACDOCA T003 T003T

45 Copyright © 2014 Deloitte Development LLC. All rights reserved.


CDS Modelling

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.

46 Copyright © 2014 Deloitte Development LLC. All rights reserved.


Creating a DDL View - Master Data Dimension

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.

CDS Text View CDS Dimension View

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

47 Copyright © 2014 Deloitte Development LLC. All rights reserved.


Creating a DDL View – Transactional Cube

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.

In the header annotations apart from the default


declarations, we need to provide a suitable SQL View
name, View description using ‘@EndUserText.label’ and
declare the view to be of type Cube. Also, since this will act
as our Reporting Layer Cube we need to enable data
extraction on the view using
‘@Analytics.dataExtraction.enabled: true’.

48 Copyright © 2014 Deloitte Development LLC. All rights reserved.


Creating a DDL View – Foreign Key Associations
Since we have the basic structure of the cube built up, we can go ahead and establish the Master data relationships for the relevant
fields.

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.

These associations can be referred using


the aliases (highlighted above) in the field
level annotation
‘@ObjectModel.foreignKey.association:’

49 Copyright © 2014 Deloitte Development LLC. All rights reserved.


CDS Views

Code Snippet - Cube

50 Copyright © 2014 Deloitte Development LLC. All rights reserved.


CDS Views

Code Snippet - Query

51 Copyright © 2014 Deloitte Development LLC. All rights reserved.


CDS Views

Cube in Analysis for office

Query in Analysis for office

52 Copyright © 2014 Deloitte Development LLC. All rights reserved.


Simple CDS View
Simple CDS view on the top of ACDOCA table

@AbapCatalog.sqlViewName: 'ZCCAAACDOCA'

@AbapCatalog.compiler.compareFilter: true

@AccessControl.authorizationCheck: #NOT_ALLOWED

@EndUserText.label: 'ACDOCA View'

define view ZCC_AA_ACDOCA

as select from ACDOCA {

@EndUserText.label: 'Year'

acdoca.gjahr,

@EndUserText.label: 'Company Code'

acdoca.rbukrs,

@EndUserText.label: 'Document No.'

acdoca.awref,

@EndUserText.label: 'Local Amount'

acdoca.hsl

53 Copyright © 2014 Deloitte Development LLC. All rights reserved.


Core Data Services (CDS) – Key Facts
CDS Views (Cubes and Queries) would be available in SAP BI tools with naming convention –
2C<SQL View Name of CDS View>

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

Reporting in CDS Views supports different type of Master data views

54 Copyright © 2014 Deloitte Development LLC. All rights reserved.


Poll Question - 10

55 Copyright © 2014 Deloitte Development LLC. All rights reserved.


THANKS!!
Q&A

56 Copyright © 2014 Deloitte Development LLC. All rights reserved.


Appendix
Download HANA Studio from Deloitte SNET website:

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

58 Copyright © 2014 Deloitte Development LLC. All rights reserved.


Below are the code snippets for the views demonstrated in the session:

59 Copyright © 2014 Deloitte Development LLC. All rights reserved.


Reference Links
S/4 HANA

CDS Analytics Annotations

60 Copyright © 2014 Deloitte Development LLC. All rights reserved.

You might also like