Professional Documents
Culture Documents
Analytics Overview
– Day 2
March 2020
1
Agenda
DCL Views
CDS Parametrization
Troubleshooting
Best Practices
Deloitte Accelerators
Q&A
• A CDS role associates one or more CDS entities with CDS access control. An access condition is
defined in the role for each of these CDS entities. When a CDS entity of this type is accessed using
Open SQL or an SADL query, the access condition is evaluated as an additional selection condition.
Syntax
... WITH PARAMETERS pname1 : parameter_type, pname2
: parameter_type, ...
• This statement defines input parameters pname1, pname2 in a comma separated list. Each input
parameter must be typed with a data type parameter_type (which can be either a predefined
ABAP Data Type or an ABAP Dictionary Data Element).
• An input parameter can be used as an operand in the following places in the SELECT statement
of the view using the syntax
:pname or $parameters.pname:
• The following CDS view has a list of three input parameters used in
the WHERE clause of the SELECT statement.
@AbapCatalog.sqlViewName: 'DEMO_CDS_PARA'
define view demo_cds_parameters
with parameters p_distance_l:S_DISTANCE,
p_distance_o:S_DISTANCE,
p_unit:S_DISTID
as select from spfli
{ key carrid,
key connid,
cityfrom,
cityto,
distance,
distid }
where distid = :p_unit and
distance between :p_distance_l
and :p_distance_o;
• CDS has many standard functions which can be used in select list of view or expressions
SQL CONCAT,SUBSTRING,LTRIM,RTRIM
Conversion CURRENCY_CONVERSION, UNIT_CONVERSION
DATS_DAYS_BETWEEN,
DATS_ADD_DAYS,TMSTP_SECONDS_BETWEEN
Date/Time
Date/Time Conversion DATS_TIMS_TO_TSTMP,TSTMP_TO_DATS
Now that we have the cube with the fields and the business logic ready, we can build the CDS Query where we would provide the query
definition.
We start with the header annotations, where in addition to the usual annotations we need to include the annotation ‘@Analytics.query:
true’. This annotation tells the system that this will be our CDS Query and will not act as the Cube/Dimension/Text.
Here, apart from listing the fields required from the CDS Cube and their descriptions, we can declare field level annotations which would
define the various aspects of the report like:
• Which of the fields need to be included on the selection screen for filtering?
12
Creating CDS Query View (contd..)
• Which of the fields would show up in the rows or columns or would stay as free characteristics for drilldown in the default view?
We can use the field level annotation ‘@AnalyticsDetails.query.axis:’ to specify the field location. The possible values are #ROWS,
#COLUMNS and #FREE
• We can also, specify any additional static filters that need to applied using the where clause of the SELECT statement defining the
CDS Query.
13
Poll Question -3
This T-Code displays the metadata of the transient provider which is used at runtime for a specific CDS view (DIMENSION, HIERARCHY,
CUBE, FACT).
Can be used to
perform general check
Enter the SQL View
on the Transient
Name and execute Provider
15
Troubleshooting Tools – RSRT
T-Code RSRT can be used to display the output of a CDS Query in the same way it is used with BEx Queries.
• So for the CDS Query ZCCQ_CX_ACDOCA which has the SQL View Name ZCCQCXACDOCA, the query name to be provided in RSRT
will be 2CZCCQCXACDOCA.
16
Important Points to Remember
• Time dependent objects and Language dependent have @Semantics set. These have to be handled based on the usage in the
view.
For example, in AO, records are fetched using the key date, but we need to explicitly specify date range conditions when using in
Select List
17
Important Points to Remember
• If there are multiple keys in a Dimension, Representative Key should be the most relevant field for given entity. Other key fields
should have @objectmodel.foreignkey.association or Business semantics assigned.
For example, we take the profit center view which has 2 keys.
18
Important Points to Remember
• You cannot have input parameters passed to a Dimension, in that case you will have to build a Cube.
For example, if you want to use input date to calculate number of days then the underlying layer where you do this has to be a
CUBE type.
• Just start typing keyword and press CTRL+SPACE to get list of all annotations.
• SAP suggests using Associations instead of joins due to its features. Just make sure to use all key fields in the ON condition of
the association.
• You can extend a standard view to include custom/not available table fields. Just follow a naming convention so the objects are
not affected after upgrade.
• The CDS views are exposed as a ODP transient InfoProvider which follows 2C<SQLVIEWNAME> naming convention.
• You can check the output of the views using Adhoc Queries which follow 2C<SQLVIEWNAME>/!2C<SQLVIEWNAME>
19
Poll Question -4
• Apply filters at lower levels before the joins and calculation logic is processed
• SAP delivered base views are normally more generic and pulls in more data than that
may be needed for custom requirements.
Best Practices – Avoid filtering using DCL
• Use DCL only for Authorization restriction and not for data filtering on certain logic
Best Practices – Avoid Unions as far as possible
• If we have a where condition which uses a field from the right table, then it is better to
go with Left Outer Join than Association.
• If the fields from the right table are only used for display then Association would be
recommended
Best Practices – Avoid Non-Equi Join
• If in case we can’t avoid due to business requirement, then move those restrictions to
where clause rather having in Join Predicate
Best Practices – Effective usage of Associations
• Use Aggregation to reduce the record set involved in further computations like Joins,
calculation
• Jarvis (Report Blueprint & Code Review):still not published, only high level information shared.
31
Appendix
Below are the code snippets used in Demo:
32
THANKS!!