Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 2

METHOD <meth> BY DATABASE PROCEDURE

    FOR <db>


    LANGUAGE <db_lang>
    [OPTIONS <db_options>]
    [USING <db_entities>].

< Insert SQLScript code here >

ENDMETHOD.

Every class containing an AMDP must contain the interface IF_AMDP_MARKER_HDB

AMDP:

1. Database procedures are valuable tools for ABAP developers


2. They allow developers to organize their programs more clearly by consolidating logic in a central
location, enabling it to be reused across multiple applications
3. They also provide the ability to perform integrity checks and grant privileges.
4. With SAP HANA, database procedures push down data-intensive logic to the database
5. Initially, these procedures were created and managed in the SAP HANA studio and consumed by the
ABAP layer.
6. SAP NetWeaver 7.4 SPS 05 introduces a new approach, known as ABAP-managed database
procedures (AMDPs).
7. AMDPs allow developers to create and manage stored procedures directly in ABAP, while they are
executed on the database level.
8. The ability to create AMDPs with proper embedding in the ABAP execution context means that they
are fully managed by the SAP system’s change and transport system, and behave like any other
ABAP artifact from a lifecycle management perspective.
9. The development work takes place completely in ABAP in Eclipse; there is no need to drill down into
the SAP HANA studio to define AMDPs.
10. Although AMDPs are defined on the ABAP level, they are by nature dependent on the underlying
database platform, so that they can fully optimize the database in use.
11. For this reason, the implementation language will vary depending on the database in use.
12. For SAP HANA, the implementation language is SQLScript, so creating an AMDP for SAP HANA is as
simple as implementing SQLScript in your ABAP program, both in new and existing programs.
13. How to create AMDP:
a. AMDPs are wrapped into regular global ABAP classes.
b. A method that contains a stored procedure is introduced by the special keyword by database
procedure for hdb language sqlscript, which indicates that other database platforms can hook
in their particular programming languages for stored procedure development.
Example of AMDP:

Goto ABAP perspective. Select temp package->new->ABAP class and write below code. Save and
activate.

class ZAMDP1 definition


public
final
create public .

public section.
INTERFACES if_amdp_marker_hdb.

TYPES:BEGIN OF ty_bupa_selection,
carrier_name TYPE c LENGTH 24,
connection_id TYPE num4,
planetype TYPE c LENGTH 10,u
END OF ty_bupa_selection.

TYPES: tt_bupa_selection TYPE STANDARD TABLE OF ty_bupa_selection WITH EMPTY KEY.

CLASS-methods get_flight_details
IMPORTING
VALUE(iv_client) TYPE mandt
EXPORTING
VALUE(et_result) TYPE tt_bupa_selection.
protected section.
private section.

ENDCLASS.

CLASS ZAMDP1 IMPLEMENTATION.


METHOD get_flight_details BY DATABASE PROCEDURE
FOR HDB
LANGUAGE SQLSCRIPT
OPTIONS READ-ONLY
USING sflight scarr.
et_result = select distinct sc.carrname as carrier_name,
sf.connid as connection_id,
sf.planetype
from sflight as sf inner join scarr as sc on sf.carrid = sc.carrid
order by carrier_name, connection_id, sf.planetype;
ENDMETHOD.

You might also like