Sie sind auf Seite 1von 36

ABAP DEBUGGING

Overview of ABAP DEBUGGING

3. Introduction in to the ABAP Runtime environment and


Debugging facilities

Purpose of that Chapter:

After that Chapter you should know / know how to perform:


How to start the Debugger
To name the components and the functionality of the ABAP debugger
How to step trough / navigate the coding (during a debugging session)
How to display the content of variables / internal tables
How to change the content of variable / internal tables
How to set Break points
How to set Watch points

In collaboration with

Automated Data Collection (ADC)

Copyright Capgemini 2008 All Rights Reserved

3. Introduction in to the ABAP Runtime environment and


Debugging facilities
How to start the Debugger

Start from any point you are by typing /h in the command field (Except: SAP displays currently a popup window )

From Transaction SE38:

Enter the Program name

Press the debugging button

Disadvantage: The debugger will show the handling of the selection screen.

In collaboration with

Automated Data Collection (ADC)

Copyright Capgemini 2008 All Rights Reserved

3. Introduction in to the ABAP Runtime environment and


Debugging facilities
How to start the Debugger

From Transaction SE80

1.

Enter the program name and check Program and click Display

3. Click on Debugging in Execution Type Popup.

Advantage:

2.

Debugging starts directly in the program event processing

Put the cursor on the program name an press the execute button

In collaboration with

Automated Data Collection (ADC)

Copyright Capgemini 2008 All Rights Reserved

3. Introduction in to the ABAP Runtime environment and


Debugging facilities
Components of the ABAP Debugger

Navigation
trough the
coding
Creation of
watch points

Creation of
watch points

Program
Coding line
number

Navigation
trough the
coding
Switch to the
internal table
display
Next
Program
step to be
executed
Delete all
variables
from

Currently
active ABAP
Program
Include in
which the
current coding
is located
Scroll trough
the list of
variables

List of variables
for which the
content should
be analysed

Important
System
Variables
In collaboration with

Automated Data Collection (ADC)

Copyright Capgemini 2008 All Rights Reserved

Introduction in to the ABAP Runtime environment and


Debugging facilities
Display Modes of the ABAP Debugger:

Fields:

Table:

Break points:

The scrollable field display can display the contents


of up to eight fields. It also always contains the values
of the three most important system fields.

The Displays the contents of an internal table. You


can also edit the contents of the table in this mode

Scrollable display containing up to 30 breakpoints.


You can also delete breakpoints from the display,
and set a counter for each one.

This is the default display mode in the Debugger.

In collaboration with

Automated Data Collection (ADC)

Copyright Capgemini 2008 All Rights Reserved

Introduction in to the ABAP Runtime environment and


Debugging facilities
Display Modes of the ABAP Debugger:

Watch Points:

Calls (Call stack):

Overview:

The scrollable field display can display the contents


of up to eight fields. It also always contains the values
of the three most important system fields.

This is the default display mode in the Debugger.

Displays the active sequences of events and


calls up to the current breakpoint. The last call is
displayed at the top of the list, with previous calls
below. As soon as an event (such as START-OFSELECTION) is finished, it disappears from the
list..

Displays the structure of the program. This display


contains the events, subroutines, and modules in the
program, and shows which section of code belongs
to which event. The section currently being
processed is displayed

In collaboration with

Automated Data Collection (ADC)

Copyright Capgemini 2008 All Rights Reserved

Introduction in to the ABAP Runtime environment and


Debugging facilities
Display Modes of the ABAP Debugger:

In collaboration with

Setting:

Displays the current Debugger settings. You can


change these using the checkboxes

Automated Data Collection (ADC)

Copyright Capgemini 2008 All Rights Reserved

Introduction in to the ABAP Runtime environment and


Debugging facilities
Navigation trough the coding

There are four different ways of stepping through program code in the Debugger:

Single step:
Use this option to step through the program a statement at a time. This is particularly suitable when you want to look into subroutines and function
modules, since this method steps through them as well as the main program. After processing a subroutine or function module, the Debugger
returns to the statement in the main program that follows the call.
Execute:
This option processes a program a line at a time. All steps in the same line are processed together. If you are positioned on a line that calls a
subroutine and choose Execute, the system executes the subroutine and proceeds directly to the next line in the main program, bypassing the
statements in the subroutine.
Return:
Returns to the position at which a calling program regains control. Use this option when you are debugging a subroutine or function module and
want to return to the program that called it.
Continue
Use this option to process the program up to the next breakpoint (dynamic or static) or up to the cursor position. If there are no more breakpoints
in the program and you have not set a cursor, the system processes the remainder of the program and ends the debugging session.

