SAP Network Blog - New ABAP Debugger - Tips and Tricks
SAP Network Blog - New ABAP Debugger - Tips and Tricks
http://weblogs.sdn.sap.com/pub/wlg/21986
Blogs
The New ABAP Debugger was first released by SAP with NetWeaver04. As of release NetWeaver 7.0 it fully replaces in the scope of its functionality the "old-fashioned" Classic ABAP Debugger. During the last SAP TechEds I learned that more and more people use the New ABAP Debugger (that is a great news!) but still many are not aware of some of its useful features. The purpose of this blog is to point you to these features so that you can make the most of the New ABAP Debugger.
Some useful debugger settings How to handover a debugger problem - Use Debugger Variants How to display all loaded programs and global variables - Use Loaded Programs Tool How to test a function module in the debugger and pass parameters Helpful hints for analyzing variables How to debug a program which is running in an endless loop How to debug a background job which is running in an endless loop How to debug a finished or crashed background job How to compare ABAP variables - Use Diff Tool How to debug HTTP requests Helpful debugger ok-codes
The New ABAP Debugger settings dialog lets you activate special debugging modes and comfort options that can speed up your troubleshooting scenarios. Here you will find some helpful debugger settings with instructions on when and how to use them. You can access debugger settings in the debugger by using Settings->Display/Change Debugger Settings:
System Debugging: if you have problems that involve system programs (such as a function that can't be accessed in the debugger), turn on this setting (or use menu Settings->System debugging On/Off " or the command /hs in the debugger command field). You can declare a program as a system program by setting Status to "System Program" in its attributes in the ABAP Editor (SE38) (check the radiobutton Attributes and press Change button).
Update Debugging: turn on this setting if you need to analyze asynchronous updates, which are functions that are called as follows: CALL FUNCTION ...' IN UPDATE TASK. These functions are executed asynchronously in a special update work process (after the next COMMIT WORK statement). The debugger can't follow them since it is attached to a single process. Set a breakpoint in the function that is called IN UPDATE TASK, start debugging, turn on this setting, and the debugger will reach the
1 of 14
18/12/2010 3:57 PM
http://weblogs.sdn.sap.com/pub/wlg/21986
TRFC (In Background Task): Block Sending: turn on this setting if you need to analyze transactional Remote Function Calls (TRFC), which are called as follows: CALL FUNCTION ...' IN BACKGROUND TASK. These functions are called asynchronously, along with other TRFC functions of this logical unit of work (LUW), after the next COMMIT WORK statement. The debugger can't follow them since it is attached to a single process. When you turn on this setting, these TRFC functions are stored in the system for debugging instead of being sent. Use the TRFC Monitor (transaction SM58) to analyze the unprocessed LUWs and select Edit->Debug LUW to debug them.
Close debugger After Continue' (F8) and Roll Area End: usually after you press Continue (F8) in the debugger session, the debugger session remains available but inactive when the program is finished. If you switch on this setting, then the debugger will be closed automatically after pressing Continue (F8) , when the roll area (internal session) is ended.
Always Create Exception Obj.: turn on this setting if you need to analyze exception objects (if you catch ABAP exceptions in your program via the CATCH CX_MY_EXCEPTION without specifying a reference variable to which the exception object can be assigned). You can then examine the created exception objects in the debugger via Display Exception Obj. magnifier button.
Imagine that you have had to reproduce and troubleshoot a problem in a rather complicated environment. You have finally found the function module which doesn't work properly under certain conditions. You may need to hand over this debugging session for further analysis to a colleague who has expert knowledge of this function module. In order to ensure that your colleague can reproduce the problem, you must create a very detailed description: the source lines at which to set breakpoints, the debugger settings that must be active, and so on. This is time consuming and there is still a chance that you might forget critical information. In such situations, use a debugger variant (menu Debugger->Debugger Session->Save) to store your debugger session. You can choose which parts to store: current layout (customized desktops), debugger settings, options and breakpoints. Then you can save the variant either in the database or in a local file and send it per email to your colleague.
Afterwards your colleague can load the saved variant from a file or the database after starting a debugging session (menu
Debugger->Debugger Session->Load). All settings and breakpoints will become active immediately. Of course he can choose which
components of the variant to load: layout, settings, options, breakpoints, or all of them.
How to display all loaded programs and global variables - Use the Loaded Programs Tool
A double-click on the variable name in the source code leads to the Variable Fast Display Tool where you get information about variable: type, value, etc. On the Locals tab you get all parameters (including parameter kind) and local variables of the current function
2 of 14
18/12/2010 3:57 PM
http://weblogs.sdn.sap.com/pub/wlg/21986
module, on the Globals tab, you can display all global variables of the current program. But sometimes this local and global information is not enough; you maybe need to display all currently loaded programs and their global variables as well. For this purpose, use the Loaded Programs Tool (button New Tool, Special Tools->Loaded Programs).
Loaded Programs shows you two tabs. On the Loaded Programs tab you see the attributes of all loaded programs and their program groups. On the Global Data tab you get global variables of each global program just by double-clicking the program in the navigation
tree.
Imagine you want to test a function module in the test framework of the Function Builder (transaction SE37) in the debugger, and you need to pass as a parameter a big internal table with many entries. It would be very time consuming to enter the input data for such a table manually in SE37. But you don't have to do this. If you access the function module from the debugger, then you can download its parameters to the SE37 test framework. Select the parameter and use the right mouse button context menu Save Parameters as Test Data (SE37). Please consider that this download is restricted to the data types which are allowed in the SE37 test framework: you cannot download objects, nested internal tables or data references. After that just open the function module in a separate SE37 window and run it in the test framework. You can access your downloaded data in SE37 via Test Data Directory button.
3 of 14
18/12/2010 3:57 PM
http://weblogs.sdn.sap.com/pub/wlg/21986
Use the Data Explorer to view deep nested objects With the Objects Tool (Objects desktop) you can examine object properties including visibility, inheritance, references to the object (where-used list ). You can double-click on attributes in order to navigate to the subcomponents of a class. But if you have to analyze deep nested objects, then the Data Explorer Tool is the better choice. The Data Explorer lets you drill down into nested objects, structures, and references without losing context of the upper levels.
Use Text Translation to display large hex strings and the XML Browser to display XML data. It is very time consuming to analyze the content of a variable that contains 2000 bytes of hex code. Therefore, the detail view (Detail Display desktop) for
4 of 14
18/12/2010 3:57 PM
http://weblogs.sdn.sap.com/pub/wlg/21986
simple types and strings allows you to translate hex strings into readable text using the appropriate code page (field View , choose Text Translation). For binary XML data, there is the XML viewer (field View , choose XML Browser).
Imagine your program is running in an endless loop and you need to analyze its behavior. In such situations you can force the running program into the debugger simply by setting a session breakpoint in a second ABAP Editor. In Utilities->Settings...->Debugging just choose the Session breakpoint active immed. option. When you activate this option, all (running and waiting) sessions of your logon session immediately inherit all session breakpoints set in any of those sessions. It is recommended that you activate this option in development environments.
Now imagine that you have a background job that is running and running, and you want to analyze its behavior. Just use the Process Overview (transaction SM50), select the running process, and choose from the transaction menu Program->Debugging.
5 of 14
18/12/2010 3:57 PM
http://weblogs.sdn.sap.com/pub/wlg/21986
Now just imagine that your background job finishes its execution so quickly, that you don't have a chance to attach a debugger to it in the Process Overview (SM50), or even worse: it crashed with a dump and you need to analyze what caused the dump. Just choose your job in the Job Overview (transaction SM37) and type "jdbg" into the command field. The debugger will start, and you just would need to press a couple of times Return (F7) to get out of the spool functions checks and you can debug your finished or crashed background job online in dialog.
Just imagine you are in the debugger and need to compare two strings which are 2000 bytes long, or you need to compare two nested objects to look for differences in deeply nested attributes. With the Diff Tool (Diff Desktop) you can compare two compatible ABAP variables, e.g. two tables, objects, structures or strings. The Diff tool provides differences concerning type and value. If you double click on a hit in the diff result list, the variables are displayed in parallel, and the debugger navigates to the difference.
6 of 14
18/12/2010 3:57 PM
http://weblogs.sdn.sap.com/pub/wlg/21986
In order to assure good performance of the diff tool, even for deeply nested variables no "deep diff" is executed. This means that if you have for example an internal table as the attribute of an object, then you can at first only check if the tables of both objects are equal. You will not get details about where they differ. To get the details of differences, you can run a diff for the unequal subcomponents (Diff button in the corresponding result line). You can use the History tab to get back to the first result list.
Nowadays, distributed HTTP based applications (like BSP, Web Dynpro for ABAP applications) are the reality in many IT scenarios. To troubleshoot such applications, you must be able to debug HTTP requests. Use transaction SICF to activate the debugger for a specific web service and a specific user (menu Edit->Debugging->Acivate Debugging). Please keep in mind that your web application must run on the server where you set user breakpoints and/or where you activate HTTP debugging via SICF. Please refer to SAP note 668256 for the details on HTTP debugging.
After activating debugging, you will stop in the system code of the http requests in the debugger. You can set new user breakpoints or watchpoints to reach the point of interest. Don't forget to save them before continuing.
/h activate debugging /hs activate system debugging /ha skip dynpro (PAI, PBO) and directly debug ABAP code /hx detach debugger /hmusa create memory snapshot (can be used in the transaction S_MEMORY_INSPECTOR for memory consumption analysis) jdbg in SM37 restart of a finished or crashed background job for debugging
7 of 14
18/12/2010 3:57 PM
http://weblogs.sdn.sap.com/pub/wlg/21986
/ron start ABAP Runtime Analysis measurement (transaction SE30) /roff stop ABAP Runtime Analysis measurement (transaction SE30)
Olga Dolinskaja
Comment on this weblog Showing messages 1 through 43 of 43. Titles Only Very Useful Article!! 2010-12-16 12:00:34 Deepan Gunalan Business Card [Reply] I am hardtime debugging issues with standard program. With this useful tips, it is going to make things easier.!! Thanks 2010-12-16 02:09:25 shishupalreddy ramreddy Business Card [Reply] Hi , It is really helpfull , Apprecaite your efforts in preparing the same . Excellent !!! Little things life easy!! 2010-12-16 01:59:56 Bhawanidutt Dabral Business Card [Reply] Nice blog!! Good 2010-12-15 21:11:19 madhurao madhurao Business Card [Reply] Nice Example with all the features of debugger.I hope it it better if you give this document download as PDF. Main Topics Oldest First
Regards, Madhu. Closing the Debugger 2010-12-14 14:00:59 Ramiro Escamilla Business Card [Reply] Great blog, always useful to be reminded of the little tricks Just a question Is there a way to close the debugger automatically after choosing continue(F8) and not waiting for the roll area to end like the classic debugger did? Currently I have a very limited number of sessions in the company I'm working for, and it's a pain to have the debugging session open when I need to check another transaction code. And yes, I'm too lazy to log on twice Closing the Debugger 2010-12-15 02:34:32 Olga Dolinskaja Hi Ramiro, Business Card [Reply]
8 of 14
18/12/2010 3:57 PM
http://weblogs.sdn.sap.com/pub/wlg/21986
yes, there is a way to do it. If you are in the debugger use menu "Settings->Change Debugger Settings", choose "Close Debugger After 'Continue' (F8) and Roll Area End" and save it.
Best Regards, Olga. Closing the Debugger 2010-12-15 04:37:04 Sandip Saha Business Card [Reply] Hello, I have activated the above suggested option,but the debugger session still remain open!Am i missing something else?
Regards, Sandip Closing the Debugger 2010-12-15 04:59:59 Olga Dolinskaja Hi Sandip, if you checked this setting accordingly and saved it, after you finish your ABAP application (press "Continue") the debugger should disappear. Business Card [Reply]
Best Regards, Olga. Closing the Debugger 2010-12-15 05:43:16 Sandip Saha Business Card [Reply] Hi Olga, Still doesn't work.Am on SAP GUI 7.20 Patch 3.
Regards, Ajay Closing the Debugger 2010-12-15 05:49:15 Olga Dolinskaja Hi, are you sure, you leave the ABAP application? Please restart the SAPGUI session and try again to debug you application. Business Card [Reply]
Best, Olga. Closing the Debugger 2010-12-15 05:58:59 Sandip Saha Business Card [Reply] Hi Olga, Am very sure,somehow it doesn't work !
9 of 14
18/12/2010 3:57 PM
http://weblogs.sdn.sap.com/pub/wlg/21986
Regards, Ajay Good one!!! 2010-12-14 13:05:34 Raja Thangamani Business Card [Reply] Thanks for the useful informations. (partial) list output 2010-12-14 11:09:56 Fred Myer Business Card [Reply] Olga, Thank you for the blog. In the old debugger, you could see the (partial) list output of a report by hitting that table icon. I thought it was a useful feature. Is this possible some way using the new debugger? (partial) list output 2010-12-15 02:28:23 Olga Dolinskaja Hi Fred, currently you have to switch to the old debugger to use list output (and then switch back to the new debugger). Business Card [Reply]
This feature is available in the new debugger with SAP NetWeaver 7.0 EHP2 (the trial version is available for download on SDN on ABAP page). If in the new debugger use menu "Miscellaneous->Display List". After the list is displayed you can press "Continue" button on the screen to return back to the new debugger.
Best Regards, Olga. Very Helpfull 2010-12-14 05:06:41 anmol bhat Business Card [Reply] Although we are working with New debugger, we dont know some of its functionality. Thanks a lot. Great document 2010-12-14 05:01:34 vengalrao jalgam Business Card [Reply] Hi, This is a amazing document, really helpful to me to debug a failed job in background.... saving breakpoints on debugging sessions 2010-12-14 02:35:12 A. de Smidt Business Card [Reply] I try to save a complex breakpoint session but somehow I can't make it work in srm on debugging shoppingcarts now we have the complex debugprocedure call class CL_BBP_SC_TRANSFER_CLASSIC method filter_items set breakpoint at line 62: IF lv_accepted = c_off.
call function in se37 META_SC_BE_CRT and set breakpoint at line 107: lv_adapter->do( EXPORTING is_sc_ext = ls_sc_ext
10 of 14
18/12/2010 3:57 PM
http://weblogs.sdn.sap.com/pub/wlg/21986
call function BBP_PD_SC_TRANSFER enter guid and start debugging. the currently set breakpoints are passed during debugging but whereever I try to save it as described above I can't make it work. after loading the debugvariant it just continues and no breakpoint is selected ?
where in debugging do I have to save the variant so I will loop through all breakpoints ?
it looks like a promising addidition to the course I followed at teched but now I have to see if it can work in these circumstances kind regards arthur
saving breakpoints on debugging sessions 2010-12-14 02:46:05 A. de Smidt Business Card [Reply] ah I see you have to save it in a file if you want to save breakpoints as well.
New ABAP Debugger Tips and Tricks 2010-12-14 02:04:43 Rakesh Kumar Business Card [Reply] Thank you for provide us such a good documents. New ABAP Debugger 2010-12-13 11:58:06 Krishnendu Laha Business Card [Reply] The blog is written in an excellent way with very useful information. Good work! 2010-12-13 08:49:30 Rodrigo Paisante Business Card [Reply] Thanks Olga, this is an excellent blog and will help us to do our job fast. Good reference of many useful options. Very clear... 2010-12-13 06:19:57 Silvio Miranda Business Card [Reply] I didnt knew all this options in the new debugger... keep going with the good job... txs.. Nice 2010-12-13 05:23:57 Guy Lamoureux Business Card [Reply] I didn't know most of these tricks. Impressive. In the old debugger we could edit an internal table: add or delete lines. How can we do it in the new one. I still haven't found how to do it. Nice 2010-12-13 05:43:26 Olga Dolinskaja Hi Guy, please use "Tables" desktop and right-mouse button menu on the table. You can add/delete/insert lines and even insert a row by using the row as a template. Alternatively use button "Services of the tool" on the "Tables" desktop. In the "Change Table" content" area you can manipulate table content as you wish. Business Card [Reply]
11 of 14
18/12/2010 3:57 PM
http://weblogs.sdn.sap.com/pub/wlg/21986
I would also recommend this recorded demo about the New Debugger: http://www.sdn.sap.com/irj/scn/elearn?rid=/library/uuid/a016346d-47ed-2c10-06ac-c6b2d683f40f
Good one 2010-12-13 04:19:41 Saujanya GN Business Card [Reply] Really useful !!! Amazing blog 2010-12-12 20:15:29 Sandeep Kumar Business Card [Reply]
This will really help people to understand the "vast" functions provided by new debugger. Great! 2010-12-12 18:11:19 YICHAO SUN Business Card [Reply] I also have some question. You know, we can download internal table in the debug mode, but can we upload them? Also, the old debugger can download the ITAB with header lines, how can I set the new debugger do it in this way, which only has the content of the table and I have to switch the old one and download? Great! 2010-12-13 03:22:09 Olga Dolinskaja Hello Yichao, on the "Table" Desktop please use the button "Services of the Tool". Business Card [Reply]
Then you can upload an internal table in the New Debugger via "Standard services"->"Upload from file". You can download the ITAB with header lines via "Standard services"->"Save in File" and choosing "Text format with separator" option.
Best Regards, Olga. Great! 2010-12-17 01:56:14 Markus Stange Business Card [Reply] Hi Olga, very nice blog! According to the question of Yichao: The faeture of uploading table entries is not available in my debugger (SAP ABA 700/ Level 17). Where can I find it? Kind regards Markus Excellent Bolg, great insight in to ABAP Debugger 2010-12-12 14:39:11 purnend maroju Business Card [Reply] Thanks Olga, The way you presented this excellent, its created interest in recheck back my ABAP dibugging skills...
Purnend
12 of 14
18/12/2010 3:57 PM
http://weblogs.sdn.sap.com/pub/wlg/21986
Great Blog 2010-12-10 04:48:58 srikanth adivanna Business Card [Reply] Hi Olga, Good blog to learn new things about debugger.Thanks a lot Superb Blog 2010-12-10 04:21:41 Irfan Rehman Business Card [Reply] Nice & Informative Blog. Regards Jameel Irfan Done a Great Job 2010-12-10 03:37:56 SeethaRamaiah Bharani Business Card [Reply] Done a GREAT JOB... Thank you.... Excellent Bolg 2010-12-09 22:19:05 Sakshi Jain Business Card [Reply] Amazing blog, really helpful and easy to understand. Thanks for sharing it. Excellent one 2010-12-09 19:24:36 Sainatha Reddy Yerri Business Card [Reply] This has simple and very detail blog related to debugging. You have provided lot of information in one place. Very informative 2010-12-09 19:01:39 Jeniphin Paul Business Card [Reply] Olga, Thanks for sharing this Excellent blog!. Thanks for the Informatvie Blog 2010-11-29 23:27:31 Praneet sai Business Card [Reply] Hi, This is blog has amazing tips and information on new debugger. Just I learned the short command codes for several ( skip the PAI/PBO and Run time meaurement) Excellent 2010-11-24 06:24:20 Abdul Hakim Business Card [Reply] Excellent blog. content has been nicely presented. warm regards, abdul hakim Excellent .. 2010-11-16 00:47:40 Vipin Bhardwaj Business Card [Reply] Excellent tips...many thanks for posting.. Thanks 2010-11-10 22:23:00 Bikas Tarway Business Card [Reply]
13 of 14
18/12/2010 3:57 PM
http://weblogs.sdn.sap.com/pub/wlg/21986
Excellent tips, Excellent prsentation Re: New ABAP Debugger 2010-11-10 10:09:18 Kenneth Moore Business Card [Reply] Excellent tips! Thanks! great input 2010-11-10 05:46:40 greg misiorek Business Card [Reply] Olga, keep them coming. SDN needs blogs like this. Excellent blog! 2010-11-10 01:30:43 Roel van den Berge Business Card [Reply] Hi Olga, Thanks for your extensive blog! It contains some very nice and handy tips. I for one didn't know the option to close the debugger after continuing which I always found really annoying.
Thanks again!
Cheers, Roel
14 of 14
18/12/2010 3:57 PM