Debugger Fundamentals
Debugger Fundamentals
Debugger
Debugger Fundamentals
1
Course Content (current Highlighted)
Debugger II Updates
Syslog
2
Unit Objectives
3
Debugger
This chapter is designed to give a basic introduction into the debugger and will set the
focus on the handling.
4
Debugger 1 - Customer Problem
5
Debugger 1 - Customer Problem - Solution
(1)Switch on debugging
on the odd popup
(use the shortcut)
(2) get the calling function
---> USER EXIT !!!!!
(3) Set a breakpoint on this
function
(4) Analyze the code or debug it
6
Start an ABAP Report With the Debugger
SE38
Button ‚Debugging‘
If you insert /h in the ok-code field then you will not debug RSPARAM but the editor
(SE38).
7
Start an ABAP Function Module With the
Debugger
SE37
Button ‚Single Test‘
For function modules use transaction SE37 -> Button ‘Single Test’
In the generated function interface fill in the parameters and press Debugging
Please notice that this is the only possibility to debug functions which are connected to
CONVERSION EXITS or FIELD EXITS. They can‘t be debugged during the running
transaction (-> only isolated testing is possible)
If you debug a complicated transaction and you are sure that the problem occurs in one
function module then get the parameters for the function interface and try to reproduce the
error in an isolated test (SE37)
8
SE37 - Demo
If the type of the export parameter is not specified in the test environment of SE37 then this
tool will generate a default field with type char(200).
By the way, if you call this function from another program without specifying the import
parameter:
Then my_export in the function will have the default type char(4).
If you specify the parameter then the system will generate a field which has the same type:
9
Start a Transaction With the Debugger
Transaction: SE93
-> Fill in your transaction (e.g. VA01)
-> Menu path: Transaction Code -> Test -> Debugging
The transaction will be started directly in debugging mode, starting with the first PBO
module of the first screen.
10
Start Debugging of an Already
Running ABAP Program
Starting the debugger while the program is already running allows you to reach the point of
interest faster and more precisely.
Start the debugger (/h) in a transaction at the point where you are having the problem
Start to debug a report when you think the problem is there (i.e.:long running report)
For debugging basis transactions usually the system debugging will be needed (/hs)
If you access the batch process via SM50 then you can use all features of the debugger
You can set dynamic/static breakpoints display or change fields ...
There is only one restriction: The ABAP statement break-point will not force the batch
process to stop. Only a syslog entry will be written (Breakpoint reached ...).
11
Batch Debugging - Demo
i = 0.
While i = 0.
I = 0.
Endwhile.
... Interesting code....
If you start the job then the program will hang in your endless loop after some time.
If you now start debugging the you can be sure that you will access the batch job exactly at
your loop. Change i to e.g. 1 in the debugger and go on debugging
12
Batch Debugging - Preparation for the
Exercise
If a program behaves different in batch input then search globally for sy-binpt.
13
Batch Debugging - Exercise
Report ZDEBUGBATCH_UEBUNG
has no spool list in batch
In dialog: In batch: no Output ??
14
Batch Debugging - Solution
15
Debugging a Batch Job
The OK-code JDBG allows to analyze a batch job in Debug Mode. Advantages are:
Jobs can be debugged right from the beginning
If a Batchjob consists of more than one step, JDBG allows to analyze subsequent steps
consecutively (unless there is no termination of a step in a shortdump).
SY-BATCH is filled automatically by the system. It is not necessary to change the field
manually.
Handling of the Job in SM37 and the Batchjob itself can be analyzed in the same
debugging session
Note that this is no test mode. Analyzing a job using JDBG will execute the job and might
perform changes on the database.
16
Start Debugging With a Shortcut
Generate Shortcut
on the desktop
17
Start Debugging With a Shortcut
Drag the shortcut directly on the screen where you want to start debugging
This technique is really helpful if you are on a popup and want to start debugging.
You can‘t access the ok-field, therefore the shortcut technique is the only possible solution
to debug e.g. the ABAP of a popup directly.
Please assure (especially if you use a CITRIX client) that you have the (e.g.NT) permission
to save files on the desktop !
18
Navigation in the Source Code
Increase program
section size
Display current
statement
Scroll source code
to navigate back to the next statement to be processed use the icon ‚display
current statement‘
to hide the view section click the icon ‚increase program section size‘
The flag Fixed pt. Arithmetic indicates whether the actual program uses fixed
point arithmetic or not. (adjustable via se38 -> Attributes)
If you use NO Fixed pt. Arithmetic then packed figures are similar to integers
independently of the DECIMALS settings.
19
Example for Fixed Point Arithmetic
10050 +
1000
----------------
11050
set ‘.’ after 2 decimals:
110.50
As of release 6.10 Program attributes can be analyzed in the Debugger (Goto – Further
Information – Program Attributes). This includes attributes like
Fixed-point arithmetic
Unicode checks active
System program
20
Navigation From the Debugger to a List Output
F5
Print next
write-line
the current state of list-output ( GOTO -> Display condition -> Display List )
the current ABAP source ( Development -> ABAP Editor / Object Browser )
the screen painter (if you are in the flow logic of a Dynpro)
21
Navigation Using the Active Call Stack
Double-click this
line in order to
navigate to this
function of the call
stack
The call stack shows the current call hierarchy (which program was called by which
program)
It is always possible to switch to the other levels of the hierarchy. Within this level it is
possible to access all variables and their values but you have to keep in mind that only the
local variables have their current values; global variables might have been changed in the
meantime. The switching itself is triggered by double-clicking on the desired level.
Please always keep in mind, that you only see the simple call hierarchy. If the program
jumped to another routine and returned you are not able to find a trace in the call stack.
(For this task use ABAP Trace (SE30))
If system debugging mode is off, then you will not be able to switch into system modules
(switch on system debugging: /hs)
22
Display Data in the Debugger
VIEW: FIELD
(2)
Double
click
(3)
Double click
In the fields view you can switch to hexadecimal display by using the magnifier icon (1).
Starting from the fields view you can double-click into any field name this will lead into the
detailed field view (3) or if the field name specifies a structured field you will be switched
into the structured field view (2).
A double click into any field in the structured field view or table view will lead you into the
detailed view of the single field.(3)
You can access the different views also from the menu:
Goto -> Display data object ->
Single field (Ctrl + F2)
Structured field (Ctrl + F3)
Internal table (Ctrl + F4)
23
Display Data in the Debugger
VIEW:
FIELD
(1)
Double-click
(2)
Double-click
Starting from the fields view you can double-click into the field name to branch into the
table view (1)
A double click into any field in the table view will lead you into the detailed view of the field
(as shown in the last viewgraph (3))
e.g.
my_struc-itab[2]-mandt will display the field mandt of the second line of the internal table
my_struc-itab
24
Exercise – Basic Navigation
Practice the navigation in the Debugger and test the display features using the
program ZDEBUGDISPLAY
25
Manipulation of Variables
0 (2) change
(1) edit
If you enter a variable in the variable area of the debugger you will be able to see the
contents of the variable (and scroll if needed). When using structures or tables instead of
‚normal‘ variables the system will display the work area of the variable. Entering a variable
can also be done by double-clicking on a variable in the coding.
It is also possible to change the contents of a variable by overtyping the contents and
pressing the pencil. This change will be documented in the SYSLOG
If you allow an user to change variables via the debugger then this user can overcome
almost all authority checks.
26
Manipulation of Internal Tables
Columns
In order to manipulate internal tables you can either use the button ‚Table‘ or a double-click
on the internal table. The system will switch to table view screen. Within this view you can :
scroll horizontally and vertically through the table
hide columns by deleting the field in the column line
Shift column by inserting your column name instead of a displayed column name
This is merely a display functionality. Your changes have no effect on the internal table.
search through the lines by using the second search button. Positioning the cursor on a
certain line will use the line contents as search pattern.
The normal (first) search button searches in the source code.
insert, modify, delete an entry
Please keep in mind that the entry is only changed column by column (except the delete button)
If you want to insert a line first you need to click on insert first and to change every column of the row
afterwards.
If you want to change a whole row you need to do that column by column as well
27
Changing Internal Tables Using the Structure
Editor
Size of ITAB
28
Exercise - Change Variables
29
Static Breakpoints
(2) If you use the ‘normal breakpoint’ in the editor (stop icon) then these breakpoints are
only valid for your user and your current logon !
(You will not see this break-point on another server !)
(3) If you set a breakpoint in the debugger then this breakpoint is only valid for the current
debug session. If you save the breakpoints then they are equal to editor breakpoints (->2)
Unfortunately it‘s not possible to set breakpoint in field-exits and conversion-exits. The
runtime will not stop there. You have to test your exits in an isolated test environment.
(SE37)
30
Dynamic Breakpoints
Set Breakpoint at :
statement e.g. select. You will find Breakpoints at all selects and cursor statements
event/subroutine: e.g. start-of-selection (event) or at a form of the actual program
function module: Insert the name at the function module. The Debugger will stop at the
first statement of the function module.
System exception: If your program uses the CATCH / ENDCATCH functionality then
you may oversee an occurring Dump. If you set Breakpoints at system exception the
debugger will stop at the statement where the skipped Dump occurred.
This technique allows you to reach the interesting part of the program as quick as possible
without loosing time because you always stop at the Breakpoint before the interesting
situation comes up.
31
Possible Problems With Breakpoints
32
Manipulation of Breakpoints
Counter
The Breakpoint overview allows you to delete e.g. only the dynamic Breakpoints at WRITE.
So you don’t have to delete all Breakpoints. You can decide very specifically which
Breakpoints should be deleted.
Example - Counter:
You are in a form which fills an internal table . This form is called very often. During the
runtime a Dump occurs at an INSERT statement which complains about a too big internal
table and a lack of memory.Now you have the problem to debug the program.
You place a Breakpoint at the valid INSERT statement, but unfortunately the
INSERT´statement is executed thousands of times.
33
Watchpoints
If you do not specify a condition then the debugger stops as soon as the field
matnr changes.
Program flow
The system will inspect the memory address which is connected to the field name
and will compare the value in this memory address with your condition.
As soon as the condition and the current value match the debugger stops.
34
Creation of Watchpoints
Create
LOCAL
or
GLOBAL
change or delete
watchpoints
If you wish to stop the program depending on the contents of a variable you have to use a
Watchpoint.
Within the Watchpoint you can specify the condition of the variable the system should stop
(<,>,<>, <=.>=). Even the comparison to another variable is possible
If you create more than one Watchpoint you can link them together with AND and OR.
35
Exercise 1
36
Exercise 1 - Solution
VBAK-VDATU is a shared Tables area. This means at least two programs look on the
same VBAK-VDATU and they can change it mutually.
If you use a local Watchpoint then you will only observe changes in program SAPMV45A.
In our case you only see, that VBAK-VDATU is changed if you reenter SAPMV45A.
Therefore you stop at the first line of the called form.
If you use a global Watchpoint then ALL changes are observed and therefore you get the
really interesting change in SAPFV45K.
37
Watchpoint on Table Reference - Demo
38
Watchpoint on Table Reference - Demo
Besides these the system needs to store some administrative information on the internal
table (e.g. the number of rows). This administration is stored in the table header *itab[].
The table reference &itab[] is pointer which points to the memory area, where the table
header is stored. Without knowing this memory area, the runtime environment cannot
execute statements on internal tables (e.g. loops …)
Sometimes the table header or the table reference gets destroyed by some dirty ABAP
statement. We are able to analyze this using Watchpoints!
39
Solution for Demo
40
Solution for Demo
<F> = 'info'.
<F>
After the assign the Field symbol <f> covers the region from c+12(23).
Therefore <f> covers also the region BEHIND the field c! After the field c the internal table
reference starts. A part of this reference is covered by the field symbols (red area).
If you now change the content of the field symbol you will destroy the content of a part of
the table reference. In our example you write ‘info’ from the position 12 in the c-string. The
rest is filled with SPACE (hex20). Therefore the area of the table reference which is
covered by the field symbol will contain the hex value hex20.
Solution: Use a length specification with the ASSIGN statement, so that the compiler will
not use the default length (length of the field c):
41
Exercise 2
carrid =
connid = 0000
fldate = 00.00.0000
42
Solution - ZDEBUGPROBLEM1
43
Debugging in a Production Client
UPDATE line1
UPDATE line2
...
...
UPDATE line3
UPDATE line4
...
Rollback Work
Field 1 Field 2 Field 3 Field 4
If you jump in the debugger during a running transaction (e.g. via SM50) then the debugger
screen pops up. As usual each screen switch is connected with a database commit.
This database commit is executed because after a screen switch you are rolled out and
perhaps rolled in in a totally different work process. Therefore the database must be
consistentwhen leaving a process (DB commit)
If a DB commit is executed then all direct updates are stored on the database.
The CALL FUNCTION IN UPDATE TASK are not executed (They are only launched if the
ABAP statement COMMIT WORK is executed).
Assume we enter the debugger after two direct updates (line1 & line2).
The debugger screen executes a DB-commit.
-> line1 and line 2 are now definitely updated on the database.
Afterwards two additional UPDATES (line3/4) are executed. The following ROLLBACK will
cancel these updates but unfortunately the first two updates are committed and therefore
will remain on the database ->DATA INCONSISTENCY
44
Debugging in a Production Client
Debugge
r
In a debug mode
The lock will be hold until you
exit debugging or you execute a
DB lock is released DB commit / Rollback explicitly.
45
Debugging in a Production Client
Start debugging
Leave debugging
46
Demo: Debugging in a Production Client
DB01
Programsource of ZDEBUG_DB01:...
15 FLDATE = ITAB-FLDATE.
16
17 BREAK-POINT.
If you stop at the breakpoint and you are in a debug mode then you will hold the DB lock on
the specified line of ZDEBARC until you exit debugging or you execute an explicit DB-
COMMIT / Rollback. All other programs which want to update or lock the same line must
wait until you release the lock. This wait situation can be observed via transaction db01.
47
Summary
48
Copyright 2009 SAP AG
All Rights Reserved
No part of this publication may be reproduced or transmitted in any form or for any purpose without the express permission of SAP AG. The information contained herein
may be changed without prior notice.
Some software products marketed by SAP AG and its distributors contain proprietary software components of other software vendors.
Microsoft, Windows, Excel, Outlook, and PowerPoint are registered trademarks of Microsoft Corporation.
IBM, DB2, DB2 Universal Database, System i, System i5, System p, System p5, System x, System z, System z10, System z9, z10, z9, iSeries, pSeries, xSeries, zSeries,
eServer, z/VM, z/OS, i5/OS, S/390, OS/390, OS/400, AS/400, S/390 Parallel Enterprise Server, PowerVM, Power Architecture, POWER6+, POWER6, POWER5+,
POWER5, POWER, OpenPower, PowerPC, BatchPipes, BladeCenter, System Storage, GPFS, HACMP, RETAIN, DB2 Connect, RACF, Redbooks, OS/2, Parallel Sysplex,
MVS/ESA, AIX, Intelligent Miner, WebSphere, Netfinity, Tivoli and Informix are trademarks or registered trademarks of IBM Corporation.
Linux is the registered trademark of Linus Torvalds in the U.S. and other countries.
Adobe, the Adobe logo, Acrobat, PostScript, and Reader are either trademarks or registered trademarks of Adobe Systems Incorporated in the United States and/or other
countries.
Oracle is a registered trademark of Oracle Corporation.
UNIX, X/Open, OSF/1, and Motif are registered trademarks of the Open Group.
Citrix, ICA, Program Neighborhood, MetaFrame, WinFrame, VideoFrame, and MultiWin are trademarks or registered trademarks of Citrix Systems, Inc.
HTML, XML, XHTML and W3C are trademarks or registered trademarks of W3C®, World Wide Web Consortium, Massachusetts Institute of Technology.
Java is a registered trademark of Sun Microsystems, Inc.
JavaScript is a registered trademark of Sun Microsystems, Inc., used under license for technology invented and implemented by Netscape.
SAP, R/3, SAP NetWeaver, Duet, PartnerEdge, ByDesign, SAP Business ByDesign, and other SAP products and services mentioned herein as well as their respective logos
are trademarks or registered trademarks of SAP AG in Germany and other countries.
Business Objects and the Business Objects logo, BusinessObjects, Crystal Reports, Crystal Decisions, Web Intelligence, Xcelsius, and other Business Objects products and
services mentioned herein as well as their respective logos are trademarks or registered trademarks of Business Objects S.A. in the United States and in other countries.
Business Objects is an SAP company.
All other product and service names mentioned are the trademarks of their respective companies. Data contained in this document serves informational purposes only.
National product specifications may vary.
These materials are subject to change without notice. These materials are provided by SAP AG and its affiliated companies ("SAP Group") for informational purposes only,
without representation or warranty of any kind, and SAP Group shall not be liable for errors or omissions with respect to the materials. The only warranties for SAP Group
products and services are those that are set forth in the express warranty statements accompanying such products and services, if any. Nothing herein should be construed
as constituting an additional warrant.
49