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: 

ALV OO: how to handle events from two alv_grids ?

Former Member
0 Kudos

Hi guys!

hope someone can help me out.

In my program i have three dynpros with differt alv of cl_gui_alv_grid.

In each of these grids i want to implement a "handle_double_click" event.

How can i do this?

acually i have my class lcl_event_receiver and there i have implemented the handle_double_click method.

but how can i figure out which grid triggered the event?

in each dynpro i have

SET HANDLER event_receiver->handle_double_click FOR grid1.

SET HANDLER event_receiver->handle_double_click FOR grid2.

SET HANDLER event_receiver->handle_double_click FOR grid3.

now in the class implementation i need something like

if grid 1 X

if grid 2 Y

1 ACCEPTED SOLUTION

former_member188685
Active Contributor
0 Kudos

using the sender addition you can differentiate.

double_click         for event double_click
                         of cl_gui_alv_grid
                         importing e_row
                                   e_column
                                   es_row_no
                                   sender,    "<====This can be used

sender hold the Current Grid reference , based on that you can differentiate.

8 REPLIES 8

former_member188685
Active Contributor
0 Kudos

using the sender addition you can differentiate.

double_click         for event double_click
                         of cl_gui_alv_grid
                         importing e_row
                                   e_column
                                   es_row_no
                                   sender,    "<====This can be used

sender hold the Current Grid reference , based on that you can differentiate.

Former Member
0 Kudos

thanks for that

but i can't find the information in "sender" which helps me.

can you show me where it is?

how can i figure out if the caller is e.g. "grid1"

0 Kudos

you can add sender addition to your double_click method.

Defintion

double_click         for event double_click
                         of cl_gui_alv_grid
                         importing e_row
                                   e_column
                                   es_row_no
                                   sender.

sender will return the Current Grid object. you can freely add the extra parameter sender. that will tell you which grid it is ..

implementation.

method double_click.
  if sender = gid1.
   "here you can handle the Grid1
  endif.
  if sender = gid2.
   "here you can handle the Grid2
  endif.

  endmethod.                    "double_click

I hope you got what i am saying...

0 Kudos

I did this by defining a totally separate event receiver for each grid so that you always know which grid you are dealing with.

DATA:
    event_receiver1      TYPE REF TO lcl_event_receiver,
    event_receiver2      TYPE REF TO lcl_event_receiver.

CREATE OBJECT event_receiver1.
     SET HANDLER event_receiver1->double_click_versions for g_grid1.

     CREATE OBJECT event_receiver2.
     SET HANDLER event_receiver2->double_click_payments FOR g_grid2.

CLASS lcl_event_receiver DEFINITION.

  PUBLIC SECTION.
    METHODS:
      double_click_versions
        FOR EVENT double_click OF cl_gui_alv_grid
        IMPORTING e_row e_column,
      double_click_payments
         FOR EVENT double_click OF cl_gui_alv_grid
         IMPORTING e_row e_column,

  ENDCLASS.

0 Kudos

This is possible, but you may need to have n number of handlers when you are dealing with n no of grids, to avoid that we can do with one grid.

0 Kudos

Yes, using one handler is much better but I didn't know how to do it at the time.....I'll know next time, thanks.

Former Member
0 Kudos

Hi,

Instead of using different double click even

use the below method to get selected row and based on that go for next detail display in user command

* Get selected Rows to Update New Entries
  CALL METHOD g_alvgrid->get_selected_rows
    IMPORTING
      et_index_rows = i_index_rows.

It will be helpful.

Regards,

Nandha

Former Member
0 Kudos

it works like this

Data:

grid1 TYPE REF TO cl_gui_alv_grid.

in the handle_double_click method you can do

if sender = grid1.

this works!

thanks