Vous êtes sur la page 1sur 54

Week 3 Unit 1:

Advanced Language Features

Advanced Language Features


Overview What and Why?

SQLScript is
Extension of ANSI standard SQL
Language for creating stored procedures in SAP HANA
Declarative Logic
SELECT queries
Calculation engine (CE) functions

Orchestration Logic
Data Definition Language (DDL)
Data Manipulation Language (DML)
Assignment and imperative logic

Main goal is to allow the execution of data-intensive calculations inside SAP


HANA
Two reasons why this is required to achieve the best performance:
Eliminate data transfer between database and application tiers
Calculations need to be executed in the database layer to get the maximum benefit from SAP
HANA features such as fast column operations, query optimization, and parallel execution
2014 SAP SE or an SAP affiliate company. All rights reserved

Public

Advanced Language Features


Traditional Programming Model vs. New Programming Model

New Model:
Code to Data

Traditional:
Data to Code

Application Layer

Application Layer

Code
Transfer
minimum
result set

Massive
data copies
creates
bottleneck

DB Layer

DB Layer

Code

2014 SAP SE or an SAP affiliate company. All rights reserved

Public

Advanced Language Features


Editor Integration with SAP HANA Development Perspective

SQLScript Editor
hdbprocedure file extension
Source code stored in the
repository
Source code-based editor
Client-side syntax checking
Code hints
Syntax highlighting

2014 SAP SE or an SAP affiliate company. All rights reserved

Public

Advanced Language Features


Declarative Logic

Allows the developer to declare the data selection via SELECT or calculation
engine (CE) functions
Developer defines the what
Engine defines the how and executes accordingly
Massively parallelized

2014 SAP SE or an SAP affiliate company. All rights reserved

Public

Advanced Language Features


Imperative Logic

Allows developer to control


the flow of the logic within
SQLScript

Scalar variable manipulation


DDL/DML logic
WHILE loops
Branching logic based on some
conditions, for example IF/ELSE
Executed exactly as scripted,
procedurally
No parallel processing

2014 SAP SE or an SAP affiliate company. All rights reserved

Public

Advanced Language Features


Arrays

Allows the developer to define


and construct arrays within
SQLScript

Set elements
Return elements
Remove elements
Concatenate two arrays
Turn array into a table
Turn a column of a table into an
array
Return cardinality of an array

2014 SAP SE or an SAP affiliate company. All rights reserved

Public

Advanced Language Features


Dynamic Filtering

Allows developers to apply a


dynamic WHERE clause to
SELECT statements
Both database tables and intermediate
table variables are supported

2014 SAP SE or an SAP affiliate company. All rights reserved

Public

Advanced Language Features


Cursors

Allows developers to iterate over a result set and perform row-based


processing and calculations

2014 SAP SE or an SAP affiliate company. All rights reserved

Public

Thank you

Contact information:
open@sap.com

2014 SAP SE or an SAP affiliate company.


All rights reserved.
No part of this publication may be reproduced or transmitted in any form or for any purpose without the express permission of SAP SE or an
SAP affiliate company.
SAP and other SAP products and services mentioned herein as well as their respective logos are trademarks or registered trademarks of SAP SE
(or an SAP affiliate company) in Germany and other countries. Please see http://global12.sap.com/corporate-en/legal/copyright/index.epx for additional
trademark information and notices.
Some software products marketed by SAP SE and its distributors contain proprietary software components of other software vendors.
National product specifications may vary.
These materials are provided by SAP SE or an SAP affiliate company for informational purposes only, without representation or warranty of any kind,
and SAP SE or its affiliated companies shall not be liable for errors or omissions with respect to the materials. The only warranties for SAP SE or
SAP affiliate company products and services are those that are set forth in the express warranty statements accompanying such products and
services, if any. Nothing herein should be construed as constituting an additional warranty.
In particular, SAP SE or its affiliated companies have no obligation to pursue any course of business outlined in this document or any related
presentation, or to develop or release any functionality mentioned therein. This document, or any related presentation, and SAP SEs or its affiliated
companies strategy and possible future developments, products, and/or platform directions and functionality are all subject to change and may be
changed by SAP SE or its affiliated companies at any time for any reason without notice. The information in this document is not a commitment,
promise, or legal obligation to deliver any material, code, or functionality. All forward-looking statements are subject to various risks and uncertainties
that could cause actual results to differ materially from expectations. Readers are cautioned not to place undue reliance on these forward-looking
statements, which speak only as of their dates, and they should not be relied upon in making purchasing decisions.

