Friday 19 January 2018

Spotlight on ABAP for SAP HANA – Again

The move from the classical SAP Business Suite to the Digital Core, i.e. SAP S/4HANA, places SAP HANA at the center of the game. The same is also valid when moving from traditional databases to SAP HANA – i.e. SAP Business Suite and SAP Business Warehouse powered by SAP HANA.

What does this really mean for ABAP developers?

I would like to use this blog to elaborate a bit on the topic ABAP for SAP HANA again.

Introduction


ABAP (development) for SAP HANA refers to all developments which leverage the power of SAP HANA within ABAP-based applications. In this context, the SAP HANA platform is the primary database underlying the ABAP platform. This system deployment option is supported with AS ABAP 7.4 onwards.

The introduction of the SAP HANA platform in the ABAP universe has brought a shift in the application programming paradigm. The general rule of thumb here is quite simple:

Do as much as you can in the database to get the best performance – but at same time, avoid unnecessary burden to the database.

SAP ABAP Development, SAP ABAP Certifications, SAP ABAP Guides, SAP ABAP Tutorials and Materials
The classical application programming paradigm, data-to-code, where a huge amount of data is fetched from the database, stored in internal tables and then processed on the application server, shifts to the in-memory database-powered code-to-data programming paradigm (aka code pushdown), where data-intensive computations are delegated to the database and only the result sets sent back to the application server. This reduces both memory consumption and workload on the application server, as well as the network load.

As a developer, it is important to understand the classical Golden Rules for SQL programming which are still valid for SAP HANA. However, there is a shift in the priority of these rules.

The illustration below provides a compact overview of these rules and how their priorities changes when programming on top of the SAP HANA platform.

SAP ABAP Development, SAP ABAP Certifications, SAP ABAP Guides, SAP ABAP Tutorials and Materials

ABAP-managed code pushdown


Various code pushdown programming techniques, with different levels of utilization of the advanced native SAP HANA capabilities, are available in the ABAP platform.

SAP recommends the following:

◈ Enhanced Search Help (F4 help)
◈ SAP List Viewer with Integrated Data Access (ALV with IDA)
◈ Open SQL
◈ ABAP Core Data Services (CDS)
◈ ABAP Managed Database Procedures (AMDP)
◈ ABAP CDS table functions

The graphic below shows the level of utilization of native SAP HANA capabilities – e.g. high performance and advanced business functions libraries – and indicates the relative level of effort required for their implementations. The real effort depends, of course, on how complex the requirements are and how much expertise the developers have.

SAP ABAP Development, SAP ABAP Certifications, SAP ABAP Guides, SAP ABAP Tutorials and Materials

Further code pushdown techniques are available besides the ones mentioned above: the so-called bottom-up techniques with external views and database procedure proxies, and the classical options with the ABAP Database connectivity (ADBC) API and native SQL.

These techniques are only mentioned here for the sake of completeness, but I’ll not really elaborate on them any further. The reason being that SAP does not recommend using them for efficient ABAP development on SAP HANA, meaning they should be used with caution or even better, simply avoided.

SAP List Viewer with Integrated Data Access (ALV with IDA)


ALV with IDA offers an in-memory optimized variant of the well-known ALV re-use component. With the new component, all data-centric UI operations such as sorting, grouping or aggregating are delegated to the database and thus always processed on the full data set. Constraints such as authorizations and value ranges are declared and evaluated directly on the database, and the database paging is used on SAP HANA so that only visible data is fetched from the database.

A typical basic use case is to improve the performance of an existing ALV-based application which worked with a huge amount of data. With the classical ALV, developers have to e.g. specify a truncation parameter to limit the amount of data fetched from the database and stored in internal tables. This means that data-centric operations were only performed on the fetched data which may not be the whole result set.

Enhanced Search Help (F4)


With ABAP 7.4 onwards, the functionality of a search help object (F4 Help) has been enhanced with optional type-ahead and fault-tolerant full-text search.

By just selecting the appropriate enhanced option in a search help, a google-like type-ahead search can be activated. Also known as search-as-you-type, this function offers a faster user interaction by displaying possible search results from the standard F4 help while typing in entries. In addition, a full text fuzzy search option can be activated. This function is SAP HANA-specific and offers a fault-tolerant cross-column search. No modification is required on the UI side.

The major programming techniques recommended by SAP in the context of core ABAP development for SAP HANA are on one side Open SQL and ABAP CDS views which are meant to cover the most variety of scenarios and should be the first choice for developers, and on the other side AMDP and ABAP CDS table functions which are meant to be used for special use cases where the other techniques are not suitable to cover the application requirements.

SAP ABAP Development, SAP ABAP Certifications, SAP ABAP Guides, SAP ABAP Tutorials and Materials

The mainstream techniques ABAP SQL and ABAP CDS views, which offers an extension of the ABAP database interfaces, should always be the first option for developers as they cover most application requirements in the ABAP development. But of course, there are applications with special requirements ranging from high performance requirements involving complex calculations to the access to specialized native SAP HANA function libraries and algorithms –  which cannot be fulfilled efficiently (or at all) with other options.

The code breakouts techniques AMDP and ABAP CDS table functions should be taken into consideration for such special scenarios – also called breakout scenarios. They are SAP HANA-specific and developers must provide fallback implementations for any other DB if required.

