Skip to Content
Author's profile photo Jerry Wang

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

I would like to share with you my debugging tip in my daily life, which makes my life much easier. 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.

/wp-content/uploads/2013/11/clipboard1_324288.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 – Use “Where Used List” function in ABAP workbench

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

/wp-content/uploads/2013/11/clipboard2_324289.png

SE91, use where use list:

/wp-content/uploads/2013/11/clipboard3_324317.png

OOPS, so many hits…

/wp-content/uploads/2013/11/clipboard5_324318.png

Then I have to manually filter 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.

/wp-content/uploads/2013/11/clipboard6_324319.png

yes it is confirmed by debugging:

/wp-content/uploads/2013/11/clipboard7_324320.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 – Use Watch-point to observe sy-msgid in ABAP debugger

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

/wp-content/uploads/2013/11/clipboard8_324321.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.

/wp-content/uploads/2013/11/clipboard9_324326.png

For detailed screenshot about how to create a watch point in Debugger, see picture provided by Jim Tasker:

/wp-content/uploads/2013/11/watchpoing_371869.jpg

How to switch into debugging mode for a modal( pop up ) window

Since the command line is not available if there is a modal( pop up window) involved, in this case please refer to SAP Note 118184 about how to switch into debugging mode or refer to this wiki.

Approach3 – Leverage the breakpoint type “ABAP Commands” to debug more efficiently

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

With this approach again I only spent 20 seconds.

/wp-content/uploads/2013/11/clipboard10_324327.png

Or you can use menu via Breakpoints->Breakpoint at->Breakpoint at messages to achieve the same result.

/wp-content/uploads/2013/11/another_334844.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 – source code scan

Tcode SE93, find the package name of SE38:

/wp-content/uploads/2013/11/clipboard11_324328.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.

/wp-content/uploads/2013/11/clipboard12_324335.png

We only have 4 results.

/wp-content/uploads/2013/11/clipboard13_324336.png

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

/wp-content/uploads/2013/11/clipboard14_324337.png

/wp-content/uploads/2013/11/clipboard15_324341.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 – ABAP Runtime Analysis Tool SAT shows its power

tcode SAT, create a new variant, ensure the radio box item “Aggregation – None” is selected.

/wp-content/uploads/2013/11/clipboard16_324342.png

Then launch the SE38 within SAT by clicking “Execute” button.

/wp-content/uploads/2013/11/clipboard17_324343.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:

/wp-content/uploads/2013/11/clipboard18_324347.png

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

/wp-content/uploads/2013/11/clipboard19_324348.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.

/wp-content/uploads/2013/11/clipboard20_324349.png

Approach6 – Have you used ST05 like this way

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

/wp-content/uploads/2013/11/clipboard21_324353.png

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

/wp-content/uploads/2013/11/clipboard22_324354.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.

/wp-content/uploads/2013/11/clipboard23_324355.png

Deal with those messages raised in ABAP webdynpro / CRM Webclient UI

If the message is not raised in SAP GUI but from ABAP webdynpro or CRM webclient UI, all of these six approaches still work.

This blog is focusing on how to efficiently locate the source code where the message is raised in CRM Webclient UI environment.

Use SAT to trace web application

The approach 5 has made good use of powerful tool SAT. Please keep in mind that SAT could not only trace the transactions running in SAP GUI but also work for Web application. For more detail please read this nice document Measure Performance and Analyze a Web UI Transaction using SE30 from Bhushan Dharmik.

Other Blogs / Wikis in SCN which could make your debugging more efficient

These blogs / wikis do not talk about the dedicated solution to find message raising location, but contain generic tips which would accelerate your debugging and make your life easier.

Troubleshooting an unfamiliar ABAP issue by Noel Connolly

Three ways to achieve conditional break point in your ABAP programAsked by my colleagues, so I write it 🙂

How to leverage breakpoint with Exception type – A real example

This tip has actually the similar logic as Approach3, the only difference is another type of ABAP breakpoint is used.

How to efficiently debug in ERP and CRM application

When I am a beginner  in CRM and have to debug CRM business transaction application to resolve ticket reported, I felt really frustrated since although I have used ALL OF THE SIX approaches I described here, still the breakpoint could not be triggered 🙁 Finally I realized that just works as designed. I share you with my tips gained through painful debugging in that area and hope they are helpful.

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 🙂

