Automate debugging using ABAP debugger scripts

...Previous

c.    Check the value of the variable obtained and if it is not 0, then trigger the breakpoint. The attached code is the final code, which would be generated using script wizard and slight modifications.  

  METHOD script.
*** insert your script code here
*1. Step over the current statement (Select)
*************************************************
* debugger commands (p_command):
* Step into(F5)   -> CL_TPDA_SCRIPT_DEBUGGER_CTRL=>DEBUG_STEP_INTO
* Execute(F6)     -> CL_TPDA_SCRIPT_DEBUGGER_CTRL=>DEBUG_STEP_OVER
* Return(F7)      -> CL_TPDA_SCRIPT_DEBUGGER_CTRL=>DEBUG_STEP_OUT
* Continue(F8)    -> CL_TPDA_SCRIPT_DEBUGGER_CTRL=>DEBUG_CONTINUE
*************************************************
****************************************************************
*Interface (CLASS = CL_TPDA_SCRIPT_DEBUGGER_CTRL / METHOD = DEBUG_STEP )
*Importing
*        REFERENCE( P_COMMAND ) TYPE I
****************************************************************
    TRY.
        CALL METHOD debugger_controller->debug_step
          EXPORTING
            p_command = cl_tpda_script_debugger_ctrl=>debug_step_into.
      CATCH cx_tpda_scr_rtctrl_status .
      CATCH cx_tpda_scr_rtctrl .
    ENDTRY.
*2. Get the value of the system variable 'sy-subrc'
****************************************************************
*Interface (CLASS = CL_TPDA_SCRIPT_DATA_DESCR / METHOD = GET_SIMPLE_VALUE )
*Importing
*        REFERENCE( P_VAR_NAME ) TYPE TPDA_VAR_NAME
*Returning
*        VALUE( P_VAR_VALUE ) TYPE TPDA_VAR_VALUE
****************************************************************
    DATA lv_subrc TYPE sy-subrc.
    TRY.
        CALL METHOD cl_tpda_script_data_descr=>get_simple_value
          EXPORTING
            p_var_name  = 'SY-SUBRC'
          RECEIVING
            p_var_value = lv_subrc.
      CATCH cx_tpda_varname .
      CATCH cx_tpda_script_no_simple_type .
    ENDTRY.
*3.Check the value of sy-subrc. Trigger point, if condition reached
    IF lv_subrc NE 0.
      me->break( ).
    ENDIF.
  ENDMETHOD.                    "script
  METHOD end.
*** insert your code which shall be executed at the end of the scripting (before trace is saved)
*** here
  ENDMETHOD.                    "end  

5.     Check the syntax of the code and start the script (using the button on the left of Pattern’.

6.     It will stop at the point where the select statement doesn’t return sy-subrc as 0.

So, the debugger has stopped at the position where SY-SUBRC is not 0.  

7.     Now, we have the option to either continue the script (to find more such select statements), or exit the script and manually debug from that point onwards. We will exit the script and go to debugger to check the SY-SUBRC value.

So, the SY-SUBRC is 4.

Note: If after starting the script, it goes to the output screen directly, you can press back and exit the script.

Summary:-

The above technique can be used for other statements as well like RFC calls, Authority checks, call method etc.

Also, you can explore the script wizard and there are a lot of things which you can do. There are a lot of standard scripts available. You can either use them directly or modify them according to your requirement.

We have written the script on the fly. We can also save our script for reusability

We can also see the trace of our debugger script, which can be very useful if we are going for layer aware debugging.

Please send us your feedback/suggestions at webmaster@SAPTechnical.COM 

HomeContribute About Us Privacy Terms Of Use • Disclaimer • SafeCompanies: Advertise on SAPTechnical.COM | Post JobContact Us  

Graphic Design by Round the Bend Wizards

footer image footer image