正常情况下ABAP是不能debug调试宏的,可但是有个变通的方法能让你初略的一步一步执行宏内的代码。
写了一段简单的abap代码,里面包括一个宏,用来取EKPO表内数据,然后sort一下。
REPORT ztest_debug_macro. DATA:lt_ekpo TYPE STANDARD TABLE OF ekpo WITH HEADER LINE. "<span class="L0S31">宏定义</span> DEFINE macro_sql. SELECT * FROM ekpo INTO TABLE lt_ekpo UP TO 10 ROWS. SORT lt_ekpo BY ebeln DESCENDING ebelp. END-OF-DEFINITION. WRITE:‘Start.....‘. macro_sql. LOOP AT lt_ekpo. WRITE:/ lt_ekpo-ebeln ,lt_ekpo-ebelp. ENDLOOP.
在调用宏的语句处设置断点,程序停在断点时,点击下图中的工具按钮,然后进一步双击 ABAP字节代码(调试宏)。
&lt;img class="alignnone size-medium wp-image-6408" src="//pic.ikafan.com/imgp/L3Byb3h5L2h0dHAvd3d3LmJhaWR1c2FwLmNvbS93cC1jb250ZW50L3VwbG9hZHMvMjAxOS0wNS0yOV8xNy0xOS0zMS03NDB4NDgwLmpwZw==.jpg" width="740" height="480" srcset="http://www.baidusap.com/wp-content/uploads/2019-05-29_17-19-31-740x480.jpg 740w, http://www.baidusap.com/wp-content/uploads/2019-05-29_17-19-31-768x498.jpg 768w, http://www.baidusap.com/wp-content/uploads/2019-05-29_17-19-31.jpg 927w" sizes="(max-width: 740px) 100vw, 740px" /&gt;
下图红框内的就是宏内的代码,可以一步一步执行,能大概分辨出来一个是SELECT语句,一个是SORT语句。
&lt;img class="alignnone size-medium wp-image-6409" src="//pic.ikafan.com/imgp/L3Byb3h5L2h0dHAvd3d3LmJhaWR1c2FwLmNvbS93cC1jb250ZW50L3VwbG9hZHMvMjAxOS0wNS0yOV8xNy0yNi01Ni03NDB4Mzk5LmpwZw==.jpg" width="740" height="399" srcset="http://www.baidusap.com/wp-content/uploads/2019-05-29_17-26-56-740x399.jpg 740w, http://www.baidusap.com/wp-content/uploads/2019-05-29_17-26-56-768x414.jpg 768w, http://www.baidusap.com/wp-content/uploads/2019-05-29_17-26-56-1024x552.jpg 1024w, http://www.baidusap.com/wp-content/uploads/2019-05-29_17-26-56.jpg 1052w" sizes="(max-width: 740px) 100vw, 740px" /&gt;
以上。
原文地址:https://www.cnblogs.com/datie/p/11428496.html