Вы находитесь на странице: 1из 6

9/30/2018 How To Create AMDP With Out Parameters In ABAP Perspective | SAP Blogs

Products
Products Industries
Industries Support
Support Training
Training Community
Community Developer
Developer Partner
Partner About
About  
Ask a Question Write a Blog Post Login

How To Create AMDP With Out Parameters In ABAP


Perspective
June 8, 2017 | 817 Views |

Former Member

BW SAP HANA Modeling Tools (Eclipse)

ABAP AMDP

share
0 share tweet share

Follow

What are AMDPs…

ABAP Managed Database Procedures are a new feature in AS ABAP allowing developers to
write database procedures directly in ABAP. You can think of a Database Procedure as a
function stored and executed in the database. The implementation language varies from one
database system to another. In SAP HANA it is SQL Script. Using AMDP allows developers to
create and execute those database procedures in the ABAP environment using ABAP methods
and ABAP data types.

Advantage of AMDP Process


The main advantage of this method that only the AMDP class has to be transported with
ABAP transport mechanism.
No HANA delivery or HANA transport system is required in this process.
Developers only need ABAP development tools for building and managing the CDS view.
There is no need for additional HANA development tools.

Features of ABAP Managed Database Procedure (AMDP)


Static check code and Syntax colouring are provided for embedded SQLScript
The user can set a Background colour for better visibility AMDP methods in the class.
The User can access other AMDP methods, ABAP dictionary view and ABAP tables in
AMDP method.
AMDP method are called like other regular ABAP methods.
User can perform detailed analysis of various error during runtime in transaction ST22
Modi cation or Enhancement of regular ABAP classes can be done by Users.

https://blogs.sap.com/2017/06/08/how-to-create-amdp-with-out-parameters-in-abap-perspective/ 1/6
9/30/2018 How To Create AMDP With Out Parameters In ABAP Perspective | SAP Blogs

Example of AMDP Class De nition


CLASS CL_AMBP_EXAMPLE DEFINITION.

PUBLIC SECTION.
INTERFACES IF_AMDP_MARKER_HDB. //Marker Interface for HANA DB//

METHODS process //Only ABAP code is possible//


IMPORTING it_param TYPE type1
EXPORTING et_param TYPE type2.

METHODS execute //SQLScript or ABAP code both are possible//


IMPORTING VALUE(it_param) TYPE type1
EXPORTING VALUE(et_param) TYPE type2. //speci c parameter interface required//
CHANGING VALUE(ch_param) TYPE type3

ENDCLASS.

AMDP Class Implementation


CLASS CL_AMDP_EXAMPLE IMPLEMENTATION

METHODS process
// Write ABAP source code here//

ENDMETHOD

METHOD execute BY DATABASE PROCEDURE //AMDP method marker//


FOR HDB //Database platform//
LANGUAGE SQLScript //Database language//
[OPTIONS READ-ONLY] //Database-speci c options//
USING name1 name2 etc… //List of used DDIC entities and AMDPs//

//Write here the SQLScript coding//


select * from dummy;

ENDMETHOD.
ENDCLASS.

Lets Take one Example: Creating AMDP with Input, Output Parameters

First Go to ABAP modeling perspective in HANA Studio

Windows->Perspective->Open Perspective->ABAP ( )

https://blogs.sap.com/2017/06/08/how-to-create-amdp-with-out-parameters-in-abap-perspective/ 2/6
9/30/2018 How To Create AMDP With Out Parameters In ABAP Perspective | SAP Blogs

Create ABAP class:

CLASS zcl_amdp_demo DEFINITION public.


PUBLIC SECTION.
types : tt_mara type table of mara.
interfaces : if_amdp_marker_hdb.
methods : my_method
exporting value(et_mara) type tt_mara.
ENDCLASS.
CLASS zcl_amdp_demo IMPLEMENTATION.
method my_method by database procedure for HDB
language sqlscript options read-only using MARA.
et_mara=SELECT * from MARA;
endmethod.
ENDCLASS.

https://blogs.sap.com/2017/06/08/how-to-create-amdp-with-out-parameters-in-abap-perspective/ 3/6
9/30/2018 How To Create AMDP With Out Parameters In ABAP Perspective | SAP Blogs

Save It(Control+S)

Open SAP GUI

Enter TCODE : SE24 (To see u r class is created or not)

We can see our methods and code also.

Click on Display

Enter TCODE : SE38 (To Create report )

In Report we are calling class (creating object to class)

Click on create

https://blogs.sap.com/2017/06/08/how-to-create-amdp-with-out-parameters-in-abap-perspective/ 4/6
9/30/2018 How To Create AMDP With Out Parameters In ABAP Perspective | SAP Blogs

REPORT ZCL_AMDP_DEMO_REP.
DATA : r_amdp TYPE REF TO zcl_amdp_demo,
et_mara TYPE TABLE OF mara,
r_salv TYPE REF TO cl_salv_table.
CREATE OBJECT r_amdp.

r_amdp->my_method(
IMPORTING et_mara = et_mara ).

TRY.
CALL METHOD cl_salv_table=>factory
IMPORTING
r_salv_table = r_salv
CHANGING
t_table = et_mara
.
CATCH cx_salv_msg .
ENDTRY.
r_salv->display( ).

Finally press F8 Button to execute

https://blogs.sap.com/2017/06/08/how-to-create-amdp-with-out-parameters-in-abap-perspective/ 5/6
9/30/2018 How To Create AMDP With Out Parameters In ABAP Perspective | SAP Blogs

Alert Moderator

Be the first to leave a comment


You must be Logged on to comment or reply to a post.

Share & Follow

Privacy Terms of Use

Legal Disclosure Copyright

Trademark Cookie Preferences

Sitemap Newsletter

https://blogs.sap.com/2017/06/08/how-to-create-amdp-with-out-parameters-in-abap-perspective/ 6/6

Вам также может понравиться