Basics of Debugging in SAP
Basics of Debugging in SAP
Basics of Debugging in SAP
Debugging on SAP:
Debuggingisoneofthebestandwonderfultoolusedbythedeveloper(Inanydevelopment
Environment)totrackdownaissueandalsotounderstandcodeorlogicwrittenbyanyother
developer.
Asweknow,sinceitsbeingatechnicalstuff,notallFunctionalConsultantswillhaveanidea
aboutit,sotheyhavesometoughtimeinitiallytounderstandaswhatitisandhowitworks,but
oncetheyunderstandit,itslikepieceofcaketoanyperson.
Ihaveputsomebasicinformationregardingdebuggerandsomebasicconceptsaboutdebugger,
goingoverthesemighthelpyouinnotgettingpanicwhenyouseeadebuggerscreen:).
Note:InSAP,thereare2typesofdebuggers.OneisClassicdebuggerandtheotheroneisNew
Debugger.ClassicdebuggerisloteasytouseandalsotounderstandbutNewdebugger(available
fromreleaselevels6.40)ishasmorefeaturesandalsowillbeusedvastlyinfuture,soIam
goingoverNewdebuggerinmyblog.
Somebriefdifferencesbetweenthese2typesare,(CourtesyofSAP)
The Classic Debugger runs in the same roll area as the application to
be analyzed (debuggee). It is therefore displayed in the same window
as the application. However, this technology also has some
restrictions. For example, some ABAP programs (such as conversion
exist) cannot be analyzed in debug mode for technical reasons.
However, the most significant restriction is that no ABAP technology
can be used for designing the Debugger interface and it is therefore
not possible to create a modern user interface.
Difference between the 2 Stop Buttons is, generally for debugging a report we use the one with
no human icon on it. STOP icon with human icon on it will be used only for External Debugging,
that is if your application is being called from out of SAP's current session. Example cases are:
1. If we are debugging a Webdynpro application which actually runs on an Internet Explorer
browser, we use the External Debugging button to put a break-point.
2. If we want to debug any Portal or PI Application Call, we use External Debugger.
This doesn't mean that you cannot use that for normal report debugging, we can set a break-point
using this button too for a normal debugging.
Also, for the below screen shots, I have configured my debug screen to show Code on the left
part of screen and the variables data on the right part of the screen, Actually this is the standard
layout, but you can change this layout to have 4 screens on a layout..
Once you are in Debug Mode,
On the left screen you will see the code and on the right screen you can see the values of the
variables at that point of the program. Like, if you see on the right side p_copy variable has value
001 at this point of the program execution.
Here, to debug step by step, we can use the buttons on the top of debugger screen which are,
In the above screen shot, I am inside a Loop of an internal table, one of the field of that table has
a value of '01', as shown below
suppose I dont have test case for that, what I can do is click on that Pencil Icon next to that field
and you will see that field as input enabled and you can change the value of that field to 02 as
shown below,
If you see the above screen, that pencil icon changed to DISPLAY icon and the field is input
enabled. Once you change the value of that field you can just hit enter and the value gets
changed.
Most important point is, you would need authorizations to do that :), most of the functional
people will not be provided authorization to do that.
2. Setting up a break-point at a particular ABAP Command or a Statement. - If we know that
the program is failing at a particular command, we can use the below option to set the breakpoint at that particular statement instead of debugging through the whole code.
When you are in debugger mode and if you want to set a break-point at any of abap command
you can do it based on the navigation screen shot below.
On the right part of screen, if you see Tabs which say Variables1, Variables3, Locals and
Globals, in that Globals shows the list of values of all the variables used in that program at that
point of time.
We have some notes under help.sap.com too about the Classic and the New Debugger. Below is
the link for the same.
Steps:
1.
Set a debugging point at the loop statement of the internal table, once the debugging screen
appears then press F5, an entry would appear in the workarea LS_MARA.
2.
Now keep the cursor on the field to which we want to set the watchpoint. In this example we
want to set watchpoint for the LS_MARA-MATNR.
3.
Press Create watchpoint button on the toolbar of the debugger screen as below.
4.
We will automatically have the variable field populated with the desired field as shown
below.
5.
Now enter the condition for which we want to set the watchpoint in the Free Condition Entry
Field.
6.
7.
The watchpoint will be created and we will have below message appeared in the status bar.
8.
Now press F7 to reach your desired record. We will get below message at the status bar of
the debugger screen:
9.