Skip to Content
Author's profile photo Armin Beil

How to debug ABAP Managed Database Procedures using ADT – Basics

If you are an ABAP developer and the terms ABAP for HANA, code push down or database procedures sound interesting for you, then you may have already heard about ABAP Managed Database Procedures (AMDP). This article shortly repeats what AMDP is and explains how to debug AMDP procedures using the new AMDP Debugger – which is now part of the ABAP Development Tools (ADT).


What is AMDP?


The goal of ABAP Managed Database Procedures is to make the world of database procedures available for ABAP Developers. In order to achieve this, AMDP offers a way to create, edit and transport database procedures nearly like standard ABAP classes. With the new AMDP Debugger there is now also debugging support directly integrated in the ABAP tool environment.


Example for an AMDP procedure:


ExampleMethod.JPG


A single AMDP procedure is implemented as an AMDP method and its content is written in a database-specific language like SQLScript. One or more AMDP methods are part of an AMDP class that looks almost like a usual ABAP class. The AMDP methods can be directly called from ABAP in the same way as normal ABAP methods.


During activation of such an AMDP class for every AMDP method one DB procedure is generated on the DB layer. During runtime (when an AMDP method is called from ABAP) the corresponding generated database procedure is executed. For the importing and exporting parameters there is an implicit automatic type mapping.


For more information about AMDP see also:


About the AMDP Debugger


Technical Prerequisites for the AMDP Debugger


  • HANA DB SPS9, or higher (SPS 8 with restricted functionality only)
  • SAP NetWeaver 7.50, or higher
  • ABAP Development Tools 2.51, or higher


To go along with the AMDP concept there is no need for a database user or additional authorizations. You only need your ABAP user with the standard ABAP debug authorization to be able to use the AMDP Debugger.


AMDP Debugger and ABAP Debugger are not identical


ABAP programs and database procedures are executed in different environments during runtime:

  • ABAP programs are executed in the ABAP runtime environment on the application server layer (AS ABAP).
  • Database procedures – also those generated from AMDP – are executed in the procedure runtime environment on the database layer (e.g. HANA DB).


Therefore the ABAP Debugger, which is also part of the application server layer, cannot simply reach out for the database layer to control the procedure execution in a foreign runtime environment. Instead that is the task of the AMDP Debugger which is in fact a standalone debugger, independent from the ABAP Debugger and technically rooted on the database layer itself.


Since AMDP procedures are directly called from ABAP it was one of the main goals of the AMDP Debugger to offer a smooth transition from ABAP debugging to AMDP debugging and vice versa. Nevertheless it’s still good to keep in mind that there are two different runtime environments / debuggers involved when working with AMDP.


Lifecycle


One difference between AMDP Debugger and ABAP Debugger is the fact that the AMDP Debugger has to be started before you can do anything else. If the debugger has not been started your DB procedures will not stop at breakpoints. To deal with this we implemented an automatism within ADT to start the debugger implicitly when a user creates a breakpoint for an AMDP.


Stopping the AMDP Debugger after usage is also important because it is rather resource intensive for the ABAP Server and it’s not affordable to have an active debugger instance for every user in the system all the time. For this reason there are two automatisms to stop the debugger implicitly:

  • When a user closes the IDE
  • When a user is idle for 10 minutes (timeout)


Besides this the user always has the possibility to start or stop the AMDP Debugger manually. This is for example necessary when you re-open your IDE after closing it and try to start a debug session with your old breakpoints instead of creating new ones.


Since the current activation state of the AMDP Debugger is quite important it is also reflected by the color of the breakpoints:

  • Gray – debugger is inactive
  • Green – debugger is active, BP is confirmed
  • Blue – debugger is active, BP confirmation is pending


Breakpoints are usually only for a very short time blue / pending, often you won’t recognize that state at all.


How to use the AMDP Debugger – Demo


The following video shows how to activate and deactivate the AMDP Debugger, how to perform stepping and variable inspection and how the AMDP Debugger cooperates with the ABAP Debugger.


In order to keep the demo simple I used strongly simplified example code, so don’t be irritated by the fact that the result of the AMDP could also be retrieved by a single line of Open SQL.



Features and Restrictions


As last part of this article you can find here the lists of currently supported features and restrictions (10/2015):


