An example of AMDP( ABAP Managed Database Procedure ) in 740
ABAP Managed Database Procedures are new feature available in AS ABAP 7.40, SP05 which enables you to manage and call stored procedures or database procedure in AS ABAP. An ABAP Managed Database Procedure is a procedure written in its database-specific language (Native SQL, SQLScript, …) implemented in an AMDP method of an AMDP class.
I use a simple example to show how it works. In line 21 the check is done against database type. Since I will demonstrate to manage and call store procedure writtin in SQLScript in HANA, the sample must be running in HANA DB.
Then in line 26 a pop up is displayed to allow user input how much price he would like to increase. In line 33, the price is increased by calling
HANA store procedure, with the help of AMDP class CL_DEMO_AMDP.
An AMDP class to handle with HANA stuff must inherit the tag interface IF_AMDP_MARKER_HDB
And AMDP method must specify the database type ( HDB ) and language type ( SQLSCRIPT ) using keyword shown below.
The “:” in line 4 and line 5 are specific syntax of SQLScript – the importing parameter should have it as prefix.
The most important part is the AMDP class could not be developed in SAP GUI, but only possible in ABAP development Tools ( i.e ABAP in Eclipse)
Every AMDP method corresponds to a store procedure which you can find in HANA studio. Or you can also find it via ST05:
Meanwhile this document Implement and consume your first ABAP Managed Database Procedure on HANA also introduces another good example.
Hi Jerry,
Just out of curiosity (I don't see myselfI using AMDP in the near future),
What is the reason that AMDP class cannot be developed in SAP GUI?
A couple of years ago, there was a decision to develop new ABAP features only for
usage in ABAP in Eclipse. One reason being resources.
At those times, we had a strong push towards Java, this was before Oracle aquired Sun.
AMDP Classes are one example, there are others, e.g. if you are in BW development
the new Composite Provides (successor of Multi Provider) require ABAP in Eclipse.
Dont ask, what I personally thinks about this decision, but it was made, and I dont think
we will ever return. The good thing at least is, that you can view the AMDP clases in SE80.
With kind regards
Uwe Gebhardt
PS: Some features in ABAP in Eclipse are quite ok, but there also some disadvantages.
An obvious example is the presentation of the class in its component parts in the GUI as opposed to editing a monolithic chunk in Eclipse.
I couldn't save my AMDP until I had managed to get an error free version. I ended up copying to a word document to keep work.
Thanks for your reply.
Quite disappointing, though..
If the editor would be open, an SQLScript syntax checker would necessarily have to be integrated into SE80 (if not, developers would cry for it with a flood of OSS tickets). Apparently, there was no time planned for this integration. Therefore, the editor is locked for input.
Bro tip: If you know what you're doing, change the source with INSERT REPORT FROM ... Since the editor lock is only because of the missing the SQLScript syntax checker, and since there is no extra generation step in the workbench (the SQLScript source code will be transferred as-is into the HANA DB), you can succeed this way.
P.S. (on 2014-04-27): The syntax check seems to be integrated in my test system (7.40, SP06). When forcing the editor to be open (by a modification in method class_implements_amdp_marker, class CL_OO_ABSTRACT_CLASS_TOOL), the syntax check is performed for language SQLScript, with the expected error messages coming from HANA. So there must be another reason why the editor has been closed for AMDP classes...
Hi Wang,
Thank you for sharing valuable info....
But still I'm struggling with AMDPs when Call Database Procedure(SAP Database).
I want to call Database in my AMDP.
Could you please provide me sample end to end code.
Thanks in Advance...
Regards,