In collaboration with

Automated Data Collection (ADC)

Copyright Capgemini 2008 All Rights Reserved

Introduction in to the ABAP Runtime environment and


Debugging facilities

Displaying Field content:

In the Fields display mode in the Debugger, you can display, and also change, the contents of up to eight program fields. This is the default
display mode in the Debugger.

Procedure:

From any display mode in the Debugger, choose Fields.

Enter the field names, either directly in the input fields, or by double-clicking the field name in the source code display. The system
automatically enters the field name in the display.

Step through the program to analyze the coding.

In collaboration with

Automated Data Collection (ADC)

Copyright Capgemini 2008 All Rights Reserved

10

Introduction in to the ABAP Runtime environment and


Debugging facilities

Displaying Field content:

Displaying Other Fields


The field display only has space for four fields. However, you can use the scroll

in the program. The three most important system fields

Displaying Fields From External Programs


You can also display the contents of fields from external programs as long as
parentheses before the field name.

display other fields.

Displaying System Fields


This mode allows you to display the contents of system fields or fields defined
(SY-SUBRC, SY- TABIX, and SY-DBCNT) are always displayed.

buttons to

you know the program name. Enter the program name in

Changing the Display Format


You can display the field contents with their normal formatting or in hexadecimal

form.

Use this button to display the field contents in hexadecimal form


Use this button to display the field contents in their normal output format.

Deleting All Field Names


Use this button to delete all of the field names from the field display.

In collaboration with

Automated Data Collection (ADC)

Copyright Capgemini 2008 All Rights Reserved

11

Introduction in to the ABAP Runtime environment and


Debugging facilities

Displaying Internal Tables :

The Debugger allows you to display and change the contents of simple or nested internal tables. The table display mode
also allows you to find out information about the table type, table key, or memory use of an internal table.

Procedure:
1.

From any display mode in the Debugger, choose Goto => Table or press
The table display mode appears.

2.

In the Internal table field, enter a table name (or double-click the name of an internal table in the source code display).

3.

Choose ENTER .

4.

Step through the program to analyze the source code.

In collaboration with

Automated Data Collection (ADC)

Copyright Capgemini 2008 All Rights Reserved

12

Introduction in to the ABAP Runtime environment and Debugging facilities

In collaboration with

Automated Data Collection (ADC)

Copyright Capgemini 2008 All Rights Reserved

13

Introduction in to the ABAP Runtime environment and


Debugging facilities

Changing the Values of Fields at Runtime:

While you are debugging a program, you might want to change the content of specific fields to influence
your program's flow. For example, suppose your debugging session reveals that a field contains a wrong value.
The Debugger allows you to replace the wrong value with a correct one. You can now see whether the program
works properly when the field values are correct.

You can change the values of all fields, database tables (with offset), and internal tables referenced in a
program. The system displays a message to notify you of any format errors.

Procedure

1.

Switch to field display mode.

2.

Double-click a field to place it in the field display. The field is displayed with its current value.

3.

Enter a new value for the field contents.

4.

Choose the pencil icon at the end of the line. Result

The Debugger writes the new value into the program field(s), and records the change in the system log. If you
forget to click on the pencil icon,
the system ignores the values you entered.

The Debugger records the values exactly as you enter them. You must therefore make sure that you use the
correct format (upper/lowercase, left-justified input for hexadecimal numbers).

In collaboration with

Automated Data Collection (ADC)

Copyright Capgemini 2008 All Rights Reserved

14

Introduction in to the ABAP Runtime environment and


Debugging facilities

Changing Internal Tables at Runtime:

The Debugger allows you to manipulate the contents of an internal table during runtime. You can delete, edit,

or add a row to an internal table

Deleting a Row :

To delete an entry from an internal table:


1.

Go to the table display screen.

2.

Enter the table name in the Internal Table field.

3.

Choose ENTER . The system displays the contents of the table.

4.

Place the cursor on the line you wish to remove from the table.

5.

Choose Delete.

The line disappears from the table and the system adjusts the line numbering accordingly.

