Professional Documents
Culture Documents
ABAP On HANA - OpenSQL - AMDP - CDS
ABAP On HANA - OpenSQL - AMDP - CDS
ABAP On HANA - OpenSQL - AMDP - CDS
Anversha Shahulhameed
Lead Consultant
10-Jan-2018
Application
Mass Mass
data
Database data
Push down data intense computations and calculations to the HANA DB layer .
Avoid bringing all the data to the ABAP layer and the processing the data to do
computations.
Code-to-Data paradigm in the context of developing ABAP applications optimized for
HANA.
Open SQL allows you to access the database tables declared in the ABAP dictionary regardless of the database
platform that the R/3 system is using.
Native SQL allows you to use database-specific SQL statements in an ABAP/4 program. This means that you can use
database tables that are not administered by ABAP dictionary, and therefore integrate data that is not part of the R/3
system.
You implicitly take advantage of all transparent optimizations that have been achieved in the
Database Interface level
All default performance optimizations like use of buffer and house keeping activities like client
handling etc are automatically taken care.
Start using the new Open SQL syntax. Remember it is easy to convert your existing Open SQL
statements to new syntax without any side effects.
Use aggregate functions where relevant instead of doing the aggregations in the ABAP layer.
Use arithmetic and string expressions within Open SQL statements instead of looping over the data
fetched to do the arithmetic and string operations
Use computed columns in order to push down computations that would otherwise be done in a
long loops
Use CASE and/or IF..ELSE expressions within the Open SQL in order embed the logic of conditional
expression which in the past would have been done after fetching the results from the database.
Basic idea: support more standard SQL features(for SAP HANA as well as for
traditional database platforms)
Extended JOIN-support
it is possible to nest JOIN-statements (i.e. to specify JOINson the ‘right hand-side’ of a
JOIN-condition)
Expression support
CASE-statements can be used in the projection list, nesting is possible
Arithmetic expressions for integral, decimal and floating point calculations (e.g. +, -, *, DIV,
MOD)
String expressions (concatenation of columns with &&)
SQL functions (e.g. CAST)
SELECT product_id && ',' && @space && category AS product, concatenation of columns
CASE tax_tarif_code
WHEN 1 THEN price * @lc_factor_1
WHEN 2 THEN price * @lc_factor_2 CASE-statement
WHEN 3 THEN price * @lc_factor_3
END AS price_vat, projection list separated by
currency_code AS currency commas
FROM snwd_pd
INTO CORRESPONDING FIELDS of @ls_result ABAP constants / variables
WHERE product_id IN @so_prod. escaped by @
WRITE: / ls_result-product,
ls_result-price_vat CURRENCY ls_result-currency,
ls_result-currency.
ENDSELECT.
Maximum number of tables supported in Open SQL JOIN clauses has been increased to 50
Maximum number of sub-queries supported in an Open SQL statement has been increased from
9 to 50
INTERSECT
Returns the distinct rows from both SELECT column name(s) FROM table1
the tables
WHERE <CONDITION1>
UNION ALL / INTERSECT/EXCEPT
SELECT column name(s) FROM table2
EXCEPT WHERE <CONDITION2> ;
Returns distinct rows from left table
that aren’t in the right side table
Performance adjustments
Code-to-Data Paradigm
Overview Code-to-Data ---- Top-Down Approach (≥ NW AS ABAP 7.40 SP05)
CDS Views
A Database-oriented programming model is supported better through:
A new and advanced Open SQL, supporting considerably more of the SQL-92
standard
New capabilities to define views. Definition capabilities were extended to have a Tight-
Database-Programming-Model by introducing a common set of domain-specific
languages and services for defining and consuming semantically rich data models –
called Core Data Services
Annotations
View Name
Joining
conditions
Session 1
AMDP- Advantages
Compare Database Procedure as a function stored and executed in the database.
In SAP HANA implementation language is SQLScript.
Allowing developers to write database procedures directly in ABAP
Only the AMDP class has to be transported with ABAP transport mechanism.
AMDP manages SQLScript source code in AS ABAP
AMDP integrates SQLScript syntax check in ABAP syntax check
AMDP creates and manages stored procedure runtime objects on HDB in the ABAP AS
database schema
AMDP- Features
Static check code and Syntax coloring are provided for embedded SQLScript
The user can set a Background color for better visibility AMDP methods in the class.
The User can access other AMDP methods, ABAP dictionary view and ABAP tables in AMDP method.
AMDP method are called like other regular ABAP methods.
User can perform detailed analysis of various error during runtime in transaction ST22
Modification or Enhancement of regular ABAP classes can be done by Users.
AMDP- Prerequisites
Classes which will act as a container for AMDPs have to implement a so called
Marker Interface IF_AMDP_MARKER_HDB.
AMDP- Implementation
Lead Consultant