Upload
matija-madaric
View
28
Download
1
Embed Size (px)
DESCRIPTION
abap hana
Citation preview
Rich Heilman / SAP HANA Product Management
Thomas Jung/ SAP HANA Product Management
Application Development Based on ABAP and SAP HANA
© 2013 SAP AG or an SAP affiliate company. All rights reserved. 2
Full Day Workshop: ABAP on HANA
• Hands-on workshop – bring your
laptops and development skills
• Focus on ABAP on HANA for the
Business Suite
• Learn HANA Modeling, consuming
views from ABAP, SQLScript, and
OData services
© 2013 SAP AG or an SAP affiliate company. All rights reserved. 3
Disclaimer
This presentation outlines our general product direction and should not be relied on in making a
purchase decision. This presentation is not subject to your license agreement or any other agreement
with SAP. SAP has no obligation to pursue any course of business outlined in this presentation or to
develop or release any functionality mentioned in this presentation. This presentation and SAP's
strategy and possible future developments are subject to change and may be changed by SAP at any
time for any reason without notice. This document is provided without a warranty of any kind, either
express or implied, including but not limited to, the implied warranties of merchantability, fitness for a
particular purpose, or non-infringement. SAP assumes no responsibility for errors or omissions in this
document, except if such damages were caused by SAP intentionally or grossly negligent.
Introduction
© 2013 SAP AG or an SAP affiliate company. All rights reserved. 5
The Role of ABAP for Application Development on SAP HANA Applications based on ABAP and SAP HANA
SAP Business Suite powered by SAP
HANA available since January 2013
transition existing ABAP custom
developments to SAP HANA
optimize and develop new add-ons for
SAP Business Suite
SAP NetWeaver BW powered by SAP
HANA available since November 2011
significant new features for Enterprise
Data Warehousing / Big Data planned for
December 2013
ABAP custom developments in context of
SAP NetWeaver BW
develop completely new applications
(often running side-by-side with SAP
Business Suite)
specifically design the applications for
leveraging SAP HANA
SAP Business Suite SAP NetWeaver BW New applications
based on ABAP 7.4 = the “to-go” release for all SAP HANA based ABAP
applications
© 2013 SAP AG or an SAP affiliate company. All rights reserved. 6
The Role of ABAP for Application Development on SAP HANA ABAP and the cloud
On-premise Private (managed cloud) Public
Cloud
SAP HANA Cloud Platform Application Development | Integration | Database and Analytics | Foundation
Any DB SAP HANA
ABAP development
Java development
SAP HANA Enterprise Cloud: managed
service offering for running
SAP Business Suite
SAP NetWeaver BW
custom SAP HANA applications
Line of Business Cloud Applications
Marketplace:
Customer applications + extensions
Partner / ISV applications + extensions
ABAP-based and non-ABAP business
applications running in your datacenter
based on
traditional database systems
SAP HANA database
native SAP HANA development
How can my ABAP code benefit
from SAP HANA?
© 2013 SAP AG or an SAP affiliate company. All rights reserved. 8
What happens during the migration to SAP HANA? Best practices for custom code transition (1/2)
SAP HANA is a complete relational database
ABAP code only using database independent features
continue to run
general performance guidelines stay valid for SAP HANA
Priorities for custom code transition
avoid (functional) regression
detect (additional) performance optimization potential
Required and recommended adaptations
DB-migration related (e.g. usage of native SQL)
functional related (in particular code relying on implicit
sorting behavior)
performance related (usage of code patterns that can be easily optimized
for SAP HANA)
© 2013 SAP AG or an SAP affiliate company. All rights reserved. 9
What happens during the migration to SAP HANA? Best practices for custom code transition (2/2)
Plan
Create project plan for migration project
including derive basic effort estimates
Housekeeping of custom code
Perform ABAP Code Analysis
Collect SQL profile of system
Proof of Concept activities
Prepare & Migrate
Regression-free migration (functional and
performance related)
Mandatory adaptations
Simple optimizations
Technical validation of migration
Optimize & Go-live
Performance tuning and harvesting of further
optimization potential / planning next steps
Analyze SQL profile of selected business
processes
Plan optimization projects
Full validation cycle
Primary goals Tasks
© 2013 SAP AG or an SAP affiliate company. All rights reserved. 10
What happens during the migration to SAP HANA? Best practices for Open SQL (“5 golden rules”)
Existing “golden rules” for Open SQL remain valid as general recommendations. There are
some shifts of priorities (e.g. index definition (lower) and avoidance of nested selects (higher))
Keep the result sets small rule still valid
Minimize amount of transferred data rule still valid and even more important for SAP HANA
avoid selecting large numbers of not required columns
Minimize the number of data transfers rule still valid and even more important for SAP HANA
prefer array operations for INSERT, UPDATE und DELETE
when changing many records
avoid nested SELECT loops
Keep load away from the database keep unnecessary load away from the database
code pushdown for data-intensive calculations to benefit
from SAP HANA (see also slide 26 for details)
Minimize the search overhead rule still valid, but less important
in most cases SAP HANA does not require secondary
indices
© 2013 SAP AG or an SAP affiliate company. All rights reserved. 11
How can my ABAP code benefit from SAP HANA? The new paradigm
AS ABAP
SAP HANA Database
Calculation
Calculation
“Data to Code” “Code to Data”
Code pushdown means delegating data intense calculations to the
database layer
© 2013 SAP AG or an SAP affiliate company. All rights reserved. 12
How can my ABAP code benefit from SAP HANA? New features in ABAP 7.4
Benefits of In-Memory Architecture
DB-near programming
Transparent optimizations
Usage of HANA-specific
features
external views SP2
database procedure proxies SP2
HANA transport container SP2
SAP HANA content integration
* might also support HANA-specific features in the future (> SP5) / ** ‘>= SP5’ means SP5 or later
advanced Open SQL SP5
advanced ABAP view building
SP5*
ABAP-managed procedures SP5
Fulltext index in DDIC SP2
Advanced ABAP database
programming
Fast Data Access (new data exchange protocol) >= SP5** optimized SELECT... INTO ITAB and SELECT SINGLE >= SP5**
optimized FOR ALL ENTRIES-clause >= SP5**
© 2013 SAP AG or an SAP affiliate company. All rights reserved. 13
How can my ABAP code benefit from SAP HANA? Demo scenario
Example: Calculation of shipping fee per
target country and period (simplified)
Shipping fee per target country = SUM shipping fee of
all delivered sales orders
Parameters to determine shipping fee per sales order
Target country
Relevant weight of sales order items
Relevant weight per item = MAX of
Volume weight (length x width x height / 5000)
Weight
January February
Jan
uary
Target country Shipping fee Currency
DE 150.000 EUR
FR 70.000 EUR
US 170.000 EUR
Feb
ruary
Target country Shipping fee Currency
DE 120.000 EUR
FR 90.000 EUR
US 180.000 EUR
© 2013 SAP AG or an SAP affiliate company. All rights reserved. 14
Transparent optimizations Overview
Basic idea: optimize the communication between the AS ABAP
and the SAP HANA database ‘under the hood’ to accelerate existing
programs automatically
Fast Data Access (FDA)
new data exchange protocol between the AS ABAP and SAP HANA database
bulk operations instead of cell-wise data exchange
currently supported for Open SQL statements (but not for native SQL)
Optimized statements
optimized SELECT... INTO ITAB and SELECT SINGLE >= SP5*
optimized FOR ALL ENTRIES-clause >= SP5*
* ‘>= SP5’ means SP5 or later
© 2013 SAP AG or an SAP affiliate company. All rights reserved. 15
Basic idea: support more standard SQL features
(for SAP HANA as well as for traditional database platforms)
Extended JOIN-support
it is possible to nest JOIN-statements (i.e. to specify JOINs on the ‘right hand-side’ of a JOIN-condition)
Support for literals
ABAP literals and ABAP variables can be used in the projection list
Expression support
CASE-statements can be used in the projection list, nesting is possible
Arithmetic expressions for integral, decimal and floating point calculations (e.g. +, -, *, DIV, MOD)
String expressions (concatenation of columns with &&)
SQL functions (e.g. CAST (currently restricted to FLTP), COALESCE)
Advanced Open SQL Overview
© 2013 SAP AG or an SAP affiliate company. All rights reserved. 16
Advanced Open SQL Example
SELECT product_id && ',' && @space && category AS product,
CASE tax_tarif_code
WHEN 1 THEN price * @lc_factor_1
WHEN 2 THEN price * @lc_factor_2
WHEN 3 THEN price * @lc_factor_3
END AS price_vat,
currency_code AS currency
FROM snwd_pd
INTO CORRESPONDING FIELDS of @ls_result
WHERE product_id IN @so_prod.
WRITE: / ls_result-product,
ls_result-price_vat CURRENCY ls_result-currency,
ls_result-currency.
ENDSELECT.
concatenation of columns
CASE-statement
ABAP constants / variables
escaped by @
projection list separated by
commas
© 2013 SAP AG or an SAP affiliate company. All rights reserved. 17
Advanced View Building Overview
Basic idea: support code pushdown to the database layer and
simplify consumption of relational data models by means of ‘view entities’
View entities
are defined through the Eclipse-based ABAP development environment by means of so-called ‘DDL source’
can be directly used in Open SQL (but also have a corresponding DDIC view)
Support code pushdown
similar features as advanced Open SQL; in addition: UNION, UNION ALL, non-equi INNER JOIN, support of literals in ON-condition
Simplify consumption
nested views (a view consumes another view)
definition of associations between view entities (and consumption within WHERE-clause as well as within expressions)
© 2013 SAP AG or an SAP affiliate company. All rights reserved. 18
Advanced View Building Example (1/2)
@AbapCatalog.sqlViewName: 'ZCD201_VRVNU'
DEFINE VIEW zcd201_revenues AS SELECT FROM snwd_so
{
snwd_so.buyer_guid,
SUM(snwd_so.gross_amount) AS gross_amount,
SUM(snwd_so.net_amount) AS net_amount,
SUM(snwd_so.tax_amount) AS tax_amount,
snwd_so.currency_code AS currency
} GROUP BY snwd_so.buyer_guid, snwd_so.currency_code
name of DDIC view
name of view entity (can be used
in Open SQL)
© 2013 SAP AG or an SAP affiliate company. All rights reserved. 19
Advanced View Building Example (2/2)
@AbapCatalog.sqlViewName: 'ZCD201_VCUST'
DEFINE VIEW zcd201_customer AS SELECT FROM snwd_bpa
INNER JOIN snwd_ad ON
snwd_ad.node_key = snwd_bpa.address_guid
ASSOCIATION[*] TO zd201_revenues AS revenues ON
revenues.buyer_guid = snwd_bpa.node_key
{
snwd_bpa.node_key, snwd_bpa.bp_id,
snwd_bpa.company_name,
snwd_ad.country,
snwd_ad.postal_code,
snwd_ad.city,
revenues.gross_amount,
revenues.currency
} WHERE bp_role = '01'
definition of an association to
previously created view entity ZCD201_REVENUES
consumption of the association
within the projection list
© 2013 SAP AG or an SAP affiliate company. All rights reserved. 20
Basic idea: manage database procedures and their lifecycles from
within the ABAP development infrastructure
ABAP method is used as container for database procedures
addition BY DATABASE PROCEDURE indicates that a method is executed in the database
addition FOR db_platform indicates the database platform (currently supported HDB = SAP HANA database)
Implementation of method body is done in SQLScript
editing environment is the ABAP class editor
embedded syntax check is available for SQLScript code (different from native SQL!)
other languages might be supported in the future (for example R)
ABAP server creates database procedure in database catalogue during generation
runtime artifact is generated into schema SAP<SID> (and not _SYS_BIC)
ABAP-managed Database Procedures Overview
© 2013 SAP AG or an SAP affiliate company. All rights reserved. 21
ABAP-managed Database Procedures Example
CLASS zcd201_cl_snippet_amdp DEFINITION...
INTERFACES if_amdp_marker_hdb.
METHODS: determine_sales_volume
IMPORTING VALUE(iv_client) TYPE mandt
EXPORTING VALUE(et_sales_volume) TYPE tt_sales_volume.
ENDCLASS.
CLASS zcd201_cl_snippet_amdp IMPLEMENTATION.
METHOD determine_sales_volume BY DATABASE PROCEDURE
FOR HDB LANGUAGE SQLSCRIPT
USING snwd_so_i snwd_so_sl snwd_pd.
-- here you use SQLScript
ENDMETHOD.
ENDCLASS.
Marker interface
method additions
forward declaration of accessed
database objects
© 2013 SAP AG or an SAP affiliate company. All rights reserved. 22
How can my ABAP code benefit from SAP HANA? Recommendations
Possibility to use HANA-specific features
Code running on all supported database systems
Prefer Advanced ABAP database programming features to optimize ABAP code advanced Open SQL
advanced ABAP view building use ABAP-managed procedures where needed,
but think of fallbacks in case the code also has to
support traditional database systems
Use SAP HANA content integration if requirements cannot be fulfilled by Advanced
ABAP database programming
to consume pre-packaged content (e.g. SAP HANA
Live)
to develop reusable artifacts across application
stacks
The SAP<SID> schema is managed by the
AS ABAP only create artifacts in SAP<SID> schema through
ABAP use APIs to write to tables in SAP<SID> schema
and avoid using native SQL / SQLScript to write to tables SAP<SID> schema
What are completely new
possibilities?
© 2013 SAP AG or an SAP affiliate company. All rights reserved. 24
Example 1: Application Function Libraries Overview
Application Function Libraries
libraries of reusable functions linked dynamically to the SAP
HANA database kernel (implemented in C++)
can be used to perform data intensive and complex calculations
BFL and AFL generally released as of SAP HANA SPS5
Business Function Library (BFL)
contains pre-built, parameter-driven business functions
(examples: annual depreciation, days outstanding)
Predictive Analysis Library (PAL)
contains statistical algorithms from areas like clustering,
classification, social network analysis
SAP HANA
Index Server
Business Function
Library (BFL)
Predictive Analysis
Library (PAL)
…
© 2013 SAP AG or an SAP affiliate company. All rights reserved. 25
Example 1: Application Function Libraries Exemplary functions
function: Linear Average (BFL)
calculates a linear average, in which larger weights are applied to more recent periods
weights decrease lineary as you look back over time
function: ABC Analysis (PAL)
classify objects (customers, employees, products…) based on a particular measure
group objects by their estimated importance (“A”, “B”, “C” objects)
function: K-means (PAL)
partition records into k clusters in which each record belongs to the cluster with the
nearest center
e.g. used to group customers into segments
© 2013 SAP AG or an SAP affiliate company. All rights reserved. 26
Example: ABC analysis of products
Classification based on revenues attributed to the products
“A” products: 20% of the products accounts for 70% of the revenue
“B” products: 30% of the products accounts for 20% of the revenue
“C” products: 50% of the products accounts for 10% of the revenue
Example 1: Application Function Libraries Demo scenario
Product ID Product Name Revenues Currency Classification
HT-1000 Notebook Basic 15 1.500.000 EUR A
HT-1001 Notebook Basic 16 800.000 EUR B
HT-2000 7” Widescreen DVD
player
1.700.000 EUR A
HT-2001 10” portable DVD player 500.000 EUR C
© 2013 SAP AG or an SAP affiliate company. All rights reserved. 27
Example 2: Business rules SAP NetWeaver Decision Service Management (DSM)
SAP NetWeaver Decision Service management helps to externalize
decision-making logic from ABAP-based application code
Decision Service
Repository
Decision Service
Versioning & Reporting
Decision Service
Modeling
Decision Service
Lifecycle Management
Model and change
decision services
Centrally store
decision services
Manage technical
aspects of decision
services
Gain full transparency for
analysis and legal
purposes
SAP NetWeaver Decision Service Management
IT Business
domain
expert
SAP
ERP 1
SAP
ERP 2
SAP
CRM …
Non-
SAP …
Decision Service Distribution Distribute decision
services for local
execution
© 2013 SAP AG or an SAP affiliate company. All rights reserved. 28
Example 2: Business rules DSM and SAP HANA (1/2)
Dynamic Database View: deployment to SAP
HANA generates a result view based on
database (tables, views) and decision table
content
database table or view as data source
decision table for calculated columns
result view to combine data source with calculated
columns
Decision table processed on SAP HANA database by SELECT on result view
can be used directly in ABAP and in database lookup
expressions
Database table or view
Decision table
Result view
Column 1 Column 2
A 10
B 20
Condition
Column 1
Condition
Column 2
Result
Column 3
Result
Column 4
A 100 1.000
B 0.. 10 200 2.000
B > 10 300 3.000
Column 1 Column 2 Column 3 Column 4
A 10 100 1.000
B 20 300 3.000
© 2013 SAP AG or an SAP affiliate company. All rights reserved. 29
Example 2: Business rules DSM and SAP HANA (2/2)
Usage of database procedures in DSM
functions on SAP HANA
either based on database procedure proxies …
… or based on ABAP-managed procedures
allows to push down expensive expressions to the
database
Analyze DSM expressions with SAP HANA
Example: decision table
Which row is mostly evaluated as true?
How do values develop over time?
Row 1 (100, 1.000)
Row 2 (200, 2.000)
Row 3 (300, 3.000)
© 2013 SAP AG or an SAP affiliate company. All rights reserved. 30
Example 3: Text Search / Analysis Overview
SAP HANA
Text Analysis
result database
table
Fu
llte
xt
ind
ex
Database
table
Text
Analysi
s
Text
Searc
h
Text Search
search character-type columns of database tables in
column store
search operations: exact, fuzzy, linguistic…
functions: ranking, snippets, facets…
requires creation of so-called fulltext index
Text Analysis
structure, transform, enrich unstructured data for the
purpose of discovery or analysis
happens based on fulltext index (optional configuration
for a fulltext index)
results of text analysis are stored in a database table
© 2013 SAP AG or an SAP affiliate company. All rights reserved. 31
Example 3: Text Search / Analysis Using text search capabilities in ABAP
Fulltext index in the SAP HANA database
is implicitly created only for column store data types TEXT and SHORTTEXT
has to be explicitly created for other character-
type columns
Creation of fulltext index through ABAP
create (extension) index in transaction SE11
choose exactly one field for the index and specify
that the index is a fulltext index
available as of ABAP 7.4 SP2
Access by means of native SQL SELECT pd.product_id, tx.text
FROM snwd_pd AS pd
INNER JOIN snwd_text_key AS tk
ON tk.node_key = pd.name_guid
INNER JOIN snwd_texts AS tx
ON tx.parent_key = tk.node_key
WHERE CONTAINS(tx.text, 'Notebuch',
FUZZY(0.7))
ORDER BY SCORE( );
Notebook Professional 15,
Notebook Basic 17,
Notebook Professional 17…
How can I get started with
ABAP on SAP HANA?
© 2013 SAP AG or an SAP affiliate company. All rights reserved. 33
How can I get started with ABAP on SAP HANA? Overview / our offers
Book a training at SAP Education
for example: HA400 ABAP Programming for SAP HANA
Visit our web site to browse through documentation and get access to trial
systems (http://scn.sap.com/community/abap/hana)
ABAP for SAP HANA reference scenario
tutorials (e.g. how use database procedures) and best practices (e.g. performance
guidelines)
AS ABAP 7.4 trial as virtual appliance
Visit one of the many SAP TechEd lectures, hands-on workshops,
expert networking sessions
© 2013 SAP AG or an SAP affiliate company. All rights reserved. 34
How can I get started with ABAP on SAP HANA? Trial systems
AS ABAP 7.4 trial as virtual appliance
application server and database are deployed at a cloud service
provider (currently supported Amazon EC2)
including integrated development environment in Eclipse…
… plus sample scenarios, tutorials and best practices
free of charge (except the charges of the cloud service provider)
Currently available systems
SAP NetWeaver Application Server ABAP 7.4 on SAP HANA
(AS ABAP 7.4 SP2, HANA Revision 1.00.56)
SAP NetWeaver Application Server ABAP 7.4 on SAP MaxDB
(AS ABAP 7.4 SP2, MaxDB 7.9.08)
An AS ABAP 7.4 trial on SAP MaxDB is planned to be available for download in
Q4/2013.
Cloud
Developer
Tune Your Custom ABAP Code
Get Ready for SAP HANA
© 2013 SAP AG or an SAP affiliate company. All rights reserved. 36
SAP Business Suite powered by SAP HANA Migrate to SAP Business Suite powered by SAP HANA
SAP HANA Database
AS ABAP 7.4
SAP Business Suite 2013
Any Database
AS ABAP
SAP Business Suite
Migrate
based on ABAP 7.4 = the “to-go” release for
all SAP HANA based ABAP applications
SAP Business Suite on SAP HANA
Upgrade
Upgrade SAP Business
Suite
Custom Code
SAP Business Suite 2013
Custom Code
Custom code is a central part of the
business functionality
How can customers smoothly migrate and
optimize their code for SAP HANA?
Adapt
© 2013 SAP AG or an SAP affiliate company. All rights reserved. 37
Migrate to SAP Business Suite powered by SAP HANA Impact on custom ABAP development
Which of my ABAP code must be changed to
avoid potential functional issues?
Which of my ABAP code shall be optimized to
ensure good performance?
Which of my main business processes have
potential for HANA so that I can speed up those
massively?
And how can I find all this ABAP code easily
and do the adaption efficiently…?
Prepare Custom Code for SAP HANA ABAP Test Cockpit and Static Checks
© 2013 SAP AG or an SAP affiliate company. All rights reserved. 39
Prepare your custom code for SAP HANA Functional corrections for existing ABAP code
In general existing ABAP code runs on SAP HANA as before
Only if ABAP code relies on technical specifics of the old database, ABAP code changes
might be necessary
Which of my ABAP code must be changed to avoid potential functional issues
© 2013 SAP AG or an SAP affiliate company. All rights reserved. 40
Prepare your custom code for SAP HANA Functional corrections for existing ABAP code
Technical changes with SAP HANA that may affect existing DB specific
ABAP code
Technical Change Details and Examples – Effect on DB specific ABAP code
DB migration Each DB has specific features and unique technical behavior.
DB specific code may rely on these features of the used database.
SAP HANA architecture Column based architecture - as a consequence e.g. secondary DB indexes are
less important.
DB specific code may rely on the existence/usage of certain DB indexes.
Depooling/Declustering During the migration to SAP HANA most pool and cluster DB tables are
transformed to transparent DB tables (depooling/declustering) so that the tables
can be used in analytic scenarios.
DB specific code may rely on the technical specifics of pool and cluster tables.
Details: See OSS note 1785057
© 2013 SAP AG or an SAP affiliate company. All rights reserved. 41
Technical Change ABAP code which must be checked / corrected Recommended solution
DB migration Native SQL, Hints, ADBC which uses DB specific features Use Open SQL if possible, adapt native SQL and DB hints if necessary
Prepare your custom code for SAP HANA Functional corrections for existing ABAP code – Details and examples
Example for native SQL Example for a DB hint
© 2013 SAP AG or an SAP affiliate company. All rights reserved. 42
Technical Change ABAP code which must be checked / corrected Recommended solution
SAP HANA
architecture
Transparent DB tables:
- Relying on not guaranteed / implicit sorting of DB query
results
- (Rare problem) Analysis of technical DB index information using
function modules 'DB_EXISTS_INDEX‘, 'DD_INDEX_NAME‘
Recommendation:
Never rely on any implicit sorting - no robust code!
Always use ORDER BY … or SORT … BY to sort query result sets
explicitly
Try to get rid of DB index analysis
Depooling/
Declustering
Pool/Cluster tables:
- Relying on not guaranteed / implicit sorting of DB query
results
- (Rare problem) Direct access to physical clusters / pools
Recommendation:
Never rely on any implicit sorting - no robust code!
Always use ORDER BY … or SORT … BY to sort query result sets
explicitly
Get rid of direct access to physical clusters / pools
Prepare your custom code for SAP HANA Functional corrections for existing ABAP code – Details and examples
Read Table … BINARY SEARCH works only for a
correctly sorted internal table.
But no explicit sorting of the query result is done
-> Error in code which may work by chance
because of DB Index usage
Correction
Add explicit sorting by adding ORDER BY
to the SELECT or by using an ABAP SORT
Example for ABAP code which
relies on sorted DB query
results
© 2013 SAP AG or an SAP affiliate company. All rights reserved. 43
Prepare your custom code for SAP HANA Functional corrections for existing ABAP code – static checks I
For all main functional error categories we provide Code Inspector checks to find the issues easily
© 2013 SAP AG or an SAP affiliate company. All rights reserved. 44
Prepare your custom code for SAP HANA Functional corrections for existing ABAP code – static checks II
“Search problematic statement…w/o ORDER BY” check
Preferred check to find code which relies on sorted DB content
searches for statements like READ BINARY SEARCH, DELETE
ADJACENT DUPLICATES, … accessing unsorted DB content
works for transparent and pool/cluster DB tables
low false positive ratio
“Depooling/Declustering: Search for…w/o ORDER BY” check
Searches for SELECT <pool/cluster table> without ORDER BY but no
further analysis of the data flow is done
works only for pool/cluster DB tables
(before and after depooling/declustering)
high false positive ratio
Recommendation
Run both checks for your custom code
Concentrate on findings (priority 1 and 2) of the “Search problematic
statement…w/o ORDER BY” check
Treat findings of “Depooling/Declustering: …” check with reduced priority
© 2013 SAP AG or an SAP affiliate company. All rights reserved. 45
Prepare your custom code for SAP HANA ABAP Test Cockpit – Run your Code Inspector checks in a new tool
ABAP Test Cockpit (ATC) is a
framework for running static checks on
ABAP objects to find: functional,
usability, performance, security, … bugs
ABAP Test Cockpit is based on Code
Inspector and adds new quality gates,
quality processes and better usability
© 2013 SAP AG or an SAP affiliate company. All rights reserved. 46
Prepare your custom code for SAP HANA ABAP Test Cockpit – Quality process and Q gates
Development System
Quality System
Q-experts run mass checks and distribute the results
Developer run static / unit / scenario tests on their objects
Periodic check runs to validate the code of a development team
Q-Gate:
Check during
transport release
Q-Gate:
Mass check run and
consolidation test
© 2013 SAP AG or an SAP affiliate company. All rights reserved. 47
Summary - Prepare your custom code for SAP HANA ABAP Test Cockpit and static checks
In general existing ABAP code runs on SAP HANA as
before. Only DB specific ABAP code must be analyzed
New static Code Inspector checks are available which
help to find the code which must be analyzed
ABAP Test Cockpit (ATC) is the new standard tool for
static ABAP code checks
ATC can be used now to prepare the custom ABAP
code for HANA and to improve the general quality of the
code
ATC availability starts with NW 702 SP12 / NW 731 SP5.
In older releases the Code Inspector can be used
Optimize Custom Code for SAP HANA
SQL Monitor, Static Checks and SQL Performance Tuning Worklist
© 2013 SAP AG or an SAP affiliate company. All rights reserved. 49
Optimize Custom Code for SAP HANA Tooling
How can I find the ABAP code which shall be optimized or which has potential
for massive acceleration using code push down to SAP HANA
In general no changes are necessary if your SQL code follows the golden Open SQL rules
Use static checks to find SQL patterns that violate the golden Open SQL rules
Add runtime performance data from production to rank the findings and to find potential for
massive acceleration
© 2013 SAP AG or an SAP affiliate company. All rights reserved. 50
Optimize Custom Code for SAP HANA Classic golden SQL rules
© 2013 SAP AG or an SAP affiliate company. All rights reserved. 51
Optimize Custom Code for SAP HANA Shift in priorities of classic golden SQL rules for SAP HANA
Shift in priorities for SAP HANA
Avoid selecting large numbers of not
required columns
Prefer array operations for INSERT,
UPDATE und DELETE when changing
many records
Avoid nested SELECT loops
In most cases SAP HANA does not require
secondary indices
Keep unnecessary load away from the
database
Code pushdown for data-intensive
calculations to benefit from SAP HANA
© 2013 SAP AG or an SAP affiliate company. All rights reserved. 52
Optimize Custom Code for SAP HANA Classic Static Performance Checks
Most golden SQL rules are covered by static checks already
Gaps for “Minimize amount/number of data transfer(s)”
© 2013 SAP AG or an SAP affiliate company. All rights reserved. 53
Optimize Custom Code for SAP HANA New Static Performance Checks I
Improved and new static performance checks:
SELECT * - Used columns vs. selected columns
Nested SELECT statements (across modularization units)
SELECT + SELECT FOR ALL ENTRIES
which can be transformed into JOIN or SUBQUERY
SELECT * check
No field used – pure existence check
Nested SQL check
SELECT in LOOP (across
modularization unit)
SELECT + SELECT FOR ALL ENTRIES
transform into JOIN or SUBQUERY
© 2013 SAP AG or an SAP affiliate company. All rights reserved. 54
Optimize Custom Code for SAP HANA New Static Performance Checks II
New checks close gaps for rules “Minimize
amount/number of data transfer(s)”
Check appendix for availability of the new
checks.
NW 740 SP3
© 2013 SAP AG or an SAP affiliate company. All rights reserved. 55
Optimize Custom Code for SAP HANA Static Performance Checks – Efficient analysis of the findings
NW 740 SP3
“Shall I analyze and correct each and every nested SELECT or
SELECT * …? This may destabilize code which is not even
performance critical…”
In general static performance checks:
Have a higher false positive ratio as functional checks
Provide mainly performance hints - not all findings are errors
Should be combined with performance/runtime data to reduce
the false positive ratio
The findings of the following static performance
checks shall be analyzed like functional errors:
SELECT, UPDATE, DELETE without any WHERE
Unsecure use of FOR ALL ENTRIES
Table attribute checks
Check DB table settings (especially buffer characteristic)
© 2013 SAP AG or an SAP affiliate company. All rights reserved. 56
Custom Code Base
Optimize Custom Code for SAP HANA Static Performance Check – Efficient analysis I
Covered by Static Checks
Concentrate on the findings
in performance hotspots
We need runtime data from
the productive system to find
the relevant code
Unused
Code
Dynamic
Code
Relevant
for performance
optimizations
Not relevant
for performance
optimizations
© 2013 SAP AG or an SAP affiliate company. All rights reserved. 57
Optimize Custom Code for SAP HANA Static Performance Check – Efficient analysis II
1. Use Usage Procedure
Logging (UPL) to separate
not used (dead) code
VISIT ITM114: Real Software Utilization with Usage and
Procedure Logging
Use monitoring and trace
tools to measure the usage
of ABAP and SQL in your
productive system
3. Find the performance
hotspots with the SQL
Monitor
Dynamic
Code
Unused
Code
Not relevant
for performance
optimizations
Relevant
for performance
optimizations
Covered by monitoring tools
2. Use the standard
performance trace tools
(ST05, SAT, …) to analyze
your core business
processes
© 2013 SAP AG or an SAP affiliate company. All rights reserved. 58
Example: A productive ERP System with
6000 concurrent users
Two weeks in this system means • 50k different business processes
• 130k different ABAP SQL statements
(>15% in customer code)
• 13B SQL requests (~1B / day)
• 140B records (~10B / day) read or changed
Where to start an optimization …?
© 2013 SAP AG or an SAP affiliate company. All rights reserved. 59
New SQL Monitor allows to get
performance data for each and every
OPEN SQL executed in production...
Answer questions like • What are the most expensive and most
frequently executed SQLs?
• Which SQL reads/writes millions of
records?
• What is the SQL profile of my business
process VA01?
Total transparency of the SQL
running in production!
© 2013 SAP AG or an SAP affiliate company. All rights reserved. 60
Business process list ranked by total DB time
Summary - Optimize Custom Code for SAP HANA SQL Monitor – DB performance profile of the business processes
SQL Monitor
• Displays performance data on process level (report, transaction, …)
• Allows to drill down from process level to the single DB operations
• Can run in production with minimal performance overhead (<3%)
Drill down to the SQL profile of
report ZSQLM_TEST
(98 SQL statements)
Navigate to the code
© 2013 SAP AG or an SAP affiliate company. All rights reserved. 61
Summary - Optimize Custom Code for SAP HANA SQL Monitor
SQL Monitor collects performance data for each and
every SQL executed in an ABAP application
SQL Monitor can run in a productive system without
disturbing business processes
SQL Monitor allows to link the monitored SQL to the
driving business process
SQL Monitor can be used in the “old” productive system
before doing the HANA migration
SQL Monitor availability is starting with NW 700 (see
appendix for details)
© 2013 SAP AG or an SAP affiliate company. All rights reserved. 62
Optimize Custom Code for SAP HANA Static Performance Check – Efficient analysis III
Covered by Static Checks
Processes covered by SQL
Monitor after a week / month
running in production. Quarter-
end or year-end processes
may not be covered
Relevant for
performance
Dynamic
Code
Unused
Code
Not relevant
for performance
optimizations
Combine SQL Monitor data and
Code Inspector / ATC check
data to rank the findings and for
complete coverage
Eliminated by UPL
© 2013 SAP AG or an SAP affiliate company. All rights reserved. 63
Optimize Custom Code for SAP HANA Guided performance optimization
New SQL monitor (SQLM)
Can run in production; also before migration
Captures aggregated runtime data (number of executions,
database times, tables, transactions)
Runtime
data
Correlate and optimize
Define context from business perspective (entry point,
transaction, involved data)
Find code with best cost/benefit ratio
Fix performance bugs and “unexpected” database
accesses
Find code which can be “pushed down” to SAP HANA
(e.g. via a SQL script procedure)
SQL Performance Tuning Worklist (SWLT)
Improved / new code inspector checks, e.g.
Nested SELECT statements across modularization units
Used columns vs. selected columns
Static code
analysis
© 2013 SAP AG or an SAP affiliate company. All rights reserved. 64
Optimize Custom Code for SAP HANA Guided performance optimization – System view
Production System
Database
Development / Q- System
Database
SQL Monitor
ABAP Test Cockpit
SQL Performance Tuning Worklist
Download / RFC
© 2013 SAP AG or an SAP affiliate company. All rights reserved. 65
Tune your custom code – Get ready for SAP HANA Summary – Process view – Tool usage
Use ABAP Test Cockpit for your general quality assurance (avoid
regressions)
Use SQL Monitor in the SAP HANA test system ( + SWLT in the
development system) to tune the top custom SQL statements of the
running test cases
Use ABAP Test Cockpit for your general quality assurance
Use SQL Monitor in the SAP HANA productive system ( + SWLT in
the development system) to iteratively tune the custom SQL
statements and to detect and realize HANA potential
Use ABAP Test Cockpit to correct potential functional issues in your
custom code (“old” system or sandbox system)
Use SQL Monitor in the „old“ productive system ( + SWLT in the
development system) to correct custom SQL issues / tune the top
custom SQL statements in your system
Eliminate unused custom code to reduce migration effort
Define your main business processes for testing and tuning
Evaluation in sandbox system
Plan SAP HANA
migration
Prepare SAP
HANA migration
SAP Business Suite
Any Database
Development / Test System
SAP HANA Database
Upgrade
Migrate
SAP HANA
migration
SAP Business Suite
Any Database
Production System
SAP HANA Database
Upgrade
Migrate
SAP Business Suite
Any Database
Sandbox System
SAP HANA Database
Upgrade
Migrate
© 2013 SAP AG or an SAP affiliate company. All rights reserved. 66
Tune your custom code – Get ready for SAP HANA Short overview – Realize SAP HANA potential - Code pushdown
AS ABAP
SAP HANA Database
Calculation
Calculation
“Data to Code” “Code to Data”
Code pushdown means delegating data intense calculations to the
database layer e.g. by using advanced Open SQL, advanced ABAP views
and SQL Script
© 2013 SAP AG or an SAP affiliate company. All rights reserved. 67
Further Information
SAP Education and Certification Opportunities
www.sap.com/education
Watch SAP TechEd Online
www.sapteched.com/online
SAP Public Web
ABAP Test Cockpit: http://scn.sap.com/docs/DOC-31773
ABAP Performance guidelines for SAP HANA:
http://scn.sap.com/community/abap/hana/blog/2013/03/24/performance-guidelines-for-abap-development-on-the-sap-hana-database
Community ABAP4HANA: http://scn.sap.com/community/abap/hana
Central SAP Notes
1885926, “ABAP SQL Monitor”
1794297: “Secondary Indexes for the business suite on HANA”
1785057: “Recommendations for migrating suite systems to SAP”
1622681: “DBSL hints for SAP HANA”
1847431: “SAP NetWeaver BW ABAP Routine Analyzer”
1051576: “Conversion of Single Code Page Systems to Unicode”
1812713: “Add-on compatibility of SAP NW AS ABAP 7.4 for Suite”
1760306: “SAP EhP6 for SAP ERP 6.0, version for SAP HANA 1.0”
1855666: “Suite on HANA : 3rd party Add-ons
Watch SAP TechEd Online
www.sapteched.com/online
Appendix Availability "Guided performance optimization"
© 2013 SAP AG or an SAP affiliate company. All rights reserved. 69
Tools in the context of guided performance optimization Availability (1/4)
ABAP Test Cockpit
The ABAP Test Cockpit (ATC) is a tool for doing static and dynamic quality checking of ABAP code and associated repository objects.
SAP_BASIS 7.00 SAP_BASIS 7.01 SAP_BASIS 7.02 SAP_BASIS
7.10, 7.11, 7.20,
7.30
SAP_BASIS 7.31 SAP_BASIS 7.40
SAP_BASIS not planned not planned SP12 not planned SP5 SP0
SAP_BASIS 7.00 SAP_BASIS 7.01 SAP_BASIS 7.02 SAP_BASIS
7.10, 7.11, 7.20,
7.30
SAP_BASIS 7.31 SAP_BASIS 7.40
SAP_BASIS SP0 SP0 SP0 SP0 SP0
SP0
Code Inspector
The Code Inspector is a tool to check repository objects in terms of performance, security, syntax and compliance with naming conventions.
© 2013 SAP AG or an SAP affiliate company. All rights reserved. 70
Tools in the context of guided performance optimization Availability of new static Code Inspector checks (2/4)
Area Check title Availability (SAP_BASIS Version)
Functional / Robust
Code
Search problematic statements for result of SELECT/OPEN CURSOR without ORDER BY
740 SP3
740 SP2 via special transport(note 1875529)
731 SP9
702 SP14
Functional / Robust Depooling/Declustering: Search SELECT for Pool/Cluster-Tables w/o ORDER BY
(Priority/Significance of this check is reduced when the more sophistcated check “Search problematic
statements for result of SELECT/OPEN CURSOR without ORDER BY” is used)
740 SP2
731 SP9
702 SP14
Functional / Robust
Code
Unsecure use of FOR ALL ENTRIES 740 SP2
731 SP5
702 SP12
701 SP14
700 SP29
Performance Search problematic SELECT * statements 740 SP2
731 SP9
702 SP14
Performance Search SELECT .. FOR ALL ENTRIES-clauses to be transformed 740 SP2
731 SP9
702 SP14
Performance Search DB Operations in loops across modularization units (reading and changing SQLs)
740 SP2:
Search SELECTs in loops across modularization units
Changing Database Accesses in Loops (no cross stack analysis !)
Old releases:
SELECTs in Loops (no cross stack analysis !)
Changing Database Accesses in Loops (no cross stack analysis !)
740 SP3
731 SP9
702 SP14
Performance Search SELECT statement with DELETE statement 740 SP2
731 SP9
702 SP14
© 2013 SAP AG or an SAP affiliate company. All rights reserved. 71
Tools in the context of guided performance optimization Availability (3/4)
SQL Monitor
The SQL Monitor is a monitoring tool for ABAP based SAP systems which allows to collect performance data of all executed SQL statements in a
productive environment. It exists in two flavours: one is delivered via SAP_BASIS, one via ST-PI plug-in. In release 7.02, 7.31 and 7.40 we recommend to
use the SQL monitor delivered via SAP_BASIS.
SQL Performance Tuning Worklist
The SQL Performance Tuning Worklist allows to combine static performance check results with relevant runtime data coming e.g. from a productive
system.
SAP_BASIS
7.00, Kernel 7.21
(PL>118)
SAP_BASIS
7.01, Kernel 7.21
(PL>118)
SAP_BASIS
7.02, Kernel 7.21
(PL>118)
SAP_BASIS
7.10, 7.11, 7.20,
7.30, Kernel 7.21
(PL>118)
SAP_BASIS
7.31, Kernel 7.21
(PL>118)
SAP_BASIS
7.40, Kernel 7.40
SAP_BASIS not planned not planned SAP_BASIS
SP14
not planned SAP_BASIS SP9 SAP_BASIS SP2
ST-PI ST-PI 2008_1_*
SP8
ST-PI 2008_1_*
SP8
ST-PI 2008_1_*
SP8
ST-PI 2008_1_*
SP8
ST-PI 2008_1_*
SP8
ST-PI 2008_1_*
SP8
SAP_BASIS 7.00 SAP_BASIS 7.01 SAP_BASIS 7.02 SAP_BASIS
7.10, 7.11, 7.20,
7.30
SAP_BASIS 7.31 SAP_BASIS 7.40
SAP_BASIS not planned not planned SP14 not planned SP9 SP2
© 2013 SAP AG or an SAP affiliate company. All rights reserved. 72
Tools in the context of guided performance optimization Availability (4/4)
Further remarks Background information for the ABAP Test Cockpit can be found here:
http://scn.sap.com/docs/DOC-32628
The current SAP Support Package Schedule can be found here:
https://service.sap.com/~sapidb/011000358700000294692004E
When using the SQL Monitor delivered via ST-PI, in all releases < SAP_BASIS 7.40 OSS
notes 1806015 and 1831460 must be applied
In release SAP_BASIS 7.40, SP2 OSS note 1834930 must be applied before using the SQL
Monitor
© 2013 SAP AG or an SAP affiliate company. All rights reserved. 73
Summary
ABAP is and will continue to be the basis for applications
like SAP Business Suite, SAP NetWeaver BW, new applications
on-premise as well as in virtual (private) cloud environments
AS ABAP 7.4 facilities leveraging SAP HANA features
by pushing down calculations to the database layer
by means of SAP HANA content integration as well as advanced ABAP database
programming
SAP HANA offers many new possibilities for ABAP-based applications
Examples: application function libraries, business rules, text search
Get started with ABAP on SAP HANA today! Use our offers and trial systems!
© 2013 SAP AG or an SAP affiliate company. All rights reserved. 74
Further Information
SAP Education and Certification Opportunities
http://training.sap.com/v2/course/ha400-abap-programming-for-sap-hana-classroom-099-g-en/
Watch SAP TechEd Online
www.sapteched.com/online
SAP Public Web
Developer Center: http://scn.sap.com/community/developer-center/abap
ABAP Development Tools for SAP NetWeaver: http://scn.sap.com/community/abap/eclipse
ABAP for HANA: http://scn.sap.com/community/abap/hana
ABAP 7.4 Trial Editions: http://scn.sap.com/docs/DOC-41566