Vous êtes sur la page 1sur 25

Debugger

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. Two types of debugging are currently possible: Debugging with the classic Debugger for release levels up to and including 6.40 or debugging with the new Debugger, which is available for all releases after 6.40. The main differences between the classic and the new ABAP Debuggers are described below: The Classic ABAP 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. The New ABAP Debugger, on the other hand, is executed in a separate external session (Debugger), while the application to be analyzed (debuggee) uses a second external session. With this technology, the user interface of the Debugger can be designed freely by ABAP means.

The new Debugger provides the user with a flexible interface that can be configured as required and has more than eight desktops. Here it is possible to place and arrange up to four tools depending on the user's selection. For example, it is possible to display source texts or structures. In this way, the user can design the Debugger interface according to its own individual requirements. As of Release 6.40, you can select the debugging type as you wish by choosing the classic Debugger or the new Debugger in the ABAP Editor from the path Utilities Settings. It is also possible to switch the Debugger at any time during a session under the menu option Debugging. As of Release 7.00, the new ABAP Debugger is the default. Overview of Functions Use 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.

Features 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 Classic 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.

Setting Breakpoints A breakpoint is a signal in a specific line of the program source code. This signal indicates to the ABAP runtime processor to stop the program at the relevant 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. Direct Processing 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 a useful procedure if you are not overly familiar with the program and therefore are not sure where best to set breakpoints. You can start the Debugger as follows: From the Object Select a program or transaction and choose Program Navigator Test Debugging. From the ABAP Editor Choose Program Execute Debugging (or the Debugging pushbutton). In the source code display, you

From any screen From any screen

need to select the menu Program Test Debugging Choose System Utilities Debug ABAP. 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 of the program that has just been executed by choosing Goto Further Information Program Attributes. Restarting the Debugger If you choose Debugging Restart, debugging mode is stopped and the system takes you to the initial screen of the last transaction you called. If, for example, you started an ABAP program in debugging mode from transaction SE38 (ABAP Editor), choosing Debugging Restart will take you back to the screen titled ABAP Editor: Initial Screen. If you want to restart the program in debugging mode, choose the menu Program Execute Debugging or choose the Debugging pushbutton. Switching Between the Single-Process and Two-Process Debugger As of Release 6.40, you can preset the call for the new Debugger in the ABAP Editor by selecting the menu Utilities Settings Debugging New Debugger. In the debugging mode, you can switch from the single-process Debugger to the two-process Debugger through the menu option Debugging Change. Display-Modes for the Classic Debugger When you start a program in the Debugger, 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 more detailed information. The most frequently-used views are available using the following pushbuttons. Display Modes Available Using Pushbuttons

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 Table Displays the contents of an internal table. This mode allows you to display and edit the entries in an internal table. Breakpoints A scrollable display containing up to 30 breakpoints. Next to each breakpoint is a counter. You can also delete breakpoints in this display. 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. 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. Fields Other Display Modes You can access other display modes by choosing Goto Display Data Object. Single field Structured field Strings Internal table Object Release Changes The following new functions were developed for Release 6.10: 1. 2. 3. Displaying Program Attributes Displaying Data References Special Display of Deep Data Objects Displays the contents and technical attributes of a 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. Display the content and current length of the string. You can also display part of the content by means of offset and length. Displays the type, line numbers and contents of an internal table. Displays the structure of an ABAP Object.

4. 5. 1. 2. 3. 4. 6.

Setting Breakpoints at Methods Handling Class-Based Exceptions 1. 2. 3. 4. Debugging Session for Business Server Pages with ABAP-Scripting Transferring Breakpoints to HTTP and Update Sessions Displaying Statements for the Database Interface Navigating Forwards and Backwards in the Source Code

Displaying the Unicode Fragment View

The following new functions were developed for Release 6.20 and are described in detail in the appropriate chapters and sections: 1. 2. 3. 4. 5. 6. Memory Use Lifetime and Transfer of Breakpoints (http Breakpoints) Checking Sort Before READ BINARY SEARCH Checking Sort Before PROVIDE Always Create Exception Object (Quick info for Text Key) Sessions