In collaboration with

Automated Data Collection (ADC)

Copyright Capgemini 2008 All Rights Reserved

15

Introduction in to the ABAP Runtime environment and


Debugging facilities

Changing Internal Tables at Runtime:

Editing a Row

The functions Modify, Insert, and Append are field-specific in the Debugger. You can only apply them to
one field at a time. For example, if you want to edit the following line:

bukrs gjahr rjahr belnr

buzei

|1500 |2002 |2002 |5110000727|001

rblnr

rbuze

|5105603189|000001|

you first need to decide which field to change. Then, do the following:

1.

Place the cursor on the row and field you want to edit.

2.

Choose Change. The system displays one field of the chosen row in the input mode.

3.

Enter a new value for the field.

4.

Choose ENTER .
The system updates the line and displays the new contents in the table.

In collaboration with

Automated Data Collection (ADC)

Copyright Capgemini 2008 All Rights Reserved

16

Introduction in to the ABAP Runtime environment and


Debugging facilities

Changing Internal Tables at Runtime:

Adding appending a Row:

The Insert and Append functions allow you to add new lines to an internal table. Append places the new
line at the end of the table. Insert lets you position the line anywhere. To add a new row to the end of the table:
1.

Choose Append.

2.

Enter a value for the first field in the line.

3.

Choose ENTER .
The system adds a line to the table and fills in the first field.

4.

Enter the remaining fields of the line by following the procedure for editing a row as described above.
To insert a new line anywhere in the internal table, position the cursor on the
line directly following the
line where you want the new row to appear. Then,
choose the Insert button and proceed as you would if you wanted to
append the
line.

In collaboration with

Automated Data Collection (ADC)

Copyright Capgemini 2008 All Rights Reserved

17

Introduction in to the ABAP Runtime environment and


Debugging facilities
Breakpoints

As well as running a program from the beginning in the Debugger, you can also set a precise point in the program at
which the Debugger is called by setting one or more breakpoint. A breakpoint is a signal from the ABAP program to
the runtime processor to interrupt processing and start the Debugger.

As an alternative to breakpoints, you can set watch points. Watch points activate the Debugger when the contents
of a selected field change. For further information, refer to Watch points
Static

To set a static breakpoint, enter the ABAP statement BREAK-POINT directly in the program code.
Normally user-independent, they can also be made user-specific.

Dynamic breakpoints set directly

These are set in the ABAP Editor or the Debugger, and are displayed as stop signs. Unlike static
breakpoints, they are always user-specific, and are deleted when you end your terminal session.

Statement breakpoint

This special form of dynamic breakpoint is set in the Debugger. The Debugger interrupts the
program immediately before the specified statement is executed.

Event breakpoint

This form of dynamic breakpoint is set in the Debugger. The Debugger interrupts the program
immediately before the event, subroutine, or module pool is called.

Breakpoints at function modules

The Debugger interrupts the program immediately before a function module is called.

Breakpoints at system exceptions

The Debugger interrupts the program as soon as a system exception occurs, that is, when a
runtime error is caught by a CATCH statement.

In collaboration with

Automated Data Collection (ADC)

Copyright Capgemini 2008 All Rights Reserved

18

Introduction in to the ABAP Runtime environment and


Debugging facilities
Dynamic Breakpoints

Dynamic breakpoints are user-specific. You should therefore use them whenever you want to interrupt a program
without affecting other users. When you log off from the R/3 System, all of your dynamic breakpoints are
automatically deleted.

Dynamic breakpoints are more flexible than static breakpoints, since you can delete or deactivate them at runtime.
This has the following advantages:

You do not have to change the source code

You can set them even if other developers are blocking the program that you are testing

You can set a counter (for example, only activate the breakpoint when it is reached for the fifth time)

In collaboration with

Automated Data Collection (ADC)

Copyright Capgemini 2008 All Rights Reserved

19

Introduction in to the ABAP Runtime environment and


Debugging facilities

Dynamic Breakpoints

You can set up to 30 dynamic breakpoints without having to change the source code of your program.

You can set them either in the ABAP Editor or directly in the Debugger:

Setting Dynamic Breakpoints in the ABAP Editor

In the ABAP Editor, you can set dynamic breakpoints in either change or display mode. You can also set
breakpoints at runtime directly within the Debugger. To set a dynamic breakpoint in the ABAP Editor:

1.

Place the cursor on the line of code at which you want to set the breakpoint.

2.

Choose Utilities => Breakpoint => Set.


The system confirms that the breakpoint was set. It is displayed as a stop sign to the right of the program code.

You can display a list of all dynamic breakpoints in a program by choosing Utilities => Breakpoints =>
Display. The dynamic breakpoint display lets you navigate to a certain breakpoint or delete one or all breakpoints
from your program code.

Setting Dynamic Breakpoints in the Debugger

1.

Place the cursor on the line where you want to set the breakpoint.

2.

Select the line either by choosing Breakpoint => Set/delete or by double-clicking.

The system sets a breakpoint at the line and places a small stop to the left side of the line indicating a
breakpoint. If the line already contains a breakpoint, the system deletes it.

When you finish your debugging session, your breakpoint will be deleted unless you have explicitly saved it.

In collaboration with

Automated Data Collection (ADC)

Copyright Capgemini 2008 All Rights Reserved

20

Introduction in to the ABAP Runtime environment and


Debugging facilities

Special Dynamic Breakpoints

Special dynamic breakpoints are useful whenever you want to interrupt a program directly before a
particular ABAP statement, subroutine, or event, but you are not sure exactly where that statement, subroutine
or event occurs. Special dynamic breakpoints are user-specific, and can only be set in the Debugger.

Breakpoint at ABAP Statement

1.

Choose Breakpoint => Breakpoint at => Statement.

2.

The following screen appears

1.

Enter the ABAP statement.

2.

Choose ENTER .
The system sets a breakpoint in all liens containing the given statement.

The system confirms the breakpoint and adds it to the breakpoint list. When you end your debugging
session, the breakpoint is deleted automatically unless you save it explicitly.

In collaboration with

Automated Data Collection (ADC)

Copyright Capgemini 2008 All Rights Reserved

21

Introduction in to the ABAP Runtime environment and


Debugging facilities
Breakpoints at Subroutines, Events, Modules

These special dynamic breakpoints allow you to interrupt a program directly before a subroutine, event, or

module is called.

Procedure
1.

Choose Breakpoint => Breakpoint at => Event/Subroutine.

2.

The following dialog box appears:

1.

Enter the subroutine, module, or event before which you want to interrupt the program.

2.

Choose ENTER.
The system sets a breakpoint immediately before all calls to the subroutine, module or event.

Result
The system confirms the breakpoint and adds it to the breakpoint list. If the subroutine, module, or event does not exist in the program, the system displays a
message and does not set the breakpoint

In collaboration with

Automated Data Collection (ADC)

Copyright Capgemini 2008 All Rights Reserved

22

Introduction in to the ABAP Runtime environment and


Debugging facilities

Breakpoints at Function Module Calls


These dynamic breakpoints allow you to interrupt a program directly before a particular function module is called.

Procedure
1.

Choose Breakpoint => Breakpoint at => Function module


The following dialog box appears:

2.

Enter the function module before which you want to interrupt program processing.
The system sets a breakpoint each time the function module appears in the program.

3.

Choose ENTER .
If you entered a function module that exists in the system, the system confirms the breakpoint and adds it to the breakpoint list.

In collaboration with

Automated Data Collection (ADC)

Copyright Capgemini 2008 All Rights Reserved

23

Introduction in to the ABAP Runtime environment and


Debugging facilities

Watch points

Watch points, like breakpoints, provide a signal from the program to the ABAP runtime processor to
interrupt processing at a particular point in the program. Unlike breakpoints, watch points only activate the
Debugger when the contents of a field change. Like dynamic breakpoints, watch points are user specific, that is,
they do not affect other users who are running the program at the same time
You can only set watch points in the Debugger.

Use

You can set watch points in the Debugger for specific fields. They allow you to determine when the
contents of a certain field change. The Debugger interrupts the program as soon as the field contents change.

Features

You can set up to five watch points in a program.

You can also specify conditions that have to be met before a watch point becomes active.

You can define a logical relationship between up to 5 conditional watch points.

See also Specifying Logical Relationships Between Watch points.

You can define watch points as either local or global. Local watch points are only active in the current

program. Global watch points are valid in the current program and in any other programs that it calls.

You can change watch points.

You can delete watch points.

In collaboration with

Automated Data Collection (ADC)