Open SQL


Open SQL is the first abstraction layer in the ABAP platform. It defines a common syntax and semantics used for accessing all relational database systems supported by SAP. Thus, allowing ABAP developers to work in a database-agnostic manner – unless making explicitly use of DB-specific features.

Code pushdown in ABAP starts with Open SQL, as it is the most known techniques of all and is used almost used everywhere when it comes to fetching data from the database.

With ABAP 7.4 onwards, Open SQL has been heavily enhanced and some of the existing limitations removed, thus, providing a broader coverage of the SQL-92 standard. A higher level of expressiveness in Open SQL statements is now possible using e.g. the rich set of built-in SQL functions and expressions, table comprehensions and enhanced JOIN capabilities.

Main characteristics & purposes:

◈ Definition of ad-hoc/single queries
◈ Non-reusable SQL statements
◈ High coverage of SQL-92 standard
◈ DML allowed
◈ Rich-set of built-in functions and expressions
◈ Table comprehension supported
◈ Direct binding into the ABAP language
    ◈ Part of the ABAP source code
    ◈ ABAP host variables within SQL statements allowed
◈ Dynamic programming allowed
◈ Flexible consumption of CDS data models and roles
◈ Coded authority checks required for classic SQL statements

ABAP Core Data Service (CDS):


CDS represents SAP’s next generation of data definition and access for database-centric applications. Technically, CDS uses and extends SQL to capture the business intent.

The CDS specification comes from the SAP HANA world, but besides the implementation provided in SAP HANA (HANA CDS), another one is provided in the ABAP platform (ABAP CDS).

The integration of CDS into the ABAP platform provides a new database abstraction layer and an advanced modelling infrastructure for defining semantically rich data models regardless of the application domains – i.e. transactions, search and analytics.

ABAP CDS represents a cornerstone technology within SAP S/4HANA, where it is used as Virtual Data Model (VDM) and within the new ABAP programming model for SAP Fiori apps.

ABAP CDS objects are created in the eclipse-based ABAP Development Tools in a text-based editor.

Main purposes and characteristics:

◈ Definition of semantically rich data models
◈ Reusable SQL statements
◈ Rich-set of built-in functions and expressions
◈ No direct binding into the ABAP language (CDS objects are consumed in Open SQL statements)
◈ No dynamic programming allowed
◈ Building view on views supported
◈ CDS associations for modeling the relationships between the different business entities as part of the data model (kind of JOIN on-demand on the conceptual level)
◈ Definition of domain-specific metadata for enriching data models
◈ Declarative access control definition as part of the data models via CDS roles (declared once and used everywhere)
◈ Request parametrization
◈ CDS table functions for accessing the advanced SAP HANA capabilities
◈ No DML allowed
◈ Where-Use list available
◈ Extensible in a modification-free manner

Open SQL vs ABAP CDS – When to use what?


When to use what? is a frequently asked question by customers and partners as both techniques seem to serve the same purpose in the ABAP platform.

ABAP CDS and Open SQL are not competitors. On the contrary, they complete each other.

There is no simple answer to this question because, yes, both extend the database interface of the ABAP platform, but different aspects have to be taken into account before making a decision. Thus what can be clearly said is that ABAP CDS and Open SQL are not competitors as they basically follow different purposes.

ABAP CDS provides the new data modelling infrastructure for building semantically rich data models in ABAP – i.e. it is the successor of SE11 when it comes to view building – whereas Open SQL is meant to be used for single queries with no re-use characters. Do not forget, that CDS views and roles can be consumed in Open SQL statements.

The table below shows a comparison of the major aspects to be taken into account during the decision process.

Open SQL ABAP CDS 
Data modelling  +
Ad-hoc / single queries 
Domain-specific metadata 
Rich set of built-in function 
Reusability 
Dynamic programming 
Direct binding into ABAP Language 
Data manipulation language (DML) 
Modification-free extensibility 
Declarative access control 
Seamless mapping to OData 
Access to advanced SAP HANA capabilities 

ABAP Managed Database Procedures (AMDP) for SAP HANA


AMDP provide a class-based framework for creating and calling SAP HANA database procedures and functions from the ABAP environment – i.e. AMDP procedures and AMDP functions. The ABAP platform is the sole master regarding the lifecycle management (creation, update, deletion and transport) of such SAP HANA entities.

The main characteristics of AMDP procedures and functions:

◈ Expression of complex logics incl. IF/ELSE
◈ Implemented in SAP HANA SQLScript
◈ Definition of local variables
◈ Parameterized requests via input parameters
◈ Multiple result sets in one roundtrip [only AMDP procedures]
◈ CUD operations supported [only AMDP procedures]
◈ Access to powerful SAP HANA function and application libraries such as predictive algorithms, text mining, geospatial and Financials

AMDP procedures and functions are implemented and debugged in the methods of properly tagged global classes (so-called AMDP classes and AMDP methods) using the eclipse-based ABAP Development Tools. They are consumed in ABAP report like any regular ABAP methods.

Various development support like syntax highlighting, static syntax checks are provided.

ABAP CDS Table Functions for SAP HANA


To keep it short: CDS table functions enable the integrate AMDP functions into CDS-based data models. Thus, providing the access to the powerful SAP HANA capabilities directly from CDS.

No comments:

Post a Comment