2014 SAP SE or an SAP affiliate company. All rights reserved

Public

11

Week 3 Unit 2:
Triggers

Triggers
Overview

Special type of stored procedure


Executed BEFORE or AFTER an
event on a table
Events such as INSERT,
UPDATE, or DELETE
Created via SQL Console

2014 SAP SE or an SAP affiliate company. All rights reserved

Public

Triggers
Limitations

INSTEAD_OF trigger not supported


Statement-level trigger supported for row-store tables only
Access to subject table is blocked
Execution order is not guaranteed
Statements not supported in the body include:

Result set assignments


Exit/Continue/Return statements
Cursor operations
Procedure calls
Dynamic SQL

2014 SAP SE or an SAP affiliate company. All rights reserved

Public

Triggers
Examples (1)

2014 SAP SE or an SAP affiliate company. All rights reserved

Public

Triggers
Examples (2)

2014 SAP SE or an SAP affiliate company. All rights reserved

Public

Thank you

Contact information:
open@sap.com

2014 SAP SE or an SAP affiliate company.


All rights reserved.
No part of this publication may be reproduced or transmitted in any form or for any purpose without the express permission of SAP SE or an
SAP affiliate company.
SAP and other SAP products and services mentioned herein as well as their respective logos are trademarks or registered trademarks of SAP SE
(or an SAP affiliate company) in Germany and other countries. Please see http://global12.sap.com/corporate-en/legal/copyright/index.epx for additional
trademark information and notices.
Some software products marketed by SAP SE and its distributors contain proprietary software components of other software vendors.
National product specifications may vary.
These materials are provided by SAP SE or an SAP affiliate company for informational purposes only, without representation or warranty of any kind,
and SAP SE or its affiliated companies shall not be liable for errors or omissions with respect to the materials. The only warranties for SAP SE or
SAP affiliate company products and services are those that are set forth in the express warranty statements accompanying such products and
services, if any. Nothing herein should be construed as constituting an additional warranty.
In particular, SAP SE or its affiliated companies have no obligation to pursue any course of business outlined in this document or any related
presentation, or to develop or release any functionality mentioned therein. This document, or any related presentation, and SAP SEs or its affiliated
companies strategy and possible future developments, products, and/or platform directions and functionality are all subject to change and may be
changed by SAP SE or its affiliated companies at any time for any reason without notice. The information in this document is not a commitment,
promise, or legal obligation to deliver any material, code, or functionality. All forward-looking statements are subject to various risks and uncertainties
that could cause actual results to differ materially from expectations. Readers are cautioned not to place undue reliance on these forward-looking
statements, which speak only as of their dates, and they should not be relied upon in making purchasing decisions.

2014 SAP SE or an SAP affiliate company. All rights reserved

Public

Week 3 Unit 3:
Exception Handling

Exception Handling
Overview

Exception handling
is a method for handling exception and
completion conditions
DECLARE EXIT HANDLER
DECLARE CONDITION
SIGNAL or RESIGNAL

2014 SAP SE or an SAP affiliate company. All rights reserved

Public

Exception Handling
SQL Exceptions

Declare exit handlers


for generic SQL
exceptions

Declare exit handlers


for specific SQL error
codes

2014 SAP SE or an SAP affiliate company. All rights reserved

Public

Exception Handling
Signaling User-Defined Conditions

Signaling and catching user-defined conditions

2014 SAP SE or an SAP affiliate company. All rights reserved

Public

Exception Handling
Re-signaling

Re-signaled user-defined exceptions to the caller

2014 SAP SE or an SAP affiliate company. All rights reserved

Public

Thank you

Contact information:
open@sap.com

2014 SAP SE or an SAP affiliate company.


