Show TOC Start of Content Area

Background documentation The Local Debugger Script Class  Locate the document in its SAP Library structure

The local debugger script class lcl_debugger_script contains the script code of your Debugger script. It is a normal local class that you can adapt to your needs. You can add methods and attributes, for example.

Caution

Do not rename the class and do not change the inheritance or the declaration of the INIT, SCRIPT,and END script methods.

Do not change the tag comment. The tags are generated automatically when you save your script.

Script Methods

The local Debugger script class provides the following methods:

Method

Purpose

prologue

Technical initialization of the script.

Init

Initialization of the script.

script

Script method, called for each trigger.

end

End of the script.

Method PROLOGUE

After the script is started, the Debugger framework first calls the prologue method of the script.

The default implementation registers the abap_source instance to the debug_step event so that the source code information you get from the abap_source instance is always up-to-date.

If you want to improve the performance of your script and you do not need abap_source, then you can delete the default the super->prologue call.

Syntax

METHOD prologue.

*** generate abap_source (source handler for ABAP)

    super->prologue( ).

ENDMETHOD.                   

Method INIT

Next, the system calls the initmethod of the Debugger script. This method is called only once, directly after the prologue method.

You use this method for initialization. It is also a place to add user interaction, for example, a dialog box, where you ask the user for input, which you need for the script.

Syntax

METHOD init.

RAISING

      cx_tpda_stop_scripting_request.

ENDMETHOD.                    "init

Method SCRIPT

This method is called when the script is triggered and contains most of the script functionality.

Syntax

METHOD script.

    IMPORT

      !p_trigger type tpda_script_trigger.

    RAISE:

      cx_tpda_stop_scripting_request,

      cx_tpda_script_continue.

ENDMETHOD.                    "script

The importing parameter p_trigger is filled with the trigger type that launched the script.

The components of p_trigger are the following flags:

      bp_reached

      wp_reached

      single_step

      single_run.

It is possible to define several triggers in parallel, for example, a breakpoint at the SELECT statement, a breakpoint at the stack-change event, and a watchpoint.

You can stop the execution of the script, by raising exception cx_tpda_stop_scripting_request.

You can let the user decide to stop or continue the script by using service method me->break( ).

You can continue the script (without user interaction) until the next trigger is reached by raising the cx_tpda_script_continue exception.

Method END

At the end of the script or when the user stops the script, the end method of the script is called.

At this point, you can display data to the user, you can close resources, or aggregate data before storing it.

Syntax

METHOD end.

*** insert your code which shall be executed at the end of the ***scripting (before trace is saved)

here

 

ENDMETHOD.                    "end

Services Provided by the Script Super Class

      Instance method break

The method stops the execution of the script. The control goes back to the user.

You can decide to stop scripting or to continue the script. The script is launched again after reaching the next trigger.

      Instance method raise_error

Use this method to terminate the script and to display a message to the user.

This method raises an exception to terminate the script. If you catch this exception in the script, the raise_error method does not terminate the script.

The super class also provides instances of the most important Debugger services:

Service

Description

abap_source

ABAP program and source code information.

For example, currr_prog = abap_source->program( ).

BP

Breakpoint services.

WP

Watchpoint services.

debugger_control

For example, Debug Step and Jump to statement.

debugger_status

Settings and status of the Debugger.

dynpro

Dynpro information.

memory

Information about memory usage and highest memory consumers.

special

System areas and other details.

 

 

End of Content Area