ABAP and Debugging For SAP Consultants
ABAP and Debugging For SAP Consultants
Content
Content.......................................................................................................................................................... 2
Introduction .................................................................................................................................................. 3
1. Start debugging from the modal screen with a file .............................................................................. 3
2. Setting up the breakpoint on specific ABAP command ........................................................................ 4
3. Setting up the specific watchpoint ........................................................................................................ 7
4. Error message analysis .......................................................................................................................... 9
5. Using ABAP trace to find the configuration ........................................................................................14
6. Activate debugging under other user .................................................................................................24
7. Changing table records under debugger .............................................................................................26
In conclusion ...............................................................................................................................................29
2
Khazanov Timofey
www.linkedin.com/in/tekhazanov1
ABAP and Debugging for SAP Consultants
Introduction
This booklet includes some tricks, features, and pieces of advice to work with SAP Debugger and
to analyse standard code and legacy Z-code. Most of these points are relevant for SAP ECC as well as for
S/4 HANA. Thereby this brochure may be useful for SAP Consultants involved in implementation a new
SAP system, on roll-out projects, or on development projects.
The problem of point (a) is that the line is locked for typing while modal screen is active, so we are
not able to use it.
There are no doubts that we can set up breakpoints like in items (b) and (c), but the trouble is that
we need to find the place in the program where it is correctly to activate breakpoint. It takes time and in
some cases could be labour-intensive.
The same reason is for (d) item. Moreover, you must have special roles (and developer’s key in some
cases) to change program’s code and start SAAB transaction.
Speaking about point (e) – using SM50 transaction could be helpless in this case due to the absence
necessity of recording in a list of active processes while the modal screen is active. In other words, you
can’t catch your screen in this transaction. Anyway, we discuss this transaction further.
3
Khazanov Timofey
www.linkedin.com/in/tekhazanov1
ABAP and Debugging for SAP Consultants
There is the simple but extraordinary decision for this issue: you can make a .txt file with the
simple code and drag-and-drop it in your GUI window with the modal screen. First of all, start Notepad
on your computer (or any other text redactor), write this code:
[FUNCTION]
Command=/H
Title=Debugger
Type=SystemCommand
Save it in txt-format and drop it on your modal window. As the result the debugging begins:
It is quite easy so I always have the same file in my work direction (Pic. 2).
Pic. 2 Debug.txt
Finally, we have created the breakpoint: . For control this point we are able
to see every breakpoint on the tab “Break./Watchpoints” and subtab “Breakpoints” of main debugger
screen (Pic. 5).
5
Khazanov Timofey
www.linkedin.com/in/tekhazanov1
ABAP and Debugging for SAP Consultants
Now we can press F8-key to go ahead through the program and be sure, that we will stop on
each authority-check operator (Pic. 6). This way we can analyse every authority object is being checked
in our code. To deactivate this breakpoint you should push on the debug icon or delete it on tab
“Break.Watchpoints” with button .
There is a list of some useful ABAP commands which you can use for setting up breakpoints:
AUTHORITY-CHECK;
CALL FUNCTION;
SUBMIT;
CALL METHOD;
SELECT;
CALL BADI;
GET BADI;
PERFORM;
etc.
Debugging tip: if you want to skip some ABAP command without deactivating your breakpoint,
you can put your cursor on the program line, which you need to go, and press the combination SHIFT +
F12 on your keyboard. Resulting, all code between current and previous position of the cursor will be
skipped (Pic. 7).
6
Khazanov Timofey
www.linkedin.com/in/tekhazanov1
ABAP and Debugging for SAP Consultants
First of all for creating the watchpoint we press key “Watchpoint” in debugger
(Pic. 8).
Next screen, that we see, consists of fields for defining data, which we would like to follow. We
are interested in fields “Variable” and “Free Condition Entry”. In the field “Variable” we provide the
7
Khazanov Timofey
www.linkedin.com/in/tekhazanov1
ABAP and Debugging for SAP Consultants
name of the structure, which will be used for looping our inner table – IT_REPORT, in the field “Free
Condition Entry” we maintain the condition for triggering the watchpoint IT_REPORT-FIPEX = ‘2.1.8.4’
Debugging tip: it is important to define the condition of triggering in way accordingly field’s type
of data. If it is CHAR or STRING or etc., you should put it in quotes. If it is DATS or NUMS or INT or etc.,
you have to maintain it without quotes.
After the creating of watchpoint we are able to see every breakpoint on the tab
“Break.Watchpoints” and subtab “Watchpoints” of main debugger screen (Pic. 10). Next we could run
the program with F8-key and wait the trigger event.
8
Khazanov Timofey
www.linkedin.com/in/tekhazanov1
ABAP and Debugging for SAP Consultants
Finally, our program stops at the moment, when IT_REPORT-FIPEX becomes 2.1.8.4 (Pic. 11). We
can see that there are 400 lines in the inner table IT_REPORT, as well as we see that SY-TABIX equals
376. In fact, we skipped 375 recording in this cycle and stopped only when the entry we need has been
beginning processed. There are no doubts, that watchpoint is useful tool, which can help consultants in
“solver problem” process.
Double click on this error opens for us details of this message (Pic. 13). These details will help us
in the further analysis. On this screen we need information about message class – RE, and about
message number – 052.
9
Khazanov Timofey
www.linkedin.com/in/tekhazanov1
ABAP and Debugging for SAP Consultants
It is correct to start error analysis from the transaction SE91. There at first we enter message
Pic. 14 SE91
10
Khazanov Timofey
www.linkedin.com/in/tekhazanov1
ABAP and Debugging for SAP Consultants
On the next screen we mark the line with need message and push on the button (Pic. 15).
After that we choose the objects which we would like to analyse: programs, classes, web dynpro
components (Pic. 16). This action could show us all places where this message is used.
In easy case these actions are enough to figure out with the message: we see the place in the
code where this message is called and analyse code or add the breakpoint before this call and debug it.
Nevertheless, there could be a few problems in little bit more difficult cases:
a) The error may be triggered implicitly; due to this fact the list of “where-used” places
may be empty.
b) There could be too many places of calling, so it may be hard to analyse each of them as
well as it could be problematically to add breakpoints on every call.
11
Khazanov Timofey
www.linkedin.com/in/tekhazanov1
ABAP and Debugging for SAP Consultants
We see four hits of calling our message (Pic. 17) and we will not check each place manually, so
we are going to debugger.
So we go to the transaction FMZ2, write the number of fund blocking document, start the
debugger by /h command and press Enter; after that the debugger begins (Pic. 18).
Next press the button “stop” for creating breakpoint window open. Here we have to go to
the tab “Message” (Pic. 19).
12
Khazanov Timofey
www.linkedin.com/in/tekhazanov1
ABAP and Debugging for SAP Consultants
On the next step we enter the message class on the “ID” field and number of message on the
“Number” field (Pic. 20). Field for message type is not necessary for entry. Press for finish. The
result is: .
For control this point we are able to see every breakpoint on the tab “Break./Watchpoints” and
subtab “Breakpoints” of main debugger screen (Pic. 21).
13
Khazanov Timofey
www.linkedin.com/in/tekhazanov1
ABAP and Debugging for SAP Consultants
Next step is the run of the program by the F8-key and we stop on the message calling operator
(Pic. 22). This is the place, where our error appears. Here we can see a cause of this error: I_BLTYP is not
equal to E_KBLK-BLTYP (I_BLTYP EQ 050 and E_KBLK-BLTYP EQ 020).
This case illustrates how quickly we can use the debugger for analysis causes of
error/warnings/informational messages.
14
Khazanov Timofey
www.linkedin.com/in/tekhazanov1
ABAP and Debugging for SAP Consultants
On the “Current mode” screen we feel fields “Comment” and “Transaction” (Pic. 24). In the field
“Transaction” we enter the tr.code, which we would like to trace – in our case it is FMZ3 transaction
(actually, FMZ2 could be better, but in this case it is not in principle important). After that we push
“Execute / start trace”.
15
Khazanov Timofey
www.linkedin.com/in/tekhazanov1
ABAP and Debugging for SAP Consultants
On the next step we see the first screen of the transaction and here we enter the number of
funds commitment document (Pic. 25). Press enter after that.
After the transaction leaving we are able to see our tracing record at the list of tracings (Pic. 27).
For more suitable using press the key “Full screen”.
Now the full list of our operations opens. All called commands are showing on this screen (Pic.
29). We have to mark the first column with the list of calls and push the button to make a filter by
command *select* (Pic. 30). These actions will help us to find the table where necessary configurations
were selected from.
18
Khazanov Timofey
www.linkedin.com/in/tekhazanov1
ABAP and Debugging for SAP Consultants
Now we are able to see all selections from tables which were used in a traced program, one of
them must be required, so we can start an analysis. For saving our time in current case it is TREF table (),
with double click we can drilldown in the program code where this select requested.
Here we can put the breakpoint for follow-up analysis terms of selection (Pic. 32) and after that
recall the transaction (FMZ3).
Pic. 32 FMR1_GET_DOCUMENT_FIELDSTATUS
19
Khazanov Timofey
www.linkedin.com/in/tekhazanov1
ABAP and Debugging for SAP Consultants
After FMZ3 recalling we stop at this selection place and we could see that L_FAUNARE = SL04
(Pic. 33), so now we can try to find this configuring in the SPRO IMG.
Pic. 33 L_FAUNARE
First of all we follow to transaction SM30 for working with views. Here we will use the name of
table which we found earlier.
Debugging tip: although SM30 transaction could be used only for working with views, we can provide a
name of a table and find the corresponding for this table view from here. For this option we need press
key (Pic. 34) and enter the table name in pop-up window (Pic. 35), after that
choose the necessary object (Pic. 36).
20
Khazanov Timofey
www.linkedin.com/in/tekhazanov1
ABAP and Debugging for SAP Consultants
After choosing the object we can see that it is not a simple view but a view cluster (Pic. 37).
Nevertheless, it is not important for us, so press on key .
21
Khazanov Timofey
www.linkedin.com/in/tekhazanov1
ABAP and Debugging for SAP Consultants
Next window offers us to choose the project (Pic. 38), but it is not relevant for our case, so we
press button .
Next we are finally able to see all places in IMG activities where this view cluster is used (Pic.
39). We choose “Funds Management Government” in this case.
This action redirects us in SPRO transaction in actual branch for configure (Pic. 40). Next we start
“Define Field Selection String”.
Finally, we are able to see the configuring of field status at the funds commitment document in
FMZ1/FMZ2/FMZ3 transactions (Pic. 42).
Now we could see only active work processes – currently working programs (Pic. 44). On this
example one program is launched under the test user account TEST00005531. We mark this row and go
to the drop down menu: “Administration” “Program” “Debugging”.
24
Khazanov Timofey
www.linkedin.com/in/tekhazanov1
ABAP and Debugging for SAP Consultants
This action throws us in the debugger (Pic. 45).
For checking that it is really works under the test user account we enter the variable SY-UNAME
and see that it is TEST00005531, however at the right low corner of the screen we could see that SAP
session is running under TEKHAZANOV1 (Pic. 46).
25
Khazanov Timofey
www.linkedin.com/in/tekhazanov1
ABAP and Debugging for SAP Consultants
Debugging tip: this way of changing data is high risky for data consistency. Thus, it should be used only
by experienced consultants. Moreover, this method is not recommended for production systems, only
for dev, test and QA, even if you have corresponding powers on prod (you must have the authority
power for changing under the debugger).
Imagine that we have to change some data in the header of FI-document, but we do not have an
opportunity to make it with FB02 transaction or other. First of all we run the SE16N transaction, provide
the name of the table and press enter. After that we can enter the selection criteria on selection screen:
document number, company code and year of document (Pic. 47).
26
Khazanov Timofey
www.linkedin.com/in/tekhazanov1
ABAP and Debugging for SAP Consultants
If we run the report right now with F8-key, we see that all fields are not available for enter and
there are no buttons for changing data.
So we return to the selection screen, enter /h in the command row for start the debugger and
run the report again. Next we should change follow variables with key : GD-EDIT and GD-SAPEDIT
(Pic. 49).
27
Khazanov Timofey
www.linkedin.com/in/tekhazanov1
ABAP and Debugging for SAP Consultants
Next we run the report by F8. Now we see that all fields are opened for changing. Moreover,
there activated buttons for creating, deleting and copying data (Pic. 51).
28
Khazanov Timofey
www.linkedin.com/in/tekhazanov1
ABAP and Debugging for SAP Consultants
In conclusion
Thank you for your attention, I hope this brochure is useful for you and you enjoy it.
I would appreciate you connecting with me on LinkedIn. Additionally, I am open to receive any
business proposals. Please connect with me by means of one the options below:
Telegram @tekhazanov1
Tel./WA +79153285391
LinkedIn www.linkedin.com/in/tekhazanov1
Sincerely yours,
Timofey Khazanov
29
Khazanov Timofey
www.linkedin.com/in/tekhazanov1