{"id":1025,"date":"2014-07-04T14:49:17","date_gmt":"2014-07-04T13:49:17","guid":{"rendered":"http:\/\/oprsteny.cz\/?p=1025"},"modified":"2014-07-04T14:49:17","modified_gmt":"2014-07-04T13:49:17","slug":"abap-advanced-debugging","status":"publish","type":"post","link":"https:\/\/oprsteny.cz\/?p=1025","title":{"rendered":"ABAP &#8211; Advanced debugging"},"content":{"rendered":"<p><img loading=\"lazy\" decoding=\"async\" data-attachment-id=\"358\" data-permalink=\"https:\/\/oprsteny.cz\/?attachment_id=358\" data-orig-file=\"https:\/\/oprsteny.cz\/wp-content\/uploads\/SAP.jpg\" data-orig-size=\"44,50\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;Picasa&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;1365690880&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;}\" data-image-title=\"SAP\" data-image-description=\"\" data-image-caption=\"\" data-large-file=\"https:\/\/oprsteny.cz\/wp-content\/uploads\/SAP.jpg\" class=\"size-full wp-image-358 alignleft\" src=\"http:\/\/oprsteny.cz\/wp-content\/uploads\/SAP.jpg\" alt=\"SAP\" width=\"44\" height=\"50\" \/>I believe that most of you know how to debug the basic report or class methods etc.<\/p>\n<p>But things can\u00a0become complicated\u00a0when\u00a0debugging is needed for a backround job, RFC function module or even some user-exit which is being triggered in an update task. E.g. when you update material master in ECC using MM02, you can&#8217;t easily debug all user-exits because they&#8217;re triggered in separate process independent on session you are currently running.<\/p>\n<p>In this article I&#8217;d like to present several useful debugging tricks you can use in your more complex scenarios.<!--more--><\/p>\n<h2>Basic debugging<\/h2>\n<ol>\n<li>Put a break-point in your code and execute the program.<\/li>\n<li>Once the line with break-point is reached, the ABAP Debugger is started automatically.<\/li>\n<\/ol>\n<h2>Basic debugging using &#8216;<em>\/h<\/em>&#8216;<\/h2>\n<p>When you are in a started transaction\/program and you would like to begin debugging at the moment:<\/p>\n<ol>\n<li>Type &#8216;<em>\/h<\/em>&#8216; (without the quotes) in the command box and press enter<\/li>\n<li>Do any action in your program (eg. Save, Display, press F4, &#8230;)<\/li>\n<li>After you do any action which triggers PAI of the screen the ABAP Debugger is started<\/li>\n<\/ol>\n<h2>Debugging of &#8220;<em>Update Task<\/em>&#8220;<\/h2>\n<p>Debugging of an Update task is not possible with\u00a0normal setup\u00a0and without modification of user settings you are basically not able to debug a program which is started in an update task. To enable debugging of update task:<\/p>\n<ol>\n<li>Start basic debugging using &#8216;<em>\/h<\/em>&#8216;<\/li>\n<li>When ABAP Debugger is started, go to Top menu -&gt; Settings -&gt; Change Debugger Settings \/ profile (Shift+F1)<\/li>\n<li>Select check box &#8220;<em>Update debugging<\/em>&#8220;<\/li>\n<li>Press F8 to let\u00a0current processing continue and wait until\u00a0the update task is\u00a0started in another window<\/li>\n<\/ol>\n<h2>Debugging &#8220;<em>Queued RFCs<\/em>&#8220;<\/h2>\n<p>Debugging Queued RFC might become useful e.g. for ECC &lt;-&gt; APO interface\u00a0where a CIF is used and data are sent back and forth using named queue called\u00a0<em>&#8216;*CF&#8217;<\/em><\/p>\n<p>The outbound debug is easy &#8211; this can either be achieved by the Basic\u00a0debugging or by Debugging of an update task (outbound queues).<\/p>\n<p>Inbound debugging is a bit harder because the queue is setup to process all incoming requests automatically at the moment of their arrival. To be able to debug inbound queue you have to STOP processing of arriving requests on a specific queue.<\/p>\n<h2>Debugging &#8220;<em>Background tasks<\/em>&#8220;<\/h2>\n<p>Debugging of a background task is not normally possible because the background task is started in another process (like the update task) so developer is not automatically navigated to the background code during debugging.<\/p>\n<p>To enable background debugging:<\/p>\n<ol>\n<li>Start basic debugging using &#8216;<em>\/h<\/em>&#8216;<\/li>\n<li>When ABAP Debugger is started, go to Top menu -&gt; Settings -&gt; Change Debugger Settings \/ profile (Shift+F1)<\/li>\n<li>Select check box <em>&#8220;TRFC (In Background task):\u00a0Block\u00a0sending&#8221;<\/em><\/li>\n<li>Press F8 to\u00a0let\u00a0current process to finish<\/li>\n<li>Go to SM58 and find your un-processed background task<\/li>\n<li>Start its debugging in Top-menu -&gt; Edit -&gt; Debug LUW<\/li>\n<\/ol>\n<h2>Debugging &#8220;<em>Dialog windows<\/em>&#8220;<\/h2>\n<p>When a dialog window is displayed in SAP you don&#8217;t have the command box available. So you are not able to start debugging using the &#8216;\/h&#8217; command as usually.<\/p>\n<p>The trick is in creating a &#8216;shortcut&#8217; as a flat file in your file system with the following contents:<\/p>\n<pre><span style=\"color: inherit; font-family: 'Courier 10 Pitch', Courier, monospace; font-size: 13px; line-height: 1.5; background-color: rgb(244, 244, 244);\">[FUNCTION]\r\n<\/span>Command=\/H\u00a0\r\nTitle=Debugger\r\nType=SystemCommand<\/pre>\n<p>To enable debugging of a dialog window just Drag&amp;Drop your prepared flat file on that dialog window and you should notice the message saying that debugging has been switched on.<\/p>\n<p>After you perform\u00a0any action on such dialog window the ABAP Debugger is started and you can evaluate the user action results.<\/p>\n<h2>Debugging as different user<\/h2>\n<p>This might become useful when processing e.g. requests from webdynpro which is handled on SAP backend\u00a0by some predefined\u00a0system user.<\/p>\n<p>To enable debugging for a different user, go to SE38 (or SE37, SE24 or anythnig else which uses ABAP Editor) in the Top-menu open Utilities -&gt; Settings -&gt; tab ABAP Editor -&gt; sub-tab Debugging -&gt; enter the name of user you would like to use for debugging.<\/p>\n<h2>Dynamic Breakpoints<\/h2>\n<p>Dynamic breakpoints are extremely useful especially in debugging of an update task because the update tasks are started in new sessions where your temporary breakpoints are not kept &#8211; so you have to set them again.<\/p>\n<ol>\n<li>Once ABAP Debugger is started for the update task you can put breakpoints to your code using Top-menu -&gt; Breakpoints -&gt; Breakpoint at &#8230;<\/li>\n<li>Just select the proper &#8220;Breakpoint at &#8230;&#8221;, eg. Function Module and enter the user-exit name you are going to debug<\/li>\n<li>Press Enter and F8 to continue running the update task until your user-exit is reached and debugger is available again\u00a0for you in the user-exit<\/li>\n<\/ol>\n<p>I personally use it a lot\u00a0when searching for the user-exits\/BAdIs called during the\u00a0program execution: just put new dynamic breakpoint as\u00a0&#8220;Breakpoint at Statement&#8221; with the following ABAP command<\/p>\n<pre>CALL CUSTOMER-FUNCTION<\/pre>\n<h2>Conditional breakpoints<\/h2>\n<p>This feature of debugger might become quite handy\u00a0when you need to debug something in a loop and let&#8217;s say in its 500<sup>th<\/sup> iteration.<\/p>\n<p>Without the conditional breakpoint you&#8217;d have to do each iteration manually. Using this approach you just set the breakpoint condition (in this case sy-tabix = 500) and you are done:<\/p>\n<p>When standard debugger is started press F9 (Create Breakpoint), select desired target (Method, Function module, Program-form) and type your &#8220;Free Condition Entry&#8221; (e.g. SY-TABIX = 500).<\/p>\n<h2>External breakpoints<\/h2>\n<ul>\n<li>User breakpoints (previously known as external breakpoints) are valid for all user logons on the current server of the current system.<\/li>\n<li>User breakpoints are specifically required when debugging BSP or Web Dynpro applications. In these cases, you do not log on using the SAP GUI but via a browser, for example.Therefore, any breakpoints must be set before logging on.<\/li>\n<li>User breakpoints are only valid for a period of 2 hours.<\/li>\n<li>As of Release 7.00, user breakpoints set for BSP or Web Dynpro applications are also valid for SAP GUI logons.<\/li>\n<\/ul>\n<p>In typical scenario an active external debugging triggers ABAP debugging when interacting with web pages: When a web page requires a call back to ABAP backend and you&#8217;ve set an external breakpoint in that code, an ABAP debugger window pops up.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I believe that most of you know how to debug the basic report or class methods etc. But things can\u00a0become complicated\u00a0when\u00a0debugging is needed for a backround job, RFC function module or even some user-exit which is being triggered in an &hellip; <a href=\"https:\/\/oprsteny.cz\/?p=1025\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"ABAP - Advanced debugging","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":true,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2},"jetpack_post_was_ever_published":false},"categories":[16,9,222],"tags":[284,303,302,301,298,300,289,299],"class_list":["post-1025","post","type-post","status-publish","format-standard","hentry","category-abap","category-development","category-dynpro","tag-debug","tag-dynamic-breakpoint","tag-inbound-queue","tag-outbound-queue","tag-rfc","tag-sm58","tag-smqr","tag-update-task"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/p3nYbe-gx","jetpack-related-posts":[],"_links":{"self":[{"href":"https:\/\/oprsteny.cz\/index.php?rest_route=\/wp\/v2\/posts\/1025","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/oprsteny.cz\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/oprsteny.cz\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/oprsteny.cz\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/oprsteny.cz\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1025"}],"version-history":[{"count":1,"href":"https:\/\/oprsteny.cz\/index.php?rest_route=\/wp\/v2\/posts\/1025\/revisions"}],"predecessor-version":[{"id":1026,"href":"https:\/\/oprsteny.cz\/index.php?rest_route=\/wp\/v2\/posts\/1025\/revisions\/1026"}],"wp:attachment":[{"href":"https:\/\/oprsteny.cz\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1025"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/oprsteny.cz\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1025"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/oprsteny.cz\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1025"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}