Upload
shankar386
View
254
Download
2
Embed Size (px)
Citation preview
8/3/2019 7202741 ABAP Debugging
1/23
ABAP DebuggingABAP Debugging
Presented by,Presented by,
Sylendra Prasad MSylendra Prasad M
8/3/2019 7202741 ABAP Debugging
2/23
Agenda for the dayAgenda for the day
Debugging An overviewDebugging An overview
ABAP DebuggingABAP Debugging
Debugging Getting startedDebugging Getting started
Break points & Watch pointsBreak points & Watch points
Debugging ToolsDebugging Tools
Debugging in BackgroundDebugging in Background
8/3/2019 7202741 ABAP Debugging
3/23
Debugging An overviewDebugging An overview
Stepwise method of finding out errors or bugs.Stepwise method of finding out errors or bugs.
The basic steps involveThe basic steps involve Recognize that the bug existsRecognize that the bug exists
Isolate source of bugIsolate source of bug Identify cause of bugIdentify cause of bug
Determine the fix for the bugDetermine the fix for the bug
Apply the fix and test it.Apply the fix and test it.
Software Debugging is done by special softwareSoftware Debugging is done by special software
called debuggers.called debuggers.
8/3/2019 7202741 ABAP Debugging
4/23
ABAP DebuggingABAP Debugging
ABAP Debugger allows you to interrupt theABAP Debugger allows you to interrupt the
running program after each step, allowing you torunning program after each step, allowing you tocheck intermediate results and processing logic.check intermediate results and processing logic.
Debugger can be called in two ways.Debugger can be called in two ways.
By setting break points.By setting break points.Write BREAK-POINT or BREAK statement in program(static)Write BREAK-POINT or BREAK statement in program(static)
Click STOP button in the toolbar of program (dynamic)Click STOP button in the toolbar of program (dynamic)
By running the program in debugging mode.By running the program in debugging mode.Using \hUsing \h
Setting break points at specified code lines.Setting break points at specified code lines.
Double clicking to set break points.Double clicking to set break points.
8/3/2019 7202741 ABAP Debugging
5/23
Debugging Getting startedDebugging Getting started
To switch on debugging, type /h and press enter.To switch on debugging, type /h and press enter.
Following buttons are used to continueFollowing buttons are used to continue
debugging.debugging.
8/3/2019 7202741 ABAP Debugging
6/23
1.1. Single step: Used to step through the programSingle step: Used to step through the program
statement by statement.For subroutines, this will gostatement by statement.For subroutines, this will go
inside the subroutine. .(F5 key can be used).inside the subroutine. .(F5 key can be used).
2.2. Execute: Similar to single step , but for subroutines,Execute: Similar to single step , but for subroutines,
this completely executes the subroutine,without goingthis completely executes the subroutine,without going
inside the routine.(F6 key can be used).inside the routine.(F6 key can be used).
3.3. Return: Used to return from a subroutine, or a calledReturn: Used to return from a subroutine, or a called
program to a calling program.program to a calling program.
4.4. Run: Used to process the program until the next staticRun: Used to process the program until the next static
or dynamic break point.If no more breakpoints areor dynamic break point.If no more breakpoints are
there, this will exit the debugging mode and executesthere, this will exit the debugging mode and executes
the rest of the program normally(F8 key).the rest of the program normally(F8 key).
5.5. Watchpoints: Used to interrupt the execution ofWatchpoints: Used to interrupt the execution of
program when variable reaches a particular value.Willprogram when variable reaches a particular value.Will
be discussed in detail later.be discussed in detail later.
8/3/2019 7202741 ABAP Debugging
7/23
Break pointsBreak points
Causes program execution to stop at thatCauses program execution to stop at that
location and start the debugger.location and start the debugger. Static Break-point.Static Break-point. User independent breakpoint:User independent breakpoint:
Using statement BREAK-POINT.Using statement BREAK-POINT.
Interrupted when execution reaches the line of code.Interrupted when execution reaches the line of code.
Useful in development phase and removed beforeUseful in development phase and removed before
transported.transported.
Can number the break points to identify them easier.Can number the break points to identify them easier.
User dependent breakpoint:User dependent breakpoint: Interrupted only for a specific user.Interrupted only for a specific user.
Using the statement BREAK .Using the statement BREAK .
Visible in program, but not active when other users use theVisible in program, but not active when other users use the
program.program.
8/3/2019 7202741 ABAP Debugging
8/23
SAMPLE PROGRAMSAMPLE PROGRAM
Static break points must be removed fromStatic break points must be removed from
program after testing.program after testing.
8/3/2019 7202741 ABAP Debugging
9/23
Dynamic break point:Dynamic break point: Done by clicking on STOP button in toolbar ofDone by clicking on STOP button in toolbar of
program.program.
User specific break point.User specific break point. No need to change the code.No need to change the code.
Can be set even when prog. is locked by any user.Can be set even when prog. is locked by any user.
Deleted when logged off the SAP system.Deleted when logged off the SAP system.
8/3/2019 7202741 ABAP Debugging
10/23
30 dynamic break points can be set without30 dynamic break points can be set without
changing the program code.changing the program code.
Can be set directly in ABAP editor or whileCan be set directly in ABAP editor or while
debugging.debugging.
While debugging, break points can be set orWhile debugging, break points can be set or
deleted by double clicking the line of code.deleted by double clicking the line of code.
OROR
8/3/2019 7202741 ABAP Debugging
11/23
Different methods of using break pointsDifferent methods of using break points
Break points at ABAP Statements:Break points at ABAP Statements: SelectSelect Breakpoint ->Breakpoint at -> StatementBreakpoint ->Breakpoint at -> Statement
8/3/2019 7202741 ABAP Debugging
12/23
Break point at Function Modules & SubroutinesBreak point at Function Modules & Subroutines
Similarly, break points can be set for Function Modules, Methods,Similarly, break points can be set for Function Modules, Methods,Exceptions etc.Exceptions etc.
8/3/2019 7202741 ABAP Debugging
13/23
Saving and Deleting Break pointsSaving and Deleting Break points Dynamic break points can be saved so that they are still active within the same session.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 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 menuBreak points can be deleted either by double clicking on the break point or selecting the menu
optionoption
Choose->Create/Delete orChoose->Create/Delete or
Choose->Delete allChoose->Delete all
8/3/2019 7202741 ABAP Debugging
14/23
Watch pointsWatch points
Used to interrupt program, when contents of fieldUsed to interrupt program, when contents of fieldor structure change.or structure change.
Can save up to 5 watch points including watchCan save up to 5 watch points including watch
points for strings.points for strings.
Can be local or globalCan be local or global Local watch points valid only in a specified programLocal watch points valid only in a specified program
Global watch points valid only in a specified programGlobal watch points valid only in a specified program
and all the programs it calls.and all the programs it calls.
8/3/2019 7202741 ABAP Debugging
15/23
Procedure to set Watch pointsProcedure to set Watch points
Choose menu optionChoose menu option Breakpoint -> Create watchpointBreakpoint -> Create watchpoint
or the corresponding Pushbuttonor the corresponding Pushbutton
OROR
Provide the program name, variable name ,Provide the program name, variable name ,relational operator(=,
8/3/2019 7202741 ABAP Debugging
16/23
So whenever gd_tcode-tcode becomes KO8G, the program execution will beSo whenever gd_tcode-tcode becomes KO8G, the program execution will beinterrupted.interrupted.
8/3/2019 7202741 ABAP Debugging
17/23
Debugging ToolsDebugging Tools
Use the following buttons during debugging.Use the following buttons during debugging.
Contents can be displayed by double clicking onContents can be displayed by double clicking on
the field name while debugging.the field name while debugging.
Fields: can be used to get values of single fields.Fields: can be used to get values of single fields.
8/3/2019 7202741 ABAP Debugging
18/23
Table: can be used to get internal table values.Table: can be used to get internal table values.
8/3/2019 7202741 ABAP Debugging
19/23
The internal table data , during debugging, canThe internal table data , during debugging, can
be downloaded to excelsheet, by clicking onbe downloaded to excelsheet, by clicking on SaveSave
as excel worksheetas excel worksheetbutton and giving the number ofbutton and giving the number of
rows to be downloadedrows to be downloaded..
Watch points and Break points: can be used toWatch points and Break points: can be used to
display them in the main program.display them in the main program.
8/3/2019 7202741 ABAP Debugging
20/23
Debugging in BackgroundDebugging in Background
Debugging can be done for programs scheduled to run inDebugging can be done for programs scheduled to run in
background.background.
Job should be either in Scheduled or Released status.Job should be either in Scheduled or Released status.
After scheduling the program to run in background, selectAfter scheduling the program to run in background, select
the job in SM37 and typethe job in SM37 and typejdbgjdbg in the command area.in the command area.
Now the debugger is activated.Now the debugger is activated.
8/3/2019 7202741 ABAP Debugging
21/23
Running programs (ie jobs with status Active)Running programs (ie jobs with status Active)
can also be debugged.can also be debugged.
GotoGoto SM50SM50to get the list of processes.to get the list of processes. Identify the process related to the program.Identify the process related to the program.
Goto menu optionGoto menu option
Program/Mode->Program->DebuggingProgram/Mode->Program->Debugging SM50 Authorization for monitoring processes areSM50 Authorization for monitoring processes are
needed for this method of debugging.needed for this method of debugging.
8/3/2019 7202741 ABAP Debugging
22/23
Reference documentsReference documents
SAP Help documentsSAP Help documents
http://www.sappro.com/http://www.sappro.com/
ExperienceExperience
http://www.sappro.com/http://www.sappro.com/http://www.sappro.com/8/3/2019 7202741 ABAP Debugging
23/23
QUESTIONS ??QUESTIONS ??