Supported Features:

  • Change comfortably between ABAP debugging and AMDP debugging
  • Create and manage breakpoints in the embedded code of AMDP classes
  • Step through procedures using Resume (F8) and Step Over (F6)
  • Inspect scalar variable values
  • Analyse table variables including sorting and filtering
  • The languages SQLScript and Llang can be debugged


Restrictions:

  • Native DB procedures – that are not generated via AMDP – cannot be debugged
  • CDS table functions are not yet supported
  • No Step Into (F5) and Step Out (F7) available
  • No support for changing variable values
  • Variable inspection only for top of stack
  • With HDB SPS8 the AMDP Debugger must be restarted after every debug session (not with SPS9+)


Further details and tips


The second part of this article is probably only relevant for you if you actually work with AMDP or plan to do so in the near future. If you only want to get an overview the first part should be sufficient.

Part 2: How to debug ABAP Managed Database Procedures with ADT – Details and Tips

Assigned Tags

      6 Comments
      You must be Logged on to comment or reply to a post.
      Author's profile photo Former Member
      Former Member

      As simple as it can be 🙂 Good one.

      Regards,

      Raghav

      Author's profile photo Torsten Wirth
      Torsten Wirth

      Hello Armin,

      Thank you for this guide. We are on 7.4 SP14. I have successfully debugged a procedure which is directly created on HANA DB. After that I have changed the procedure to AMDP. Now I can't debug it anymore because I'm getting a dump in ABAP:

      "transaction rolled back by an internal error: exception 70000000: The

      attached Debugger compiled some procedures in debug mode on-the-fly. Please

      restart your statement in order to debug them.#"

      I have tried it several times now but there is no difference in the behaviour. Is it really necessary to have 7.5 for using AMDP debugging? Another error message would be better in this case.

      Regards,

      Torsten

      Author's profile photo Armin Beil
      Armin Beil
      Blog Post Author

      Hello Torsten,

      this blog is about the ADT AMDP Debugger that is only available for NetWeaver 7.5 and higher. Since you are working with 7.4 you are most probably not using the ADT AMDP Debugger but the Procedure Debugger of HANA Studio.

      The different debuggers can be confusing and I tried to explain a bit about the differences in the second part of the blog How to debug ABAP Managed Database Procedures using ADT - Details and Tips (Section "Differences to other DB procedure debuggers").

      I will try to answer your question in the other blog that is more suitable: Tutorial: How to Debug an ABAP Managed Database Procedure

      Best regards,

      Armin

      Author's profile photo Torsten Wirth
      Torsten Wirth

      Hello Armin

      ok, I think I have got it now. AMDP Debugger does mean to set the breakpoints in the ABAP Code and not in the generated AMDP Procedures. If I try the first alternative I'm getting this message:

      Debug3.jpg

      And this is what is working with 7.5.

      The alternative is to debug the procedure which is created by AMDP byself.

      Regards,

      Torsten

      Author's profile photo Former Member
      Former Member

      Great Blog Armin! 🙂

      I try to debug an AMDP in a BW Transformation Expert Routine. But when I start the related DTP (Background and Dialog), the debugger is not invoked (although it is started in HANA Studio Debug perspective). We are on 7.5 SP04, HANA 1.0 SP12 Rev 2.
      Do you have any ideas?

      Best regards

      Thorsten

      Author's profile photo Armin Beil
      Armin Beil
      Blog Post Author

      Hello Thorsten,

      thank you!

      1) Did you create the breakpoint directly in the AMDP class (the ABAP class that contains the SQLScript as embedded code) or rather in the generated SQLScript procedure itself? The debugger instance in the debug view should show the name "AMDP Debugger".debug_view.JPG

      2) Is the procedure that you are trying to debug called from ABAP or from other SQLScript procedures (nested)? In case it is nested you should also try to create an additional breakpoint in the calling procedure. In rare situations maybe also further additional breakpoints in the calling procedure of the calling procedure completely up to the top level procedure. For HDB SPS13+ it is planned that the debug mode setting becomes available again in order to avoid the need for multiple breakpoints.

      3) Are you 100% sure the code is really executed? This is actually quite often the reason that the debugger is not invoked and this also happens to the most experienced developers.

      4) If you started with a Hello World program and you used the option "read-only" make sure the procedure is returning some values. Otherwise it might be detected as useless and is not executed at all.

      Best regards,

      Armin