2. Table of Contents
SAP HANA
What is Code-To-Data?
Where does Code push down start?
Open SQL
Open SQL: Extended Features
Core Data Service(CDS)
ABAP Managed Database Procedure
3. Code-To-Data
Key difference for developing applications in ABAP for
HANA is to push down data intensive calculation to the HANA
DB layer
Processing of data is done at DB layer, instead of bringing
data to the ABAP Layer and then doing computation
This is what termed as Code-to-Data paradigm
4. Where does Code push down starts?
General misconception about it i.e. to use either HANA native
SQL or build complex HANA artefacts.
SAP provides a few ways to implement ‘code pushdown’
approach which are as follows:
Open SQL
CDS Views
ABAP Managed Data Procedures(AMDP)
5. 1. Open SQL
Allows developers to perform database operation on
traditional DB, regardless underlying RDBMS
Open SQL written in program is converted by the kernel into
Native SQL and then executed on actual RDBMS
In order to make use the advanced feature of Open SQL one
needs to accommodate minor change as shown on next
slide
6. Open SQL
As shown in above code snippet the changes are the following in
terms of syntax
The column list needs to be separated by commas
The host variable used within the open SQL statement needs to be
escaped by an “@” symbol.
7. Open SQL : Extended Features
Support for arithmetic and string expression and computed
columns in the projection list.
Literals
Operators: +,-,*,/, etc,
Built in function e.g. CONCAT ,Substrings etc.
CAST and CASE expression
Specially built-in functions:
Currency and unit conversion
COALESCE
8. Ways of achieving Code push Down using open
SQL
Use aggregate function where relevant
Use arithmetic and string expression within Open SQL statements
Use computed columns in order to push down computation
Use CASE and/or IF….ENDIF expression within open SQL in order
to embed the logic of conditional expression
10. 2. Core Data Services(CDS)
It is data modeling infrastructure for defining & consuming
semantic & re-usable data models on database
SQL like language ,provides an open source Data Definition
Language for creation of Database artefacts
CDS can be used to create tables , views, data types,
CDS views, are in many ways similar to standard view that
would be defined in se11
Main difference that CDS view resides on the HANA DB itself
therefore can be consume by non-ABAP application also
Can only be created in Eclipse(by utilizing ADT) and not in SAP
GUI
12. Terminology related to CDS view
Annotations: The term Annotation implies attaching data to
another piece of data
Generally used annotations are as follows:
AbapCatalog.sqlViewName: Name of the CDS Database View
AbapCatalog.compiler.compareFilter – Defines the evaluations of filter condition in path
expression of the CDS view
EndUserText.label : Translatable short text of the CDS view
AccessControl.authorizationCheck : Defines the implicit access control when Open SQL is
used to access
Each active ABAP CDS view has corresponding ABAP dictionary
view and database view. These corresponding objects are
managed automatically by the ABAP system when activating
DDL source.
13. CDS View with parameter
CDS view with parameter execution through SE11 is not yet supported
To use CDS view with parameter we need to consume this view directly in
class or ABAP report
E.g. Use of above CDS view ( Z_CDSVIEW_VBRK) in report
Z_TEST_HANA_CDSVIEW1
15. Joins in CDS view
Inner Join or Just Join – Selects all entries in both tables which meet ON
condition
16. Left Outer Join
Left Outer Join – Selects all record from the left table matching with the right table
which meet ON condition. If no record found in second table those record fields are
null
17. Right Outer Join
Right Outer Join - Selects all records from right table matching with left table which
meet ON condition . If no records are found in left table those record fields are null
18. Full Outer Join
The FULL JOIN keyword returns all the rows from the left table ,and all the
rows from the right table
If there are rows in the left table that do not have matches in right table or if
there are rows in right table that do not have matches in left table , those
rows will be listed as well
Conceptual Entity
19. 3. ABAP Managed Database Procedure
AMDP are specialized ABAP methods that allow the creation of
database procedure written in DB specific language
The basic idea of AMDP is to manage HANA procedure and their
lifecycle inside the ABAP server.
To use AMDP with HANA, the developer would create a method
written in SQLscript that could be directly executed upon in the
database layer
Classes that implement AMDP methods are required to
implement specific interface (In case of HANA it is
IF_AMDP_MARKER_HDB)
20. ABAP Managed Database Procedure
The method that actually implements the SQLscript would then
need to specify it’s purpose with specific addition . An example
21. ABAP managed Database
BY DATABASE PROCEDURE - Identify this method as AMDP
FOR HDB – The HDB part identifies this is procedure for HANA.
LANGUAGE SQLSCRIPT - This identifies the language that will be
used within the method . SQLSCRIPT is the language that the
HANA DB uses, and is the language that must be used with the
AMDP method.
USING xxxxx – Any code within the AMDP method has no
knowledge of any DDIC types. To specify the use of a table OR a
view , you need to call out the tables that will be used as the
part of the method header (where XXX is Table OR view name)
22. ABAP Managed Database Procedure
AMDP allows developers to create and manage stored
procedures directly in ABAP, while they are executed at
database level
Though the AMDPs are defined on the ABAP level, they are by
nature dependent on the underlying database platform, so that
they can fully optimize the database in use
The implementation language for the AMDP varies according to
the Database in use, For SAP HANA it is SQLscript.
24. AMDP Restrictions
RETURNING parameters cannot be used
Parameters have to be passed by VALUE
Parameters can only be either Table OR Scalar . That means ,only
variables, structures and simple internal tables can be passed .
No deep structure , no complex tables( i.e. Nested Tables)
IF ABAP dictionary structures are used for typing ,the method
cannot be implemented as an AMDP
Whatever Dictionary tables, views ,other procedures etc you
want to use in AMDP methods has to be declared while
implementing using keyword USING