01_ABAP_on_HANA
description
Transcript of 01_ABAP_on_HANA
ABAP on HANA
SoH Technology Training
© 2013 SAP AG. All rights reserved. 2
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.
© 2013 SAP AG. All rights reserved. 3
HANA Platform
Development
Experience
Consumption
HANA Data Platform (DB)
HANA Application Platform
HANA Cloud Platform
HANA
XS
ABAP Java
Native Device
Business Expert / RDE
JavaScript
Browser
Professional Developer / IDE
Agenda
Apps
HANA Database
Application Server ABAP
Development Tools
Porting your Apps
DB
Data Store
Application Logic
Views Procedures
© 2012 SAP AG. All rights reserved. 4
HANA Database
HANA
ABAP Java
DB Application Logic
Views Procedures
Data Store
Column and
row store Multi-core/
parallelization
In-memory
Compression
SQLScript Attribute, Analytics
& Calculation Views
JDBC DBI
R R
others
ODBC/ODBO
R
Database
Connection
SQL/MDX
R
XS JavaScript
© 2012 SAP AG. All rights reserved. 5
DBs typically use a row-based storage; SAP HANA supports rows, but is optimized
for column-order data organization Order Country Product Sales
456 France corn 1000
457 Italy wheat 900
458 Italy corn 600
459 Spain rice 800
Column and Row Store
456 France corn 1000
457 Italy wheat 900
458 Italy corn 600
459 Spain rice 800
456
457
458
459
France
Italy
Italy
Spain
corn
wheat
corn
rice
1000
900
600
800
Row order organization
Column order organization
Single-record access:
SELECT * FROM SalesOrders
WHERE Order = ‘457’
SQL
Single-scan aggregation:
SELECT Country, SUM(sales) FROM
SalesOrders WHERE Product=‘corn’ GROUP BY
Country
© 2012 SAP AG. All rights reserved. 6
Concurrent users
Concurrent operations within a query
Data partitioning, on one host
or distributed to multiple hosts
Horizontal and vertical
parallelization of a single query
operation, using multiple
cores / threads
Transparent to app developer
Parallelization
quant.
150
60
100
45
75
84
96
162
45
366
sales
$1000
$900
$600
$800
$500 $750
$600
$600
$1100
$450
$2000
type
43
12
12
33
33
12
32
43
12
33
core3
core4
core1 core2
© 2012 SAP AG. All rights reserved. 8
HANA Database
HANA
ABAP Java
DB Application Logic
Views Procedures
Data Store
Column and
row store Multi-core/
parallelization
In-memory
Compression
SQLScript Attribute, Analytics
& Calculation Views
JDBC DBI
R R
others
ODBC/ODBO
R
Database
Connection
SQL/MDX
R
XS JavaScript
© 2012 SAP AG. All rights reserved. 9
Development in SAP HANA
SAP HANA provides two essential techniques for expressing operations
on data:
• Column Views allow to easily define optimized data models for fast read
access based on database tables and views. They support standard
operations (e.g. joins, aggregations, filters) but also business functions
(e.g. for currency/measure conversion).
Column views can be modeled via graphical tools or implemented via
SQLScript in SAP HANA studio. After activation, the generated views can
be accessed via standard SQL.
• Stored Procedures allow to implement data intensive logic via
SQLScript. Procedures can have multiple importing and exporting
parameters (scalar or table types).
Both Column Views and Procedures are highly optimized to leverage the
engines in SAP HANA and can make use of advanced features like built-in
library functions, text analysis and data mining.
© 2012 SAP AG. All rights reserved. 10
HANA Database
HANA
ABAP Java
DB Application Logic Column
Views Procedures
Data Store
Column and
row store Multi-core/
parallelization
In-memory
Compression
SQLScript Attribute, Analytics
& Calculation Views
JDBC DBI
R R
others
ODBC/ODBO
R
Database
Connection
SQL/MDX
R
R HTTP
XS JavaScript
HTTP Client (Browser, Mobile)
© 2013 SAP AG. All rights reserved. 11
Development
Experience
Consumption
HANA Data Platform (DB)
HANA Application Platform
HANA Cloud Platform
HANA
XS
ABAP
Java
Native Device
Business Expert / RDE
JavaScript
Browser
Professional Developer / IDE
Agenda
HANA Database
Application Server ABAP
Development Tools
Porting your Apps
DB Application Logic
Views Procedures
Data Store
© 2013 SAP AG. All rights reserved. 12
SAP Business Suite powered by SAP HANA Unifying analytics and transactions into a single in-memory platform
Real-Time
Execution
Real-Time
Reporting
and Analysis
Real-Time
Interactions
Real-Time
Planning
Real-Time
Platform
The Most Modern Business Platform for Innovation Without Disruption
© 2013 SAP AG. All rights reserved. 13
SAP NetWeaver AS ABAP 7.4
Overview
ABAP 7.4 release strategy
• ABAP 7.4 is an enhancement package for NetWeaver 7.x
• Underlying application server for SAP Business Suite and
SAP NetWeaver BW
• Available already; GA is planned for May 2013
• There is no formal ramp-up for ABAP 7.4
Major structural news in AS ABAP 7.4
• New ABAP kernel version 7.40 supporting new ABAP
server and runtime features
• NetWeaver Gateway and SAPUI5 are part of AS ABAP 7.4
• ABAP Development Tools are part of the SAP Eclipse
Release Train (central update site for SAP Eclipse tools)
SAP NetWeaver AS ABAP 7.4 is the “to-go” release for all SAP HANA based ABAP applications
SAP
NetWeaver
BW
SAP
Business
Suite
Custom Applications
...
ABAP Development Tools for SAP NetWeaver
SAP HANA Database
SAP NetWeaver AS ABAP 7.4
Any DB
© 2013 SAP AG. All rights reserved. 14
ABAP Development on SAP HANA
Accelerate, Extend, Innovate using proven SAP NetWeaver qualities
Benefits for customers and partners
• Proven – Built on mature NetWeaver qualities
• Efficient – Leverage existing investments and skills
• Non-disruptive – Step-wise approach possible
CR
M
SC
M
SR
M
PL
M
ER
P
An
aly
tics
SAP Business Suite
BW
Ap
ps
HANA DB
Custom Development Opportunities
EXTEND ACCELERATE
INNOVATE
Guided performance optimizations
Real-time access to any data
Advanced view building
From batch to interactive
Text search
Predictive Analysis
© 2013 SAP AG. All rights reserved. 15
ABAP Development on SAP HANA
Bringing the power of SAP HANA to the end-user
ABAP 7.4 will support this through existing UI technologies
• New ALV variant supporting fast navigation through large data sets
(usable in SAP GUI and Web Dynpro ABAP Floorplan Manager)
• Fault-tolerant value helps using SAP HANA text search
• Analytical side-panels allowing non-disruptive enrichment of
transactions providing additional insights for end-users
• New possibilities for combining transactional and analytical data in new
consumption scenarios through NetWeaver Gateway / SAPUI5
• Full suite of SAP BI clients supported based on embedded BW
The most important benefit of SAP HANA is to support customers to make smarter and faster decisions.
The power of SAP HANA has to “reach the end-user” by simplifying concrete business processes.
© 2013 SAP AG. All rights reserved. 16
SAP NetWeaver AS ABAP 7.4
Options for customer / partner developments
SAP
Business
Suite
SAP
HANA Any DB
Customer
/ Partner
SAP
Business Suite
SAP HANA
CD /
PD SAP
Business
Suite
SAP
HANA Any DB
CD /
PD
SAP
NetWeaver BW
SAP HANA
CD /
PD Customer / Partner
Development
SAP HANA
1) Accelerators for
Add-Ons
2) Add-Ons for SoH 3) New applications
(side-by-side with
Business Suite)
4) Add-Ons for
NetWeaver BW
5) New applications
(no direct link to
Business Suite)
customer-specific
developments in SoH context
enable existing Add-Ons to
run on SoH
optimize them for SAP HANA
technology
develop completely new
Add-Ons for SoH
develop new applications
running side-by-side with
Business Suite (similar HPAs)
specifically designed and
implemented for SAP HANA
technology
customer-specific
developments in NetWeaver
BW context
along the lines of 2)
develop new applications
(but no direct link to Business
Suite)
along the lines of 3)
accelerate existing Z-coding,
develop application-specific
accelerators
possible also with ABAP 7.x
CD / PD = customer development / partner development
© 2013 SAP AG. All rights reserved. 17
Development
Experience
Consumption
HANA Data Platform (DB)
HANA Application Platform
HANA Cloud Platform
HANA
XS
Java
Native Device
Business Expert / RDE
JavaScript
Browser
Professional Developer / IDE
Agenda
HANA Database
Application Server ABAP
Development Tools
Porting your Apps
DB Application Logic
Views Procedures
Data Store
ABAP
© 2013 SAP AG. All rights reserved. 18
ABAP Development on SAP HANA
Code Pushdown as paradigm
Push data-intensive calculations to SAP
HANA leading to less data transfer
Exploit advanced SAP HANA
capabilities from ABAP
Development on each layer
© 2013 SAP AG. All rights reserved. 19
ABAP Development on SAP HANA
Overview: Integrated Development Experience based on Eclipse
• It is possible to install the new ABAP Development
tools for SAP NetWeaver into the SAP HANA studio
via the Eclipse update site mechanism.
• This integrated installation offers developers a
combined environment for end-to-end application
development with ABAP on SAP HANA including
Lifecycle Management aspects.
• ABAP 7.4 provides a reference scenario (Open
Items Analytics) which demonstrates how to develop
an ABAP application on SAP HANA, and in
particular how to integrate into existing user
interface technologies such as Web Dynpro ABAP
Floorplan Manager and SAPUI5.
© 2013 SAP AG. All rights reserved. 20
Development in SAP HANA
Column Views
SAP HANA offers advanced view modeling, e.g.
• Attribute views (join views)
• Analytic views (star schemas)
• Calculation views (modeled or coded via SQL script)
These views can be accessed by standard SQL (see example)
• With ABAP < 7.4 these views can only be accessed low-level
via native SQL (ADBC)
• With ABAP 7.40 they are natively supported in ABAP
• Access possible via standard Open SQL
• Support for automatic client handling
• Mapping to DDIC types possible
© 2013 SAP AG. All rights reserved. 21
Development in SAP HANA
Database Procedures
SAP HANA offers writing stored procedures in SQLScript –
a extension to SQL - for expressing data intensive application
logic.
Stored procedures are invoked via the CALL SQL statement
by passing the importing and exporting parameters (which
can be scalars or table types)
• With ABAP < 7.40 stored procedures can be called using
ADBC, which requires
• Manual handling of transfer tables for input and output
parameters via temporary tables or result views
• Manual mapping of database types to DDIC types
• With ABAP 7.40 they are natively supported in ABAP
• Exporting/Importing parameters like for function modules
(including mapping parameter to DDIC types)
Demo Accessing SAP HANA views and procedures from ABAP
© 2013 SAP AG. All rights reserved. 23
Example: create and use a
HANA Attribute View
© 2013 SAP AG. All rights reserved. 24
© 2013 SAP AG. All rights reserved. 25
© 2013 SAP AG. All rights reserved. 26
© 2013 SAP AG. All rights reserved. 27
© 2013 SAP AG. All rights reserved. 28
© 2013 SAP AG. All rights reserved. 29
Proxy
© 2013 SAP AG. All rights reserved. 30
© 2013 SAP AG. All rights reserved. 31
© 2013 SAP AG. All rights reserved. 32
© 2013 SAP AG. All rights reserved. 33
© 2013 SAP AG. All rights reserved. 34
© 2013 SAP AG. All rights reserved. 35
© 2013 SAP AG. All rights reserved. 36
© 2013 SAP AG. All rights reserved. 37
Remark
• Open SQL
enhancement
available as of
NW 7.40 SP 2
© 2013 SAP AG. All rights reserved. 38
Example: use a HANA
SQL Procedure
© 2013 SAP AG. All rights reserved. 39
© 2013 SAP AG. All rights reserved. 40
© 2013 SAP AG. All rights reserved. 41
Proxy
© 2013 SAP AG. All rights reserved. 42
© 2013 SAP AG. All rights reserved. 43
© 2013 SAP AG. All rights reserved. 44
© 2013 SAP AG. All rights reserved. 45
Remark
• New ABAP
language element
available as of
NW 7.40 SP 2
© 2013 SAP AG. All rights reserved. 46
R
Development Experience
HANA
DB Application Logic
Views Procedures
NW AS ABAP 7.40
Code Pushdown – Buttom-up
HANA Studio
ABAP
Development
Tools
XS
Orchestration (ABAP Coding)
External
DDIC Views
Procedure
Proxies
SQL B
ottu
m-u
p
1. Modelling
2. Consumption
© 2013 SAP AG. All rights reserved. 47
R
Development Experience
HANA
DB Application Logic
Views Procedures
NW AS ABAP 7.40
Code Pushdown – Top-down
HANA Studio
ABAP
Development
Tools
XS
Orchestration (ABAP Coding)
Views ABAP managed
Procedures
SQL
To
p-d
ow
n
Modelling &
Consumption
Not needed for
ABAP development
in future
Gene
rate
© 2013 SAP AG. All rights reserved. 48
Core Data Services (CDS)
A homogeneous approach for modeling of SAP data
Java ABAP
River / XS H
AN
A (
DB
)
Core Data Services
Calc Engine SQL Script (S)QL Engine
DDL QL DML …
Other… RDL JS
Extend SQL to capture
the business intent avoiding
complex & error prone statements
Provide
Database-/
HANA
optimized
programming
model
Harmonize the programming model across all
SAP platforms on HANA to ensure reuse and
interoperability
© 2013 SAP AG. All rights reserved. 49
R
HANA DB
Application Logic
Views Procedures
NW AS ABAP 7.40
Code Pushdown – Runtime
XS
Orchestration (ABAP Coding)
Procedure
Proxies
External
DDIC Views
SQL
NW AS ABAP < 7.40
select ..
from ..
call
database
procedure ..
DBI ADBC Open SQL IF
cl_sql_connection=>get_connection ()
execute_query( ‚SELECT .. <view>‘ )
execute_query(‚CALL <procedure>‘)
NW ABAP < 7.40
• native SQL via
ABAP database
connectivity
(ADBC) is a valid
option
© 2013 SAP AG. All rights reserved. 50
Development
Experience
Consumption
HANA Data Platform (DB)
HANA Application Platform
HANA Cloud Platform
HANA
XS
Java
Native Device
Business Expert / RDE
JavaScript
Browser
Professional Developer
Agenda
HANA Database
Application Server ABAP
Development Tools
Porting your Apps
DB Application Logic
Views Procedures
Data Store
ABAP
Customer / Partner
Applications
Hans-Jürgen Hennrich
March 2013
How to adapt Add-ons for SoH
How to adapt Add-ons for SoH
Mandatory Steps
© 2013 SAP AG. All rights reserved. 53
Column Store vs. Row Store
The HANA Database consists of a row storage and a column storage
The default storage is the column store
All existing tables are automatically created in the column store during deployment of an Add-on (using
transaction SAINT) into an ECC System running on HANA
Using transaction SE13 (tab strip DB specific attributes), you can check which store is used in case of HANA
Example:
© 2013 SAP AG. All rights reserved. 54
Column Store vs. Row Store
Recommendation: Use column store for all existing and new tables of your add-on
The row store should only be used in very exceptional cases. Reasons why a table should be in
row store:
Very huge OLTP load on the table (huge rate of single updates / inserts / deletes)
© 2013 SAP AG. All rights reserved. 55
New OpenSQL Compiler
New OpenSQL compiler is active as of NW7.4 SP2
New compiler identifies syntactically wrong coding (errors) which were ignored before.
Ignoring these errors in existing coding leads to unintended application behavior.
Each errors in existing coding will either result in build errors or runtime errors.
For background information see SAP note 1832139 - OpenSQL runtime environment
The risk of having errors in your code is very low
For the whole ERP around 10 corrections had to be made
How to adapt Add-ons for SoH
Optional Steps
© 2013 SAP AG. All rights reserved. 57
Optimize your Code
HA400 – Programming on SAP HANA
Provides information how to leverage the power of HANA for your applications/coding
The course is currently based on NW 7.31
– the concepts how to improve coding for HANA are the same in NW 7.40
– but the development tools are significantly improved in NW 7.40
© 2013 SAP AG. All rights reserved. 58
Optimize your Code
Reasons why to optimize your code?
With HANA, SQL statements can be processed extremly fast
– the bottleneck is no longer the database, but the transfer of the results to the application server
– therefore new programming paradigms are needed: move calculations into the database
OLTP applications typically use select single
– Select single on HANA (column store) is up to two times slower compared to a traditional database
– Avoid selects single in loops and nested selects
© 2013 SAP AG. All rights reserved. 59
Detect optimization potential on SAP HANA
Performance Tools and Guidelines
Outlook: new tools for “Guided Optimization”
(ABAP 7.4 SP2; RTC May 2013)
• Improved ABAP profiler and new SQL monitor for runtime
analysis
• New performance checks in ABAP code inspector
• “Worklist tool” combining results from code checks and
runtime analysis
Adapted Performance Guidelines
• Existing golden rules remain valid as general
recommendations
• There are some shifts of priorities (e.g. index definition
(lower) and avoidance of nested selects (higher))
• Available in SCN
Key takeaways and Outlook
© 2013 SAP AG. All rights reserved. 61
ABAP Development on SAP HANA
Tools and best practices provided with ABAP 7.4
• Advanced view building in ABAP
• Guidelines, check tools, and best practices
• New ABAP profiler and SQL monitor in Eclipse
• Native access to all SAP HANA features from ABAP
with proven SAP NetWeaver lifecycle management
• Integrated development environment across ABAP and
SAP HANA in Eclipse
• New usage options in existing environments (e.g.
ALV with integrated data access, fault tolerant
search helps, etc.)
• Built upon proven SAP NetWeaver business
frameworks and extensibility concepts
Accelerate
Extend
Innovate
© 2013 SAP AG. All rights reserved. 62
SAP NetWeaver AS ABAP 7.4
What changes – and what doesn’t
No Change
AS ABAP as a strong pillar of
SAP’s product strategy with
commitment to non-disruptive
innovation and the existing
eco-system
Core architecture and qualities
of the AS ABAP remain the
same (kernel, data dictionary,
security, connectivity, etc.)
Change
Challenge existing application
and component designs
Good SQL knowledge as the
key enabling skillset
Eclipse as integrated
development environment
across SAP HANA and ABAP
(and other domains, e.g.
SAPUI5)
© 2013 SAP AG. All rights reserved. 63
HANA Platform
HANA
XS
ABAP Java
JavaScript
DB
Data Store
Application Logic
Views Procedures
Suite Openess Embedded
© 2013 SAP AG. All rights reserved. 64
HANA XS in a nutshell
HANA
ABAP Java
DB Application Logic Column
Views Procedures
Data Store
Column and
row store Multi-core/
parallelization
In-memory
Compression
SQLScript Attribute, Analytics
& Calculation Views
JDBC DBI
R R
others
ODBC/ODBO
R
Database
Connection
SQL/MDX
R
R HTTP/OData
XS JavaScript
HTTP Client (Browser, Mobile)
SQL
Presentation
Logic
© 2013 SAP AG. All rights reserved. 66
HANA View
Entity name
(used to call that service
via HTTP)
Entity name (used to call that service via HTTP)
© 2013 SAP AG. All rights reserved. 67
Package Odata service definition file
© 2013 SAP AG. All rights reserved. 68
Odata service entity name
© 2013 SAP AG. All rights reserved. 69
Odata service definition file
Odata service entity name
© 2013 SAP AG. All rights reserved. 71
© 2013 SAP AG. All rights reserved. 72
HANA XS
HANA
ABAP Java
DB Application Logic Column
Views Procedures
Data Store
Column and
row store Multi-core/
parallelization
In-memory
Compression
SQLScript Attribute, Analytics
& Calculation Views
JDBC DBI
R R
others
ODBC/ODBO
R
Database
Connection
SQL/MDX
R
R HTTP/OData
XS JavaScript
HTTP Client (Browser, Mobile)
SQL
Open Data Protocol
© 2013 SAP AG. All rights reserved. 73
Development
Experience
Consumption
HANA Data Platform (DB)
HANA Application Platform
HANA Cloud Platform
HANA
XS
Java
Native Device
Business Expert / RDE
JavaScript
Browser
Professional Developer
Questions
&
Answers
DB Application Logic
Views Procedures
Data Store
ABAP
Customer / Partner
Applications
Thank you
Contact information: [email protected]
© 2013 SAP AG. All rights reserved. 75
Code pushdown: Top down
Advanced ABAP view building via Core Data Services (CDS)
ABAP
<<Resource>> View Definition
SAP HANA
DDIC
Activation Transport
CDS-DDL Compiler
Calc Engine
Other DB
SQL DDL Compiler
ABAP in Eclipse
Text-based View Editor
Graphical View Editor
CREATE CDS VIEW …
<CalcXML>…
CREATE VIEW …
Table Definitions
SQL Engine
CREATE VIEW …
CDS-QL Views
OpenSQL
SQL 92 HANA SQL
Column Views “One View Model” (= CDS View Entity)
The first step to leverage CDS in ABAP is to
massively improve the view building
capabilities in ABAP
• Support “standard” SQL feature even
beyond current Open SQL capabilities (e.g.
UNIONs).
• Possibility to support SAP HANA specific
extensions via annotations
• Combine native SAP HANA development
with proven ABAP platform qualities
(Lifecycle Management, Extensibility)