Automate debugging using ABAP debugger scripts

By Jaspreet Singh, SAPLabs India (External)


There must be many situations in which you have to debug very complex SAP standard or custom code. It might be possible that you have to check all the RFC calls, database updates, authority checks etc.

But as you might very well know, that complex applications can have very large number of these statements. Checking the result of each statement in debugger can be very cumbersome. Using debugger scripts, you can automate the above process and pin point the particular statement in the code.

Example: Here, I have created a demo program which contains some ‘Select’ statements. We wish to check the statement, which is not returning SY-SUBRC  = 0. Note that this is a test program and you might not appreciate the use of scripts here. But applying the same technique in large programs can increase your productivity significantly.

There are some select statements in the above program. We wish to know which statement is giving SY-SUBRC = 4.  


1.     Enter in debug mode in the code in which you want to check. Open the script tab.

2.     Now, change the trigger of the script. Tick the checkbox ‘Breakpoint reached’.

3.     Note that, the breakpoint for the script trigger is not the same one as we create in ABAP. For triggering in script, you would have to create your breakpoint through script.

Click on the ‘Change’ button in front of ‘Breakpoint Reached’ checkbox.

Create a breakpoint for ABAP statement ‘Select’.

4.     Now that the trigger is created. We have to write the code to analyze the statement at which the script is triggered.  All the code can be easily generated using  ‘Script wizard’ and has to be written in method ‘Script’. Following are the steps which we need to perform using script.  

-          The script will trigger at the ‘Select’ statement. Execute this statement

-          Get the value of the program variable ‘SY-SUBRC’.

-          Analyze the sy-subrc value. If sy-subrc  NE 0, we will trigger the breakpoint.  

a. So, we will use script wizard to step over (execute) the current statement (‘Select’). Remember to pass the parameter for ‘F5’ from the flower box that we get after selecting the Debug step. (Refer to attached code)

b.    Get the value of the system variable ‘SY-SUBRC’ using script wizard.

Click here to continue...

Please send us your feedback/suggestions at webmaster@SAPTechnical.COM 

HomeContribute About Us Privacy Terms Of Use • Disclaimer • SafeCompanies: Advertise on SAPTechnical.COM | Post JobContact Us  

Graphic Design by Round the Bend Wizards

footer image footer image