Skip to Content
In WebUI we can maintain search parameter for dynamic search:

The value maintained in WebUI could be found from dynamic query service instance in backend via debugging. Double click variable qs:

We need the following FIVE steps to see the selection parameter value.
1. double click SELECTION_PARAM_COL:

2. Double click ENTITY_LIST:

3. These four entities represent the four selection parameters we see in WebUI. Double click one of them:

4. Double click PARAMETER_DATA:
5. double click:

Finally we see the value:

Use ABAP debugger script to directly review variable content without so many double clicks

1. Click Script tab, create a new Script:

2. Choose a name for your script:

Paste the following source code to overwrite automatically generated source code:

*---------------------------------------------------------------------*
*       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.

    INTERFACES: if_tpda_script_w_input.


  PRIVATE SECTION.

    DATA      queryservicename TYPE string.
    CONSTANTS querydefaultname TYPE string VALUE 'QUERY_SERVICE'.

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.
    queryservicename = querydefaultname.
  ENDMETHOD.                    "init

  METHOD script.

    TYPES:
        BEGIN OF ty_selparam,
          attrname TYPE string,
          sign     TYPE string,
          option   TYPE string,
          low      TYPE string,
          high     TYPE string,
        END OF ty_selparam.

    DATA lt_col_alv                   TYPE tpda_script_service_source_tab.
    DATA ls_col_alv                   like LINE OF lt_col_alv.
    DATA ls_selparam                  TYPE ty_selparam.
    DATA lr_query_service             TYPE tpda_quick_vars.
    DATA lv_query_service_object_name TYPE tpda_var_name.
    DATA lv_selparamcol_object_name   TYPE tpda_var_name.
    DATA lv_bo_object_name            TYPE tpda_var_name.
    DATA lv_number_of_selparam        TYPE i.
    DATA lt_attr                      TYPE tpda_script_object_attribut_it.
    DATA ls_attr                      TYPE tpda_script_object_attributes.
    DATA lt_selparam                  TYPE STANDARD TABLE OF ty_selparam.
    DATA lr_attr                      TYPE REF TO cl_tpda_script_data_descr.
    DATA lr_entity_list               TYPE REF TO cl_tpda_script_tabledescr.
    DATA lr_obj_descr                 TYPE REF TO cl_tpda_script_objectdescr.

    REFRESH lt_selparam.

    TRY.
        lv_query_service_object_name = cl_tpda_script_data_descr=>get_variable_info( queryservicename )-varvalue.
        lv_selparamcol_object_name = cl_tpda_script_data_descr=>get_variable_info( lv_query_service_object_name && '-SELECTION_PARAM_COL' )-varvalue.
        lr_entity_list ?= cl_tpda_script_data_descr=>factory( lv_selparamcol_object_name && '-ENTITY_LIST' ).
        lv_number_of_selparam = lr_entity_list->linecnt( ).
        DO lv_number_of_selparam TIMES.
          lv_bo_object_name = cl_tpda_script_data_descr=>get_variable_info( lv_selparamcol_object_name && '-ENTITY_LIST[' && sy-index && ']-BO')-varvalue.
          ls_selparam-attrname = cl_tpda_script_data_descr=>get_simple_value( lv_bo_object_name && '-PARAMETER_DATA->ATTR_NAME' ).
          ls_selparam-option = cl_tpda_script_data_descr=>get_simple_value( lv_bo_object_name && '-PARAMETER_DATA->SIGN' ).
          ls_selparam-sign = cl_tpda_script_data_descr=>get_simple_value( lv_bo_object_name && '-PARAMETER_DATA->OPTION' ).
          ls_selparam-low = cl_tpda_script_data_descr=>get_simple_value( lv_bo_object_name && '-PARAMETER_DATA->LOW' ).
          ls_selparam-high = cl_tpda_script_data_descr=>get_simple_value( lv_bo_object_name && '-PARAMETER_DATA->HIGH' ).
          APPEND ls_selparam TO lt_selparam.
        ENDDO.
        REFRESH lt_col_alv.
        ls_col_alv-fieldname = ls_col_alv-content = 'ATTRNAME'.
        APPEND ls_col_alv TO lt_col_alv.
        ls_col_alv-fieldname = ls_col_alv-content = 'SIGN'.
        APPEND ls_col_alv TO lt_col_alv.
        ls_col_alv-fieldname = ls_col_alv-content = 'OPTION'.
        APPEND ls_col_alv TO lt_col_alv.
        ls_col_alv-fieldname = ls_col_alv-content = 'LOW'.
        APPEND ls_col_alv TO lt_col_alv.
        ls_col_alv-fieldname = ls_col_alv-content = 'HIGH'.
        APPEND ls_col_alv TO lt_col_alv.
        CALL METHOD cl_tpda_script_data_display=>data_display
          EXPORTING
            p_list_header = 'Query Selection Parameters'
            p_column_it   = lt_col_alv
            p_popup       = 'X'
          CHANGING
            p_data_it     = lt_selparam.

      CATCH cx_tpda_varname
            cx_tpda_data_descr_invalidated
            cx_sy_move_cast_error
            cx_tpda_table_wrong_key
            cx_tpda_script_no_simple_type
            cx_tpda_table_wrong_table_type.
        me->raise_error( ).
    ENDTRY.
  ENDMETHOD.                    "script

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

  ENDMETHOD.                    "end

  METHOD if_tpda_script_w_input~get_parameters.

    DATA l_input   TYPE tpda_transfer_struc.

    IF p_parameters_it IS INITIAL.
      l_input-id      = 'Query Service Variable Name'.
      l_input-value   = querydefaultname.
      APPEND l_input TO p_parameters_it.
    ENDIF.

  ENDMETHOD.                    "if_tpda_script_w_input~get_parameters

  METHOD if_tpda_script_w_input~set_parameter_values.

    DATA l_input   TYPE tpda_transfer_struc.

    READ TABLE p_parameter_values_it INTO l_input INDEX 1.
    queryservicename = l_input-value.

  ENDMETHOD.                    "if_tpda_script_w_input~set_parameter_values

