Professional Documents
Culture Documents
ABAP Managed Database Procedure
ABAP Managed Database Procedure
Procedures
Sounds like some kind of jargon, yes? Actually, it is what it says. It is a
Database Procedure which is managed by ABAP i.e. you can create, change
or delete AMDPs using ABAP Development Tools in Eclipse. This also means
that AMDPs can be transported using ABAP Transport.
AMDP method can only be created in a global class. If you try to create it in
Local Class, you will get below error.
So create a global class in Eclipse.
2. Add AMDP marker interface
IF_AMDP_MARKER_HDB
Generic types can not be used for parameters. For example Type Any can not be
used.
Only elementary data types and table types with a structured row type can be used.
The table type components must be elementary data types and it can not have
elements which are table types.
Additional restrictions on method parameters
Only pass by value can be used. Pass by reference is not permitted. Using
VALUE keyword for all parameters is required.
In RAISING clause, only class based exceptions are allowed from a specific
exception list.
Parameter names can not start with %_. I like this rule as it does not affect me.
Some keywords like connection, client, endmethod are reserved. Do not use such
names for parameters.
CX_ROOT
|
|--CX_DYNAMIC_CHECK
|
|--CX_AMDP_ERROR
|
|--CX_AMDP_VERSION_ERROR
| |
| |--CX_AMDP_VERSION_MISMATCH
|
|--CX_AMDP_CREATION_ERROR
| |
| |--CX_AMDP_DBPROC_CREATE_FAILED
| |
| |--CX_AMDP_NATIVE_DBCALL_FAILED
| |
| |--CX_AMDP_WRONG_DBSYS
|
|--CX_AMDP_EXECUTION_ERROR
| |
| |--CX_AMDP_EXECUTION_FAILED
| |
| |--CX_AMDP_IMPORT_TABLE_ERROR
| |
| |--CX_AMDP_RESULT_TABLE_ERROR
|
|--CX_AMDP_CONNECTION_ERROR
|
|--CX_AMDP_NO_CONNECTION
|
|--CX_AMDP_NO_CONNECTION_FOR_CALL
|
|--CX_AMDP_WRONG_CONNECTION
(Source : https://help.sap.com/doc/abapdocu_740_index_htm/7.40/en-US/index.htm?file=abenamdp.htm )
Every AMDP method will have below addition. READ-ONLY is only the optional
addition and is used for methods that only read the data.
o BY DATABASE PROCEDURE
o FOR HDB
o LANGUAGE SQLSCRIPT
o READ-ONLY
It is also mandatory to specify all the database objects and other AMDP methods
that are used within the SQLSCRIPT code.
Restrictions
Refer post Working With Eclipse [2] : Useful Eclipse Preferences to set up different
background color for SQLSCRIPT code
Code Reference
CLASS zjp_simple_admp_class DEFINITION
PUBLIC FINAL CREATE PUBLIC .
PUBLIC SECTION.
INTERFACES : if_amdp_marker_hdb.
TYPES : tt_flights TYPE STANDARD TABLE OF sflight.
METHODS : get_flights IMPORTING VALUE(iv_carrid) TYPE sflight-carrid
EXPORTING VALUE(et_flights) TYPE tt_flights.
ENDCLASS.
ENDMETHOD.
ENDCLASS.