Copyright Capgemini 2008 All Rights Reserved

24

Introduction in to the ABAP Runtime environment and


Debugging facilities

Setting Watch points

Use watch points when you want to interrupt a program when the contents of a field or structure change.
You can set up to five watch points.

Watch points can be either local or global. Local watch points are only active in the current program.
Global watch points are active in the current program and any programs that it calls.

You set watch points in the Debugger.

Procedure

1.

Choose Breakpoint => Create watchpoint.

The following dialog box appears:

2.

Decide whether you want to create a local or a global watch point.

3.

Enter the name of the field for which you want to set the watch point.

4.

If you want your watch point to be activated each time the field contents change, you have now entered all of the
necessary information, and can return to the Debugger by choosing ENTER . The watch point now appears in the
watch point list.

5.

If you want to specify conditions for the watch point, continue with step 5.

6.

To create a conditional watch point, choose one of the following relational operators:
In collaboration with

Automated Data Collection (ADC)

Copyright Capgemini 2008 All Rights Reserved

25

Introduction in to the ABAP Runtime environment and


Debugging facilities
Setting Watch points

To create a conditional watch point, choose one of the following relational operators:

Operator

Meaning

= or eq

Equal

<> or ne

Not equal

< or lt

Less than

<= or le

Less than or equal

>= or ge

Greater than or equal

> or gt

Greater than

In collaboration with

Automated Data Collection (ADC)

Copyright Capgemini 2008 All Rights Reserved

26

Introduction in to the ABAP Runtime environment and


Debugging facilities

Specifying logical Conditions between Watchpoints

If you create more than one conditional watchpoint, you can link them using a logical operator:

OR:

only one of the conditions must be met.

AND:

All conditions must be met.

Procedure:

To establish a logical relationship between watch points:

Open the watch points list by choosing Goto => Watch points.

Set the Logical operator option. The default is always OR.

In collaboration with

Automated Data Collection (ADC)

Copyright Capgemini 2008 All Rights Reserved

27

Introduction in to the ABAP Runtime environment and


Debugging facilities

Changing a Watchpoint

1.

Choose Goto => Watch points to display the watch points.

2.

Click the pencil icon in the line containing the watch point that you want to change.

The following dialog box appears:

1.

Change the attributes of the watch point

2.

Choose ENTERIn.collaboration with

Automated Data Collection (ADC)

Copyright Capgemini 2008 All Rights Reserved

28

Introduction in to the ABAP Runtime environment and


Debugging facilities

Deleting Watch points

You cannot use Breakpoint => Delete or Breakpoint => Deactivate/ activate to deactivate or delete a watch point.
Instead, you must:

1.

Choose Goto => Watch points to display the watch points.

2.

Click the trashcan icon in the line containing the watch point that you want to delete

In collaboration with

Automated Data Collection (ADC)

Copyright Capgemini 2008 All Rights Reserved

29

Suppose we take a example where we need to find the value of Invoice number and other
details in Report.
Program-ZRVO0006 TCode-ZVO3

In collaboration with

Automated Data Collection (ADC)

Copyright Capgemini 2008 All Rights Reserved

30

In report put the breakpoint at the place where you have written code for the field which you
want to search , here in this example like we want to search invoice number so we put
breakpoint at place where logic is written to fetch invoice data:

In collaboration with

Automated Data Collection (ADC)

Copyright Capgemini 2008 All Rights Reserved

31

In collaboration with

Automated Data Collection (ADC)

Copyright Capgemini 2008 All Rights Reserved

32

Then Choose the variant maintained in the selection screen and execute the program,you will
reach in debug mode.

Press F5 to move word by word in LINE,


Press F6 to move line by line
Press F7 to move in particular include or program and f8 to execute.

In collaboration with

Automated Data Collection (ADC)

Copyright Capgemini 2008 All Rights Reserved

33

The value of invoice number is stored in ZVBELN

In collaboration with

Automated Data Collection (ADC)

Copyright Capgemini 2008 All Rights Reserved

34

The Method is given below to put the Watch Point in Program.

In collaboration with

Automated Data Collection (ADC)

Copyright Capgemini 2008 All Rights Reserved

35

Thanks

In collaboration with

Automated Data Collection (ADC)

Copyright Capgemini 2008 All Rights Reserved

36

Das könnte Ihnen auch gefallen