Show TOC

Automating Repetitive TasksLocate this document in the navigation structure

Definition

Perhaps you have had this experience while debugging: To reach the site of a presumed problem, you must repeatedly confirm a message or reset a return code or do some other repetitive task in the debugger in order to proceed.

Scripting in the new ABAP Debugger is ideally suited for quickly automating such repetitive tasks. With ABAP debugger scripting, you can automate anything that you can do by hand in the debugger.

Assume that your application starts by checking its partner systems - and that the necessary configuration is missing in your test system. How could you proceed beyond this loop without first confirming an unknown number of messages?

Here is how the application code might look at the point at which the messages are issued:

...
LOOP AT lt_remote_systems ASSIGNING <rs>.
        l_rc = check_remote_system( SYSTEM = <rs> ).
        IF l_rc = ABAP_FALSE.
                MESSAGE i000(msg_id) WITH 'Application APP is inactive on system' 'SID'.
        ENDIF.
ENDLOOP.
...
         

You could skip over the messages with the following script. The script uses two functions that you can insert from the Debugger Control and the Variable Information sections of the Script Wizard.

To use the script, you would trigger it to run at a breakpoint set at the call to the CHECK_REMOTE_SYSTEM method.

The script then does the following:

  1. With a call to the DEBUG_STEP method from the Script Wizard, the script runs the CHECK_REMOTE_SYSTEM method.

  2. With a call to CHANGE_VALUE method, the L_RC variable is reset so that no warning message appears.

    You will need the change-value authorization in the debugger in order for this script to work.

With the help of the script, you can skip over the information messages issued in the loop and stop at a later breakpoint in the code.

CLASS lcl_debugger_script IMPLEMENTATION.
  METHOD script.

* First use a method from the Control section of the 
* Script Wizard to run the check_remote_system method.
*************************************************
* 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
**************************************************
    debugger_controller->debug_step( 
      p_command = cl_tpda_script_debugger_ctrl=>debug_step_over ).

* Then change the value of l_rc using a function
* from the Change Variable Value section 
* of the Script Wizard.
***************************************************
*Interface (CLASS = CL_TPDA_SCRIPT_DATA_DESCR / METHOD = CHANGE_VALUE )
*Importing
*        REFERENCE( P_NEW_VALUE ) TYPE STRING
*        REFERENCE( P_OFFSET ) TYPE I
*        REFERENCE( P_LENGTH ) TYPE I
*        REFERENCE( P_VARNAME ) TYPE STRING
****************************************************
    cl_tpda_script_data_descr=>change_value(
     p_new_value = ABAP_TRUE
     p_varname   = 'L_RC'.

  ENDMETHOD.                    "end
ENDCLASS.                    "lcl_debugger_script IMPLEMENTATION