Quantcast
Channel: SCN : Blog List - ABAP Development
Viewing all articles
Browse latest Browse all 943

Six kinds of debugging tips to find the source code where the message is raised

$
0
0

I would like to share with you my debugging tip in my daily life, which makes my life much eaiser. In case you found your own tip are not listed here, please kindly comment it so that it could benefit more people here

 

I will use a simple example to demonstrate. Input an invalid name in SE38 and click display button. An message is displayed in the bottom. I will show you how to find the exact line of code which raises this information.

 

clipboard1.png

 

note: some of the approaches listed here might not be efficient for this very case, I just list all of my tips here for completeness. I do believe each tip could be useful in certain case.

 

approach1:

 

click on the green icon and we can find message class ID: DS, number 017

 

clipboard2.png

 

SE91, use where use list:

 

clipboard3.png

 

OOPS, so many hits...

 

clipboard5.png

 

Then I have to manually fitler them one by one to find the correct one. Double click one by one. I ignore all entries with type MESSAGE E since in my case the message type is not E, but S. After one minute I confirm the following one is the one I try to find.

 

clipboard6.png

 

yes it is confirmed by debugging:

 

clipboard7.png

Summary: the drawback of A1 is that as you see, if there are many where used list results say a hundred, it still takes you some time to manually find the correct one.

 

Approach2:

 

type /h in command area, and click display button to trigger debugger.

 

clipboard8.png

Create a watch point with below two conditions. After that click F8, the debugger will stop automatically at the correct line you want. This approach just took me 20 seconds to finish the job.

 

clipboard9.png

 

Approach3:

 

Launch the debugger just the same as A2, create a dynamic breakpoint with ABAO command = MESSAGE. The debugger will again stops at the correct line.

With this approach again I only spent 20 seconds.

 

clipboard10.png

 

Summary: if the scenario you want to debug is quite complex, for example deep callstack with several components involved, the debugger might stops at the ABAP code with MESSAGE keyword frequently. You must still manually check whether the code is just the one you are looking for at each stop. However it is still much more efficient than you debug manually one by one.

 

Approach4:

 

Tcode SE93, find the package name of SE38:

 

clipboard11.png

Then use report RS_ABAP_SOURCE_SCAN and maintain the search criteria below. The reason why I do not use program name RSABAPPROGRAM is that it is just a wrapper report. The actual implementation of SE38 is not put within it.

 

clipboard12.png

We only have 4 results.

 

clipboard13.png

You can use an alternative tcode CODE_SCANNER which can achieve the same result:

 

clipboard14.png

clipboard15.png

From my point of view, I do like this A4. I can not remember how many times it has helped with my debugging life. What's more, it would be used not only as a debugging tip, but also one way of studying other people's code. Suppose you are curious of how a certain function is implemented by a software component, it is a good starting point to think of a meaningful search keyword and specify the package of that software component and go deep into the result code.

 

Approach5:

 

tcode SAT, create a new variant, ensure the radio box item "Aggregation - None" is selected.

 

clipboard16.png

 

Then launch the SE38 within SAT by clicking "Execute" button.

 

clipboard17.png

 

repeat your steps as usual - input an non-exist report and click display button to see the message. After that click back or quit button in SE38. SAT will automatically be opened to show you all runtime trace information. It will take some time - you can see the progress information in the bottom:

clipboard18.png

click tab "Call Hierarchy", click find button. Input Statement = MESSAGE and go. You will see two search results.

clipboard19.png

double click on the hit list row and then you can see the source code.

 

Summary: if the scenario you are tracing with SAT is complex, you will get a huge trace file.  Although you can specify an extremely big size in trace file, according to my real experience, you will fail to open the result trace file when it exceeds 1 G, at least in my application server. 

 

clipboard20.png

Approach6:

 

First you open SE38, type and invalid program name.

Open a second session, switch on your ST05 with default settings.

Go back to your SE38 window, click display button.

Go back to your ST05 trace, deactivate and display trace result:

 

We know that the PROGDIR table stores the header information of report. It makes sences for ABAP editor to check whether the program name is valid by search it in that table, doesn't it? So the undoubted next step would be the raise of a message if database search fails. Click the "Display ABAP call location" button to go to the source code:

 

clipboard21.png

We see the logic is that first try to search in DB with inactive version, if failed, try with active version.

 

clipboard22.png

So hopefully the code we are trying to find is just in the very neighborhood of the SQL statement in line 774 and 779. Fortunately in this case, yes it is in line 813.

 

clipboard23.png

 

Summary:

 

In my previous work I used to struggle with some tricky case where I don't know how to start my debugging at all. The A6 I call it "ST05 weapon" do prevent me from working over late into the night. Even for the most sophisticated application, I can switch on ST05, repeat the application again, and analyze the trace result to judge which line is useful to start debugging. So I like this overwhelming tool. You may say that it would not help if there is completely no database access for the application to be debugged. Well I would say that would be a rare case at least in my own working area.

 

Do you have additional tips not included in this article? Please kindly share with us


Viewing all articles
Browse latest Browse all 943

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>