Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

Debugger Scripting

airwave
Explorer
0 Kudos
751

Hello Experts,

Do you know what is the reason why this script is not executable? It is showing syntax error , with class tpda_scr_globals_it it is executable but not with tpda_scr_locals_it. Is there a restriction from SAP why it may not be executable.
Looking forward to your reply. Thank you in advance.

*<SCRIPT:PERSISTENT>
REPORT  rstpda_script_template.

*<SCRIPT:HEADER>
*<SCRIPTNAME>RSTPDA_SCRIPT_DUMMY</SCRIPTNAME>
*<FILE_NAME>C:\SCRIPTDEBU\ZSCRIPT_LOCALS.TXT</FILE_NAME>
*<SCRIPT_CLASS>LCL_DEBUGGER_SCRIPT</SCRIPT_CLASS>
*<SINGLE_RUN>X</SINGLE_RUN>

*</SCRIPT:HEADER>

*<SCRIPT:PRESETTINGS>

*</SCRIPT:PRESETTINGS>

*<SCRIPT:SCRIPT_CLASS>
*---------------------------------------------------------------------*
*       CLASS lcl_debugger_script DEFINITION
*---------------------------------------------------------------------*
*
*---------------------------------------------------------------------*
CLASS lcl_debugger_script DEFINITION INHERITING FROM  cl_tpda_script_class_super  .

  PUBLIC SECTION.
    METHODS: prologue  REDEFINITION,
      init    REDEFINITION,
      script  REDEFINITION,
      end     REDEFINITION.

ENDCLASS.                    "lcl_debugger_script DEFINITION
*---------------------------------------------------------------------*
*       CLASS lcl_debugger_script IMPLEMENTATION
*---------------------------------------------------------------------*
*
*---------------------------------------------------------------------*
CLASS lcl_debugger_script IMPLEMENTATION.
  METHOD prologue.
*** generate abap_source (source handler for ABAP)
    super->prologue( ).
  ENDMETHOD.                    "prolog

  METHOD init.
*** insert your initialization code here
  ENDMETHOD.                    "init
  METHOD script.

    DATA:
    lt_locals TYPE tpda_scr_locals_it.
    ls_locals like line of lt_globals,
    lv_value  type tpda_var_value,
    trace_entry type tpda_trace_custom.

    CALL METHOD trace->add_src_info.

    CALL METHOD cl_tpda_script_data_descr=>locals(
      RECEIVING
        p_locals_it = lt_locals ).

    LOOP AT lt_locals INTO ls_locals.

      TRY.
          CALL METHOD cl_tpda_script_data_descr=>get_simple_value
            EXPORTING
              p_var_name  = ls_locals-name
            RECEIVING
              p_var_value = lv_value.
        CATCH cx_tpda_varname .
        CATCH cx_tpda_script_no_simple_type .
      ENDTRY.

      trace_entry-value = 'Wert der Variablen' && space && ls_locals-name && '=' && lv_value.

      CALL METHOD trace->add_custom_info
        EXPORTING
          p_trace_entry = trace_entry.
    ENDLOOP.
*  me->break( ).

  ENDMETHOD.                    "script
  METHOD end.
*** insert your code which shall be executed at the end of the scripting (before trace is saved)
*** here

  ENDMETHOD.                    "end
ENDCLASS.                    "lcl_debugger_script IMPLEMENTATION
*</SCRIPT:SCRIPT_CLASS>

*</SCRIPT:PERSISTENT>

Br

Hakan

7 REPLIES 7

Sandra_Rossi
Active Contributor
603

Difficult to help if you don't post the message of the syntax error.

I tried your code. The syntax error is very clear:

Comma without preceding colon (after LS_LOCALS ?).

What don't you understand?

airwave
Explorer
0 Kudos
603

Please disregard typo eror with "comma without preceding colon".

In the end even after correcting the code doesn't do what it should do.

All what I see is the message although I am not using the program RSTPDA_SCRIPT_DUMMY

The program "RSTPDA_SCRIPT_DUMMY" is not Unicode-compatible, according to its program attributes.

Pls. help why it is not working as expected.

Br

Hakan

0 Kudos
603

I can "disregard" your original question if you update it. Don't post an answer just to change your original question.

I see nowhere in your code the presence of "RSTPDA_SCRIPT_DUMMY". Again, difficult to help if the question is unclear...