All rights reserved.
No part of this publication may be reproduced or transmitted in any form or for any purpose without the express permission of SAP SE or an
SAP affiliate company.
SAP and other SAP products and services mentioned herein as well as their respective logos are trademarks or registered trademarks of SAP SE
(or an SAP affiliate company) in Germany and other countries. Please see http://global12.sap.com/corporate-en/legal/copyright/index.epx for additional
trademark information and notices.
Some software products marketed by SAP SE and its distributors contain proprietary software components of other software vendors.
National product specifications may vary.
These materials are provided by SAP SE or an SAP affiliate company for informational purposes only, without representation or warranty of any kind,
and SAP SE or its affiliated companies shall not be liable for errors or omissions with respect to the materials. The only warranties for SAP SE or
SAP affiliate company products and services are those that are set forth in the express warranty statements accompanying such products and
services, if any. Nothing herein should be construed as constituting an additional warranty.
In particular, SAP SE or its affiliated companies have no obligation to pursue any course of business outlined in this document or any related
presentation, or to develop or release any functionality mentioned therein. This document, or any related presentation, and SAP SEs or its affiliated
companies strategy and possible future developments, products, and/or platform directions and functionality are all subject to change and may be
changed by SAP SE or its affiliated companies at any time for any reason without notice. The information in this document is not a commitment,
promise, or legal obligation to deliver any material, code, or functionality. All forward-looking statements are subject to various risks and uncertainties
that could cause actual results to differ materially from expectations. Readers are cautioned not to place undue reliance on these forward-looking
statements, which speak only as of their dates, and they should not be relied upon in making purchasing decisions.

2014 SAP SE or an SAP affiliate company. All rights reserved

Public

Week 3 Unit 4:
User-Defined Functions

User-Defined Functions
Overview

Language used within the body is


SQLScript, no other languages are
supported
Functions are read-only, side
effect-free
Two types:
Table user-defined function (UDF)
Scalar user-defined function (UDF)

2014 SAP SE or an SAP affiliate company. All rights reserved

Public

User-Defined Functions
Table UDF (1)

New repository artifact (.hdbtablefunction) and wizard


Currently a simple text editor. More robust editor features are planned for a
future support package

2014 SAP SE or an SAP affiliate company. All rights reserved

Public

User-Defined Functions
Table UDF (2)

Can have any number of


input parameters

Returns exactly one table


Table operations are
allowed within the body
Consumed in the FROM
clause of a SELECT
statement

2014 SAP SE or an SAP affiliate company. All rights reserved

Public

User-Defined Functions
Scalar UDF (1)

New repository artifact (.hdbscalarfunction) and wizard


Currently a simple text editor. More robust editor features are planned for a
future support package

2014 SAP SE or an SAP affiliate company. All rights reserved

Public

User-Defined Functions
Scalar UDF (2)

Can have any number of input


parameters
Can return multiple values
Expression statements are
allowed within the body
No table operations such as
CURSOR, CE functions or
Array operations
Input parameters cannot be
table type
Consumed from the field list
or the WHERE clause of the
SELECT statement. Also
callable via direct
assignment( x :=
my_scalar_func() )

2014 SAP SE or an SAP affiliate company. All rights reserved

Public

Thank you

Contact information:
open@sap.com

2014 SAP SE or an SAP affiliate company.


All rights reserved.
No part of this publication may be reproduced or transmitted in any form or for any purpose without the express permission of SAP SE or an
SAP affiliate company.
SAP and other SAP products and services mentioned herein as well as their respective logos are trademarks or registered trademarks of SAP SE
(or an SAP affiliate company) in Germany and other countries. Please see http://global12.sap.com/corporate-en/legal/copyright/index.epx for additional
trademark information and notices.
Some software products marketed by SAP SE and its distributors contain proprietary software components of other software vendors.
National product specifications may vary.
These materials are provided by SAP SE or an SAP affiliate company for informational purposes only, without representation or warranty of any kind,
and SAP SE or its affiliated companies shall not be liable for errors or omissions with respect to the materials. The only warranties for SAP SE or
SAP affiliate company products and services are those that are set forth in the express warranty statements accompanying such products and
services, if any. Nothing herein should be construed as constituting an additional warranty.
In particular, SAP SE or its affiliated companies have no obligation to pursue any course of business outlined in this document or any related
presentation, or to develop or release any functionality mentioned therein. This document, or any related presentation, and SAP SEs or its affiliated
companies strategy and possible future developments, products, and/or platform directions and functionality are all subject to change and may be
changed by SAP SE or its affiliated companies at any time for any reason without notice. The information in this document is not a commitment,
promise, or legal obligation to deliver any material, code, or functionality. All forward-looking statements are subject to various risks and uncertainties
that could cause actual results to differ materially from expectations. Readers are cautioned not to place undue reliance on these forward-looking
statements, which speak only as of their dates, and they should not be relied upon in making purchasing decisions.

