New AMDP Debugger available in ADT starting with release ABAP 7.5. Check how to use it here…
Remarks before you start
- All screenshots have been made in an AS ABAP System with SID “HANAABAP” installed in the HANA Database Schema “SAPHANAABAP”.
Please consider to adapt this based on the System ID (<SID>) and schema of your system.
- The screenshots have been created based on HANA Studio version 1.0.7000 and might differ with respect to other HANA releases.
What’s in this document
This document describes how to debug an ABAP Managed Database Procedure in SAP NetWeaver 7.4 SP5 and higher.
For a video tutorial please visit How to debug an ABAP Managed Database Procedure (AMDP) – YouTube.
In order to debug an ABAP Managed database procedure (AMDP) in AS ABAP 7.4 SP5, an ABAP user as well as a HANA user is required.
We assume that the AMDB is executed via an ABAP report and is subject to a debugging procedure initiated by the HANA user DEBUGUSER.
For the ABAP user the standard ABAP authorization to execute the corresponding report is required.
For the HANA user DEBUGUSER, the authorization to read the catalogue needs to be granted by the SYSTEM user:
grant catalog read to DEBUGUSER;
Additionally, debugging authorizations are required as described in SAP note 1942471 (http://service.sap.com/sap/support/notes/1942471). According to the note, for SAP HANA releases >= SPS7, three authorizations are required:
- Authorization to debug the procedure
- Authorization to execute the procedure
- Authorization to attach the debugger to a SAP<SID> user session
The corresponding grant statements to be executed in the SQL console of the SAP HANA studio (as SAP<SID> user) for the ABAP Managed DB procedure <AMDP_NAME> are:
grant debug on “SAPHANAABAP”.“<AMDP_NAME>” to DEBUGUSER;
grant execute on “SAPHANAABAP”.“<AMDP_NAME>” to DEBUGUSER;
grant attach debugger to DEBUGUSER;
Alternatively, the grant statements for the authorization to debug any ABAP Managed database procedure in the schema SAPHANAABAP are:
grant debug on schema SAPHANAABAP to DEBUGUSER;
grant select on schema SAPHANAABAP to DEBUGUSER;
grant attach debugger to DEBUGUSER;
Remark: For SAP HANA release SPS6, only the authorization to execute SYS.DEBUG is required.
Since ABAP Managed database procedures are created in the HANA catalogue at first execution – during ABAP class activation – you might need to generate the catalogue object before you can start the debugging. For this purpose you can execute the ABAP report RSDBGEN_AMDP.
Step-by-Step Guide: Debug an ABAP Managed DB procedure
Set a Breakpoint
- Set the breakpoint:
External Debugging: Attach the SQLScript debugger
- Go to the Debug perspective and create a debug configuration:
- Create a new SAP HANA Stored Procedure debug configuration and insert the information depicted in the screenshot:
For the debugging process described in this document, we use the option “Debug an External Session”. The debug user can be selected from the drop down list, in our case the DEBUGUSER. The filter attributes should be as specific as possible. We debug an external session of the “HANA User” SAPHANAABAP, i.e. the user assigned to the primary database connection when running the ABAP report. The user DEVELOPER executes the ABAP report, for this purpose we apply the optional filter on the “Application User”. Finally, click on Apply and start the debugging process via the Debug
- If everything worked fine you should now see in the debug view that the external debugging is running, and you should additionally see the active break point in the Breakpoints view:
Execution of the ABAP report
In this document, the ABAP report ZR_DEMO_AMDP is executed. In the report the call of the class method zcl_demo_amdp=>get_open_so_inv_for_customer leads to the call of the corresponding AMDP procedure. The coding for both, the ABAP report and the ABAP class, can be found in the attached files.
- Switch to the ABAP perspective and execute the ABAP report ZR_DEMO_AMDP (alternatively also the execution of the AMDP via transaction SE24 is possible).
- The debugger attaches to the running session and stops at the breakpoint. Switch to the Debug perspective to use all debugging features (this is not mandatory but might become handy):
You can now use the tools provided by the SQLScript debugger, e.g. you can investigate the values of variables in the Variables view or a data preview of tables et_so_inv_h via right-click on the table:
The data preview is displayed in a corresponding window:
You can proceed to the next breakpoint (if available) via F8 or just end the current debugging cycle of this procedure (via F8 if no other breakpoints are given).
- After this process, the debugger will be in the state described in paragraph “External Debugging: Attach the SQLScript debugger”, i.e. the debugger is in external debug mode. Therefore, you can repeat the debug procedure by re-execution of the ABAP report.
Remark: Please explicitely terminate the debugging process once you are finished. The debug procedure described attaches externally to a running session based on certain filter criteria (in our case “HANA user” SAPHANAABAP and “Application user” DEVELOPER) and if an active breakpoint is set. Therefore, you might accidentially/unintentionally debug a colleagues’ report execution if the criteria are matched – your colleague then either has to wait until you press F8 or until the debugger time out helps .