The following new functions were developed for Release 6.40: 1. 2. 3. Offset and Length Specifications in Internal Table Columns Table History Single Step for the CASE Statement

Breakpoints Apart from being able to execute an ABAP program in the Debugger, you can also start the Debugger call by the choosing a breakpoint. This is achieved by setting one or more of these 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 Debugger is activated when the program reaches this point. 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.

Breakpoint Variants The Debugger contains different breakpoint variants: Static A user-specific breakpoint is inserted in the source code as an ABAP statement using the keyword BREAK-POINT. A non user-specific breakpoint is set in the ABAP Editor using the BREAK user name statement. Can be set in the ABAP Editor or the Debugger by double-clicking a line, for example. Dynamic breakpoints are always user-specific, and are deleted when you log off from the R/3 System. The Debugger stops the program immediately before the specified statement is executed.

Directly set dynamic breakpoints

Breakpoints

at statements Breakpoints The Debugger stops the program immediately before at subroutines the specified subroutine is called. Breakpoints at function The Debugger stops the program immediately before modules the specified function module is called. Breakpoints at methods The Debugger stops the program immediately before the specified method is called. Breakpoints at exceptions The Debugger stops the program immediately after a and system exceptions system exception, that is, after a runtime error has been intercepted.

Static Breakpoints Static breakpoints are always user-independent if there is no specification of a user name. Once a user has inserted the statement BREAK-POINT or BREAK name in an ABAP program, the system always interrupts the program at that point for that user or only for the user name. This procedure is only useful in the development phase of an application when program execution is always to be interrupted at the same place. In HTTP sessions, a static breakpoint is skipped if you did not set additional dynamic HTTP breakpoints in the editor of a BSP page. Instead, a corresponding system log entry is written, which can be checked using transaction SM21. Dynamic Breakpoints Dynamic breakpoints are user-specific. Therefore, you should use them if you only want the program to be interrupted when you run it yourself, not when it is being executed by other users. 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 that only activates the breakpoint after it has been reached.

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 source 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. In HTTP sessions, the system stops both at static and dynamic breakpoints if a dynamic breakpoint was set in the editor of a BSP page before program execution. Lifetime and Transfer of Breakpoints A static breakpoint remains intact as long as the BREAK-POINT or BREAK-POINT name statement is not removed from the source code. Without saving, dynamic breakpoints only remain intact in the relevant internal session. However, they remain in effect during the entire user session if they are saved by choosing the menu path Breakpoints Save in the ABAP Debugger. For more details on the subject of user sessions and modes, refer to Modularization Techniques in the ABAP keyword documentation. If you call an HTTP session during a user session, only the HTTP breakpoints are loaded when the HTTP session is started. You activate HTTP debugging in the ABAP Editor by choosing Utilities Settings HTTP Debugging. Depending on the setting, the system then displays either the HTTP or standard breakpoints in the Editor. If you call an update session during a user session, breakpoints that were defined beforehand in the calling processing unit are copied to the new update session, where they can be displayed under Breakpoints. If, in the ABAP Debugger, you check Update Debugging under Settings and then, for example, call the update module func using CALL FUNCTION func IN UPDATE TASK, a new window is opened in which you can debug this function module in the update session. All the breakpoints that were set in the calling processing unit can also be processed here. Static Breakpoints You should only use static breakpoints during the development phase of an application. You must remove them from your program before you transport it. Setting Breakpoints 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.

Program RSDEBUG_01. .... if SY-SUBRC <> 0. break-point. endif. .... 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, BREAKPOINT 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. Deleting Breakpoints 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. 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. Dynamic Breakpoints 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: 1. Position the cursor on the line of the source code at which you want to set the breakpoint.

