Sap Hana Modeling Workshop
Sap Hana Modeling Workshop
RDP361
2
In this session RDP361 you have the opportunity work on several exercises that focuses primarily on
Graphical Calculation views. However, several of the exercise also contains Script-based Calculation Views
and Analytical Views and how to integrate them all together.
Due to time constraints during the Hands-on session, it is recommended that you first take a look at the
different exercises and how long they should take you and then decide which ones you want to work
through first.
Exercise 5 (Ranking)
30 Minutes
This exercise will combine several different models (Analytical, Script-based & Graphical) to calculate and
rank customers by total revenue and amount of orders within a specific time range. Analytical views will be
used to calculated total number of orders, including aggregation of total sales. A Script-based calculation
view will be used to perform the actual ranking functions. Finally a Graphical calculation view wrapper will be
used to derive the time range from a table instead of having to prompt the user.
Explanation Screenshot
Password = Welcome13
Click Finish.
Explanation Screenshot
Explanation Screenshot
Enter
SALESORDER_BASKET_ANALYSI
S_CV for the name of the view.
Click Finish.
8
Explanation Screenshot
Explanation Screenshot
Explanation Screenshot
Explanation Screenshot
Explanation Screenshot
SO_I_KEY
NET_AMOUNT
COUNTER
Take product HT-1502 as an example. Total sales for the APJ region (includes 2 countries) for this product
equal 12 Million, total sales across all products in the APJ region equal 30 Million. The share sales number is
calculated by dividing the 2 numbers. Alternatively you can change the query to rank profitability by country
and product and then sales and total sales will be calculated by country instead of by region.
15
Explanation Screenshot
Enter
SALESORDER_DYNAMIC_JOIN_CV
for the name of the view.
Explanation Screenshot
COUNTRY
REGION
PRODUCT_ID
Explanation Screenshot
Explanation Screenshot
COUNTRY_1
REGION_1
SALES
PRODUCT_ID
Explanation Screenshot
Product ID
SALES ( as an Aggregated Column)
Explanation Screenshot
Name :
SALESORDER_DYNAMIC_TIME_PE
RIOD_AV
Explanation Screenshot
IP_StartDate
Explanation Screenshot
Explanation Screenshot
Name: CA_StartDate
(STUDENT_EXAMPLE_CODE.TXT)
Name: CA_EndDate
Explanation Screenshot
Enter the following case statement
code. (You can find a copy of the code
within session folder.)
(STUDENT_EXAMPLE_CODE.TXT)
Explanation Screenshot
SELECT
"CATEGORY","CA_StartDate","CA_EndDate",SUM("CM_NetAmount")
FROM "_SYS_BIC"."rdp361.session0.0/
Change the SQL to report on the SALESORDER_DYNAMIC_TIME_PERIOD_AV"
Previous Year’s sales. GROUP BY "CATEGORY", "CA_StartDate", "CA_EndDate"
WITH PARAMETERS (
'PLACEHOLDER' = ('$$IP_PeriodType$$', 'Previous Year')
);
30
Explanation Screenshot
SALESORDER_YEAR_COMPARISON_CV
Explanation Screenshot
NET_AMOUNT
CATEGORY
YEAR
Explanation Screenshot
Name: IP_YEAR_1
Parameter Type: Direct
Name: IP_YEAR_2
Parameter Type: Direct
string(double(midstr(string(now()),1,4))-1)
Explanation Screenshot
Click OK.
Explanation Screenshot
Explanation Screenshot
Explanation Screenshot
Explanation Screenshot
SELECT "CATEGORY",
sum("YEAR2_NET_AMOUNT") AS "YEAR2_NET_AMOUNT",
Alter the SQL statement by adding sum("YEAR1_NET_AMOUNT") AS "YEAR1_NET_AMOUNT"
input parameters and thereby FROM "_SYS_BIC"."rdp361.session0.0/
overriding the default values. SALESORDER_YEAR_COMPARISON_CV"
GROUP BY "CATEGORY"
YEAR 1 = 2011 WITH PARAMETERS (
YEAR 2 = 2012 'PLACEHOLDER' = ('$$IP_YEAR_1$$', '2011'),
'PLACEHOLDER' = ('$$IP_YEAR_2$$', '2012')
)
Select
company,
total sales,
number of orders,
sales total rank,
order total rank
from Model …
42
Name:
SALESORDER_RANKING_AV
Explanation Screenshot
Based on the order count and order total determine the ranking.
Explanation Screenshot
Name:
SALESORDER_RANKING_SQL_CV
Explanation Screenshot
BEGIN
var_out =
select
company_name, sales, orders, sales_rank, order_rank
from(
select
Change the SQL ranking code; enter company_name, sum(net_amount) as sales,
your assigned session and student count(orders) as orders, dense_rank() over
number and reference your ( order by sum(net_amount) desc )
Analytical view created in the as sales_rank, dense_rank() over
previous step.
(
order by count(orders) desc
Also, uncomment the WHERE
) as order_rank
clause line.
from
>>>> “_SYS_BIC”.”rdp361.session0.0/
Hint. Notice the where clause input
SALESORDER_RANKING_AV”
parameters that will first filter the
where
Analytical view before the ranking
functions occur on a smaller more >>>> date_sql between :IP_FR_DTE and :IP_TO_DTE
precise data-set. group by
company_name
order by
sales_rank, company_name
)
where sales_rank < 11;
END
Explanation Screenshot
Name: IP_FR_DTE
Type: Direct
Semantic Type: Date
Name: IP_TO_DTE
Type: Direct
Semantic Type: Date
The previous model requires 2 mandatory input parameters. In this exercise instead of the user specifying
the TO and FROM parameters, create a Calculation view wrapper that will automatically read the parameter
values from a table and therefore hiding the input parameters from the user.
Explanation Screenshot
Name:
SALESORDER_RANKING_CV
Explanation Screenshot
Explanation Screenshot
Click Ok.
52
Explanation Screenshot
Explanation Screenshot
Select
SALESORDER_RANKING_AV
Explanation Screenshot
SELECT
Execute the following SQL
"COMPANY_NAME","SALES","ORDERS","SALES_RANK","ORDER_RANK"
statement. Enter your assigned
FROM
session and student number.
"_SYS_BIC"."rdp361.session0.0/SALESORDER_RANKING_CV"
Decision Table
Create a decision table based on a table type, this will allow you to have a generic rule that can get re-used
assuming the data-set passed into the rule conforms to the table-type columns. The rule will take in a
customer list based on the rankings calculated in Exercise 5 and will return discounts for each customer.
Explanation Screenshot
Create a Decision Table in your assigned
package.
Name:
CUSTOMER_DISCOUNT_CALCULATION_
DT
Click Finish
CUSTOMER_DISCOUNT_CALCULATION_
TT
Click OK.
Explanation Screenshot
Info. You can view the table types in the
SYSTEM_BIC schema.
REGION
SALES
ORDERS
SALES_RANK
ORDER_RANK
Explanation Screenshot
Create a new Parameter
Name: DISCOUNT
Default Value: 1.5
Explanation Screenshot
Add the Discount as an Action.
AMEA
AMER
Click OK.
61
Explanation Screenshot
Delete the Default Value
Explanation Screenshot
Within the session folder (click on the
Student Share folder on the desktop) and
select the file called
CUSTOMER_DISCOUNT_CALCULATION_
DT.xlsx
Name:
SALESORDER_RANKING_AND_DISCOUNT_SQ
L_CV
Explanation Screenshot
CALL "_SYS_BIC"."rdp361.session0.0/
Remember to supply your session and student
CUSTOMER_DISCOUNT_CALCULATION_DT" (:var_rank,
number.
var_out);
Explanation Screenshot
Name: DISCOUNT
Data Type: DECIMAL
Length: 12
Scale: 2
Explanation Screenshot
Name:
CUSTOMER_DISCOUNT_BY_RAN
KING_AND_REGION_CV
Explanation Screenshot
Select
SALESORDER_RANKING_AND_DI
SCOUNT_SQL_CV within your own
work package folder and drag and
drop that unto the AMEA projection
node.
COMPANY_NAME
REGION
SALES
DISCOUNT
70
Explanation Screenshot
Explanation Screenshot
Explanation Screenshot
AFR
AMEA
AMER
APJ
Explanation Screenshot
Explanation Screenshot
Explanation Screenshot
Rename it to IP_AMEA
Explanation Screenshot
Rename it to IP_AMER
IP_APJ
IP_AFR
Explanation Screenshot
Explanation Screenshot
Explanation Screenshot
SELECT
"COMPANY_NAME","REGION","SALES","ORDERS",
"SALES_RANK","ORDER_RANK","DISCOUNT"
To confirm that the 6 row count is FROM "_SYS_BIC"."rdp361.session0.0/
correct execute the following SQL SALESORDER_RANKING_AND_DISCOUNT_SQL_CV"
statement against the scripted WITH PARAMETERS (
calculation view. 'PLACEHOLDER' = ('$$IP_FR_DTE$$', '20100101'),
'PLACEHOLDER' = ('$$IP_TO_DTE$$', '20130112'),
'PLACEHOLDER' = ('$$IP_REGION$$', 'APJ')
);
Explanation Screenshot
To expose models to Multi-
Dimensional reporting tools ensure
that the model is flagged as ‘Multi-
Dimensional’
Explanation Screenshot
System: coe-he-084.wdf.sap.corp
Instance: 20
Click Select
83
Explanation Screenshot
Explanation Screenshot
Finish!
85