0% found this document useful (0 votes)
234 views

Reading Sample Sap Press Abap Development For Sap Hana

Uploaded by

Ashutosh Jha
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
234 views

Reading Sample Sap Press Abap Development For Sap Hana

Uploaded by

Ashutosh Jha
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 34

First-hand knowledge.

Browse the Book


ABAP-managed database procedures can be leveraged to optimize
nonnative, ABAP-based applications such as programs, forms, and
interfaces by leveraging the code pushdown features supported by SAP
HANA database. In this chapter you will learn to define and implement
AMDP methods.

“ABAP-Managed Database Procedures”

Contents

Index

The Authors

Mohd Mohsin Ahmed, Sumit Dipak Naik


ABAP Development for SAP HANA
643 Pages, 2021, $89.95
ISBN 978-1-4932-1877-6

www.sap-press.com/4954
Chapter 6
ABAP-Managed Database Procedures
ABAP-managed database procedures can be leveraged to optimize non-
native, ABAP-based applications such as programs, forms, and interfaces
by leveraging the code pushdown features supported by SAP HANA 6
database. In this chapter you will learn to define and implement AMDP
methods.

In Chapter 2, we briefly introduced you to the code pushdown paradigm, which helps
developers optimize business applications on the SAP HANA database. This chapter
will include an emphasis on ABAP-managed database procedures (AMDPs), one of the
recommended approaches to achieve code pushdown functionalities.
In this chapter, we’ll start by covering essential aspects like the motivation behind
introducing AMDPs, including how they are created and consumed in business appli-
cations in Section 6.1. We’ll then show you how to create AMDP classes in Section 6.2
and also explore the concepts behind enhancements using AMDPs in Section 6.3.
Next, we’ll turn to exception handing in Section 6.4 and explore different debugging
tech- niques to analyze your procedures in Section 6.5. We’ll conclude this chapter on
AMDPs tools in Section 6.6.

6.1 Introduction
Let’s briefly recap some information you learned earlier in this book about code push-
down. In the classic style of coding, as shown in Figure 6.1, developers used to design
applications by retrieving all the data at once using database array operations such as
FOR ALL ENTRIES, JOIN, or ABAP Dictionary views. This approach reduced loads on data-
base servers by limiting data transfer requests between the application and the data-
base server.
Subsequent data processing operations are performed on the application server’s
internal table to achieve the desired results. However, this approach’s drawback was
the formation of complex SQL queries to retrieve data. Performance issues arose
because unnecessary data was retrieved, filtered, and processed in the application
layer.

159
6 ABAP-Managed Database Procedures 6.1 Introduction

view changed. These shortcomings were later handled with the release of SAP Net-
Classical Database New Approach
Weaver AS ABAP 7.4 SP05 by introducing progressive code pushdown techniques like
ABAP-managed database procedures (AMDPs) and core data services (CDS). These tech-
Presentation Layer niques are referred to as top-down approaches because the entire lifecycle manage-
Presentation Layer ment is conducted by the ABAP layer. SAP HANA artifacts such as views and
Data-to-Code
Data Operations (Calculations, Aggregations) procedures are automatically created in the database.

Data retrieval Bottom-up approach Top-down approach


6
Application Layer Application Layer
Code-to-Data Lifecycle management in SAP HANA and ABAP stackLifecycle Management in ABAP stack only
Data requested Data retrieval

Data Operations (Calculations, Aggregations)

Database Layer Database Layer < 7.4 SP02 > 7.4 SP02 > 7.4 SP05
SAP HANA ABAP
transport container AMDP CDS transport (CTS)
Oracle or any database SAP HANA database Native SQL Proxy objects

AS
Created on first method call
Figure 6.1 New Programming Approach

Delivery unit Created automatically when CDS is


This fundamental change to the ABAP programming model in favor of pushing code SAP HANA SAP HANA
Database procedures SAP HANA
views procedures views procedures
views

SAP
and data processing to the database is called the code-to-data paradigm, shown in
Figure 6.1, instead of the classic data-to-code approach.
Package
In SAP HANA, several code-to-data techniques are available for implementing data-
intensive calculations in the database layer. SAP HANA performs data-intensive calcu-
lations in the database layer using SAP HANA views or procedures. These artifacts are Figure 6.2 Code-to-Data Approach
later utilized in ABAP applications using several code-to-data techniques. Whether or
not you should use these techniques depends on the SAP NetWeaver Application For example, when an AMDP class and method are defined, a procedure is created in
Server for ABAP (AS ABAP) release used in your landscape. the database before an AMDP method is called for the first time in the calling program
As shown in Figure 6.2, if you are using SAP NetWeaver AS ABAP 7.4 SP02 or lower, SAP and updated on the subsequent calls if it has been changed. In contrast, in the case of
HANA repository objects, such as SAP HANA views or procedures, are directly a CDS view, the SAP HANA view is created when the CDS view is activated.
accessed in ABAP applications using native SQL. With SAP NetWeaver AS ABAP 7.4
SP02 or higher, these objects are accessed in ABAP applications using ABAP proxy 6.1.1 ABAP-Managed Database Procedure Framework
objects such as external views or database procedure proxies to overcome the limitations
AMDPs are a recommended technique for achieving code pushdown functionality if
of using native SQL.
your underlying database is SAP HANA. The framework uses a top-down approach to
The techniques used before SAP NetWeaver AS ABAP 7.4 SP05 are known as bottom- create and manage database procedures in the ABAP environment. The AMDP frame-
up approaches because SAP HANA views or procedures are created in the database work guarantees that the complete lifecycle of the AMDP procedure—from creating,
layer. The views are created using a database user in the Modeler perspective and later changing, activating, and transporting the procedure—occurs in the application layer
con- sumed in the ABAP layer using Native SQL or proxy objects. Although these by the ABAP runtime environment.
techniques offer the benefit of performing the data processing in the database layer,
As a developer, you’ll write procedures in an AMDP method implementation of an
one limitation of using a bottom-up approach is its complex lifecycle management
AMDP class. In contrast to the traditional ABAP method, an AMDP method is a
requirements. For example, handling SAP HANA repository objects must occur
unique method and implements database-specific programming languages, such as
separately through deliv- ery units and ABAP proxy objects by using the SAP HANA
SQLScript, native SQL, and L (used internally by SAP). The keyword LANGUAGE specifies
transport containers to import objects to other systems. Additionally, developers must
the database- specific language for implementing the procedure.
ensure proper synchro- nization of all SAP HANA artifacts in all the environments
whenever any procedure or

161
160
6 ABAP-Managed Database Procedures 6.1 Introduction

As shown in Listing 6.1, the usage of the keyword BY DATABASE PROCEDURE in the imple- ■ Currently, the AMDP framework only supports database procedures for SAP HANA
mentation section of the AMDP method helps differentiates whether the method uses databases. However, SAP has designed the framework to support stored procedures
ABAP or any other language to implement the procedure.
for other databases.
AMDP Class Definition ■ You can only create or edit an AMDP using the Eclipse-based ABAP Development
CLASS zcl_amdp_example DEFINITION Tools (ADT). Thus, the classic SAP GUI-based class builder (Transaction SE24) is not
PUBLIC
suitable for managing an AMDP class and its methods, as only the display function
FINAL
CREATE PUBLIC. is supported in Transaction SE24. 6
■ Developers classified as standard ABAP users with appropriate authorizations can
PUBLIC SECTION. manage database procedures using an AMDP class, and Transaction SICK can
detect missing permissions.
AMDP Marker Interface
INTERFACES if_amdp_marker_hdb.
Benefits of Using AMDPs
AMDP Method 6.1.2 Development Environment for AMDP
CLASS-METHODS amdp_method Let’s discuss a few benefits of using AMDPs:
Importing parameter defined using Dictionary Using
■ AABAP Development
standard ABAP userTools (ADT) isanmandatory
can manage for creating
AMDP, unlike and changing
in bottom-up techniquesAMDPs,
like
type IMPORTING VALUE(im_input) TYPE matnr as the SAP
classic
HANA views and procedures, where both ABAP and SAP HANAfunction.
SAP GUI-based Transaction SE24 only supports the display databaseADT
Importing parameter defined using ABAP type
users are required.
EXPORTING VALUE(ex_output) TYPE i
Importing parameter defined using TABLE type ■ The AMDP framework is responsible for communicating with the database
CHANGING VALUE(ch_param) TYPE ttyp_d. and automatically creating the database procedures as SAP HANA repository163
catalog objects.
PROTECTED SECTION.
■ The entire lifecycle management to synchronize, create, change, activate, and
PRIVATE SECTION.
transport procedures is performed in the ABAP layer.
ENDCLASS.
■ The ABAP perspective within ADT serves as a development environment for
AMDP Class Implementation writing and managing your SQL scripts.
CLASS zcl_amdp_example IMPLEMENTATION. ■ The framework supports full integration of SQLScript syntax check and
debugging into the ABAP environment.
AMDP Method Implementation
■ Even though an AMDP might be implemented using a database-specific
METHOD amdp_method BY DATABASE PROCEDURE
FOR HDB language, such as native SQL or SQLScript, the ABAP environment still evaluates
LANGUAGE SQLSCRIPT. source code for any syntax errors.
--Implement SQLScript Code ( Database specific code ) ■ Procedures are automatically created in the SAP HANA database by the ABAP
ENDMETHOD. run- time environment before the first AMDP method call.
ENDCLASS.
■ You can extend an AMDP using Business Add-Ins (BAdIs) if it has an extension
Listing 6.1 AMDP Framework Definition pro- visioned by the software provider.
■ An AMDP is not a replacement for database procedure proxies, which are still
In general, you should consider the following points before creating or consuming an con- sidered in sidecar scenarios with secondary database connections to access
AMDP: SQL- Script procedures in a different SAP HANA database.

162
6 ABAP-Managed Database Procedures 6.1 Introduction

also delivers additional features for developers to work effectively with AMDPs and Select General • Appearance • Colors and Fonts • ABAP, as shown in Figure 6.5. Then,
improve developer productivity and efficiency. select Embedded language under Syntax Coloring and click Edit... to modify the color
Some features delivered by ADT for managing ADMPs include the following: according to your preferences.

■ Code completion functionality for ABAP, accessed by pressing (Ctrl) + (Space)


■ SQLScript syntax check available in the ABAP environment
■ Highlighting of syntax errors in SQLScript
6
■ Analysis of AMDP methods via the debugging functionality
■ Highlighted usage of embedded language to distinguish between database-specific
language and ABAP code

Let’s take a look at some of the features supported by ADT next.


As shown in Figure 6.3, the SAP GUI-based class builder (Transaction SE24) does not
allow you to edit an AMDP class and only supports display function; thus, ADT is the
preferred development environment for AMDPs.

Figure 6.5 Modifying Colors and Fonts of the Form-Based Editor

