ABAP On HANA Topics
ABAP On HANA Topics
ABAP On HANA Topics
Done
As an Accounts Receivable accountant, you use OIA to perform the following tasks:
Check sales orders with open status.
o Table
SNWD_SO_INV_HEA
PAYMEnt_STATUS <> ‘ ‘.
Check open sales orders based on Buyer ID, Sales Order Number, and
Calendar days.
o Table
SNWD_BPA
BP_ID -> Business Partner ID
COMPANY_NAME -> Company Name
SNWD_SO_INV_HEAD
CHANGED_AT -> Calendar Days
Link: https://sapyard.com/view-the-hana-views-from-different-angles/
***How many Times views are there? And How what are they?
1. Attribute View
2. Analytical View
3. Calculation View
a. Graphical View
b. SQL Script
4. Decision Table
SQL Engine
SQL OPTIMIZER
CALCULATION ENGINE
CALCULATION VIEW
Calculation View are view with SQL Script inside
(with the calculation logic). It has Graphical &
Script based editor.
Uses
Complex data modeling. Uses both Attribute and
Analytical views Characters to be seen
Example
Created Attribute and Analytical(two or more )
joined here.
ANALYTICAL VIEW
Analytic view is typically used for analyzing ATTRIBUTE
ATTRIBUTE VIEW
VIEW
numerical data and figures. That is Numbers, Good
Good Performance
Performance JOIN
JOIN on
on Master
Master tables.
tables.
Quantities and Currencies.
Uses
Uses
Uses Only
Only Text
Text and
and Numeric
Numeric Characters
Characters to
to be
be
Whenever want to deal with Quantities, seen
seen
Price, Measures.
Example
Example
Example Join
Join on
on MARA
MARA and
and MAKT
MAKT
EKPO PO Quantity, Unit of Measure etc.
The SQL Optimizer decides the best way to call the engines depending on the involved
models and queries.
The SAP HANA architecture provides different types of engines:
Join Engine: The Join Engine used to perform all type of joins.
OLAP Engine: The OLAP Engine is used for calculation and aggregation ‚based
on star schema‛ or similar.
Few FAQs
Q. Why should we link attribute view to transactional table (fact) to create
Analytic view? What is the advantage? Why not just join tables directly to
transactional table?
A. Yes, technically, we can join tables directly to fact tables. But creating Attribute
view has more advantages and HANA adovcates modelling objects like attribute views
instead of tables.
Reasons:
i) Reusability: Attribute views are reusable building blocks and would be useful in
future developments. .
ii) Maintenance: Any change in the dimension or characteristic of the field in
Attribute view would flow downstream to all developed objects and models. We do
not need to change/update each and every development.
iii) Coherence : If we always use attribute view instead of adding the base tables,
we can ensure that all our developments are coherent.
iv) Analysis: HANA does not have ‘where-used’ search to find the tables. But we can
do the ‘where-used’ of HANA modeling objects. So, it is easier to find the views and
then figure out the tables when we want to do some analysis or investigating
something.
Q. Can there be calculative field/column in Analytical View or Attribute View?
A. Yes, we can. But any Attribute/Analytic View containing a calculation attribute
would automatically become a Calculation View.
Q. Attribute Views do not store data, then how does it display the output?
A. When Attribute Views are called for output, the Join Engine takes care of
processing the data and providing the output.
Q. Which engine is responsible for Analytic View?
A. OLAP (Online Analytical Processing) engine processes the Analytical View.
Q. How does Calculation View work?
A. Once the Calculation view is successfully generated, a column view is generated in
_SYS_BIC Schema. This column view is available to HANA reporting tools.
Q. Is Calculation View directly available for reporting?
A. No. But, Calculation view can be made available for reporting, by enabling
MultiDimensional Reporting under the Semantics section. Once it is enabled, the
execution occurs using CE (Calculation Engine) functions in the Index Server at the
database level.
Q. Between Calculation View and Analytic View, which view has
better performance?
A. Analytic View. Calculation View is executed in CE (Calculation Engine) while
Analytic View in OLAP. Calculation View is not as fast as an Analytical View.
Please note:
Analytic views with calculated attributes and Calculation views both run in
Calculation Engine.
Analytic Views (without derived columns or calculated columns) use the OLAP Engine
Q. Views analogy with SAP BW terminology
A. Attribute View is like BW Dimension which can be reused throughout the system
and not just one model.
Info Cubes or Info Sets in SAP BW are the closest cousins to Analytic View.
Q. Analytic view can have attribute view. So will the join engine of attribute
would trigger or OLAP of analytic view?
A. During activation of the analytic views, the joins in the attribute views get
‘flattened’ and included in the analytic view run time object. Only the OLAP engine
will be used thereafter.
1. Attribute View
An Attribute View can be created by taking data from one or more data
tables.
The attribute shows relationships between different attributes. The
attributes can be Customers, Region, Product, Period etc.
In an Attribute View, joins can be made between two master data tables,
a text table, and a master data table, etc.
Example:
MARA table Join with MAKT (Text Table of Material
Description)
MARA table Join with MARD (Material Plant table)
Product Dimension
Customer Dimension
2. Analytical View
Analytical Views are used to perform complex calculations and
Aggregations ie., SUM, COUNT, MAX, MIN etc.
Analytical view is designed as star schema.
Each analytical view will have one Fact table and surrounded by several
dimension tables.
Fact table will contain primary key for each dimension table.
FACT Table
Example:
Data Foundation
Star Join
Semantic
3. Calculation View
It enables the user to perform the complex calculation logic.
It combines measures from more than one fact table. It enables to combine
attribute view, analytical view and tables (fact and dimension) tables.
It supports both:
Graphical Calculation View.
Scripted ( SQL Script ) Calculation View.
While creating calculation view there are other scenario panel for data
filterationa and data joining.
Join
A join option connects two source objects or tables into a single
object. It is also referred to as a join node in the view hierarchy.
The join types between two tables can be inner, left outer, right
outer and text join.
Union
The union option performs a full outer join on n number of source
objects and creates a single object by combining their contents.
Projection
The projection option projects the table in a certain way. You can
use it to filter the columns of a table or add some columns before
using it in other nodes like aggregation, rank, union, etc.
Aggregation
In the aggregation node, you can perform aggregation on selected
dimensions and measures.
Rank
This is used to rank the values based on a criterion. You can define
the order by clause and partition in this node based on the
modeling requirements.
4. Decision Tables
Decision tables are kind of ETL rules applied on a Column. So it a table with ETL
rules wrapped in ti with Conditions and Actions.
There are few information about Decision Table but we must know when we
need it and if at all we need How to do it. Below blog post Cleary illustrates the
creation and usage of DT in SAP HANA 2.0 SPS 04
Before giving or declaring the discount the business want to analyze if we give
the discounts will it give us profit or loss etc. Decision table helps in directly
updating the value or it returns certain action on which business can decide on
further decisions.
1) Decision Table Update Value.( When the user want to change and update
the values in DB itself)
2) Decision table Return Value (If user want to add new field and change the
values).
Now let us create a decision table. For Every decision table we need to have a
condition and a action to the measure or the Key Figure KF.
I created two tables out of Sales Oder header and Item table as Below. HANA
provides excellent feature like Teradata to create a table on the fly same as a base
table. see Below : –
Create a decision table as Below : –
The first time when you create a decision table it looks like as below : –
Now add the ZVBAP_TEST table and I created that with the intention not to
affect the original VBAP table. ?
Added MATNR which is the material as the condition and NETWR to the
action as in above snapshot.
Now applying the logic of the discounts as in below snapshot. We can also
import the calculations from an excel file as well. Import from excel file I Will
cover letter.
Save Validate and Activate the data. By Default Decisions tables are created
under “_SYS_BIC” schema but we can create a decision table under any
schema if we have right previlage enabled for the Decision Table Object or
artifact.
we cannot see the data in a decision table directly in Data Preview just as we
do with a table or a CV. Whenever we create a decision table a Stored
procedure is also getting created under the “_SYS_BIC_” SCHEMA.
let us find the stored procedure and to the data in the DT we need to call the
procedure. A stored procedure is just like a function module or a executable
statement which can be used n number of times. we can call the procedure in
scripted CVS. Point to note here is that we cannot call the SP inside a TF as
Table functions are not allowed to modify database state, and stored
procedures are allowed to modify database state. Therefore, it is not
allowed to execute a stored procedure from within a function.
Now let us call the SP created for the Decision Table.
Once you call the SP you will see that data is getting updated to the base
NETWR value is DB.
You can choose a base table too when we are creating a decision table.
But ideally better not to choose the actual base table as the base table
may be used for other modelling purposes. Create a copy of the base
table and create decision table on top that. Depends on your business
scenario.
We can also feed the decision table to a calculation view and also we can use inside a
table function Node (HANA 2.0 SPS 04)
1. Text Join
Used when ever want to join Main table with text tables
2. Inner Join
Join which is always performed between tables, records are fetched
when we have matching records in both the tables.
5. Referential Join
Referential join is the default join type in SAP HANA modeling.
It is similar to inner join; evaluation of join depends on selection of
fields from view.
Example
Order Table
Customer Table and State Table
Create Attribute View for Customer and State -> JOIN is REFERENTIAL JOIN.
Output:
Studio Modeling
6. Temporal Join
In HANA to join fact with time dimension
7. Spatial Join
Co-ordinate join, used when Geo spatial analysis to be done in HANA.
Example: Find the distance between the places., ie., Distance between
Bengaluru to Mumbai via Hyderabad.
Co-ordinates are locations to find the distance
8. Star Join
In Calculation view to join 2 star schemas.
Partner Master
Customer Master
FACT Table
Customer
Partner
Supplier
Quantity
Supplier Master