2. 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: 1. Position the cursor on the line in which you want to set the breakpoint. 2. 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. Prerequisites You must already be running the program in the Debugger. Procedure To set a breakpoint at an ABAP statement: 1. Choose Breakpoint Breakpoint at The following dialog box appears: Statement...

2.

Enter the ABAP statement. The system sets a breakpoint at all points in the program at which the ABAP statement occurs. 3. Choose ENTER. The breakpoint applies to all lines containing the specified statement.

Result The system confirms the breakpoint and adds it to the list in the display. When you finish your debugging session, the breakpoint is automatically deleted unless you have explicitly saved it. Breakpoints at Subroutines You can use this special kind of dynamic breakpoint to interrupt a program directly before a subroutine is called. Prerequisites You must be already running the program in the debugger. Procedure To set a breakpoint for a subroutine: 1. Choose Breakpoint Breakpoint at The following dialog box then appears: Subroutine...

2. Enter the name of the subroutine before which you want to interrupt the program. By default, the Program field contains the name of the program that is currently active. The system sets a breakpoint wherever the specified subroutine occurs in the program code. 3. Choose ENTER.

Breakpoints at Function Module You can use this kind of dynamic breakpoint to interrupt a program directly before a function module is called. Prerequisites You must already be running the program in the Debugger. Procedure To set a breakpoint for a function module:

1. Choose Breakpoint Breakpoint at The following dialog box appears:

Function module...

2. Enter the name of the function module before which you want to interrupt the program. The system sets a breakpoint wherever the specified event, module pool, or subroutine occurs in the program code. 3. Choose ENTER. Result If you entered a valid function module name, the system confirms that the breakpoint has been set. If the function module exists in the system, the new breakpoint is added to the display list. Result The system confirms the breakpoint. The breakpoint is added to the list in the display.

Breakpoints at Methods You can use this special kind of dynamic breakpoint to interrupt a program directly before a method is called. Prerequisites You must be already running the program in the debugger. Procedure To set a breakpoint for methods: 1. Choose Breakpoint Breakpoint at Method... The following dialog box then appears:

Enter the name of the method and class before which you want to interrupt the program. A breakpoint is then set each time the specified processing block appears in the source code. 3. Choose ENTER. Result The system confirms the breakpoint. The breakpoint is added to the list in the display. Breakpoints at System Exceptions You can use this special form of dynamic breakpoint to interrupt a program immediately after a runtime error has occurred. Prerequisites You must already be running the program in the Debugger. Procedure To set a breakpoint at a system exception: Choose Breakpoint Result The system confirms the breakpoint. The breakpoint is added to the breakpoints displayed. When a system exception is triggered, a warning triangle appears in the line containing the statement that caused it. If you double-click the warning triangle, the internal name of the runtime error appears. Saving Breakpoints 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. Breakpoint at System exception.

2.

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. Example

Functions This display mode contains the following functions for breakpoints: Breakpoint Display The scrollable breakpoint display contains up to 30 dynamic breakpoints. For breakpoints that you set directly, the program name and line number at which the breakpoint occurs are displayed. For special breakpoint forms, the list displays the statements, events, subroutines, and module calls at which the relevant breakpoints are set. Counter In the breakpoint display, you can specify a counter. When you use a counter, the breakpoint is not activated until it has been reached a specified number of times. For example, if you enter 5 for the counter, the breakpoint is not activated until it is reached

for the fifth time. After the breakpoint has been activated, it remains so, and the counter no longer appears in the breakpoint display. Deleting Breakpoints Position the cursor on the breakpoint that you want to delete, and either double-click the line or choose Breakpoint Set/delete. To delete all breakpoints, choose Breakpoint Delete all. Activating and Deactivating Breakpoints Position the cursor on the breakpoint that you want to activate or deactivate and choose Breakpoint Activate/deactivate.

Watchpoints 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. Features Setting 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. Procedure To set a watchpoint, start the Debugger and proceed as follows: 1. Choose Breakpoint Create watchpoint or the corresponding pushbutton. The Create Watchpoint dialog box appears:

