Skip to Content
avatar image
Former Member

CL_SALV_TABLE - how to trigger Double_Click question

I am trying to find how to trigger an event on double click similar to using Event Double_Click in Class CL_GUI_ALV_GRID I am fresh out of the ABAP OO class and everything is a blur. This is what I did. I created a program that with

Data: r_grid TYPE REF TO cl_salv_table.

CALL METHOD CL_SALV_TABLE=>FACTORY

Importing R_SALV_TABLE = r_grid

Changing ITAB.

I then tried to create an Include program to define a Local Class

&----


*& Include ZSD_DISPLAY_CUSTOMER

&----


class lcl_event_handler definition.

PUBLIC SECTION.

METHODS: on_double_click for event double_click of cl_gui_alv_grid

  • METHODS: on_double_click for event double_click of cl_salv_table

IMPORTING es_row_no e_column.

ENDCLASS.

class lcl_event_handler IMPLEMENTATION.

METHOD on_double_click.

Data: IT_CUSTHIER type ZSD11_CUST_HIER_TABLE_TYPE.

Data: WK_CUSTHIER LIKE LINE OF IT_CUSTHIER.

types: BEGIN OF custhier_x,

custhier like WK_CUSTHIER,

number TYPE int4,

quantity type MENGE_D,

dollars_n_cents type DMBTR,

END OF custhier_x.

data: it_custhier_x type STANDARD TABLE OF custhier_x.

data: wk_custhier_x like LINE OF it_custhier_x.

read table it_custhier_x into wk_custhier_x

index es_row_no-row_id.

data: wk_vkorg type vkorg.

data: wk_vtweg type vtweg.

data: wk_spart type spart.

wk_vkorg = '3290'.

wk_vtweg = '00'.

wk_spart = '00'.

SET PARAMETER ID: 'KUN' field wk_custhier_x-custhier-kunnr.

SET PARAMETER ID: 'VKO' field wk_vkorg.

SET PARAMETER ID: 'VTW' field wk_vtweg.

SET PARAMETER ID: 'SPA' field wk_spart.

call TRANSACTION 'VD03' AND SKIP FIRST SCREEN.

ENDMETHOD.

ENDCLASS.

When I try to do a syntax check I get this error

The Handler Method ON_DOUBLE_CLICK is only defined for trigger objects of CL_GUI_ALV_GRID, but the system tried to register a trigger object of CL_SALV_TABLE

Any suggestions on what I need to do in order to trigger a event for double click ?

Thanks

Edited by: Bob Ackerman on Sep 22, 2010 11:25 AM

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

2 Answers

  • Sep 22, 2010 at 04:06 PM

    Since you are using the CL_SALV_TABLE, you need to register the event which is known to CL_SALV_TABLE.

    * event handler
        METHODS:
          on_DOUBLE_CLICK
            FOR EVENT DOUBLE_CLICK OF cl_salv_events_table
              IMPORTING
                row
                column  .
    *...
    *... register to the events of cl_salv_table
      data: gr_events type ref to lcl_handle_events.
      data: lr_events type ref to cl_salv_events_table.
      lr_events = gr_table->get_event( ).
      create object gr_events.
      set handler gr_events->on_double_click for lr_events.
    

    Check my blog post http://help-abap.blogspot.com/2008/09/salv-model-8-add-handle-hotspot.html. This gives you an idea how to handle the event.

    You can also check the std test program SALV_DEMO_TABLE_COLUMNS.

    Regards,

    Naimesh Patel

    Add comment
    10|10000 characters needed characters exceeded

    • Former Member Former Member

      I found the problem. I was defining the internal table again in the class implementation for method on_double_click. So the class was trying to read the local class version of the internal table. When I took out the definition of the internal table in the class, the internal table showed values.

      The internal table is filled when the Factory method is called. The ALV screen is populated when it is displayed. Double clicking on a line in the internal table returns the Row and Column of the line that was double clicked on when the on_double_click event is called

      Edited by: Bob Ackerman on Sep 23, 2010 11:32 AM

  • Sep 22, 2010 at 04:13 PM

    METHODS: on_double_click for event double_click of cl_gui_alv_grid

    Obviously you are trying to register handler for class cl_gui_alv_grid which has nothing to do with cl_salv_table .

    It should be registered like

    methods: on_double_click for event double_click of cl_salv_events_table
            importing row column.
    

    Please refer standard program SALV_DEMO_TABLE_EVENTS for more information on this.

    Regards

    Marcin

    Add comment
    10|10000 characters needed characters exceeded