In ADT, SQLScript syntax error is fully supported and integrated into ABAP. This can be
seen by toggling the cursor on the error marker on the right-hand side of the form-
based editor. The detailed SQLScript syntax errors can be seen by toggling the cursor
on the error, as shown in Figure 6.6.

Figure 6.3 SAP GUI-Based Class Builder (Transaction SE24)

In ADT, the appearance of the form-based editor can be changed by the developer to
highlight syntax errors and to differentiate between the embedded (database-specific)
language and the ABAP language. To enable syntax highlighting, navigate to Win-
dows • Preferences, as shown in Figure 6.4.

Figure 6.6 SQLScript Syntax Errors

In ADT, you can also highlight the SQLScript syntax errors at the point where they
occur. As shown in Figure 6.7, the syntax error statement SFLIGHT is emphasized in
amber color. Additionally the detailed syntax error description can also be seen on the
right-hand side of the source code editor.

Figure 6.4 Preferences for the Form-Based Editor

164 165
6 ABAP-Managed Database Procedures 6.2 Creating AMDP Classes

code shown in Listing 6.2 illustrates a simple AMDP definition implementing all the
required prerequisites. These prerequisites are as follows:
■ An AMDP class definition should contain a marker interface IF_AMDP_MARKER_HDB, as
it implements an AMDP method for the SAP HANA database.
■ In the class definition, the AMDP method parameter types should be a dictionary,
ABAP (for example, integer or character), or table types. For parameters with table
types, the line types should contain elementary components because nested tables 6
are not supported.
■ An AMDP method can only contain importing, exporting, and changing
parameters. An AMDP method cannot have return parameters.
■ Similar to remote function call (RFC) parameters, all method parameters should be
Figure 6.7 Emphasizing SQLScript Errors and Differentiating between ABAP and Database defined as pass by value. Pass by reference in the method definition is not permitted.
Specific Code
■ An AMDP method can be defined in the PUBLIC SECTION, PRIVATE SECTION, or
PROTECTED SECTION of the class. However, if the AMDP methods of other classes do
In the AMDP method, you can also set the background color of the embedded
not call the method, you must declare the method as PRIVATE.
language to differentiate between ABAP and database specific code such as SQLScript.
Set the color using the same process we discussed earlier in Figure 6.4: navigate to CLASS zcl_amdp_demo_01 DEFINITION
Windows • Preferences • General • Appearance • Colors and Fonts • ABAP • Embedded PUBLIC
FINAL
language. Figure 6.7 you can see that the background color for database-specific
CREATE PUBLIC.
syntax is empha- sized in gray color.
PUBLIC SECTION.

AMDP Marker Interface


6.2 Creating AMDP Classes INTERFACES if_amdp_marker_hdb.

A global class must be defined in the class library using ADT to create an AMDP Type Declaration
proce- dure. A class is categorized as an AMDP class if its definition contains one or TYPES: BEGIN OF d_flight,
carrid TYPE s_carr_id,
more tag interfaces. The tag interfaces are prefixed with IF_AMDP_MARKER and end in a
connid TYPE s_conn_id,
suffix indi- cating database system for which the procedure is implemented.
bookamt TYPE s_f_cur_pr,
In the following sections, we will understand several prerequisites that you should loccurkey TYPE s_currcode,
con- sider while defining and implementing an AMDP method. You will also learn to END OF d_flight.
con- sume AMDP and check if current database (or a database specified using a TYPES: tt_flight TYPE STANDARD TABLE OF d_flight.
database connection) supports the AMDP features in the ABAP applications.
AMDP Method Definition
CLASS-METHODS get_flight_data
IMPORTING
Example
VALUE(iv_filters) TYPE string
6.2.1 Prerequisites
The marker interface IF_AMDP_MARKER_HDB is relevant for SAP HANA database, where VALUE(iv_client) TYPE sy-mandt
An HDB
AMDP class that
indicates can be
thecomprised ofintended
procedure is one or more
for antraditional
SAP HANA and AMDP methods. It
database. EXPORTING
can also contain AMDPs for each database system specified by a tag interface. The VALUE(e_flight) TYPE tt_flight
source

166
167
6 ABAP-Managed Database Procedures 6.2 Creating AMDP Classes

CHANGING
CLASS zcl_amdp_demo_01 IMPLEMENTATION.
VALUE(c_return) TYPE i METHOD get_flight_data BY DATABASE PROCEDURE
FOR HDB
RAISING cx_amdp_no_connection LANGUAGE SQLSCRIPT
cx_amdp_execution_error. OPTIONS READ-ONLY
PROTECTED SECTION. USING sflight sbook.
PRIVATE SECTION.
ENDCLASS. Data selection from data sources using SQLScript 6
Listing 6.2 AMDP Class Definition E_FLIGHT = SELECT a.carrid,
a.connid,
sum(loccuram) AS bookamt,
6.2.2 Implementing AMDP Methods b.loccurkey
FROM sflight AS a INNER
An AMDP method is a unique method that optimizes ABAP applications by imple- JOIN sbook AS b
menting code pushdown from the application server layer to the database layer. This ON a.carrid = b.carrid
method is wrapped in a global class and can be defined as either a static method or AND a.connid = b.connid
instance method. Even though you can define an AMDP method as an instance WHERE a.mandt =
:iv_client
method, it will always be executed as a static method call.
GROUP BY A.carrid, a.connid, b.loccurkey;
Two types of AMDP methods exist:
Filter based on the selection screen criteria
■ An AMDP procedure without a return code is defined by a method using the addi-
E_FLIGHT = APPLY_FILTER( :E_FLIGHT, :iv_filters );
tion BY DATABASE PROCEDURE.
■ An AMDP function with a return code is defined by a method using the addition BY ENDMETHOD.
DATABASE FUNCTION. ENDCLASS.

Any regular method within an AMDP class can be transformed into an AMDP method Listing 6.3 AMDP Method Implementation Example
by using either the BY DATABASE PROCEDURE or BY DATABASE FUNCTION addition at the
start of the method statement in the method implementation part, followed by the Listing 6.3 contains the following elements:
database system for which the procedure is implemented, the language in which the ■ A global AMDP class implementation contains the AMDP method implementation.
business logic is written, and the mandatory ABAP objects (which may include In our example, our AMDP method will summarize total flight sales by airline and
transparent tables, views, and other AMDPs that are used as data sources). flight code.
Additionally, you can mark an AMDP method as READ ONLY using the addition OPTIONS, ■ The method GET_FLIGHT_DATA is implemented as an AMDP method since the method
which is optional. is defined with the addition BY DATABASE PROCEDURE.
The body of an AMDP method, shown in Listing 6.3 uses database-specific language ■ What follows is the database addition HDB to implement the procedure for the SAP
such as SQLScript or native SQL. The source code shown in Listing 6.3 illustrates an HANA database. The AMDP framework only supports SAP HANA database; however,
AMDP class and method with database-specific logic using SQLScript to summarize the framework is designed to work with other databases.
sales by airline and flight code. The procedure also filters records based on the ■ Further, the database-specific language to be used is specified. In this case, SQLScript
selection screen using the FILTER keyword. To implement business logic, you can use will be used in the AMDP method to implement the business logic.
the full SQLScript reference, except for calculation engine (CE) functions such as the ■ All database objects, such as dictionary tables, views, and other AMDP methods
following: used as data sources within the method body, must be declared explicitly with the
■ CE_LEFT_OUTER_JOIN key- word USING. These objects can be accessed directly, that is, without the need to
■ CE_COLUMN_TABLE prefix these objects with SAP<SID> (Schema). However, for nested AMDP calls, that
is, for
■ CE_UNION_ALL

168 169
6 ABAP-Managed Database Procedures 6.2 Creating AMDP Classes

AMDP methods called inside an AMDP body, you should specify objects by their
full names, that is, with the class they belong to and the method name in uppercase
and closed in double quotation marks.
■ You must ensure that any objects that are not part of SAP<SID> schema are available
at runtime since these objects are not managed and therefore are not included in
the USING clause.
■ Finally, the SQLScript language is used within the AMDP body to write the business
6
logic that is executed in the database layer.
Figure 6.8 Consuming AMDP Method in ABAP (Eclipse)
■ The procedure results are filtered using the SQLScript function APPLY_FILTER based
on the selection criteria provided as an importing parameter to the AMDP method.
■ The procedure written in the AMDP body is highlighted in gray to differentiate
between ABAP-specific language and database-specific language. Refer to Figure
6.4 to see how to set the color for the editor’s background.

You should consider the following restrictions when implementing an AMDP method:
■ Data definition language (DDL) such as Create, Alter, or Delete are not allowed to
create, change, or delete any database objects.
■ You cannot access local temporary data objects, such as internal tables, or variables
defined in the class definition in the method implementation.
■ Statements like database commits and rollbacks are not allowed in the method
body. Also, to avoid data inconsistencies between procedures, you should handle Figure 6.9 Consuming AMDP Method in ABAP (SAP GUI)
logical units of work separately in the ABAP program.
■ You cannot extend AMDP methods using implicit enhancement options, as these However, to consume an AMDP, the SAP NetWeaver AS ABAP’s central database should
methods are directly executed on the database, and implicit options are not avail- be managed by the database system for which the AMDP method is implemented. If
able within an AMDP method. not the case, then the procedure call results in a runtime error.

■ While using data manipulation language (DML), such as INSERT, UPDATE, MODIFY, As shown in Figure 6.10, before the first method call, the ABAP runtime environment
DELETE, etc., write access to buffered tables is not allowed. creates the procedure implemented in the AMDP method in the database system
or updates any existing database procedure if the AMDP has changed, as shown in
Figure
6.2.3 Calling AMDP Methods in Applications 6.11. Once the method is called, the execution is performed in the database system.
An AMDP method is called in an ABAP application similar to any other regular Parameters of the interface are passed from the native SQL interface to the database
method, using an Eclipse-based form editor in ADT or through SAP GUI-based system or are applied by the database system.
transactions. These methods are always executed as static method calls, even if
defined as instance methods.
You can call an AMDP method in an ABAP application in several ways. In the Eclipse-
based ABAP perspective (see Figure 6.8), you can use the code completion template by
pressing (Ctrl) + (Space) to call an AMDP method. In SAP GUI-based editors (see
Figure 6.9), you can use ABAP-based patterns by pressing (Ctrl) + (F6).

Figure 6.10 AMDP Method Called in Application

170 171
6 ABAP-Managed Database Procedures 6.2 Creating AMDP Classes

bookamt TYPE s_f_cur_pr,


loccurkey TYPE s_currcode,
END OF d_flight.

" Internal table


DATA: gt_flight TYPE STANDARD TABLE OF d_flight.

" Variable 6
DATA: gv_return TYPE i.