2014 SAP SE or an SAP affiliate company. All rights reserved

Public

Week 3 Unit 5:
Application Function Library
(AFL)

Application Function Library (AFL)


Overview

Application Function Library (AFL) what is it?


Pre-delivered, commonly utilized business, predictive, and other types of algorithms
What are its benefits?
Algorithms can be leveraged directly in development projects

What are its primary libraries?


The Predictive Analysis Library (PAL)
The Business Function Library (BFL)
Application Functions (C++)
Predictive Analysis Library

2014 SAP SE or an SAP affiliate company. All rights reserved

Business Function Library

Public

Application Function Library (AFL)


Framework in SAP HANA

AFL technology includes


Application functions
Written in C++ and delivered as AFL content by
SAP
Predictive Analysis Library and Business Function
Library have been released in SPS05 as AFL
content

AFL framework
On-demand library-loading framework for
registered and supported libraries
AFLs are consumed for use from SQLScript via
wrapper procedures. Consumption can be
controlled via permissions
Beyond the initial script-based approach, the
Application Function Modeler is released with
SPS06 as a graphical editor to facilitate the
design-time process of creating the
wrapper procedures, and can easily be re-used as
part of development workflow
2014 SAP SE or an SAP affiliate company. All rights reserved

SAP HANA Clients


(App Server, Analytics Technology,)
SAP HANA

AFM
SQLScript

Parameter Table

AFL Framework

Application Functions (C++)


Predictive
Analysis
Library

Business
Function
Library

Public

Application Function Library (AFL)


Business Function Library (BFL)

Compiled analytic function library for business functionality


Supports various pre-built, parameter-driven algorithms

Embedded into calculation engine


http://help.sap.com/hana/SAP_HANA_Business_Function_Library_BFL_en.pdf
Help customers to
Build applications quickly

Reuse common business functionalities without re-inventing


them

Compute quickly

Perform functions in real time with high-performance inmemory computation

Empower the business

Bring decision support capabilities to the business users


through simplified experience and pre-built scenarios

2014 SAP SE or an SAP affiliate company. All rights reserved

Public

Application Function Library (AFL)


BFL Diminishing Balance Depreciation Example
...
declare
declare
declare
declare
declare

capitalization double ARRAY;


rate double ARRAY;
flag double ARRAY;
capitalizationtype double ARRAY;
periods double array;

capitalization[1] := '100000';
lt_capitalization = unnest(:capitalization) as ("VALUE");
rate[1] := '0.1';
lt_rate = unnest(:rate) as ("VALUE");
flag[1] := '0';
lt_flag = unnest(:flag) as ("VALUE");
capitalizationtype[1] := '0';
lt_capitalizationtype = unnest(:capitalizationtype) as ("VALUE");
periods[1] := '24';
lt_periods = unnest(:periods) as ("VALUE");
CALL "_SYS_AFL"."AFLBFL_DBDEPRECIATION_PROC"(:lt_capitalization,
:lt_rate, :lt_flag,
:lt_capitalizationtype,
:lt_periods,
:lt_depreciation);
ex_depreciation_tab = SELECT TO_DECIMAL(DEP_VALUE, 9, 2)

...

2014 SAP SE or an SAP affiliate company. All rights reserved

Public

Application Function Library (AFL)


Predictive Analysis Library (PAL)