ENDCLASS.                    "lcl_debugger_script IMPLEMENTATION
Specify the name of your query service variable in line 21. In my example, it is QS.
Start script by clicking button “Start Script”:
Now you see all four selection parameter value displayed in ALV.
To report this post you need to login first.

2 Comments

You must be Logged on to comment or reply to a post.

  1. Sandra Rossi

    Hi Jerry,

    You could use a popup to enter the name of the variable when you run the script. To be done in the INIT method. For one field, I use this method (part of code is copied from a standard script) :

    METHOD init.
        popup_one_field( EXPORTING  popup_title = 'Enter the name of query service variable'
                                    field_label = 'Name of object reference'
                         IMPORTING  field_input = queryservicename ).
    ENDMETHOD.
    
    METHODS popup_one_field
              IMPORTING
                popup_title TYPE csequence
                field_label TYPE csequence
              EXPORTING
                field_input TYPE any.
    
    METHOD popup_one_field.
        DATA: l_dd03p_tab TYPE TABLE OF dd03p,
              l_key       TYPE abap_keydescr,
              l_fields    TYPE TABLE OF sval,
              l_field     TYPE sval,
              l_rc(1)     TYPE c.
    
    *(1) get oref name
        l_field-tabname   = 'TPDA_DYNP_SRC_INFO'.
        l_field-fieldname = 'PROGRAM'.
        l_field-fieldtext = field_label.
        l_field-value      =      space.
        l_field-field_obl = abap_true.
        APPEND l_field TO l_fields.
    
    
    
        CALL FUNCTION 'POPUP_GET_VALUES'
          EXPORTING
            popup_title     = popup_title
          IMPORTING
            returncode      = l_rc
          TABLES
            fields          = l_fields
          EXCEPTIONS
            error_in_fields = 1
            OTHERS          = 2.
    
    
    
        IF sy-subrc <> 0 OR l_rc <> space.
          MESSAGE w144(tpda) .
          RAISE EXCEPTION TYPE cx_tpda_stop_scripting_request.
        ENDIF.
    
        READ TABLE l_fields INTO l_field
        INDEX 1.
        IF sy-subrc = 0.
          field_input = l_field-value.
          IF field_input IS INITIAL.
            MESSAGE w144(tpda) .
            RAISE EXCEPTION TYPE cx_tpda_stop_scripting_request.
          ENDIF.
        ELSE.
          MESSAGE w300(tpda).
          RAISE EXCEPTION TYPE cx_tpda_stop_scripting_request.
        ENDIF.
    ENDMETHOD.
    

    Regards.
    Sandra

    (3) 

Leave a Reply