2. Decide whether you want to set a local or global watchpoint. 3. Enter the program and 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. 4. If you want your watchpoint to be activated each time the contents of the field change, the definition is now complete, and you can return to the Debugger by pressing ENTER . 5. To create a conditional watchpoint, that is only activated when a particular situation arises, choose one of the following relational operators. Operator < <= = <> >= > Meaning Less than Less than or equal Equal Not equal Greater than or equal Greater than

6. You can use the Comparison field option to specify whether the comparison is to be carried out with a value that you specify or with the contents of another field. Depending on your choice from step 6, enter a value or a field for the comparison. Result The system confirms the watchpoint and adds it to the list in the display. When you finish your debugging session, the watchpoint is automatically deleted unless you have explicitly saved it.

Specifying Logical Links If you have more than one conditional watchpoint, you can specify a logical link between them: OR AND Only one of the specified conditions must be met All of the conditions must be met.

To create a logical link between watchpoints: 1. Choose Goto Control debugging Watchpoints or the Watchpoints pushbutton to open the watchpoint display. 2. Set the Logical operator between watchpoints option. The default value is always OR. Changing Watchpoints 1. Choose Goto Control debugging Watchpoints or the Watchpoints pushbutton to display the watchpoint list. The following dialog box appears:

2. Choose the pencil icon in the line containing the watchpoint you want to change. 3. Change the watchpoint attributes in the Create/Change Watchpoint. 3. Choose ENTER. Deleting Watchpoints You cannot delete watchpoints by choosing Breakpoint Deactivate/activate. Instead, proceed as follows: Delete or Breakpoint

1. Choose Goto Control debugging Watchpoints or the Watchpoints pushbutton to display the watchpoint list. 2. Choose the trashcan icon in the line containing the watchpoint you want to delete. Memory Monitoring with Watchpoints You can use watchpoints to display changes to the references of strings, data and object references, and internal tables. By placing an ampersand (&) in front of the object name, you

can display the reference in question in hexadecimal format. With internal tables, you can also display the table header by placing an asterisk (*) at the beginning of the name. &objectname *itab Example Displays the references of strings, internal tables, as well as data and object references Displays the table header of the internal table itab

If a watchpoint is set for the object in question at runtime, the program is stopped as soon as the reference is changed. A short dump can be intercepted in this way to stop the program being terminated when the memory is overwritten. Analyzing Source Code The Debugger contains an extensive range of functions that help you to analyze the source code of a program. You can step through the source code of a program in four different ways. Displaying the Source Code All of the display modes in the Debugger have the same structure. The top half of the screen displays an extract from the program source code as it appears in the ABAP Editor. Example:

Features The Source code of field contains an extract from the program, subroutine, or function module currently being processed. The source code display also contains the following additional functions: Enlarge/Reduce Program Segment Use this button to close the information about the current display mode. The system then displays more of the source code. Use this button to reopen the information for the current display mode. Enter Line Numbers

You can scroll in the source code using the arrow keys. If you enter a line number in the lefthand field, that line will become the top line of the display. Scroll by Double-Clicking If you double-click the first column of a line, it becomes the top line of the display. Scroll One Screen at a Time You can use the PgUp and PgDn keys to scroll up and down one page at a time in the source code. Navigate Forwards and Backwards If you choose Debugging Goto Statement, the line containing the cursor is displayed. This provides you with a straightforward way of navigating forwards and backwards in the displayed source code. To execute this function you require change authorization for the Debugger. However, the statements between your current location and the location of the cursor will not be executed. Before using this function, be aware that jumping between statements can change the program logic.

Display the Current Line This arrow indicates the next line of source code that will be processed. Use this button to make the current line appear in the source code display. Display After a System Exception When a system exception is triggered, a warning triangle appears in the line containing the statement that caused it. If you double-click the warning triangle, the internal name of the runtime error appears. Find a String in the Source Code To find a string in the source code, choose Edit Find in source code or the Find icon from the standard toolbar. A dialog box appears in which you can enter a string:

To find the next occurrence of the same string, choose Edit Find next in source code, or the appropriate icon. Going Through the Source Code There are four different ways in which you can go through the source code of a program you want to analyze:

Execution Types in Debugging Mode Single step Use this option to execute the program statement by statement. This allows you to branch to other program units. Execute Use this option to process a program line by line. All of the statements on the current line are processed in a single step. This allows you to process the whole program. The Debugger returns to the point at which control is passed back to the main program. Use this option to return from other program units. Use this option to process the program up to the next breakpoint. If there are no more breakpoints in the program,

Return

Continue

the system exits debugging mode and executes the rest of the program normally. If you are at a CASE statement, the system will branch to the corresponding WHEN block when you choose Single Step.

Processing Fields Displaying Field Values at Runtime You can use the Fields display mode in the Debugger to display the contents of program fields. The display can accommodate up to eight fields. This is the default display mode in the Debugger. The following data objects are supported: Single field Structured fields Strings Internal tables Objects With more complex data objects such as references or tables, the contents are not displayed directly in the default display mode. Instead, you have to double-click the field display to call up the appropriate attribute display. Procedure To display the contents of a field, enter the name of this field under field name and press <ENTER>. Alternatively, you can double-click the name of a field in the program code to show this fields contents. Example:

Displaying Further Fields The field display can contain up to eight fields, of which only four can be displayed at a time. You can display the other fields by using the scroll buttons.

Displaying System Fields This display mode allows you to display the contents of any system fields. The three most important system fields SY-SUBRC, SY-TABIX, and SY-DBCNT are always displayed. Displaying Fields from External Programs You can also display the contents of fields from external programs if you know the names of these programs and have already stepped through them. To do so, enter the program name in brackets before the field name in the field display, that is: (program name)field name, for example (SAPMSCLM)ACTION; lowercase is also possible. Special Types of Field Display As in the program source code, you can make offset and length entries for charactertype fields. If, for example, you enter sy-datum+4(2) in the field display, the current month of the system date is displayed under Field contents. If you specify an integer in angle brackets after the name of an internal table, the content of the line that corresponds to the integer is output. The entry itab[4], for example, displays the fourth line of the internal table itab. If the integer exceeds the number of current table lines, the table will be flagged as unknown. With data references, the content of the referenced data object is displayed if an arrow and asterisk are appended to the name of the reference. r->* displays the content of the field that is referenced by the data reference r. If you double-click a data or object reference under Field contents in the default display mode, all the attributes and field contents of the referenced data object are displayed in the next screen (data references). The attributes and values of the current instance of all referenced classes and interfaces are output under object references. 7<cl>, for example, displays all the values of the seventh instance from class cl. The headers of strings, internal tables as well as data and object references are displayed if you place an asterisk at the beginning of the name. For example, the header of the internal table itab is displayed in hexadecimal format if you enter *itab in the field display. The field contains zeros if a table does not have a header. If you place an ampersand at the beginning of the name, the reference of strings, internal tables as well as data and object references are displayed in hexadecimal format. The entry & str, for example, displays the reference to the string str. Changing the Display Format You can display the field contents either formatted for their data type or in hexadecimal format. Use this button to display the field contents in hexadecimal format. Use this button to display the field contents in their original output format.

Deleting All Field Names Use this button to delete all field names from the field display. 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. You can change the values of the following data objects of your program. If you enter a value with an incompatible type, the system displays an error message. Single fields Structured fields Strings Fields of internal tables Fields of classes and interfaces Procedure To replace the contents of a single field, proceed as follows: With certain data objects such as structures or internal tables, you first have to double-click the appropriate field name to display the attributes. You then have to double-click the individual fields again to open the display mode. Result The Debugger writes the new value to the program field and the system records the change in the system log. If you do not click the pencil icon, the changed value is ignored. The Debugger accepts the values exactly as you entered them. You must, therefore, ensure that you use the correct format (upper and lowercase, left-justified entry for hexadecimal numbers). Names for Anonymous Storage Objects Anonymous storage objects are objects that are accessed in the ABAP program indirectly through a reference, not directly through their names. They include:

