ABAP Debugger for Functional consultant Version – 1.0 Compiled by : Siddhartha Srivastava Reviewed by: Venu Gurram Author email id :
[email protected] Review date: 27 Jan 2015
January 27, 2015
Proprietary and Confidential
-1-
Topics to be covered
Overview Different types of breakpoints Flow of Control Debugger Settings Debugging various ABAP objects
January 27, 2015
Proprietary and Confidential
-2-
Overview - Introduction For any day to day issue faced in SAP, debugger is the most basic tool that can be utilized to reach the root cause. It not only lets you trouble shoot effectively but also helps you visualize ‘what-if’ scenarios. The Debugger is a programming tool that you can use to execute ABAP programs, by line or by section. With this tool, you can display data objects and check the flow logic of programs. There are two types of Debugger available: Classic Debugger for release levels up to and including 6.40 New Debugger, which is available for all releases after 6.40
January 27, 2015
Proprietary and Confidential
-3-
Overview - Difference
Classic Debugger
Runs in the same roll area as application to be debugged
Not all ABAP code can be debugged like conversion exits and field exits.
No state of the art user interface
The classic Debugger analyzes a roll area that, when canceled, itself cancels the classic Debugger. Therefore, all the existing settings, such as breakpoints or display of variables in the classic Debugger, disappear as soon as the limits of the roll area are exceeded.
January 27, 2015
Proprietary and Confidential
-4-
New ABAP Debugger
executed in a separate external session , while the application to be analyzed uses a second external session
a flexible interface that can be configured as required and has more than eight desktops
the new Debugger analyzes an external mode. As long as this external mode is active, the Debugger will remain open and control this mode.
Overview - Switching Switching from new debugger to classic debugger
Switching from classic debugger to new debugger
January 27, 2015
Proprietary and Confidential
-5-
Overview - A first look at the detailed view of new debugger
January 27, 2015
Proprietary and Confidential
-6-
Overview - Advanced features of ABAP debugger
Split screen debugging Searching contents in internal table Download internal table to excel sheet Flow of control while debugging
January 27, 2015
Proprietary and Confidential
-7-
Different types of breakpoints 1. Debugger Breakpoint
When a breakpoint is set in a debugger, it is set as debugger breakpoint by default. It is valid only when the debugger instance, in which it was set, is active. When the debugger is closed, all breakpoints set in it are deleted, unless saved.
2. Session Breakpoint
A breakpoint set in the ABAP Editor is a session breakpoint. It remains active independent of existence of the debugger. It is valid for all external sessions of a logon.
3. User Breakpoint (also known as external break point)
January 27, 2015
It is valid for all user logons on the current server of the current system. It is particularly required ,when debugging BSP applications. It is valid only for a period of 2 hours.
Proprietary and Confidential
-8-
Different types of breakpoints There are different ways to put break points Hard coded / Static break points: You can put a breakpoint in a program by writing following statements. “BREAK-POINT” : To stop the execution irrespective of who is executing it. “BREAK ”: To stop the execution only for specific user mentioned by .
Dynamic/Session break points: We can put dynamic breakpoints from SE80 or SE38 or debugger. Dynamic breakpoints are always user-specific, and are deleted when you log off from the R/3 System. They can be deleted or deactivated during runtime.
January 27, 2015
Proprietary and Confidential
-9-
Different types of breakpoints Debugging without Breakpoint : You can start the Debugger as follows
In SE80: Select a program or transaction and from the top menu choose Program -> Test -> Debugging. In SE38: From the top menu choose Program -> Test -> Debugging. From any other screen: From the top menu choose System -> Utilities -> Debug ABAP or Enter /h in the command field and press enter.
Once inside the debugger, breakpoints can be set at statements, subroutines, FM, etc as shown here.
January 27, 2015
Proprietary and Confidential
- 10 -
Flow of Control
F5 (Single Step) F6 (Execute)
: Step through the program statement by statement. : Process Line by Line .Mainly used to execute a Module or subroutine without entering into it. F7 (Return) : Use this option to return back to the calling program. F8 (Run/Continue) : Use this option when no more step check is required. The program either executes normally or the debugger stops at the next breakpoint. Display Field/List Contents: Double Click on the field or structure required. Its contents are then displayed. If the program generates a List, then an icon appears as soon as the list is populated. Click to open the list display. January 27, 2015
Proprietary and Confidential
- 11 -
Flow of Control - Watchpoints Watch points help in monitoring the contents of individual variables. By setting a watch point, the debugger stops as soon as the value of the monitored variable changes. To set a watchpoint, start the debugger and proceed as follows:
Choose Watchpoint. Enter the name of the field for which you want to set the watchpoint. In the Program field, the name of the program currently running is always defaulted. You can use the Additional Condition option to specify whether the flow should interrupt after meeting the specified condition. Useful in looping conditions where you have to reach a particular material out of several iterations. This can be achieved by setting the variable SY-TABIX = intended iteration.
January 27, 2015
Proprietary and Confidential
- 12 -
Debugger Settings Debugger settings are accessed in ABAP debugger by navigating to Settings > Display/Change Debugger settings.
System debugging : In SE38, programs can be set to ‘system program’ in the status. The debugger then skips the program if system debugging is turned off. If there is problem that involve system programs, such as with a function that can’t be accessed in debugger, turn on this setting. System debugging can be turned on by entering ‘/hs’ in the command field in the debugger. Update debugging : To analyze asynchronous updates, we use update debugging. Asynchronous updates are functions that are called with addition IN UPDATE TASK as CALL FUNCTION ‘..’ IN UPDATE TASK .. The debugger cant follow this update modules, and we won’t see anything for these modules during debugging, if we don’t use ‘update debugging’ setting. January 27, 2015
Proprietary and Confidential
- 13 -
Debugging various ABAP objects – Sap Script There are 2 separate kinds of debugging available when you try to debug scripts. Debugging the print program: This is the normal debugging we do for our report programs. Debugging the script itself : You Can debug a SAP Script by activating debugger in two ways:
January 27, 2015
In SE71 (which is the transaction for Sap script), from top menu goto Utilities>Activate Debugger. The debugger will be get activated and when your print program is executing Script Debugger will be in active state and you can proceed with your debugging.
Goto SE38-> Give the program name RSTXDBUG ->Execute this same as going through in se71-> Menu, now debugger will be activated.
Proprietary and Confidential
- 14 -
Debugging various ABAP objects – Smartforms The best way to debug the form is to put a breakpoint in the function module generated by the smartform. For this, open the smartform we want to debug. Goto Environment -> Function module name.
January 27, 2015
Proprietary and Confidential
- 15 -
Debugging various ABAP objects – Smartforms Open the function module in SE37. From the menu GOTO -> main program. Open the last include.
This include contains the entire code i.e. the code we have written in initialization + form routines + program lines + sap generated code. Put a breakpoint at any point you want. If we issue any doc which triggers this form, when the control reaches the break point it will stop. Prefer session break point in the related function module. January 27, 2015
Proprietary and Confidential
- 16 -
Debugging various ABAP objects – Batch Jobs Debugging Active Jobs(SM50 OR SM66): Go to SM50 (Waiting/Running/On hold jobs) : Menu > Program/Session > Program > Debugging. Now control will go to debug mode.
January 27, 2015
Go to SM66(Running/Debugging Objects) : Place cursor on your job and click on debugging button in tool bar.
Proprietary and Confidential
- 17 -
Debugging various ABAP objects Debugging Completed/Cancelled jobs
January 27, 2015
If necessary, place a breakpoint in the program. Go to transaction SE37 and select our job. Enter 'jdbg’ in the command window and press on the enter key. Now the control goes to the debugger . Press F8 and control goes to our break point.
Proprietary and Confidential
- 18 -
Thank You!
January 27, 2015
Proprietary and Confidential
- 19 -