Sie sind auf Seite 1von 23

ABAP Debugging

Presented by, Sylendra Prasad M

Agenda for the day


Debugging

An overview ABAP Debugging Debugging Getting started Break points & Watch points Debugging Tools Debugging in Background

Debugging An overview
Stepwise The

method of finding out errors or bugs.

basic steps involve

Recognize

that the bug exists Isolate source of bug Identify cause of bug Determine the fix for the bug Apply the fix and test it.
Software

Debugging is done by special software called debuggers.

ABAP Debugging
ABAP

Debugger allows you to interrupt the running program after each step, allowing you to check intermediate results and processing logic. Debugger can be called in two ways.
By

setting break points.

Write

BREAK-POINT or BREAK statement in program(static) Click STOP button in the toolbar of program (dynamic)
By

running the program in debugging mode.

Using

\h Setting break points at specified code lines. Double clicking to set break points.

Debugging Getting started


To

switch on debugging, type /h and press enter.

Following

buttons are used to continue debugging.

1.

2.

3. 4.

5.

Single step: Used to step through the program statement by statement.For subroutines, this will go inside the subroutine. .(F5 key can be used). Execute: Similar to single step , but for subroutines, this completely executes the subroutine,without going inside the routine.(F6 key can be used). Return: Used to return from a subroutine, or a called program to a calling program. Run: Used to process the program until the next static or dynamic break point.If no more breakpoints are there, this will exit the debugging mode and executes the rest of the program normally(F8 key). Watchpoints: Used to interrupt the execution of program when variable reaches a particular value.Will be discussed in detail later.

Break points
Causes

program execution to stop at that location and start the debugger. Static Break-point.
User

independent breakpoint:

Using

statement BREAK-POINT. Interrupted when execution reaches the line of code. Useful in development phase and removed before transported. Can number the break points to identify them easier.
User

dependent breakpoint:

Interrupted

only for a specific user. Using the statement BREAK <username>. Visible in program, but not active when other users use the program.

SAMPLE PROGRAM

Static

break points must be removed from program after testing.

Dynamic
Done

break point:

by clicking on STOP button in toolbar of program.

User

specific break point. No need to change the code. Can be set even when prog. is locked by any user. Deleted when logged off the SAP system.

30

dynamic break points can be set without changing the program code. Can be set directly in ABAP editor or while debugging. While debugging, break points can be set or deleted by double clicking the line of code.

OR

Different methods of using break points


Break

points at ABAP Statements:

Select Breakpoint ->Breakpoint at -> Statement

Break point at Function Modules & Subroutines

Similarly, break points can be set for Function Modules, Methods, Exceptions etc.

Saving and Deleting Break points

Dynamic break points can be saved so that they are still active within the same session.

Break points will remain active until you delete it or you logoff the system. Break points can be deleted either by double clicking on the break point or selecting the menu option

Choose->Create/Delete or Choose->Delete all

Watch points
Used

to interrupt program, when contents of field or structure change. Can save up to 5 watch points including watch points for strings. Can be local or global
Local

watch points valid only in a specified program Global watch points valid only in a specified program and all the programs it calls.

Procedure to set Watch points


Choose

menu option Breakpoint -> Create watchpoint or the corresponding Pushbutton

OR

Provide

the program name, variable name , relational operator(=,<,<=,>= etc) and the value.

So whenever gd_tcode-tcode becomes KO8G, the program execution will be interrupted.

Debugging Tools
Use

the following buttons during debugging.

Contents

can be displayed by double clicking on the field name while debugging.

Fields:

can be used to get values of single fields.

Table:

can be used to get internal table values.

The

internal table data , during debugging, can be downloaded to excelsheet, by clicking on Save as excel worksheet button and giving the number of rows to be downloaded.

Watch

points and Break points: can be used to display them in the main program.

Debugging in Background

Debugging can be done for programs scheduled to run in background. Job should be either in Scheduled or Released status. After scheduling the program to run in background, select the job in SM37 and type jdbg in the command area.

Now the debugger is activated.

Running

programs (ie jobs with status Active) can also be debugged. Goto SM50 to get the list of processes. Identify the process related to the program. Goto menu option Program/Mode->Program->Debugging SM50 Authorization for monitoring processes are needed for this method of debugging.

Reference documents
SAP

Help documents http://www.sappro.com/ Experience

QUESTIONS ??

Das könnte Ihnen auch gefallen