Predictive Analysis Library (PAL)


Compiled analytic function library for predictive analysis
Supports multiple algorithms
http://help.sap.com/hana/SAP_HANA_Predictive_Analysis_Library_PAL_en.pdf

Help customers to
Know the business

Decide with confidence

Compute quickly

Empower the business

Uncover deep insights and patterns about the business

Drive more advanced analyses

Query and analyze data in real time with high-performance


in-memory computation
Bring decision support capabilities to the business users
through pre-built scenarios

2014 SAP SE or an SAP affiliate company. All rights reserved

Public

Application Function Library (AFL)


Predictive Analysis Library (PAL) Supported Algorithms

Supported Algorithms

Association Analysis
Classification Analysis
Regression
Cluster Analysis
Time Series Analysis
Probability Distribution
Outlier Detection
Statistic Functions (Univariate)
Link Prediction
Data Preparation
Statistic Functions (Multivariate)

X
Z

Multiple Linear Regression example Z = f(X,Y)

2014 SAP SE or an SAP affiliate company. All rights reserved

Public

Application Function Library (AFL)


PAL K-Means Example Generate PAL Procedure via SQL Console
CREATE TYPE SAP_HANA_EPM_NEXT.PAL_KMEANS_DATA_T AS TABLE(
"ID" INTEGER, "V000" DOUBLE, "V001" VARCHAR(2), "V002" DOUBLE
);
CREATE TYPE SAP_HANA_EPM_NEXT.PAL_KMEANS_ASSIGNED_T AS TABLE(
"ID" INTEGER, "CLUSTER" INTEGER, "DISTANCE" DOUBLE
);
CREATE TYPE SAP_HANA_EPM_NEXT.PAL_KMEANS_CENTERS_T AS TABLE(
"CLUSTER_ID" INTEGER, "V000" DOUBLE, "V001" VARCHAR(2), "V002" DOUBLE
);
CREATE TYPE SAP_HANA_EPM_NEXT.PAL_CONTROL_T AS TABLE(
"NAME" VARCHAR (100), "INTARGS" INTEGER, "DOUBLEARGS" DOUBLE,
);

"STRINGARGS" VARCHAR (100)

CREATE COLUMN TABLE SAP_HANA_EPM_NEXT.PAL_KMEANS_PDATA_TBL(


"ID" INTEGER, "TYPENAME" VARCHAR(100), "DIRECTION" VARCHAR(100)
);
INSERT
INSERT
INSERT
INSERT

INTO
INTO
INTO
INTO

SAP_HANA_EPM_NEXT.PAL_KMEANS_PDATA_TBL
SAP_HANA_EPM_NEXT.PAL_KMEANS_PDATA_TBL
SAP_HANA_EPM_NEXT.PAL_KMEANS_PDATA_TBL
SAP_HANA_EPM_NEXT.PAL_KMEANS_PDATA_TBL

VALUES
VALUES
VALUES
VALUES

(1,
(2,
(3,
(4,

'SAP_HANA_EPM_NEXT.PAL_KMEANS_DATA_T', 'in');
'SAP_HANA_EPM_NEXT.PAL_CONTROL_T', 'in');
'SAP_HANA_EPM_NEXT.PAL_KMEANS_ASSIGNED_T', 'out');
'SAP_HANA_EPM_NEXT.PAL_KMEANS_CENTERS_T', 'out');

call "SYSTEM".afl_wrapper_eraser('PAL_KMEANS_PROC');
call "SYSTEM".afl_wrapper_generator('PAL_KMEANS_PROC', 'AFLPAL', 'KMEANS',
SAP_HANA_EPM_NEXT.PAL_KMEANS_PDATA_TBL);
DROP
DROP
DROP
DROP
DROP

TABLE SAP_HANA_EPM_NEXT.PAL_KMEANS_PDATA_TBL;
TYPE SAP_HANA_EPM_NEXT.PAL_KMEANS_DATA_T;
TYPE SAP_HANA_EPM_NEXT.PAL_KMEANS_ASSIGNED_T;
TYPE SAP_HANA_EPM_NEXT.PAL_KMEANS_CENTERS_T;
TYPE SAP_HANA_EPM_NEXT.PAL_CONTROL_T;