airwave
Explorer
0 Kudos
603

I don't understand what you mean with?

Don't post an answer just to change your original question

I have never have tried to change the original question. The syntax error doesn't change

the fact that it is not possible to trace the internal variables same as the globals. You can simply

test by your own to see that Write a sniplet and test above script.

When you perform the script by using the type tpda_scr_globals_it intead using tpda_scr_locals_it

you will notice it is working. But not by using tpda_scr_locals_it. This is still the original question.

0 Kudos
603

Please use the COMMENT button for comments, asking for complements, adding details, replying to a comment or a proposed solution or to the OP question, etc., ANSWER is only to propose a solution, dixit SAP text at the right of the answer area.

0 Kudos
603

First please explain what exactly means "it is not working"?

(I ran the script, I don't know what your question is)

airwave
Explorer
0 Kudos
603

Hi Sandra,

you can trace global/local variables from any program by this way while Debugging with this script.

You can test this with below script.

You need simply to load this script as local file and execute directly. This generates an entry where you can later see in transaction SAS.

The issue is when you are using above script where I am tracing the local variables of a program

by using of class tpda_scr_locals_it then it fails

and end up with the message "syntax error" and no more detailed error message.

But in below script I am refering to class tpda_scr_globals_it. This works fine.

tpda_scr_globals_it => works fine

tpda_scr_locals_it => fails

*<SCRIPT:PERSISTENT>
REPORT  rstpda_script_template.

*<SCRIPT:HEADER>
*<SCRIPTNAME>RSTPDA_SCRIPT_DUMMY</SCRIPTNAME>
*<FILE_NAME>test.TXT</FILE_NAME>
*<SCRIPT_CLASS>LCL_DEBUGGER_SCRIPT</SCRIPT_CLASS>
*<SINGLE_RUN>X</SINGLE_RUN>

*</SCRIPT:HEADER>

*<SCRIPT:PRESETTINGS>

*</SCRIPT:PRESETTINGS>

*<SCRIPT:SCRIPT_CLASS>
*---------------------------------------------------------------------*
*       CLASS lcl_debugger_script DEFINITION
*---------------------------------------------------------------------*
*
*---------------------------------------------------------------------*
CLASS lcl_debugger_script DEFINITION INHERITING FROM  cl_tpda_script_class_super  .

  PUBLIC SECTION.
    METHODS: prologue  REDEFINITION,
      init    REDEFINITION,
      script  REDEFINITION,
      end     REDEFINITION.

ENDCLASS.                    "lcl_debugger_script DEFINITION
*---------------------------------------------------------------------*
*       CLASS lcl_debugger_script IMPLEMENTATION
*---------------------------------------------------------------------*
*
*---------------------------------------------------------------------*
CLASS lcl_debugger_script IMPLEMENTATION.
  METHOD prologue.
*** generate abap_source (source handler for ABAP)
    super->prologue( ).
  ENDMETHOD.                    "prolog

  METHOD init.
*** insert your initialization code here
  ENDMETHOD.                    "init
  METHOD script.

    DATA:
    lt_globals TYPE tpda_scr_globals_it,
ls_globals like line of lt_globals,
lv_value type tpda_var_value, trace_entry type tpda_trace_custom. CALL METHOD trace->add_src_info. CALL METHOD cl_tpda_script_data_descr=>globals( RECEIVING p_globals_it = lt_globals ).

    LOOP AT lt_globals INTO ls_globals.
TRY. CALL METHOD cl_tpda_script_data_descr=>get_simple_value EXPORTING p_var_name = ls_globals-name
            RECEIVING
              p_var_value = lv_value.
        CATCH cx_tpda_varname .
        CATCH cx_tpda_script_no_simple_type .
      ENDTRY.

      trace_entry-value = 'Wert der Variablen' && space && ls_globals-name && '=' && lv_value.

      CALL METHOD trace->add_custom_info
        EXPORTING
          p_trace_entry = trace_entry.
    ENDLOOP.
  ENDMETHOD.                    "script
  METHOD end.

  ENDMETHOD.                    "end
ENDCLASS.                    "lcl_debugger_script IMPLEMENTATION
*</SCRIPT:SCRIPT_CLASS>

*</SCRIPT:PERSISTENT>