0% found this document useful (0 votes)
139 views29 pages

ABAP and Debugging For SAP Consultants

Uploaded by

shamshu zaman
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
139 views29 pages

ABAP and Debugging For SAP Consultants

Uploaded by

shamshu zaman
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 29

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.

1. Start debugging from the modal screen with a file


It is an ordinary situation when you need to start debugging from the dialog window such as on
the Pic. 1 – after activation a command from this window.

Pic. 1 Modal screen

Most common ways for activation the debug regime:

a) Type /h on the command line at the top of the SAP screen;


b) Set a breakpoint at the current program before you run it;
c) Set an external breakpoint for a user;
d) Write BREAK or BREAK-POINT ID commands in the program code;
e) Use SM50 transaction.

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

2. Setting up the breakpoint on specific ABAP command


Sometimes we need stop on some specific ABAP-operator in an executable program. For
instance let’s figure it out with case when we need to debug every authority check in our program. First
of all start your program and activate the debugger, next press the button “stop” (Pic. 3).

Pic. 3 Setting up the breakpoint


4
Khazanov Timofey
www.linkedin.com/in/tekhazanov1
ABAP and Debugging for SAP Consultants
Next screen which you will see consist of a list of tabs. In this case we are working with “ABAP
Cmnds” tab (Pic. 4), we have to add ABAP operator in the field “ABAP Cmnds”. Due to our task of
debugging all authority checks in this report, we add the operator ‘AUTHORITY-CHECK’ and press
key.

Pic. 4 Addition an ABAP command

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).

Pic. 5 All breakpoints

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 .

Pic. 6 Authority objects

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

Pic. 7 SHIFT + F12

3. Setting up the specific watchpoint


Sometime we have to work with huge inner tables for hundreds and thousands recordings in it
and there are some cases, when we need to analyse changing the specific data in these tables while it
are being processed in a loop. For example we have a Z-report ZFM_BDPS_USE and here is an inner
table IT_REPORT. In include ZFM_BDPS_USE_F01 is the loop by this inner table and modifying data in it.
There are a lot of recordings (~400 in our case), but we would like to analyse the modifying specifically
lines only with the commitment item equal 2.1.8.4 (IT_REPORT-FIPEX = ‘2.1.8.4’). Browse every line in
this cycle is extremely labour-intensive, so we activate a watchpoint. It must stop us when the variable
IT_REPORT-FIPEX becomes equal 2.1.8.4.

First of all for creating the watchpoint we press key “Watchpoint” in debugger
(Pic. 8).

Pic. 8 Watchpoint key

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’

(Pic. 9). After creating we see information about it .

Pic. 9 Create Watchpoint

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.

Pic. 10 All watchpoints

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.

Pic. 11 Watchpoint triggering

4. Error message analysis


Error message analysis is a part of daily routine for most SAP Consultants. In this paragraph we
figure out how it could be done easily with debugger help. Let’s find some error for the example. For
instance, let’s try to open for changing document of fund blocking in the transaction for changing funds
commitment documents – FMZ2. We start FMZ2, provide the number of fund blocking document and
press Enter for message error (Pic. 12).

Pic. 12 Error message

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

Pic. 13 Message details

It is correct to start error analysis from the transaction SE91. There at first we enter message

class and message number (Pic. 14), after that click on .

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).

Pic. 15 Message Maintenance

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.

Pic. 16 Where-Used List Message

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.

Pic. 17 List of Where-used places

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).

Pic. 18 Debugger begins

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

Pic. 19 Create Breakpoints window

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: .

Pic. 20 Message tab

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

Pic. 21 All breakpoints

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).

Pic. 22 Call message

This case illustrates how quickly we can use the debugger for analysis causes of
error/warnings/informational messages.

5. Using ABAP trace to find the configuration


Configuring a system is the daily routine most SAP Consultants. Nevertheless there could be a
situation when you need to set up something, but you don’t know where this configuration is. In this
case there is the way to try to find the configuring via ABAP trace. For instance, we would like to set the
field status at the funds commitment document in FMZ1/FMZ2/FMZ3 transactions: make some fields
hide, visible, optional to entry or required to entry. So at first we start the transaction ST12 (Pic. 23).
Here we go to the tab “Current mode” by the button with the same name.

14
Khazanov Timofey
www.linkedin.com/in/tekhazanov1
ABAP and Debugging for SAP Consultants

Pic. 23 ST12 main screen

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

Pic. 24 Current mode

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.

Pic. 25 FMZ3 main screen


16
Khazanov Timofey
www.linkedin.com/in/tekhazanov1
ABAP and Debugging for SAP Consultants
So we are on the next screen of this transaction, now we are ready to leave it and start analyse
the trace (Pic. 26). As we suppose, all configuring data has already collected in the trace log.

Pic. 26 FMZ3 second screen

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”.

Pic. 27 Record of tracing


17
Khazanov Timofey
www.linkedin.com/in/tekhazanov1
ABAP and Debugging for SAP Consultants
Here we see the range of tracing recordings and there is our recording on the top of this list (Pic.
28). We should double click on this for open the trace.

Pic. 28 Trace analyses fullscreen list

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.

Pic. 29 ABAP Trace Per Call

Pic. 30 Setting up the filter

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.

Pic. 31 TREF table

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).

Pic. 34 Finding a view for a table

20
Khazanov Timofey
www.linkedin.com/in/tekhazanov1
ABAP and Debugging for SAP Consultants

Pic. 35 View for Customizing Object

Pic. 36 Choosing a Customizing Object

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 .

Pic. 37 View cluster maintenance

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 .

Pic. 38 Choosing the project

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.

Pic. 39 IMG activities overview

This action redirects us in SPRO transaction in actual branch for configure (Pic. 40). Next we start
“Define Field Selection String”.

Pic. 40 SPRO IMG


22
Khazanov Timofey
www.linkedin.com/in/tekhazanov1
ABAP and Debugging for SAP Consultants
As we determined earlier while debugging: current selection string is SL04 in our situation, so we
choose this one in the range, mark it and double click on “Maintain Field Status” (Pic. 41).

Pic. 41 Field selection

Finally, we are able to see the configuring of field status at the funds commitment document in
FMZ1/FMZ2/FMZ3 transactions (Pic. 42).

Pic. 42 Maintain Field Status


23
Khazanov Timofey
www.linkedin.com/in/tekhazanov1
ABAP and Debugging for SAP Consultants

6. Activate debugging under other user


Sometimes there could be non-common situations when you need to debug some program
under an account of some other user (it could be technical account, test account, end user account and
etc.). There are few ways to do it, we will use SM50 transaction. The main screen of this transaction is
ALV-grid with the list of processes (Pic. 43), we press the “Active Work Processes Only” for filter this
array.

Pic. 43 SM50 main screen

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”.

Pic. 44 Active work processes

24
Khazanov Timofey
www.linkedin.com/in/tekhazanov1
ABAP and Debugging for SAP Consultants
This action throws us in the debugger (Pic. 45).

Pic. 45 Debugger under other user

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

Pic. 46 Checking user account

7. Changing table records under debugger


Sometimes there could be situations when some records in tables must be changed without
using programs and views. It could be necessary for testing or for correcting some data after incorrect
program working, anyway it can be realized with the debugger.

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

Pic. 47 SE16N selection screen

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.

Pic. 48 Display of Entries

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

Pic. 49 SE16N debugger

In these variables we put down X (Pic. 50).

Pic. 50 Variables changing

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).

Pic. 51 SE16N changing entries

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

You might also like