Strings Internal tables Class instances Anonymous data objects

Value semantics apply to the anonymous storage objects strings and internal tables so that it will suffice to enter the variable name in order to process its data content. Names for describing anonymous data objects are necessary here so that each storage object has a unique identification. If you have string sharing, for example, these names are important since several string variables can point to the same storage address On the other hand, in the case of class instances created with the CREATE OBJECT statement and anonymous data objects created with the CREATE DATA statement, only their references in the program can be addressed. Here reference semantics apply since the objects need to be de-referenced first in order to be able to access the data of the object concerned. Anonymous storage objects cannot be directly addressed in the program; however, they can be addressed in the Debugger, using the following notation rules for their names. As a rule, the names of anonymous storage objects are enclosed in curly brackets. They contain an abbreviation, together with a colon and the internal identification. The following notation rules apply to the abbreviations: Abbrev. S T O A C Storage Object Strings Internal tables Class instances Anonymous data objects Class

The internal identifications in the form x or x. y follow after an abbreviation and colon, except in the case of classes. X stands for the object identification used internally and y for the identification of the internal Shared Objects version. In the case of classes, the class name instead of the identification - must be after the colon. After the identifications, there follows an asterisk or an exclamation mark, which however is allowed solely for instances of classes. After the exclamation mark, you have the specification of a superclass. In this way you can ensure that the object is displayed from the view of the superclass. On the other hand, the asterisk introduces a comment or additional information that is not interpreted. The following table contains some examples of possible identifications that are used both in the classic as well as in the new Debugger. Name {S:1} {S:1.3} {O:3*\CLASS=MY_CLASS} {O:1!MY_SUPER_CLASS}ATTR {C:MY_CLASS}-ATTR Explanation String with internal identification 1 String with internal identification 1 and internal Shared Objects version Instance of my_class class with nterna identification 3 Attribute attr of instance with internal identification 1 from the view of the my_super_class superclass Class attribute attr of my_class class

Displaying Objects in ABAP Objects The Debugger displays the attributes of classes, instances, and interfaces in a similar way to structured fields. Procedure To display an object in ABAP Objects: 1. Choose Fields. This opens the default display mode. 2. In the ABAP program code display, double-click the name of an object to place it in the field display. The Field contents field contains the object ID (class name and identification number). 3. Double-click the object ID. The Debugger opens the Object display mode. You can also open the object display by choosing Goto Display data object Object. However, in this case, you must specify the object ID explicitly. 4. Adjust the display to your requirements by setting the Class attributes and instance attributes options and selecting a visibility section (public, protected, or private). 5. Choose Filter to filter the attributes for the display. The object attributes are listed with their names, technical properties (data type and length), and their content. The display also contains the interfaces. You can display its attributes by choosing Expand. Example

If an attribute is a reference to another object, you can display the attributes of the referenced object by double-clicking the field contents of the object in the display.

If you enter the name of a class (<name>) in the Object (Id) field, the system displays the static attributes of the class, regardless of whether it has been instantiated. Other Functions Navigation If you double-click the name of an attribute, the system opens the single field display. If you double-click the name of an interface, the system displays only the attributes that belong to that interface. References If you position the cursor on a field in the field display that contains an object reference, you can find all variables or attributes (both local and global) that point to the object by choosing Goto System Find references. The same applies to data references. Displaying Events The event display provides an overview of all of the events belonging to an object and the handlers that are registered for them. To open the event display, choose Events. The system lists all of the events belonging to the object specified under Object (Id). The display lists the object IDs of all handler objects registered for the event and the handler methods that will be called when the event is triggered. Example

Use the Object pushbutton to return to the ABAP Objects display. If you enter a class in the Object (Id) field (<name>) and then choose Events, the system displays the handler methods and objects for all events of the class. The class does not have to have been instantiated.

Vous aimerez peut-être aussi