2014 SAP SE or an SAP affiliate company. All rights reserved

Public

Application Function Library (AFL)


PAL K-Means Example Call PAL Procedure from SQLScript Procedure
...
lt_PAL_CONTROL_TBL = unnest(:control_name, :control_intargs,
:control_doubleargs, :control_stringargs)
as ("NAME", "INTARGS", "DOUBLEARGS", "STRINGARGS");

...
lt_PAL_KMEANS_DATA_TBL = unnest(:data_id, :data_v000, :data_v001, :data_v002)
as ("ID", "V000", "V001", "V002");
CALL "_SYS_AFL".PAL_KMEANS_PROC( :lt_PAL_KMEANS_DATA_TBL,
:lt_PAL_CONTROL_TBL,
:lt_PAL_KMEANS_ASSIGNED_TBL,
:lt_PAL_KMEANS_CENTERS_TBL);
ex_pal_kmeans_assigned_tbl = SELECT * FROM :lt_PAL_KMEANS_ASSIGNED_TBL;
ex_pal_kmeans_centers_tbl = SELECT * FROM :lt_PAL_KMEANS_CENTERS_TBL;

...

2014 SAP SE or an SAP affiliate company. All rights reserved

Public

Application Function Library (AFL)


Application Function Modeler

Application Function Modeler


A graphical editor to facilitate a faster and easier design-time process of creating the
wrapper procedures
AFL models are stored as repository objects and can easily be re-used as part of
development workflow
Model Editor
Drag and drop of
functions
Template for table types
Data source selection and
automatic mappings to
table types

Sample SQL
for procedure
consumption

Function List
and Search

Library
Selection
Parameters and
specifications
for table types

2014 SAP SE or an SAP affiliate company. All rights reserved

Public

10

Thank you

Contact information:
open@sap.com

2014 SAP SE or an SAP affiliate company.


All rights reserved.
No part of this publication may be reproduced or transmitted in any form or for any purpose without the express permission of SAP SE or an
SAP affiliate company.
SAP and other SAP products and services mentioned herein as well as their respective logos are trademarks or registered trademarks of SAP SE
(or an SAP affiliate company) in Germany and other countries. Please see http://global12.sap.com/corporate-en/legal/copyright/index.epx for additional
trademark information and notices.
Some software products marketed by SAP SE and its distributors contain proprietary software components of other software vendors.
National product specifications may vary.
These materials are provided by SAP SE or an SAP affiliate company for informational purposes only, without representation or warranty of any kind,
and SAP SE or its affiliated companies shall not be liable for errors or omissions with respect to the materials. The only warranties for SAP SE or
SAP affiliate company products and services are those that are set forth in the express warranty statements accompanying such products and
services, if any. Nothing herein should be construed as constituting an additional warranty.
In particular, SAP SE or its affiliated companies have no obligation to pursue any course of business outlined in this document or any related
presentation, or to develop or release any functionality mentioned therein. This document, or any related presentation, and SAP SEs or its affiliated
companies strategy and possible future developments, products, and/or platform directions and functionality are all subject to change and may be
changed by SAP SE or its affiliated companies at any time for any reason without notice. The information in this document is not a commitment,
promise, or legal obligation to deliver any material, code, or functionality. All forward-looking statements are subject to various risks and uncertainties
that could cause actual results to differ materially from expectations. Readers are cautioned not to place undue reliance on these forward-looking
statements, which speak only as of their dates, and they should not be relied upon in making purchasing decisions.

2014 SAP SE or an SAP affiliate company. All rights reserved

Public

12

Week 3 Unit 6: Plan Visualizer

Plan Visualizer
Overview

Tool used to analyze SQL and SQLScript procedures


Integrated directly into SAP HANA studio
Shows graphical representation of execution plan of SQL statement or procedure call

2014 SAP SE or an SAP affiliate company. All rights reserved

Public

Thank you

Contact information:
open@sap.com

2014 SAP SE or an SAP affiliate company.


