The ABAP Debugger is an integrated test tool within the ABAP Workbench. You use it to check the program logic and to find errors in the source code of an ABAP program. In the Debugger, you can step through the source code of a program. The running program is interrupted after each step, allowing you to check its processing logic and the results of individual statements.
As of Release 6.10, you can also run Business Server Pages (BSP) in the debugging mode. You can also display and set breakpoints here. Business Server Pages can be displayed in the Object Navigator when you select an appropriate application under BSP Application.
The Debugger provides an efficient means of identifying errors in ABAP programs. It contains the following functions:
- Ways of starting the Debugger
- Choosing different views
- Choosing different execution options in the Debugger
- Displaying source code in the Debugger
- Setting and deleting breakpoints
- Setting and deleting watchpoints
- Stopping a program at a particular statement or event
- Displaying and changing field contents at runtime
- Displaying ABAP Objects and references
- Displaying and positioning strings
- Setting and deleting database locks
- Opening the ABAP Editor, or Object Navigator
- System settings and runtime warnings
Starting the Debugger
There are two possible strategies for starting the Debugger in the ABAP Workbench:
- By setting breakpoints then running the program
- By running the program in debugging mode.
A breakpoint is a signal in a line of code that tells the ABAP runtime processor to interrupt the program at that line and start the ABAP Debugger. A distinction is made between static and dynamic breakpoints. For further information about the different types of breakpoints and how to use them, refer to Breakpoints.
Running a Program in Debugging Mode
You can start the Debugger without previously having set breakpoints. This is the best procedure to use when you want to test a program right from the beginning. It is also useful if you do not know the program very well and therefore are not sure where best to set breakpoints. You can start the Debugger as follows:
|From the Object Navigator||Select a report or transaction and program and choose Program - Test - Debugging.|
|From the ABAP Editor||Choose Program - Execute - Debugging (or the Debugging pushbutton).|
|From any screen||Choose System - Utilities - Debug ABAP.|
|From any screen||Enter " /h " in the command field.|
Checking System Programs for Errors
To check a program or program component that is part of the ABAP Workbench (for example, the Screen Painter), you must use the system Debugger. To start the system Debugger, choose System - Utilities - Debug system from any screen. To stop the system Debugger, choose Debugger - Debugging off.
Displaying Program Attributes
You can display the attributes Fixed point arithmetic, System program and Unicode checks active of the program that has just been executed by choosing Goto - Further Information - Program Attributes.
Display Modes in the Debugger
When you are debugging a program, there are various display modes that you can use. All of the display modes have the same structure. The top part of the screen displays an extract of the program source code. The bottom part displays the information specifically available in that display mode. There are also push buttons on the screen allowing you to switch to the most frequently-used display modes.
Display Modes Available Using Pushbuttons
|Fields||The scrollable field display contains the contents of up to eight fields. The contents of the three most important system fields are always displayed. This is the default display mode in the Debugger. See also Processing Fields|
Displays the contents of an internal table. This mode allows you to display and edit the entries in an internal table. See also Processing Internal Tables
|Breakpoints||A scrollable display containing up to 30 breakpoints. Next to each breakpoint is a counter. You can also delete breakpoints in this display. See also Managing Dynamic Breakpoints|
|Watchpoints||You can set a watchpoint for a field so that the program is interrupted whenever the value of that field changes. This display mode contains a list of watchpoints, the fields and programs to which they are assigned, the current values of the fields, and the conditions upon which the watchpoint is activated. See also Setting Watchpoints|
|Calls||This mode displays the current sequence of events, and the sequence of calls up to the current breakpoint. The last active call is displayed at the top of the list; previous calls are listed in reverse chronological order. When an event (for example, START-OF-SELECTION) concludes, it is deleted from the display.|
|Overview||This mode displays the structure of the program. It lists its events, subroutines, and modules, and shows which sections belong to which events. It also displays the section currently being processed.|
|Settings||This mode displays the current Debugger settings. You can change the settings by selecting or deselecting various options. For further information, refer to Settings and Warnings|
Other Display Modes
You can access other display modes by choosing Goto - Display data object.
|Single field||Displays the contents and technical attributes of a field.|
|Structured field||Displays the components of a structure, along with their contents and attributes. If you double-click a component, the system displays detailed information for it.|
|Strings||Display the content and current length of the string. You can also display part of the content by means of offset and length.|
|Internal table||Displays the type, line numbers and contents of an internal table.|
|Object||Displays the structure of an ABAP Object.|
For further information on these displays, refer to Displaying Attributes and Displaying ABAP Objects
Instead of starting an ABAP program directly in the Debugger, you can also debug a program by creating one or more breakpoints in the program. A breakpoint is a signal at a particular point in the program that tells the ABAP runtime processor to interrupt processing and start the Debugger. The program runs normally until the breakpoint is reached.
There is also a special kind of breakpoint called a watchpoint. When you use watchpoints, the Debugger is not activated until the contents of a particular field change. For further information, refer to Watchpoints.
The Debugger contains different breakpoint variants:
|Static||The BREAK-POINT statement in an ABAP program. Static breakpoints are not normally user-specific. However, you can make them user-specific.|
|Directly-set dynamic breakpoints||Can be set in the ABAP Editor or the Debugger. Dynamic breakpoints are always user-specific, and are deleted when you log off from the R/3 System.|
|Breakpoint at statement||The Debugger stops the program directly before the specified statement is executed.|
|Breakpoint at subroutine||The Debugger stops the program directly before the specified subroutine is called.|
|Breakpoint at method||The Debugger stops the program directly before the specified method is called.|
|Breakpoints at system exceptions||The Debugger stops the program directly after a system exception, that is, after a runtime error has been intercepted.|
Static breakpoints are not normally user-specific. Once a user has inserted a BREAK-POINT statement in an ABAP program, the system always interrupts the program at that point. You should only use static breakpoints during the development phase of an application. You should set static breakpoints whenever more than one programmer is working on the same program and you always want to stop the program in the same place.
Dynamic breakpoints are user-specific. You should, therefore, use them when you only want the program to be interrupted when you run it yourself. All dynamic breakpoints are deleted when you log off from the R/3 System.
Dynamic breakpoints are more flexible than static breakpoints, because you can deactivate or delete them at runtime. They have the following advantages:
- You do not have to change the program code
- You can set them even when the program is locked by another programmer
- You can define a counter (for example, only activate the breakpoint after it has been reached five times).
Special Dynamic Breakpoints
Special dynamic breakpoints are useful when you want to interrupt a program directly before a particular ABAP statement, a subroutine, or an event, but do not know exactly where to find it in the program code. Event here is used to refer to the occurrence of a particular statement, for example, or calling up a method. Special dynamic breakpoints are user-specific. You can only set them in the Debugger.
Transferring Breakpoints to HTTP and Update Sessions
If an HTTP or update session is called from a Logical Unit of Work (LUW), new work processes are started for these new sessions. Breakpoints that were defined beforehand in the calling LUW are copied to these sessions where they can be displayed under breakpoints.
If, for example, the update module func is called via CALL FUNCTION func IN UPDATE TASK, the new work process is displayed in a second window if Update debugging was selected under Settings in the debugging mode. All the breakpoints that were set in the calling LUW can then be processed here.
You should only use static breakpoints during the development phase of an application. You must remove them from your program before you transport it.
To set a static breakpoint, use the ABAP statement BREAK-POINT . Place the breakpoint in the line at which you want to interrupt the program.
if SY-SUBRC <> 0.
When you run the program, the runtime processor interrupts it when the breakpoints occur. You can number your breakpoints to make them easier to identify ( BREAK-POINT 1, BREAK-POINT 2 …).
Static breakpoints are not normally user-specific. The program is, therefore, always interrupted as soon as the runtime processor reaches the line containing the breakpoint. The program is interrupted regardless of the user who executes it.
However, you can set user-specific static breakpoints using the BREAK statement followed by your user name. For example, if you use the statement BREAK SMITH , the program is only interrupted when user Smith runs it. Although user-specific breakpoints appear in the program code, they are not active when other users run the program. You should, however, be careful if an application is being used by several users with the same name.
Since static breakpoints apply to all users, you must remove them from the program once you have finished testing it. In the ABAP Editor, you can find breakpoints quickly by choosing Utilities - Global search. You can also use the Extended Program Check to find them. If you do not remove static breakpoints from your program, they will be transported to your production system. This could cause serious problems in the production system.
You can set up to 30 dynamic breakpoints without changing the program code. Dynamic breakpoints can be set either in the ABAP Editor or directly in the Debugger.
Setting Dynamic Breakpoints in the ABAP Editor
You can set dynamic breakpoints in the ABAP Editor regardless of whether you are in display or change mode. You can also set breakpoints directly from within the Debugger at runtime. To set a dynamic breakpoint in the ABAP Editor:
- Position the cursor on the line of the source code at which you want to set the breakpoint.
- Choose Utilities - Breakpoints - Set or the Stop icon. The system confirms that the breakpoint has been set.
To display a list of all dynamic breakpoints in a program, choose Utilities - Breakpoints - Display. You can use this list to navigate to a particular breakpoint or to delete one or more breakpoints from the program.
Setting Dynamic Breakpoints in Debugging Mode
To set a dynamic breakpoint in the Debugger:
- Position the cursor on the line in which you want to set the breakpoint.
- Select the line by double-clicking it or choosing Breakpoint - Set/delete.
The system sets the breakpoint, and displays a small stop sign to the left of the relevant line. If the line already contained a breakpoint, it is deleted. When you finish your debugging session, the breakpoint is automatically deleted unless you have explicitly saved it.
Breakpoints at Statements
You can use this special kind of dynamic breakpoint to interrupt a program directly before an ABAP statement is processed.
Breakpoints at Subroutines
You can use this special kind of dynamic breakpoint to interrupt a program directly before a subroutine is called.
Breakpoints at Function Module
You can use this kind of dynamic breakpoint to interrupt a program directly before a function module is called.
Breakpoints at System Exceptions
You can use this special form of dynamic breakpoint to interrupt a program immediately after a runtime error has occurred.
If you want to leave the Debugger temporarily, you can save your dynamic breakpoints so that they are still active when you return to the Debugger within the same terminal session.
To save the breakpoints that you have set in the Debugger:
Choose Breakpoint - Save.
The system saves all of the breakpoints that you have set in the current program. These breakpoints will remain active until you either explicitly delete them or log off from the system.
You can also delete breakpoints that you have saved:
- By deleting individual breakpoints from the display and then saving again. In this case, only your selected breakpoints will be deleted.
- By choosing Breakpoint - Delete all. In this case, the system deletes all dynamic breakpoints.
Managing Dynamic Breakpoints
The ABAP Debugger provides a convenient user interface for managing breakpoints. To open the breakpoint display, choose Breakpoints, or, from the menu, Goto - Control debugging - Breakpoints.
Like a breakpoint, a watchpoint is an indicator in a program that tells the ABAP runtime processor to interrupt the program at a particular point. Unlike breakpoints, however, watchpoints are not activated until the contents of a specified field change. Watchpoints, like dynamic breakpoints, are user-specific, and so do not affect other users running the same program. You can only define watchpoints in the Debugger.
Use: You set watchpoints in the Debugger to monitor the contents of specific fields. They inform you when the value of a field changes. When the value changes, the Debugger interrupts the program.
- You can set up to five watchpoints in a program.
- You can also specify the conditions on which a watchpoint is to become active.
- You can specify logical conditions between up to five conditional watchpoints.
- You can define watchpoints as either local or global. If you define a global watchpoint, it is active in all called programs. Local watchpoints are only active in the specified program.
- You can change and delete watchpoints.
If you want to interrupt a program when the contents of a field or structure change, use a watchpoint. You can set up to five watchpoints, including watchpoints for strings.
A watchpoint can be either local or global. Local watchpoints are only valid in the specified program. Global watchpoints are valid in the specified program, and also in all the other programs it calls.
Specifying Logical Links
Memory Monitoring with Watchpoints
Analyzing Source Code
Displaying the Source Code
Stepping Through the Source Code
Displaying Field Values at Runtime
Displaying Fields from External Programs
Special Types of Field Display
Changing the Display Format
Deleting All Field Names
Changing Field Values at Runtime
You can change the values of fields at runtime to see how the change would affect the program flow. Suppose you have found out that a field contains an incorrect value. You would be able to replace it with another value in the Debugger to test whether the program would run properly in that case.
Processing Internal Tables
Attributes of Data Objects
In the Debugger, you can display the attributes and contents of data objects in a separate area of the screen.
Displaying Data References
Displaying the Unicode Fragment View
Displaying Objects in ABAP Objects
The Debugger displays the attributes of classes, instances, and interfaces in a similar way to structured fields.
Debugging in Production Clients
Since the contents of the database in a production client must always be consistent, there are particularly strict requirements for debugging in them:
Production clients do not have the value "T" in the CCCATEGORIE field of table T000.
- This is why the system must not execute a COMMIT WORK . What is particularly important is that all database changes can be rolled back in the event of a program termination. To ensure that this is possible, a dialog process converts to a debugging process. This process is assigned to the user for the duration of their debugging session. This is why no COMMIT WORK is executed by the system.
- To ensure that debugging activities cannot block the whole system, only half of all dialog processes can be used for debugging.
Since only a restricted number of dialog work processes can switch to debugging mode, you should exit the Debugger as soon as you no longer need it. Otherwise, you will unnecessarily block the work process.
In test clients, where data integrity is not so crucial, the number of dialog processes that are available for debugging is defined via the profile parameter rdisp/wpdbug_max_no. If another users want to debug the database, and the process cannot, therefore, convert to a debugging process, a COMMIT WORK must be executed after each step, and the process is released again for all other users. The database changes cannot, therefore, be rolled back if a program termination occurs.
Releasing Database Locks
During Debugging, the COMMIT statement, which indicates the end of a Logical Unit of Work (LUW), may occur after a significant number of debugging steps. Any database locks that are set are maintained for the whole of this time.
There may be occasions when you want to interrupt your testing without actually ending the debugging session. In this case, you should release the database locks, otherwise other users will not be able to make changes until your debugging session is finished.
To do this, choose Debugging - Database - Commit (unlock) to unlock the database and permanently write the changes to the database. Remember that this could, in certain circumstances, lead to database inconsistencies.
If you want to undo all of the database changes that have been made since the last commit, choose Debugging - Database - Rollback.
You can check the last statements transferred to the database by choosing Goto - System - System areas after you have started the Debugger, and entering OSQL in the Area field.
Settings and Warnings
From the Debugger, you can set the debugging mode and the system behavior in the event of a kernel warning by choosing Settings.
In Background Task: Do not Process
Creating Exception Objects
Read Here for More SAP ABAP TutorialsDownload attached file:
You must be Loged in to download file