[Series] create ABAP SAP ABAP AMDP with parameters

No public: SAP Technical
Author: Matinal
 

 

The preface

We can focus on my public number, the number public in the layout better, read more comfortable.

Body part

What is AMDP ......

ABAP database hosting process is a new feature in AS ABAP, and allows developers to write database procedures directly in ABAP. You can use the database in the process as a function stored in the database and executed. Implementation language because the database system to another. In the SAP HANA, it is a SQL script. Use AMDP allows developers to use ABAP ABAP data types and methods to create and execute processes in these databases ABAP environment.

AMDP flow advantage

  • The main advantage of this method is that only class must AMDP ABAP transmission mechanism for transmission.
  • This process does not require HANA HANA transmission or delivery system.
  • Developers need only ABAP development tools to build and manage CDS view. No additional HANA development tools.

ABAP database hosting process (AMDP) function

  • Embedded SQLScript provide static checking code and syntax coloring
  • The user can set the background color, to better see AMDP method in the class.
  • Users can access other methods in AMDP AMDP method , ABAP dictionary view and ABAP table .
  • Like other conventional methods as ABAP call AMDP method.
  • Users can transaction ST22 to perform a detailed analysis of various errors during runtime of
  • Users can ABAP class conventional modified or enhanced .

Exemplary class definition AMDP

CLASS CL_AMBP_EXAMPLE definition.

Public section.
INTERFACES IF_AMDP_MARKER_HDB. // HANA DB marker interface //

METHODS process // only use the ABAP code //
IMPORTING it_param the TYPE type1 
EXPORTING et_param the TYPE type2.

The method may be used SQLScript performed // or ABAP code // 
IMPORTING of VALUE (it_param) the TYPE Type1 
EXPORTING of VALUE (et_param) the TYPE Type2. // require specific parameters of the interface //
CHANGING of VALUE (ch_param) the TYPE type3

ENDCLASS。

Achieve AMDP class

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-specific options//
USING name1 name2 etc… //List of used DDIC entities and AMDPs//
//Write here the SQLScript coding// 
select * from dummy;
…
ENDMETHOD.
ENDCLASS.

​

Let's take an example: Create AMDP with input and output parameters

Turning first to FIG ABAP modeling perspective view of HANA Studio

Windows-> Perspective-> Open Perspective-> ABAP

Creating ABAP class:

CLASS ztestk DEFINITION public.

PUBLIC SECTION.

types : tt_mara type table of mara.

interfaces : if_amdp_marker_hdb.

methods : my_method

importing value(im_matnr) type mara-matnr

exporting value(et_mara) type tt_mara.

ENDCLASS.

CLASS ztestk IMPLEMENTATION.

method my_method by database procedure for HDB

language sqlscript options read-only using MARA.

et_mara=SELECT * from MARA where MATNR= IM_MATNR;

endmethod.

ENDCLASS.

​

Save (Control + S)

Open the SAP GUI

Enter TCODE: SE24 (To see if your class is created)

We can also see that our methods and code.

Click on "Show"

Enter TCODE: SE38 (Create Report)

In the Report, we call the class (create an object of class)

Click Create

Here you enter the code to call the class

REPORT ZTESTK_REP.
PARAMETERS : p_matnr TYPE matnr DEFAULT ‘000000000000001109’.

DATA : r_amdp TYPE REF TO ztestk,
et_mara TYPE TABLE OF mara,
r_salv TYPE REF TO cl_salv_table.

CREATE OBJECT r_amdp.

r_amdp->my_method( EXPORTING im_matnr  = p_matnr
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( ).

​

 

Guess you like

Origin www.cnblogs.com/SAPmatinal/p/11184763.html