All rights reserved.
No part of this publication may be reproduced or transmitted in any form or for any purpose without the express permission of SAP SE or an
SAP affiliate company.
SAP and other SAP products and services mentioned herein as well as their respective logos are trademarks or registered trademarks of SAP SE
(or an SAP affiliate company) in Germany and other countries. Please see http://global12.sap.com/corporate-en/legal/copyright/index.epx for additional
trademark information and notices.
Some software products marketed by SAP SE and its distributors contain proprietary software components of other software vendors.
National product specifications may vary.
These materials are provided by SAP SE or an SAP affiliate company for informational purposes only, without representation or warranty of any kind,
and SAP SE or its affiliated companies shall not be liable for errors or omissions with respect to the materials. The only warranties for SAP SE or
SAP affiliate company products and services are those that are set forth in the express warranty statements accompanying such products and
services, if any. Nothing herein should be construed as constituting an additional warranty.
In particular, SAP SE or its affiliated companies have no obligation to pursue any course of business outlined in this document or any related
presentation, or to develop or release any functionality mentioned therein. This document, or any related presentation, and SAP SEs or its affiliated
companies strategy and possible future developments, products, and/or platform directions and functionality are all subject to change and may be
changed by SAP SE or its affiliated companies at any time for any reason without notice. The information in this document is not a commitment,
promise, or legal obligation to deliver any material, code, or functionality. All forward-looking statements are subject to various risks and uncertainties
that could cause actual results to differ materially from expectations. Readers are cautioned not to place undue reliance on these forward-looking
statements, which speak only as of their dates, and they should not be relied upon in making purchasing decisions.

2014 SAP SE or an SAP affiliate company. All rights reserved

Public

Week 3 Unit 7: ABAP Managed


Database Procedures (AMDP)

ABAP Managed Database Procedures


Overview

Manage database procedures and


their lifecycles from within the ABAP
development infrastructure
ABAP method is used as container
Implementation of method body is
done in SQLScript
ABAP server creates database
procedure in database catalog

2014 SAP SE or an SAP affiliate company. All rights reserved

Public

ABAP Managed Database Procedures (AMDP)


Example

CLASS zcl_example_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 zcl_example_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.

2014 SAP SE or an SAP affiliate company. All rights reserved

Marker interface

Method additions

Forward
declaration of
accessed
database objects

Public

Thank you

Contact information:
open@sap.com

2014 SAP SE or an SAP affiliate company.


All rights reserved.
No part of this publication may be reproduced or transmitted in any form or for any purpose without the express permission of SAP SE or an
SAP affiliate company.
SAP and other SAP products and services mentioned herein as well as their respective logos are trademarks or registered trademarks of SAP SE
(or an SAP affiliate company) in Germany and other countries. Please see http://global12.sap.com/corporate-en/legal/copyright/index.epx for additional
trademark information and notices.
Some software products marketed by SAP SE and its distributors contain proprietary software components of other software vendors.
National product specifications may vary.
These materials are provided by SAP SE or an SAP affiliate company for informational purposes only, without representation or warranty of any kind,
and SAP SE or its affiliated companies shall not be liable for errors or omissions with respect to the materials. The only warranties for SAP SE or
SAP affiliate company products and services are those that are set forth in the express warranty statements accompanying such products and
services, if any. Nothing herein should be construed as constituting an additional warranty.
In particular, SAP SE or its affiliated companies have no obligation to pursue any course of business outlined in this document or any related
presentation, or to develop or release any functionality mentioned therein. This document, or any related presentation, and SAP SEs or its affiliated
companies strategy and possible future developments, products, and/or platform directions and functionality are all subject to change and may be
changed by SAP SE or its affiliated companies at any time for any reason without notice. The information in this document is not a commitment,
promise, or legal obligation to deliver any material, code, or functionality. All forward-looking statements are subject to various risks and uncertainties
that could cause actual results to differ materially from expectations. Readers are cautioned not to place undue reliance on these forward-looking
statements, which speak only as of their dates, and they should not be relied upon in making purchasing decisions.

2014 SAP SE or an SAP affiliate company. All rights reserved

Public

Vous aimerez peut-être aussi