Assigned tags

      55 Comments
      You must be Logged on to comment or reply to a post.
      Author's profile photo nabheet madan
      nabheet madan

      Hi Jerry

      Thanks for sharing.  For your first point where you have put in a message statement you can also put directly the message number and then it will stop exactly at the same place.

      You can follow the path break point->Break point at--> Choose message and provide messag number etc.

      Nabheet

      Author's profile photo Jerry Wang
      Jerry Wang
      Blog Post Author

      Hi Nabheet,

      I didn't know that tip until you tell me today. Thank you very much!

      Best regards,

      Jerry

      Author's profile photo Former Member
      Former Member

      Like the Knowledge flowing here.. Lot of Debugging Tips 😀

      Author's profile photo Jelena Perfiljeva
      Jelena Perfiljeva

      Thank you for sharing, good tips.

      Just a suggestion - this is a long blog and might benefit from some formatting to separate/highlight the sections. I find Jason Lax's documents (e.g. Everything I know about... Inserting Links and Table of Contents ) very helpful in this area.

      Author's profile photo Jerry Wang
      Jerry Wang
      Blog Post Author

      Hello Jelena,

      sorry for late response, I have read the document in your link, it is really helpful! I have formatted the blog. Is it better now?

      Best regards,

      Jerry

      Author's profile photo Noel Connolly
      Noel Connolly

      When I am completely unfamiliar with the code, I like to set a breakpoint at function module  SAPGUI_PROGRESS_INDICATOR and to work from there. This would probably be more relevant when you are trying to catch code that does not raise a message (but I think it is still relevant to this discussion). It is explained here: http://wiki.scn.sap.com/wiki/display/ABAP/Troubleshooting+an+unfamiliar+ABAP+issue

      Author's profile photo Jerry Wang
      Jerry Wang
      Blog Post Author

      Hi Noel,

      Thank you very much for your comment. I read your wiki, it is really helpful. I have added the link to this blog and mark you as the author. Thank you for your kind suggestion.

      Best regards,

      Jerry

      Author's profile photo Former Member
      Former Member

      Several ERP applications (esp. Financials) often use a "message collector" technique especially when handling "multiple objects", where after the application ist "detecting" an error it will be "stored" to an "error collection" and after all checks have been done the list of maybe many erros is shown in a popup or list.

      In these cases, when the message is "shown" is far to late to analyze, because the application data/situation which is causing the error is analyzed somewhere else (far earlier in the runtime). In these cases I often use breakpoints in FM "MESSAGE_STORE".

      Similar handling is needed in case the BC Application Log-technique is used (SLG0, SLG1 etc.) a breakpoint in FM BAL_LOG_MSG_ADD can help.

      When searching for the message occurence in the source with code scanners you should not only look for "MESSAGE Xnnn WITH" ... occurences but also for "MESSAGE TYPE X ID XYZ NUMBER nnn" strings. (which is rather difficult 🙁 )

      Author's profile photo Jerry Wang
      Jerry Wang
      Blog Post Author

      Hi Fabian,

      Thank you very much for your suggestion. The message handling logic described by you in ERP sometimes took more time and effort for developers to debug indeed. I think the tip suggested by you is worth a separate blog. I have created one using CRM service contract as example. I have added it to part "Other Blogs / Wikis in SCN which could make your debugging more efficient". Thank you. 

      Best regards,

      Jerry

      Author's profile photo Andriy V. Bazdyrev
      Andriy V. Bazdyrev

      Jerry, thanks for a good compilation of debugging tips.

      Just wanted to add more tips to your A2 and A3 approaches.

      Sometimes it's not possible to give a "/H" debug command, because the window is modal (i.e. screen for entering serial numbers in transaction VL02N for outbound deliveries) and neither the command window nor system menu are immediately available. In this case one can create SAPGUI shortcut for activating debugger from popup window and use drag-n-drop to initiate it. Official recommendations from SAP on this approach is given in note 118184

      BR, Andriy

      Author's profile photo Former Member
      Former Member

      Great hint with SAP Note 118184!

      I was looking for a functionality like that, but always assumed, it just was not possible.Kudos to you, sir!

      Author's profile photo Jerry Wang
      Jerry Wang
      Blog Post Author

      Hello Andriy V.

      Actually I am using the tip in SAP note 118184 frequently during my daily work, but still thank you very much to mention it, I have already added it as one part of Alternative 2. Thank you for your kind suggestion and comment on this blog.

      Best regards,

      Jerry

      Author's profile photo Adi Sieker
      Adi Sieker

      If you are confronted with new style class based exception for error handling, then a good trick is placing a session break point in the constructor of CX_ROOT the abstract superclass for all global exceptions.

      Author's profile photo Jerry Wang
      Jerry Wang
      Blog Post Author

      Hi Adi,

      Thank you very much for reading the blog with your kind suggestion. I have added your tip into the blog.

      Best regards,

      Jerry

      Author's profile photo Former Member
      Former Member

      Thanks Jerry, nice blog.

      Here's my personal favorite: activate the debugger and create a watchpoint on SY-MSGNO.  Enter a "Free condition" on the watchpoint of "= 'nnn'" where 'nnn' is the message number.  As long as the message is issued via the MESSAGE statement this will stop at exactly the right spot.

      /wp-content/uploads/2014/01/watchpoing_371869.jpg

      Author's profile photo Jerry Wang
      Jerry Wang
      Blog Post Author

      Hi Jim,

      Thank you for your screenshot. I just added it to Approach2, so that it can help more SCNers which are not familiar with it yet.

      Best regards,

      Jerry

      Author's profile photo Siow Fong Chen
      Siow Fong Chen

      Thanks Jerry for the wonderful blog. Certainly look forward to you sharing more debugging tips on debugging web based system like the CRM UI. It is definitely not the easiest system to debug!

      Author's profile photo Former Member
      Former Member

      A helpful blog.

      It's worth noting, especially for those new to SAP, that approaches 2,3, and 6 have the benefit of finding messages that are issued dynamically, which you can't find with a where-used list. I'll generally start with the specifc message, and widen the search to any message statement if I still get no result.

      Author's profile photo Former Member
      Former Member

      Very informative blog..

      Author's profile photo Former Member
      Former Member

      Very Helpful Blog...... Nice One !!

      Author's profile photo Former Member
      Former Member

      SWEET!!!  Thanks  for sharing Jerry

      Author's profile photo Former Member
      Former Member

      Thankyou Jerry , Loved it

      Author's profile photo Former Member
      Former Member

      Thank you for sharing jerry ,good topics 🙂

      Author's profile photo Former Member
      Former Member

      Hello Jerry,

      Thank you very much for a nice document, these tips would help more for  functional people.

      Thanks,

      VNR

      Author's profile photo Former Member
      Former Member

      It is very helpfull

      Author's profile photo Former Member
      Former Member

      very useful.. thanks for sharing

      Author's profile photo Roopa M
      Roopa M

      Thanks for the information.

      helpful.

      Author's profile photo Always Learner
      Always Learner

      It is very helpful.

      Author's profile photo Former Member
      Former Member

      A good time-saver debugging tips.

      Author's profile photo solen dogan
      solen dogan

      Its a nice blog. Good work

      Theres also

      Ewk1 as well

      Author's profile photo Former Member
      Former Member

      An excellent guide for on-going programmers and consultants (who should be able to debug as well)!

      Author's profile photo Former Member
      Former Member

      nice blog.

      best regards

      Author's profile photo Former Member
      Former Member

      Interesting the ST05 for this.

      Author's profile photo Suman Chakravarthy K
      Suman Chakravarthy K

      Excellent tips 🙂 Will be handy !!

      Author's profile photo Former Member
      Former Member

      Thank you!!

      by taking the example of finding the message where it's raised, you have helped me to enhance my debugging skills as a programmer.

      Author's profile photo abhijeet sharma
      abhijeet sharma

      Nice And really helpful for budding abapers lyk myself. 🙂

      Author's profile photo Former Member
      Former Member

      Some tips for web dynpro users.

      Set breakpoint in

      WDA (web dynpro abap): CL_WDR_MESSAGE_MANAGER -> REPORT_MESSAGE

      FPM (floorplan manager): CL_FPM_MESSAGE_MANAGER -> IS_POPUP_OPEN

      Author's profile photo Crystal Chen
      Crystal Chen

      vey helpful!

      Author's profile photo Sneha Jadhav
      Sneha Jadhav

      These tips will help new ABAPer's alot. Thanks for sharing

      Author's profile photo Pradeep Mani
      Pradeep Mani

      Hi,

      First of all i should thank you for presenting this.

      I am a functional consultant,your post was helpful for me.

      My error message was F5351.

      I used the were used list,got few programs listed

      The program concerned is LFACSU10.

      FORM lock_check USING i_bukrs    LIKE t001-bukrs

                             i_account  LIKE skb1-saknr

                             i_sperr

                             i_sperr_b.

      *

         CHECK NOT i_sperr   IS INITIAL

         OR    NOT i_sperr_b IS INITIAL.

         MESSAGE e351 WITH i_account i_bukrs

                      RAISING account_locked.

      My message type is "5",my error was with "Message e351".

      How can i come to a conclusion at this stage.

      Author's profile photo Former Member
      Former Member

      Hi,

      When you have the messagge class and the number (in your case messagge class F5 and messagge number 351) the fastest way is to create a breakpoint like this :

      /wp-content/uploads/2015/04/debug_681984.jpg

      If you also know if it is an error messagge you can type E in the field Ty.

      In your case , in the messagge statement, the ID of the messagge is not given because it is declared in the top include of your function group.

      id.PNG

      Hope it helps.

      Author's profile photo Former Member
      Former Member

      Thanks For sharing 🙂

      Author's profile photo Former Member
      Former Member

      Interesting. thanks for share.

      Good material.

      Thanks.

      Author's profile photo Mark Suarez
      Mark Suarez

      Hi Jerry,

      I am a WM functional consultant and I am not familiar in any abap transactions. I'm having an issue on my replenishment for fixed bins in tcode LP21. Configuartion on IMG are all okay, but still this error always occur on batch managed articles.

      Capture.JPG

      Below is the error description but I believe all config regarding batch management are already set.

      Capture2.JPG

      Now, I want know how this error 999 is taken and under what circumstances.

      Hope you can help.

      Thanks in advance.

      Mark

      Author's profile photo Jerry Wang
      Jerry Wang
      Blog Post Author

      Hi Mark,

      It is really difficult to locate the exact position of line where the error message is raised without debugging.

      Best regards,

      Jerry

      Author's profile photo Mark Suarez
      Mark Suarez

      Thank you.

      Author's profile photo Shailesh Deshmukh
      Shailesh Deshmukh

      Really Nice sharing ..!!

      This will help ABAP consultants to debug the code/program smartly 😎

      Thanks.

      Author's profile photo vigneshwar reddy
      vigneshwar reddy

      thanks for sharing..

      Good one.

      Author's profile photo Leonard Tan
      Leonard Tan

      Thanks a lot for the blog and thanks for those that have contributed through your comments!

      Author's profile photo Smriti Gupta
      Smriti Gupta

      Hello Jerry,

       

      Thanks for such an informative Blog on debugging and specially your effort to make it complete by including all the helpful contributions from the comments and various links

      Thanks to all those also who have added their inputs here. 

       

      Could you also pls suggest some blog on Abap Test Cockpit / Code Inspector and other means of tracing  errors in Abap.

      Best Regards

      Smriti

      Author's profile photo Jörg Knaus
      Jörg Knaus

      Hi Jerry

      cool there are a lot of tricks which I can use for Debugging.

      To find the message I like this feature of S/4HANA. If i look at the Note it looks like you can also downport it to older releases:

      Note 2566819 - Source code navigation to source of ABAP message and where-used list via F1 help

      now you see here the ABAP Program and Code Line, you can double click it to jump directly into the source code!!

      Author's profile photo Meng Yuxin
      Meng Yuxin

      would you like to post that how to debug the background job?

      Author's profile photo Tamás Holics
      Tamás Holics

      There is another way by simply installing an SAP add-on, which allows you to attach all the message details (including source code position) to tickets in external ITSM platforms or directly to SAP Solution Manager tickets.

      You can see how this works here: https://youtu.be/LoJWXunN6ok

      Cheers,
      Tamás

      Author's profile photo Narasimha reddy Tavanam
      Narasimha reddy Tavanam

      Thank you for the post, informative.

      Author's profile photo Muhammad Hasan Mufid
      Muhammad Hasan Mufid

      Thanks for Sharing Mr. Jerry, Very informatif

       

      Regards,

      Muhammad Hasan Mufid