" Build dynamic where clause, and pass it to the AMDP method
Figure 6.11 AMDP Procedure Created on the Database
TRY.
DATA(lv_where_clause) = cl_shdb_seltab=>combine_seltabs
Once a database procedure managed using AMDP has been created (ZCL_AMDP_DEMO_01 (it_named_seltabs = VALUE #(
=>GET_FLIGHT_DATA) on the database schema, SAPABAP2, as show in Figure 6.11, this proce- ( name = 'CARRID' dref = REF #( s_carrid[] ) )
dure can be called from other database procedures using the database syntax, ( name = 'CONNID' dref = REF #( s_connid[] ) ) ) ).
provided that the database permits this access, including AMDP procedures (or CATCH cx_shdb_exception INTO DATA(lref_shdb_exception).
DATA(lv_meesage) = lref_shdb_exception->get_text( ).
database proce- dures) that are not managed by AMDP. If an AMDP procedure calls
ENDTRY.
another procedure, this procedure must be specified in the calling method with the
addition USING.
In general, we recommend that AMDP procedure implementations that are not called " AMDP Method Call
TRY.
from AMDP methods of other classes be created as private methods of an AMDP class
and that they be called in regular ABAP methods.
zcl_amdp_demo_01=>get_flight_data( EXPORT
ING
Note iv_filters = lv_where_clause
iv_client = sy-mandt
In database systems that do not support AMDP, a traditional method can be created
IMPORTING
using aninalternative
As shown implementation
Listing 6.4, in Open SQL
an ABAP application can or native
call SQL. procedure to display
an AMDP e_flight = gt_flight
flight booking information based on a user’s selection. The example also illustrates the CHANGING
use of SELECT-OPTIONS to filter data records. c_return = gv_return ).
" Error Handling
REPORT zcl_amdp_demo_call_01. CATCH cx_amdp_no_connection INTO DATA(lref_no_connection).
DATA(lv_error) = lref_no_connection->get_text( ).
" Data declaration CATCH cx_amdp_execution_error INTO DATA(lref_amdp_execution_error).
DATA: gwa_sflight TYPE sflight. lv_error = lref_amdp_execution_error->get_text( ).
ENDTRY.
" Select Options
SELECT-OPTIONS: s_carrid FOR gwa_sflight-carrid, " Display results
s_connid FOR gwa_sflight-connid. IF lv_error IS INITIAL.
cl_demo_output=>display_data(
" Types Declaration EXPORTING
TYPES: BEGIN OF d_flight, value = gt_flight
carrid TYPE s_carr_id, name = 'Flight Booking information').
connid TYPE s_conn_id,

172 173
6 ABAP-Managed Database Procedures 6.2 Creating AMDP Classes

" Error Handling An ABAP report can consume an AMDP method, as shown in Listing 6.5, filtering data
ELSE.
based on the user selection via parameters or based on SELECT-OPTIONS to display
WRITE: lv_error.
ENDIF. book- ings for all airline codes by a specific date and customer category.

Listing 6.4 AMDP Method Call in ABAP Application REPORT zamdp_sflight_details.

* Data declaration
6.2.4 Using Multiple Selection Criteria DATA: gwa_sflight TYPE sflight. 6
In ABAP reports, defining a selection screen is essential to empowering business users
* Selection screen
so they can filter data based on the desired elements. Selection criteria ensure that
PARAMETERS: p_date TYPE s_date.
applications can process data faster by filtering out unwanted data in the database
layer. But, to filter the data, you must define selection criteria using parameters, SELECT-OPTIONS: s_carrid FOR gwa_sflight-carrid,
SELECT-OPTIONS, or a combination of both. s_connid FOR gwa_sflight-connid.
The purpose of parameters is to filter the records based on a single value, whereas
* Build dynamic where clause
with SELECT-OPTIONS, you can define complex selection criteria to filter out records.
TRY.
Develop- ers can then use these selection screen elements directly in a WHERE clause of DATA(lv_where_clause) = cl_shdb_seltab=>combine_seltabs(
an Open SQL statement to filter the data. These selection criteria are then converted it_named_seltabs = VALUE #(
into the SQL WHERE conditions by the ABAP application server. ( name = 'CARRID' dref = REF #( s_carrid[] ) )
However, suppose you want to use these selection screen elements in an AMDP proce- ( name = 'CONNID' dref = REF #( s_connid[] ) )
)
dure. In this case, you can use parameters directly in the AMDP method, but this
iv_client_field = 'MANDT' ).
approach is not valid with SELECT-OPTIONS.
CATCH cx_shdb_exception INTO DATA(lref_shdb_exception).
Because you cannot pass SELECT-OPTIONS directly to an AMDP method, this limitation DATA(lv_meesage) = lref_shdb_exception->get_text( ).
of using an AMDP must be kept in mind. To pass SELECT-OPTIONS to an AMDP method, ENDTRY.
you must first transform the selection criteria into a filter string and then pass the
string as an IMPORTING parameter to the AMDP method. To convert the SELECT-OPTIONS * AMDP Method call to summarize booking amount by flight, airline code,
(selection tables or range tables) into a dynamic SQL WHERE clause, you can use the static date, and customer type
zcl_amdp_sflight_details=>get_data( E
method COMBINE_SELTABS( ) of the new class CL_SHDB_SELTAB.
XPORTING
This generated condition can then be used in SQLScript to filter the data source using iv_client = sy-mandt
the SQLScript function APPLY_FILTER in the AMDP method implementation. This func- iv_date = p_date
tion can be applied to database tables, views, and SAP HANA views, however this iv_filters = lv_where_clause
IMPORTING
func- tion cannot be used with analytical or table variables.
et_results = DATA(gt_results) ).
The APPLY_FILTER function expects two parameters. The first parameter is the data
source to which you want to apply the filter, and the second parameter is the * Display results
generated WHERE clause, which is passed as a string argument. cl_demo_output=>display_data(
EXPORTING
The CL_SHDB_SELTAB class is not available with SAP NetWeaver AS ABAP 7.4 and
value = gt_results
should be imported by following the steps described in SAP Note 2124672. SAP
name = 'Flight Booking information').
NetWeaver AS ABAP 7.4 SP08 or higher is required to apply this SAP Note.
Listing 6.5 ABAP Report: Handling SELECT-OPTIONS

Note
The class CL_LIB_SELTAB and its methods are obsolete.

174 175
6 ABAP-Managed Database Procedures 6.2 Creating AMDP Classes

The AMDP method shown in Listing 6.6 is filtering the data based on parameters and WHEN 'P' then 'Private Customer'
SELECT-OPTIONS passed from the application program shown earlier in Listing 6.5 using ELSE 'Others'
the SQLScript function APPLY_FILTER. END AS "TYPE",
SUM(b.loccuram) AS TOTAL
CLASS zcl_amdp_sflight_details DEFINITION
from sflight as a INNER JOIN
PUBLIC
sbook as b on a.carrid = b.carrid
FINAL
and a.connid = b.connid
CREATE PUBLIC. 6
WHERE a.mandt = :iv_client --Parameters
AND b.fldate = :iv_date --Parameters
PUBLIC SECTION.
GROUP BY a.carrid, a.connid, b.fldate, b.custtype
* AMDP Marker Interface
;
INTERFACES: if_amdp_marker_hdb.
* Data declaration
* Filter based on Selection screen (Select options)
TYPES: BEGIN OF d_sflight,
ET_RESULTS = APPLY_FILTER( :ET_RESULTS, :iv_filters );
carrid TYPE s_carr_id,
ENDMETHOD.
connid TYPE s_conn_id,
ENDCLASS.
fldate TYPE s_date,
type TYPE string, Listing 6.6 AMDP: Filtering Using SELECT-OPTIONS and Parameters
total TYPE s_l_cur_pr,
END OF d_sflight,
6.2.5 Feature Support Check Using Global Classes
tty_sflight TYPE STANDARD TABLE OF d_sflight.
We recommend checking whether the current database or a database specified using a
* AMDP Method
CLASS-METHODS get_data database connection supports AMDP features and if it can be used at runtime in the
IMPORTING ABAP applications.
VALUE(iv_client) TYPE sy-mandt
The method USE_FEATURE of the global class CL_ABAP_DBFEATURES can be used to check
VALUE(iv_date) TYPE s_date
support for the database-specific feature. Several constants are provided to check data-
VALUE(iv_filters) TYPE string
EXPORTING base-specific features and can be passed to the USE_FEATURE method in an internal table.
VALUE(et_results) TYPE tty_sflight. The method returns the value of ABAP_TRUE if the feature is supported by the database,
PROTECTED SECTION. whereas unsupported values raise an exception from the class CX_ABAP_INVALID_PARAM_
PRIVATE SECTION. VALUE and can be handled within the application program to avoid runtime errors. The
ENDCLASS. database-specific features listed in Table 6.1 can be validated using the global class CL_
ABAP_DBFEATURES.
CLASS zcl_amdp_sflight_details IMPLEMENTATION.
METHOD get_data BY DATABASE PROCEDURE Database Feature Constant Name Value
FOR HDB
External views EXTERNAL_VIEWS 2
LANGUAGE SQLSCRIPT
OPTIONS READ-ONLY Maximum number of key fields > 16 (120) TABLE_KEYCNT_MAX1 3
USING sflight sbook.
Maximum width of key fields > 900 bytes TABLE_KEYLEN_MAX1 4
ET_RESULTS = SELECT a.carrid, a.connid, b.fldate, (up to 2000)
CASE b.custtype Maximum width of table or view > 4030 bytes TABLE_LEN_MAX1 5
WHEN 'B' then 'Business Customer' (up to 16293)

AMDP table functions AMDP_TABLE_FUNCTION 6

176 Table 6.1 Database-Specific Features

177
6 ABAP-Managed Database Procedures 6.2 Creating AMDP Classes

Database Feature Constant Name Value

AMDP methods are supported CALL_AMDP_METHOD 8

CALL DATABASE PROCEDURE is supported CALL_DATABASE_PROCEDURE 7

Internal table as the source in the FROM clause ITABS_IN_FROM_CLAUSE 9


(from release 7.52) Figure 6.12 Execute DEMO_DBFEATURES in Transaction SE38
6
Limit/offset in subselect or common table LIMIT_IN_SUBSELECT_OR_CTE 10
expressions (CTEs) 2. You can choose the database features to validate for the SAP HANA database
version (see Figure 6.13). Click on Enter to view the results.
CTE used in a correlated subquery CTE_IN_CORRELATED_SUBQUERIES 11

MODIFY FROM SELECT MODIFY_FROM_SELECT 12

Hierarchies HIERARCHIES 13

GROUPING SETS GROUPING_SETS 14

Table 6.1 Database-Specific Features (Cont.)

The AMDP-specific constants CALL_AMDP_METHOD and AMDP_TABLE_FUNCTION can be passed


to the importing parameters of the method USE_FEATURES to validate if the underlying
database supports the AMDP procedure, as shown in Listing 6.7.

TRY.
DATA(lv_supported) =
cl_abap_dbfeatures=>use_ features( EXPORTING
requested_features =
VALUE #( ( cl_abap_dbfeatures=>call_amdp_method ) Figure 6.13 Select Database Features for AMBP Supportability Check
( cl_abap_dbfeatures=>amdp_table_function ) ) ).
CATCH cx_abap_invalid_param_value INTO DATA(lref_invalid_value). 3. The report displays the list of supported and unsupported features for the underly-
DATA(lv_message) = lref_invalid_value->get_text( ). ing database (see Figure 6.14).
ENDTRY.
IF lv_supported IS NOT INITIAL."ABAP_TRUE
WRITE:'Database specific feature', cl_abap_dbfeatures=>call_amdp_
method, 'is supported'.
ELSE.
WRITE lv_message.
ENDIF.

Listing 6.7 Database Specific Feature Check

You can also use the standard program DEMO_DBFEATURES to validate if the current
data- base supports any database features before using them.
To validate database-specific features, follow these steps:
1. Execute the standard SAP program DEMO_DBFEATURES using Transaction SE38 (see
Figure 6.12).
Figure 6.14 Resulting List of Supported and Unsupported AMDP Features

178
179
6 ABAP-Managed Database Procedures 6.3 Enhancements

6.3 Enhancements In addition to implementing the methods of a normal BAdI as AMDP methods and
making these methods callable using CALL BADI, you can also create a special AMDP
Similar to classic ABAP extensions, where several enhancement techniques like user
BAdI.
exits, customer exits, business transaction events (BTE), and business add-ins (BAdI),
An AMDP BAdI is created in Transaction SE20 and is later called within an AMDP imple-
enhancement frameworks are available to perform modification-free extensions to
mentation, similar to other AMDPs. An AMDP BAdI is a BAdI that is categorized accord-
SAP applications. These enhancements frameworks include implicit and explicit
ingly in the BAdI Builder and meets the following prerequisites, which are shown in
enhancements or are BAdI-managed using enhancements spots.
Figure 6.16: 6
In the following sections, you’ll learn how to define, implement, and invoke AMDP
1. SAP has provided an Enhancement Spot (ES_PPH_READ_BADI, in our example) and a
BAdI calls within other AMDP methods to extend standard business functionality.
BAdI Definition (PPH_AMDP_READ_MRP_BADI, in our example).
2. An AMDP BAdI does not currently have any filters, as they are not supported, indi-
6.3.1 AMDP BAdI Overview cated by the unchecked Limited filter use box in the Usability section.
You can also extend an AMDP procedure if the software or extension provides for this 3. In its definition, the BAdI is categorized as an AMDP BAdI, as you can see in the
extensibility. As described in Table 6.2, AMDP BAdIs were introduced with SAP Net- Usability section.
Weaver AS ABAP 7.4 SP08 to allow for modification-free extensions. As shown in Figure 4. The software provider has provided the mandatory Fallback Class. In this example,
6.15, you could then consume these extensions to add or modify a business require- the fallback class is CL_PPH_AMDP_READ_MRP_BADI. Only an AMDP class can be provided
ment in the procedure. as a fallback class or implementation class.

Software or Extension Provider Customer or Partner Extension Consumer


■ Responsible for creating an enhancement ■ Responsible for providing an implementa-
spot in Transaction SE20 tion class for the AMDP BAdI
■ Responsible for creating a BAdI definition ■ Responsible for creating an active BAdI
categorized as an AMDP BAdI, defines the implementation with SQLScript code to
BAdI interface, and implements the fall- extend or add a business requirement
back class
■ Responsible for integrating the enhance-
ment spot with the application

Table 6.2 Modification-Free Extensions

Default fallback
implementation

AMDP to Customer Figure 6.16 AMDP BAdI Prerequisites


enhance Executed when implementation
there
is no active 5. Additionally, every BAdI method of an AMDP BAdI must be an AMDP method and
Calls the AMDP customer Business logic is
added inside BAdI must be implemented for the same database platform (only SAP HANA currently
BAdI provided by implementation
the software implementation supported). This is shown in Figure 6.17 where the addition FOR DATABASE PROCEDURE
provider class
FOR HDB is used to specify the database platform in the AMDP method IF_PPH_AMDP_
READ_MRP_BAID~MDPSX_CHANGE. The addition HDB indicates this procedure is only rele-
Figure 6.15 AMDP BAdI Framework vant for the SAP HANA database.

180 181
6 ABAP-Managed Database Procedures 6.3 Enhancements

executes the default fallback class ZCL_RECLASSIFY_CUSTOMER_DEF, if no active imple-


mentation exists for the AMDP BAdI.

Figure 6.17 BAdI Method Declared as AMDP Method Figure 6.19 AMDP Method Implementation

Let’s consider an example of an AMDP BAdI. Let’s say we want an AMDP class that 3. The AMDP method EXECUTE is consumed in an ABAP application, as shown in Figure
determines a customer’s category based on the customer type, which requires an 6.20, to display the custom category classification (see Figure 6.21) before
extension to achieve a customer-specific business requirement. The class’s AMDP extending the AMDP BAdI definition.
method will be consumed in an ABAP application to display the customer’s category
classification by following these steps:
1. The AMDP class definition ZCL_AMDP_CUST_CLASSIFICATION, as shown in Figure 6.18,
determines the customer category based on the customer type. The business logic is
encapsulated in the AMDP BAdI definition in the AMDP method ZIF_RECLASSIFY_
CUSTOMERS~RECLASSIFY of the fallback class and is called in the EXECUTE method imple-
mentation of the AMDP class ZCL_AMDP_CUST_CLASSIFICATION.

Figure 6.20 AMDP Method Consumed in an ABAP Application

Figure 6.18 AMDP Class Definition

2. In the AMDP method implementation EXECUTE, the AMDP BAdI method RECLASSIFY
is called to determine the customer category, as shown in Figure 6.19. The method
Figure 6.21 ABAP Application Output

182
183
6 ABAP-Managed Database Procedures 6.3 Enhancements

To extend the ADMP method shown in Figure 6.20, the software provider needs to pro- 3. Our AMDP BAdI method ZIF_RECLASSIFY_CUSTOMERS~RECLASSIFY will encapsulate the
vision an AMDP BAdI. In this case, BAdI definition ZBADI_RECLASSIFY_CUSTOMERS is avail- business logic written in SQLScript language, as shown in Figure 6.24, to classify and
able and encapsulated in the enhancement spot ZES_RECLASSIFY_CUSTOMER. You can determine the customer category.
view the AMDP BAdI definition in Transaction SE18. Let’s look at the definition more
deeply, especially the following aspects:
1. An AMDP BAdI definition ZBADI_RECLASSIFY_CUSTOMERS is provided by SAP to extend
the procedure and is encapsulated in the Enhancement Spot ZES_RECLASSIFY_CUS
6
TOMER, as shown in Figure 6.22.

Figure 6.24 AMDP BAdI Method with SQLScript Logic

6.3.2 AMDP BAdI Implementation


To extend an AMDP method ZIF_RECLASSIFY_CUSTOMERS~RECLASSIFY shown in Figure
6.24, open the BAdI definition in Transaction SE18 and follow these steps to implement
the BAdI definition:
Figure 6.22 AMDP BAdI Definition
1. After opening the BAdI definition in Transaction SE18, right-click on the BAdI defini-
tion name ZBADI_RECLASSIFY_CUSTOMERS and select on Create BAdI Implementation,
2. If no active implementation exists for the AMDP BAdI under Implementations sec-
as shown in Figure 6.25.
tion, the default implementation of the fallback class ZCL_RECLASSIFY_CUSTOMER_DEF
will be executed, as shown in Figure 6.23.

Figure 6.23 AMDP BAdI Method

Figure 6.25 Create BAdI Implementation

184 185
6 ABAP-Managed Database Procedures 6.3 Enhancements

2. Create the enhancement implementation by providing a name and a short text and
then clicking on OK, as shown in Figure 6.26.

6
Figure 6.26 Create Enhancement Implementation

3. Now, create a BAdI implementation by providing the BAdI implementation a name


and specifying the class to extend the AMDP method, as shown in Figure 6.27.
Then, click on OK.

Figure 6.27 Name and Describe BAdI Implementation and Specify Implementing Class

4. Click on Save or use the shortcut (Ctrl + S) to save the BAdI implementation.
Figure 6.29 Extend AMDP Method
5. Click on the Implementing Class (see Figure 6.28) to extend the AMDP method
RECLASSIFY and incorporate the customer requirement using database-specific lan-
guage (SQLScript). The customer category will be determined in this step, with
'Privilege Customer' for customer type B and 'General Customer' for customer type
P, as shown in Figure 6.29.
6. Click on Save and Activate to activate the implementation. The active implementa-
tion is shown in Figure 6.30.

Figure 6.30 Active Enhancement Implementation

7. After implementing the BAdI definition, the business requirement is extended


in the implementing class, to redetermine the business category as 'Privilege
Cus tomer' or 'General Customer' based on the customer type, as shown in Figure
6.31.
Figure 6.28 Select the Implementing Class to Extend the AMDP 8. Execute (F8) the application that calls the AMDP BAdI (see Figure 6.32) to display the
Method customer classification data, as shown in Figure 6.33. The application program
reclassifies the customer category to 'Privilege Customer' or 'General Customer'
cat- egory using BAdI extensions.

186 187
6 ABAP-Managed Database Procedures 6.3 Enhancements

9. If the implementation as shown in Figure 6.30 is deactivated or no active customer


implementation exists for the BAdI definition. Then the application program calls
the default fallback implementation as shown in Figure 6.34. This implementation
categorizes customers as either 'Business Customer' or 'Private Customer' based on
customer type, as shown in Figure 6.34.

Figure 6.31 Implementing Class to Reclassify the Customer Category


Figure 6.34 Default Fallback Implementation (No Active Customer Implementation)

6.3.3 AMDP BAdI Definition


In general, a software provider will anticipate extension points for extending AMDP
procedures. SAP also allows you to create AMDP BAdIs for enhancement spots for
your applications using the Eclipse-based editor in ADT or through the Enhancement
Builder (Transaction SE20). The BAdI definition should be categorized as an AMDP BAdI
and should conform to the prerequisites shown earlier in Figure 6.16 and Figure 6.17.
Let’s walk through the steps for creating a BAdI definition to classify a customer into a
category based on the customer type. Follow these steps:
Figure 6.32 Create BAdI Implementation
1. First, we’ll create an enhancement spot by right-clicking on the package name and
selecting New • Other ABAP Repository Object, as shown in Figure 6.35.

Figure 6.35 Select Other ABAP Repository Object

Figure 6.33 Resulting Customer Category Classification

188 189
6 ABAP-Managed Database Procedures 6.3 Enhancements

2. Choose the object type Enhancement Spot and click on Next to create the enhance- 4. Alternatively, you can also use Transaction SE20 to create the BAdI definition (see
ment spot, as shown in Figure 6.36. Figure 6.38).

Figure 6.38 Create an Enhancement Spot using Transaction SE20

5. Next, specify a name for the enhancement spot and maintain the Short Text and
Technology fields, as shown in Figure 6.39. To create the enhancement spot, click on
OK.
Figure 6.36 Create an Enhancement Spot using ADT in SAP HANA Studio

3. To create the enhancement spot, maintain the Object Name field and click on Next,
as shown in Figure 6.37.

Figure 6.39 Specify Name and Short Text for the Enhancement Spot Using Transaction SE20

6. Under the Enh. Spot Element Definitions tab, as shown in Figure 6.40, click on Create
BAdI to create the definition.

Figure 6.40 Create a BAdI Definition


Figure 6.37 Specify Object Name for the Enhancement Spot using ADT in SAP HANA Studio

190 191
6 ABAP-Managed Database Procedures 6.3 Enhancements

7. Provide the BAdI a name and a short description and click on OK to create the 9. Click on the Interface node under BAdI Definitions and specify the BAdI interface
defini- tion, as shown in Figure 6.41. name ZIF_RECLASSIFY_CUSTOMERS and then click on Yes to create the BAdI interface,
as shown in Figure 6.43.

Figure 6.41 Specify BAdI Name and Short Description

8. Under the Usability section, categorize the BAdI definition as an AMDP BAdI by
selecting the AMDP BAdI checkbox, as shown in Figure 6.42. You cannot classify the Figure 6.43 Create a BAdI Interface
BAdI as filter dependent as the AMDP BAdI does not support filter functionality.
10. Click on the interface name ZIF_RECLASAIFY_CUSTOMERS to define the AMDP method
RECLASSIFY in the BAdI interface, as shown in Figure 6.44.

Figure 6.44 Define AMDP Method in BAdI Interface

11. In the BAdI interface, as shown in Figure 6.45, include the AMDP marker interface
IF_AMDP_MARKER_HDB for the database for which the procedure is to be created, In our
case, this is specific to the SAP HANA database.

Figure 6.42 Categorize BAdI Definition as AMDP BAdI

192 193
6 ABAP-Managed Database Procedures 6.3 Enhancements

Figure 6.45 AMDP Method Definition

Figure 6.47 Encapsulate Business Logic in AMDP Method


12. Finally, click on the fallback class ZCL_RECLASSIFY_CUSTOMER_DEF. Click Yes to create
the fallback class, as shown in Figure 6.46. Then, encapsulate the business logic in
Listing 6.8 illustrates an AMDP interface ZIF_RECLASSIFY_CUSTOMERS definition where an
the AMDP method ZIF_RECLASSIFY_CUSTOMERS~RECLASSIFY, as shown in Figure 6.47.
AMDP Method RECLASSIFY has been defined, the AMDP method RECLASSIFY is imple-
If no active implementation is created for the BAdI definition, then the runtime
mented in the fallback class ZCL_RECLASSIFY_CUSTOMER_DEF to encapsulate the business
environment calls the active implementation in the fallback class when the AMDP logic written in database specific SQL language to reclassify customers.
BAdI is called.
*AMDP Interface Definition
INTERFACE zif_reclassify_customers
PUBLIC .
INTERFACES if_badi_interface .
INTERFACES if_amdp_marker_hdb.

TYPES: BEGIN OF d_results,


carrid TYPE s_carr_id,
connid TYPE s_conn_id,
custtype TYPE s_custtype,
category TYPE string,
END OF d_results,

tt_results TYPE STANDARD TABLE OF d_results WITH EMPTY KEY.

METHODS: reclassify
IMPORTING
VALUE(iv_client) TYPE sy-mandt
EXPORTING
VALUE(et_results) TYPE tt_results.
ENDINTERFACE.
*AMDP Method Implementation in the fallback Class ZCL_RECLASSIFY_CUSTOMER_DEF
Figure 6.46 Create a Fallback Class
METHOD zif_reclassify_customers~reclassify BY DATABASE PROCEDURE

195

194
6 ABAP-Managed Database Procedures 6.3 Enhancements

FOR HDB LANGUAGE SQLSCRIPT OPTIONS READ-ONLY 2. The BAdI call is invoked by specifying both the BAdI definition and the method
USING sbook. name in uppercase and with the => separator. As shown in Figure 6.49, the BAdI
call is enclosed in double quotation marks, and furthermore, importing, exporting,
and
et_results = select carrid, changing parameters are passed to the interface method.
connid,
custtype,
CASE custtype
WHEN 'B' then 'Business Customer' 6
WHEN 'P' then 'Private Customer'
ELSE 'Others'
END AS "CATEGORY"
FROM sbook
where mandt = :iv_client
order by carrid, connid;
Figure 6.49 BAdI Call in an AMDP Method
ENDMETHOD.

Listing 6.8 BADI Interface and AMDP Method Implementation 3. Finally, as shown in Figure 6.50, the AMDP BAdI call is invoked in an ABAP
applica- tion to derive the customer category classification.

6.3.4 AMDP BAdI Calls


Software or extension providers usually call the AMDP method of an AMDP BAdI
inter- face in another AMDP method or an application program to support
modification-free extensions to AMDPs. The AMDP framework then generates a
database procedure for each AMDP BAdI. An AMDP BAdI’s name consists of the BAdI
name and the interface method with the => separator.
If you want to call an AMDP BAdI in an AMDP method, its usage must be first defined
in the AMDP method implementation with the USING clause. Inside the AMDP
method body, the BAdI call is invoked by specifying the BAdI definition and method
name in uppercase and with the => separator. The BAdI call is enclosed in double
quotation marks, and furthermore, importing, exporting, and changing parameters
Figure 6.50 AMDP BAdI Call Invoked in ABAP Application
are passed to the interface method. To define the usage of an AMDP BAdI, follow
these steps:
The source code shown in Listing 6.9 illustrates a BAdI AMDP method call in another
1. In the AMDP method implementation, the usage of the BAdI definition is specified
AMDP method.
in the USING clause, as shown in Figure 6.48.
CLASS zcl_amdp_cust_classification DEFINITION
PUBLIC
FINAL
CREATE PUBLIC.
PUBLIC SECTION.
* Marker Interface
INTERFACES if_amdp_marker_hdb.

* Type Definition
TYPES: BEGIN OF d_results,
Figure 6.48 BAdI Definition Usage in an AMDP Method carrid TYPE s_carr_id,

197
196
6 ABAP-Managed Database Procedures 6.4 Exception Handling

connid TYPE s_conn_id, IMPORTING


custtype TYPE et_results = gt_results.
s_custtype, category
TYPE string, cl_demo_output=>display_data( EXPORTI
END OF d_results, NG
* Table Type value = gt_results
tt_results TYPE STANDARD TABLE OF d_results WITH EMPTY KEY. name = 'Customer Category Classification').
* AMDP Method 6
METHODS: execute Listing 6.10 BAdI Method Call in an Application Program
IMPORTING
VALUE(iv_client) TYPE sy-mandt
EXPORTING
VALUE(et_results) TYPE tt_results. 6.4 Exception Handling
PROTECTED SECTION.
Like any other traditional method call, an AMDP method call may produce ABAP run-
PRIVATE SECTION.
time errors. Even though these calls are executed directly in the SAP HANA database,
ENDCLASS.
runtime errors can be traced and analyzed in Transaction ST22. This transaction pro-
CLASS zcl_amdp_cust_classification IMPLEMENTATION. vides additional AMDP-relevant information in the Database Procedure (AMDP) Infor-
METHOD execute BY DATABASE PROCEDURE mation area under ABAP Developer View.
FOR HDB
These errors can occur for several reasons, such as a version mismatch with the stored
LANGUAGE SQLSCRIPT
OPTIONS READ-ONLY procedure, while creating or executing the method. Other reasons include missing
* Specify BAdI Usage before Call authorizations or database connectivity errors.
Exceptions are raised when any such error occurs either by the runtime environment
USING zbadi_reclassify_customers=>reclassify.
-- BAdI Call or by the method definition’s RAISE exception statement. Therefore, exceptions should

CALL "ZBADI_RECLASSIFY_CUSTOMERS=>RECLASSIFY" be handled in the calling program to avoid runtime errors during program execution.
(:IV_CLIENT, :ET_RESULTS );
Figure 6.51 shows the exception classes that can be handled within an AMDP method
ENDMETHOD.
to avoid runtime errors.
Listing 6.9 BAdI Method Call in an AMDP Method

CX_RO
As shown in Listing 6.10, an AMDP BAdI method call in any application is similar to a
kernel BAdI call using a CALL BAdI or GET BAdI statement. CX_DYNAMIC_CHEC

CX_AMDP_ERROR
REPORT zamdp_cust_classification.

DATA: gref_flights_check TYPE REF TO zbadi_reclassify_customers, Figure 6.51 AMDP Exception


CX_AMDP_VERSION_MISMAT
CX_AMDP_VERSION_ERROR Classes
CX_AMDP_DBPROC_CREATE_FAIL
CX_AMDP_CREATION_ERROR CX_AMDP_EXECUTION_FAILED
CX_AMDP_EXECUTION_ERROR CX_AMDP_NO_CONNECTION
CX_AMDP_CONNECTION_ERROR
CH ED CX_AMDP_IMPORT_TABLE_ER CX_AMDP_NO_CONNECTION_FOR_CAL
gt_results TYPE zif_reclassify_customers=>tt_results. CX_AMDP_NATIVE_DBCALL_FAILE ROR L CX_AMDP_WRONG_CONNECTION

* AMDP BAdI Handle The methods are prefixed with CX_AMDP, indicating these classes are exception classes
GET BADI gref_flights_check. for handling errors during AMDP calls. These exception classes belong to the
CX_DYNAM IC_CHECK category and must be declared explicitly using the RAISING
* AMDP BAdI Call addition in the definition of an AMDP method and handled when called in the
CALL BADI gref_flights_check->reclassify application program.
EXPORTING
iv_client = sy-mandt
199

198
Contents

Acknowledgments.....................................................................................................17

1 SAP HANA Overview 19

1.1 Features................................................................................................. 19
1.1.1 Main Memory and CPU Innovations.....................................................21
1.1.2 Storage Innovations...........................................................................22
1.1.3 Data Compression..............................................................................23
1.1.4 Data Partitioning................................................................................25
1.2 Architecture............................................................................................ 27
1.3 Platform Capabilities................................................................................ 29
1.4 Use Cases............................................................................................... 30
1.4.1 Side-by-Side Scenario.........................................................................30
1.4.2 Fully Integrated Scenarios.......................................................................32
1.4.3 New Applications................................................................................32
1.5 Summary................................................................................................ 33

2 Code-to-Data Paradigm 35

2.1 What Is the Code-to-Data Paradigm?............................................................... 35


2.2 Bottom-Up Approach............................................................................... 38
2.2.1 Using Native SQL................................................................................39
2.2.2 Using Proxy Objects............................................................................40
2.3 Top-Down Approach................................................................................ 41
2.3.1 Using Transparent Optimization...........................................................42
2.3.2 Using ABAP SQL.................................................................................43
2.3.3 Using ABAP-Managed Database Procedures..............................................45
2.3.4 Using Core Data Services.........................................................................45
2.4 Performance Benefits of Code-to-Data Techniques............................................ 46
2.5 Summary................................................................................................ 49

7
Contents Contents

3 Development Environments 51
5 SQLScript Programming 123

3.1 Evolution of Programming Languages and Development Tools.................... 51 5.1 What Is SQLScript?................................................................................ 123
3.2 SAP HANA Studio.................................................................................... 54 5.1.1 SQL versus SQLScript........................................................................124
3.2.1 Compatibility Checks...........................................................................56 5.1.2 Types of SQLScript Statements...............................................................125
3.2.2 Download..........................................................................................60 5.1.3 Prerequisites....................................................................................125
3.2.3 Installation.........................................................................................64
5.2 SQL Query Template.............................................................................. 128
3.2.4 Basic Navigation and Actions...............................................................67
5.2.1 Creating a Schema............................................................................128
3.2.5 ABAP Perspective...............................................................................72
5.2.2 Creating Tables................................................................................129
3.2.6 Modeler Perspective............................................................................75
3.2.7 Administration Perspective..................................................................83 5.3 Stored Procedures................................................................................. 131
5.3.1 Creating Procedures..........................................................................131
3.3 SAP HANA Client..................................................................................... 87
5.3.2 Deleting Procedures..........................................................................133
3.4 ABAP Development Tools......................................................................... 88
5.4 User-Defined Functions.......................................................................... 133
3.4.1 Overview...........................................................................................88
5.4.1 Joins and GROUP BY Clauses.................................................................135
3.4.2 Installation.........................................................................................90
5.4.2 Subqueries.......................................................................................137
3.5 SAP Business Technology Platform, ABAP Environment............................... 99
5.5 Constructs............................................................................................. 139
3.6 Summary.............................................................................................. 101 5.5.1 Local Scalar Variables.......................................................................139
5.5.2 Local Table Variables........................................................................139
5.5.3 Conditional Statements.....................................................................140
5.5.4 FOR Loops and WHILE Loops.................................................................141
4 Native SQL 103
5.5.5 Operators.........................................................................................141
5.5.6 Emptiness Check for Tables and Table Variables......................................143
4.1 Executing Native SQL Statements............................................................ 104 5.5.7 Getting the Number of Records for Tables and Table Variables............144
4.1.1 Literals and Host Variables................................................................105
5.6 Cursors................................................................................................. 144
4.1.2 Statement for Cursor Processing.............................................................105
5.6.1 Example Cursor................................................................................145
4.1.3 Database Procedure Calls.......................................................................106
5.6.2 Looping over Cursors........................................................................146
4.1.4 Statements for Establishing Database Connections.............................107
4.1.5 Data Type Compatibility....................................................................108 5.7 Transactional Statements....................................................................... 147
4.2 ABAP Database Connectivity................................................................... 109 5.8 Dynamic SQL......................................................................................... 148
4.2.1 Querying the Database.....................................................................110 5.9 Exception Handing................................................................................. 149
4.2.2 DDL and DML Operations..................................................................115 5.9.1 Continue after Handling....................................................................149
4.2.3 Secondary Connections..........................................................................118 5.9.2 Block Parallel Execution.....................................................................150
4.2.4 Precautions While Using ABAP Database Connectivity.........................120
5.10 Arrays................................................................................................... 150
4.3 Summary.............................................................................................. 121 5.10.1 Creating an Array.............................................................................150
5.10.2 Accessing the Array..........................................................................151
5.10.3 Concatenating Arrays........................................................................151
5.10.4 Converting a Table into an Array.......................................................151
5.10.5 Unpacking an Array into a Table........................................................152

8 9
Contents Contents

5.10.6 Deleting or Trimming an Array...........................................................152


5.10.7 Cardinality in Arrays..........................................................................153 7 Modeling 219

5.11 SQL Injection Prevention Functions................................................................. 153


7.1 What Is Modeling for SAP HANA?............................................................ 219
5.12 Explicit Parallel Execution....................................................................... 154 7.1.1 Measures and Attributes....................................................................220
5.13 System Variables................................................................................... 155 7.1.2 Dimensions......................................................................................220
7.1.3 Fact Tables......................................................................................221
5.14 Debugging SQLScript............................................................................. 156
7.1.4 Star Schemas...................................................................................222
5.15 Summary.............................................................................................. 158 7.1.5 Hierarchies.......................................................................................223
7.1.6 Semantics........................................................................................224
7.1.7 Joins................................................................................................224

6 ABAP-Managed Database Procedures 159 7.2 Information Views................................................................................. 229


7.2.1 Features...........................................................................................230
6.1 Introduction.......................................................................................... 159 7.2.2 Information View Types....................................................................231
6.1.1 ABAP-Managed Database Procedure Framework......................................161 7.3 Calculation Views................................................................................... 232
6.1.2 Development Environment for AMDP.................................................163 7.3.1 Creating Dimension Calculation Views................................................233
6.2 Creating AMDP Classes........................................................................... 166 7.3.2 Creating Calculated Attributes...........................................................235
6.2.1 Prerequisites....................................................................................166 7.3.3 Time Dimension-Based Calculated Views............................................237
6.2.2 Implementing AMDP Methods............................................................168 7.3.4 Base Tables Aliases...........................................................................238
6.2.3 Calling AMDP Methods in Applications................................................170 7.3.5 Hidden Columns...............................................................................240
6.2.4 Using Multiple Selection Criteria.........................................................174 7.3.6 Labels and Hidden Attributes.............................................................241
6.2.5 Feature Support Check Using Global Classes............................................177 7.3.7 Using Measures in Calculation Views..................................................241

6.3 Enhancements....................................................................................... 180 7.4 Modeling Functions................................................................................ 243


6.3.1 AMDP BAdI Overview........................................................................180 7.4.1 Using a Hierarchy.............................................................................243
6.3.2 AMDP BAdI Implementation..............................................................185 7.4.2 Restricted Columns...........................................................................250
6.3.3 AMDP BAdI Definition.......................................................................189 7.4.3 Calculated Columns..........................................................................252
6.3.4 AMDP BAdI Calls...............................................................................196 7.4.4 Filtering Data...................................................................................256
7.4.5 Using Variables and Input Parameters................................................258
6.4 Exception Handling................................................................................ 199
7.4.6 Currency Conversion.........................................................................263
6.5 Debugging............................................................................................ 202 7.4.7 Decision Tables................................................................................265
6.5.1 AMDP Debugging before SAP NetWeaver AS ABAP 7.5.............................203
7.5 SQL in Information Models..................................................................... 270
6.5.2 AMDP Debugging with SAP NetWeaver AS ABAP 7.5...........................208
7.5.1 Query a Modeled Hierarchy Using SQLScript............................................271
6.5.3 AMDP Dump Analysis Using Transaction ST22....................................209
7.5.2 Creating and Using Functions in Information Views.............................271
6.6 Tools.................................................................................................... 214 7.5.3 Procedures in Calculation Views.........................................................272
6.6.1 AMDP Dependencies for ABAP and SAP HANA....................................214
7.6 Virtual Data Models........................................................................... 275
6.6.2 AMDP Precondition Checks................................................................215
7.6.1 SAP HANA Live.................................................................................275
6.6.3 AMDP Consistency Check for AMDP Table Functions...........................216
7.6.2 SAP S/4HANA Embedded Analytics and Core Data Services Views.............280
6.6.4 Delete Obsolete AMDPs.....................................................................218
7.7 Optimizing Data Models......................................................................... 284
6.7 Summary.............................................................................................. 218
7.7.1 Tools to Check Model Performance....................................................284
7.7.2 Good Modeling Practices...................................................................286
7.8 Summary.............................................................................................. 290

10 11
Contents Contents

8 Core Data Services 291

8.10.2 Introduction to CDS Table Functions.......................................................389


8.1 The Evolution of Core Data Services............................................................... 291
8.10.3 Defining CDS Table Functions............................................................391
8.2 Introduction.......................................................................................... 295
8.11 Summary.............................................................................................. 399
8.2.1 Domain-Specific Languages....................................................................295
8.2.2 Availability and Features...................................................................296
8.2.3 Integration with ABAP.......................................................................297
8.3 Defining CDS Views............................................................................... 298 9 Open SQL and ABAP SQL 401
8.3.1 Using Templates...............................................................................300
8.3.2 Structure Definition...........................................................................304 9.1 What Is Open SQL?............................................................................... 401
8.3.3 Creating CDS Views in ADT...............................................................307 9.2 Features of Open SQL............................................................................ 403
8.3.4 Syntax and Naming Guidelines..........................................................310
9.3 ABAP SQL............................................................................................. 410
8.4 Built-In Functions and Expressions.................................................................. 312
9.3.1 Code Pushdown in ABAP SQL.................................................................412
8.4.1 Numeric Built-In Functions................................................................312 9.3.2 Joins................................................................................................423
8.4.2 String Functions................................................................................315
8.4.3 COALESCE Function..........................................................................321
9.4 Open SQL versus ABAP SQL Statements......................................................... 430
8.4.4 Conversion Functions........................................................................323 9.4.1 Major Syntax Changes in the SELECT Query............................................430
8.4.5 Date and Time Functions...................................................................334 9.4.2 Arithmetic Operations and String Operations......................................431
9.4.3 Joins and Unions..............................................................................431
8.5 Annotations........................................................................................... 349
8.5.1 Scope of Annotations........................................................................349
9.5 ABAP SQL versus CDS Views and AMDPs.........................................................432
8.5.2 Types of Annotations........................................................................351 9.5.1 CDS Views........................................................................................433
9.5.2 ABAP-Managed Database Procedures......................................................433
8.6 Associations.......................................................................................... 351
8.6.1 Defining Associations........................................................................352
9.6 Summary.............................................................................................. 434
8.6.2 Cardinality........................................................................................354
8.6.3 Types of Associations........................................................................355
8.7 Consuming CDS Views........................................................................... 358 10 Business Object Processing Framework 435
8.7.1 Using ABAP SQL...............................................................................359
8.7.2 Using SAP List Viewer with Integrated Data Access..................................360 10.1 Introduction to Business Object Processing Framework....................................435
8.8 Enhancements....................................................................................... 364 10.2 Elements of BOPF.................................................................................. 438
8.8.1 CDS View Extensions........................................................................367 10.2.1 Nodes..............................................................................................439
8.8.2 Limiting CDS View Extensibility..........................................................368 10.2.2 Attributes.........................................................................................441
8.8.3 Finding CDS Extensions to Enhance CDS View Definitions...................369 10.2.3 Alternate Keys..................................................................................442
8.9 Authorization Concept............................................................................ 370 10.2.4 Actions.............................................................................................442
8.9.1 Data Control Language Overview............................................................371 10.2.5 Determinations.................................................................................445
8.9.2 Data Control Language Syntax and Access Conditions.........................372 10.2.6 Associations.....................................................................................447
8.9.3 Data Control Language Source Definition...........................................379 10.2.7 Validations.......................................................................................448
8.9.4 Data Control Language Source Annotations........................................384 10.2.8 Queries............................................................................................448

8.10 CDS Table Functions.............................................................................. 386 10.3 BOPF API.............................................................................................. 449


8.10.1 AMDP Functions...............................................................................387 10.3.1 BOPF Interface Objects..........................................................................449
10.3.2 Business Object Key..........................................................................451
10.3.3 BOPF Constants Interface......................................................................451
12 13
Contents Contents

10.4 CRUD Operations Using the BOPF API............................................................. 453


10.4.1 Creating Business Object Instances........................................................453
10.4.2 Searching for Business Object Instances.................................................456 12 SAP Business Technology Platform,
10.4.3 Updating and Deleting Business Object Instances...............................457
ABAP Environment 535
10.5 Advanced BOPF API Features......................................................................... 458
10.5.1 Consistency Checks...........................................................................458
12.1 Introduction to Application Development in the Cloud with SAP.................535
10.5.2 Triggering Actions.............................................................................459
10.5.3 Action Validations.............................................................................460 12.2 ABAP Environment in the Cloud.............................................................. 540
10.5.4 Transaction Management..................................................................461 12.2.1 Architecture.....................................................................................541
12.2.2 Creating an ABAP Trial Instance............................................................542
10.6 Enhancement Techniques....................................................................... 462
12.2.3 Connecting SAP HANA Studio to SAP BTP, Cloud Foundry
10.6.1 Enhancement Workbench..................................................................463
Environment.....................................................................................546
10.6.2 Enhancing the Business Object Data Model........................................464
12.2.4 ABAP Restrictions in the Cloud...........................................................549
10.7 Summary.............................................................................................. 469 12.2.5 Migrating ABAP Applications to the Cloud...........................................552
12.3 Creating ABAP Repository Objects in the Cloud........................................ 555
12.3.1 Creating ABAP Packages in the Cloud....................................................556
11 Performance and Optimization 471 12.3.2 Creating ABAP Database Tables in the Cloud......................................560
12.3.3 Creating ABAP Classes in the Cloud....................................................564
12.3.4 Creating ABAP CDS Views in the Cloud...............................................569
11.1 Runtime Statistics Records..................................................................... 472
12.4 Summary.............................................................................................. 572
11.2 Runtime and Statistical Analysis.............................................................. 475
11.2.1 Transaction SAT...............................................................................476
11.2.2 ABAP Profiling Perspective......................................................................484
11.2.3 SQL Performance Trace.........................................................................496 Appendices 575
11.2.4 Single Transaction Analysis (Transaction ST12).......................................498
11.2.5 Explain Plan.....................................................................................499
A Programming Guidelines......................................................................... 577
11.2.6 SAP HANA Plan Visualizer..................................................................505
B Code Migration...................................................................................... 589
11.3 ABAP Code Analysis............................................................................... 509
11.3.1 SAP Global Check Variants.................................................................509 C The Authors.................................................................................................. 637
11.3.2 Using the ABAP Test Cockpit.............................................................510
11.3.3 ABAP Test Cockpit Administration......................................................516
11.4 System-Wide Analysis............................................................................ 521 Index.....................................................................................................................639
11.4.1 Database Administrator Cockpit.........................................................522
11.4.2 SQL Monitor..............................................................................524
11.5 SQL Performance Optimization................................................................ 526
11.5.1 Guided Performance Analysis.............................................................527
11.5.2 SQL Performance Tuning Worklist...........................................................528
11.5.3 Recommended Static Checks..................................................................532
11.6 Summary.............................................................................................. 533

14 15
Index

A ABAP SQL............................................................43, 401


joins........................................................431
ABAP......................................................................36
unions.....................................................431
classes (cloud)............................................564
ABAP Test Cockpit.........44, 55, 509, 510, 514, 589
cloud restrictions.......................................549
administration...................................516, 517
core data services view......................283, 569
checks......................................................512
database table (cloud)...............................560
cloud readiness..........................................553
database tables..........................................560
local check.................................................617
migrating applications..............................552
remote check run.......................................611
profile configuration..................................486
static check................................................532
profiler trace..............................................487
statistics..................................................511
profiling perspective..................................484
ABAP trace..............................................................491
readiness.................................................601
ABAP trace parameters.....................................491
repository objects.......................................555
ABAP-managed database procedure.............587
runtime measurements..............................485
dump analysis...........................................209
SQL statements..........................................430
execution failure........................................210
trace request..............................................489
ABAP-managed database procedures.......37, 45,
trial............................................................542
159, 433
ABAP annotations..............................................351
benefits...................................................163
ABAP code analysis...........................................509
best practices.............................................213
ABAP database connectivity...........103, 109, 579
business add-in call...................................196
API classes..................................................110
business add-in definition.................184, 189
example...................................................114
business add-in framework...........................180
precautions.............................................120
business add-in implementation...............185
secondary database...................................118
business add-in method............................184
ABAP database connectivity class...................116
business add-in prerequisites........................181
ABAP development...........................................123
business add-ins........................................180
ABAP Development Tools.......40, 55, 88, 163, 514
call methods...............................................170
install Eclipse components..........................94
class definition...................................168, 182
install package.............................................96
consistency check......................................216
links..........................................................96
create business add-in
platform supportability...............................91
implementation..................................187
readiness checks..........................................92
create classes.............................................166
software supportability...............................91
database-specific features.............................177
ABAP Dictionary...........................................309, 578
debug......................................................202
core data service views..............................427
debug process............................................205
limitations..................................................293
debug users................................................203
ABAP dictionary................................................116
debugging with SAP NetWeaver AS
ABAP Open SQL
ABAP 7.5......................................................208
advantages.............................................412
delete obsolete AMDP................................218
joins.........................................................424
dependencies.............................................214
multiple joins.............................................425
development environment........................163
runtime...................................................411
enhancements.........................................180
ABAP package....................................................556
exception classes........................................199
ABAP perspective................................................72
exception handling.............................199, 200
ABAP profiler, debugger..................................492
extend method....................................184, 186
ABAP runtime analysis.....................................476
fallback class.............................................195
form-based editor......................................164

639
Index Index

ABAP-managed database procedures (Cont.)


Business object................................................436 Construct.........................................................139 Data control language .. 125, 296, 371, 401, 577
framework.................................................161
enhancement..........................................464 Conversion functions........................................323 access conditions........................................372
framework definition.................................162
Business object instance....................................453 Core data services.................37, 45, 161, 291, 433 annotation values......................................385
global classes.............................................177
delete.......................................................457 ABAP integration............................................297 create new source......................................380
method definition.......................................194
update.....................................................457 ABAP SQL........................................................359 source annotation......................................384
method implmentation..............................183
Business object key.........................................451 annotation types.......................................349 source definition........................................379
methods...........................................168, 169
Business Object Processing annotations............................................349 syntax.....................................................372
precondition checks...................................215
Framework..........................................435–437 association types.......................................355 Data definition language.................103, 125, 295,
prerequisites...........................................166
Business rules.....................................................435 associations...............................................351 296, 401, 577
tools.........................................................214
Business transaction events..........................180 authorizations...........................................370 statement................................................115
Action validations..........................................460
built-in functions.......................................312 Data definition, create...................................299
Ad-hoc associations.......................................355
Advanced Open SQL
C consume views...........................................358 Data engine functions......................................28
create views...............................................307 Data manipulation language..................103, 125,
code pushdown..........................................412
Calculated column.............................................252 define......................................................298 401, 577
comma-separated field lists......................412
aggregation............................................254 define table functions................................391 Data mart...........................................................31
compute columns.......................................416
persistency..............................................254 enhancements.........................................364 Data model
escaping host variables.............................412
Calculation view................................................232 expressions.............................................312 attribute..................................................220
sample code................................................415
attributes................................................241 limit view extensibility..............................368 dimension...................................................220
SQL expressions.........................................418
base table alias..........................................238 naming guidelines.....................................310 fact table....................................................221
Alternate keys.....................................................442
calculated attribute....................................235 structure definition...................................304 hierarchy....................................................223
Analytic privileges.............................................273
cube calculation view................................233 syntax.....................................................310 measure..................................................220
Analytic views....................................................255
default view...............................................233 table function definition............................390 optimizing..................................................284
Architecture.......................................................27
dimension view.........................................233 table functions...........................................387 semantics................................................224
index server.................................................28
hidden column............................................240 view entity.................................................307 star schema................................................222
Array................................................................150
labels.......................................................241 view extensions.........................................367 Data modeling................................................219
access......................................................151
measures.................................................241 CPU innovations..................................................21 best practices.............................................286
cardinality.................................................153
parameters.............................................258 Create, read, update, and delete......................453 Data modification language
concatenating.........................................151
procedures..............................................272 CRUD..................................................................453 statement................................................116
create......................................................150
time dimension-based calculation save operation...........................................456 Data partitioning..............................................25
delete.......................................................152
view.....................................................237 CRUD → Create, read, update, and delete Data types........................................................108
unpack....................................................152 Currency conversion.................................263, 323
Central check system.....................................609 Database administrator cockpit...................522
Array trim........................................................152
Check results......................................................520 SAP HANA.......................................................264 Database procedure.......................................106
Associations....................................................447
Check run............................................................519 Cursor..............................................................144 Database schema............................................128
cardinality.................................................354
frequency................................................519 example..................................................145 Data-to-code approach......................................160
define......................................................352
Cloud Foundry...................................................548 loop.........................................................146 Date functions.................................................335
Coalesce...........................................................321 Cursor technique...............................................105 Debug query mode............................................285
B Code Inspector...................................................509 Custom code Decimal shift...................................................329
static check................................................532 analysis...................................................604 Decision table..................................................265
Block parallel execution................................150 evaluation..................................................605
Code migration...............................................589 create......................................................266
BOPF functional modifications...........................595
Code pushdown matrix......................................48 name.......................................................267
API..............................................................449 remote check..............................................608
Code pushdown techniques.............................586 sample.....................................................266
consumer layer..........................................437 SAP S/4HANA readiness...............................598
Code-to-data SQLScript...................................................270
elements..................................................438 SQL performance optimization....................596
performance benefits...................................46 Design-time object..........................................231
enhancement techniques............................462 Custom code adaption......................................617
Code-to-data paradigm..............................35, 160 Determinations.......................................445, 465
interface objects.........................................449 Custom code migration............................589, 616
bottom-up approach...................................38 Development environments...........................51
nodes.......................................................439 Custom query.....................................................469
top-down approach.....................................41 Development tools...........................................51
persistence layer........................................438
Column pruning.................................................288 Direct Extractor Connect.................................82
runtime layer.............................................438
transaction layer.......................................437
Component annotations................................351 D Domain............................................................257
Conditional statements.....................................140 Domain fix values..........................................258
trigger actions...........................................459
Consistency check..........................................458 Data and time functions...................................334 Domain-specific languages...........................295
BOPF → Business Object Processing Consistency validation..................................466 Data compression................................................23
Framework
Constants interface............................................451

640 641
Index Index

E L Procedure SAP Business Warehouse....................................82


call..........................................................132 SAP BusinessObjects Business Intelligence......75
Embedded analytics..........................................280 Lightweight Directory Access Protocol............88 create......................................................131 SAP BusinessObjects Web Intelligence...........219
Emptiness check.................................................143 Literals.............................................................105 delete.......................................................133 SAP BW powered by SAP BW/4HANA................32
Enhanced SQL expressions..............................420 Local scalar variable...........................................139 language.................................................132 SAP BW powered by SAP HANA.....................32
Enhancement workbench.................................463 Local table variable............................................139 parameters................................................131 SAP BW/4HANA...............................................277
Exception handing.............................................149 Procedure alter...................................................133 SAP Cash Management.......................................33
Explain plan........................................................499 M Procedure call.....................................................274 SAP Cloud Platform.....................................537, 594
Exposed associations.........................................357 Procedure schema..............................................132 SAP Concur.........................................................536
Extract, load, and transform...............................81 Measurement restriction..........................477, 480 Programming guidelines..................................577 SAP Crystal Reports.....................................219, 280
Microsoft Excel.................................................75 Proxy objects.....................................................40 SAP Customer Experience................................536
F Modeling functions........................................243 Pseudo comments..............................................632 SAP Data Services................................................82
Python................................................................87 SAP Fieldglass....................................................536
Filtering data......................................................256 N SAP global check variants.................................509
Q SAP HANA....................................................19, 51, 589
G Name server..........................................................29 code migration...........................................592
Native SQL.............................39, 103, 401, 434, 579 Queries.............................................................448 compression.................................................25
GitHub...............................................................87 data type compatibility.............................108 Query language.........................................295, 296 features.....................................................19
Guided performance analysis..........................527 executing statements.................................104 Query unfolding................................................287 repository.................................................28
interface..................................................104 services.........................................................30
H secondary connections...............................118 R storage......................................................22
Node actions...................................................442 SAP HANA accelerators.....................................31
Hierarchy........................................................243 Node attribute.................................................441 Readiness check 2.0...........................................607 SAP HANA Application Function Library...........75
level.........................................................243 Restricted columns............................................250 SAP HANA client.................................................87
level hierarchy creation.................................244 O Root node............................................................455 compatibility................................................87
node styles.................................................245 Row-based storage...............................................23 SAP HANA Cloud...............................................33
parent-child...............................................243 Open Database Connectivity..............................87 Run series parameters.......................................518 SAP HANA cockpit.............................................86
parent-child creation.....................................246 Open SQL..............................................401, 430, 579 Runtime analysis...............................475, 479, 481 SAP HANA cockpit 2.0.......................................86
time-based..............................................249 arithmetic operations................................431 overview....................................................483 SAP HANA extended application services......29
Host variables.....................................................105 best practices.............................................404 variant....................................................480 platform....................................................51
database guidelines...................................580 Runtime object................................................231 SAP HANA Live...............................................275, 277
customization.........................................280
I enhanced.................................................410 Runtime statistics records................................472
features...................................................403 deployment.............................................276
Information models with SQL.........................270 joins.........................................................423 S private views..............................................279
Information views.....................................219, 229 limitations..................................................292 query views................................................278
functions.................................................271 string operations.......................................431 SAP Adaptive Server Enterprise...........................81 reuse views.................................................279
types.......................................................231 usage.......................................................580 SAP Ariba.........................................................33, 536 value help views.........................................279
Infrastructure-as-a-service............................536 SAP Business Explorer......................................219 SAP HANA Live Browser.................................279
In-memory database............................................20 P SAP Business One, version for SAP HANA........32 SAP HANA Live Rapid Development............280
Internet of Things..............................................540 SAP Business Suite powered by SAP HANA Live virtual data model...............277
Parallel execution...........................................154 SAP HANA...............................................................32 SAP HANA plan visualizer.........................505, 506
analysis...................................................508
J Parameters.......................................................258 SAP Business Suite powered by
Partitioning.....................................................289 SAP S/4HANA.....................................................32 execute....................................................507
Java Database Connectivity................................87 Perforce..............................................................87 SAP Business Technology Platform.......535, 537 SAP HANA platform edition.............................62
Joins..................................................................224 Performance analysis mode..........................284 ABAP environment.........................................541 SAP HANA Predictive Analytics Library.............28
inner join...................................................224 Performance optimization.......................472, 580 architecture............................................541 SAP HANA Studio....................................54, 219, 546
left outer join.............................................225 Persistence layer...............................................28 Cloud Foundry environment.........................547 ABAP perspective.......................................623
referential join...........................................227 Persistent node...............................................441 cockpit....................................................540 ABAP project................................................75
right outer join..........................................226 Plan analysis........................................................506 trial............................................................538 actions..........................................................67
star join.....................................................228 Platform-as-a-service.....................................536 SAP Business Technology Platform, administration console................................83
temporal join.............................................228 Preprocessor server..........................................29 ABAP environment.........................................99 catalog.........................................................77
text join...................................................227 setup.......................................................100 check database version................................57

642 643
Index Index

SAP HANA Studio (Cont.)


compatibility...............................................56
compatibility issues.....................................59
SQL modeler.......................................................286 Transaction (Cont.) User-defined function (Cont.)
content......................................................79
SQL monitor.......................................................524 SICK...........................................................216 join..........................................................135
custom perspective......................................69
SQL performance trace.....................................496 ST04...........................................................500 scalar......................................................134
download.....................................................60
SQL performance tuning worklist..................529 ST05...................................................497, 500 table........................................................134
enhancement spot.....................................190
execution.................................................530 ST22...................................................199, 212
installation..................................................64
modeler perspective.........................................75
SQL performance tuning worklist..................528 STAD..........................................................473 V
SQL query SWLT..........................................................528
navigation...................................................67
execution.................................................111 SYCM..........................................................600 Validations......................................................448
perspective................................................67
template..................................................128 Transaction manager.....................................461 Variables..........................................................258
perspectives.................................................55
SQL security mode............................................132 interface..................................................450 Variant configuration
provisioning.............................................81
SQL statement, methods...................................117 Transactional statement................................147 duration..................................................478
security.....................................................80
SQL trace.................................................................500 Transient node................................................441 program parts...........................................479
views............................................................71
SQLScript...................................................28, 123 Transparent optimization...............................42 statements...............................................479
SAP HANA Business Function Library...............28
debug......................................................156 Virtual data model.............................................275
SAP Landscape Transformation
Replication Server........................................82
loop.........................................................141 U
SAP List Viewer..................................................360
operators................................................141 W
syntax error....................................................165 Unit conversion..............................................326
SAP Lumira.............................................................219
system variables.............................................155 User-defined function....................................133 Web Dynpro.........................................................55
SAP NetWeaver........................................................88
table........................................................129 alter function.............................................134 WHERE clause.......................................................256
SAP NetWeaver Application Server
Statistical records...............................................474 drop function.............................................135 Whitelisted objects.............................................602
for ABAP......................................................37, 401
analysis...................................................475
SAP Note 1935918..........................................595
Statistical server...................................................29
SAP Note 2339297..............................................473
Stored procedure...............................................131
SAP Note 2375176................................................58
String functions..................................................315
SAP Note 2436955..............................................498
Structured Query Language (SQL).....................103
SAP Precision Marketing....................................33
Subquery.........................................................137
SAP product evolution....................................53
System-wide analysis........................................521
SAP S/4HANA
code migration...........................................591
readiness check..........................................600 T
SAP S/4HANA Embedded Analytics.................280
Table
SAP Smart Meter Analytics................................33
array conversion............................................151
SAP Software Download Center...........................61
buffering.................................................585
SAP SuccessFactors.....................................33, 536
field.........................................................129
SAP Lumira...........................................................75
inserting data............................................130
Scalar function................................................272
select query................................................130
Scheduled check run..........................................517
type.........................................................130
Selection criteria e..............................................174
TCUR schema.........................................................264
Service manager interface................................449
Templates........................................................300
Session-dependent function.............................257
Time function.....................................................338
Single transaction analysis............................498
Time zone functions..........................................343
Software-as-a-service.....................................536
Timestamp functions........................................339
SourceForge......................................................87
Transaction
Special type conversion function....................331
ATC............................................................517
SQL......................................................................124
DB59..........................................................523
dynamic..................................................148
DBACOCKPIT...........................78, 107, 119, 523
performance optimization.........................526
DBCO.................................................107, 119
view definition...........................................307
LC10...........................................................523
SQL console........................................................505
SAT............................................................476
SQL injection prevention function..................153
SE11............................................................291
SE38.............................................................89
SE80.....................................................53, 511
644 645
First-hand knowledge.

Mohd Mohsin Ahmed is an SAP HANA certified professio-


nal with more than 14 years of experience as an SAP technical
consultant. He currently specializes in implementing SAP S/4HA-
NA solutions with a variety of methodologies, across various in-
dustry sectors, including manufacturing, retail, food and beverage,
life science, energy and utilities, public sector, and IT. He holds a degree in
has a degree in computer science engineering from Jawaharlal Nehru
Technologi- cal University in Hyderabad, India.
Sumit Dipak Naik is an experienced ABAP and SAP HANA
certified professional. He has more than 16 years of technical
consulting, solutioning, and management experience. His focus
is in implementing SAP ERP and SAP S/4HANA solutions, across
various industry sectors, including telecommunications, food and
beverages, manufacturing, retail, life sciences, energy and utilities, public
sec- tor, and IT. He has extensive experience with different implementation
metho- dologies, approaches, and accelerators.

Mohd Mohsin Ahmed, Sumit Dipak Naik


ABAP Development for SAP HANA
We hope you have enjoyed this reading sample. You may recommend
643 Pages, 2021, $89.95
or pass it on to others, but only in its entirety, including all pages. This
ISBN 978-1-4932-1877-6
reading sample and all its parts are protected by copyright law. All usa-
ge and exploitation rights are reserved by the author and the
www.sap-press.com/4954
publisher.

You might also like