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: 

2 ALVs on one screen using same event class

Former Member
0 Kudos

Hello,

I have implemented my event class for my ALV, and it works. Now i have added a second alv to my screen, and this also activates the event fx. when clicking te alv, it also sends the correct row and collumn etc.

But my problem is, how do i detect in which alv i fx. doubble clicked?

/Kenneth

1 ACCEPTED SOLUTION

raymond_giuseppi
Active Contributor

Every event has an implicit (formal) parameter "sender", use this parameter to identify the ALV grid

class lcl_event_receiver definition.

  public section.

    methods:

      handle_double_click

        for event double_click of cl_gui_alv_grid

            importing e_row e_column sender,

(...)

class lcl_event_receiver implementation.

  method handle_double_click.

    case sender.

      when grid_0201. " the ref to cl_gui_alv_gri

        read table itab_0201 index e_row-index into record_0201.

        perform recd_display_201 using record_0201.

      when grid_0202.

        read table itab_0202 index e_row-index into record_0202.

        perform recd_display_202 using record_0202.

(...)

Regards,

Raymond

6 REPLIES 6

Private_Member_49934
Contributor
0 Kudos

If you see the DBLCLICK_ROW_COL event of CL_GUI_ALV_GRID you will see only two parameters (

ROW_ID, COL_ID). It means it will never return you the reference of the ALV grid.

Recomended solution.

1) Create two different handler method a) one for grid2(say method_a) b) other of the grid2(say method_b)

2) Register the two methods for diffrent alv. say method_a will always be triggered for grid1 and method_b will always be triggered for grid 2.

    set handler handler_ref->method_a for ref_alv1.
    set handler handler_ref->method_b for ref_alv2.


raymond_giuseppi
Active Contributor

Every event has an implicit (formal) parameter "sender", use this parameter to identify the ALV grid

class lcl_event_receiver definition.

  public section.

    methods:

      handle_double_click

        for event double_click of cl_gui_alv_grid

            importing e_row e_column sender,

(...)

class lcl_event_receiver implementation.

  method handle_double_click.

    case sender.

      when grid_0201. " the ref to cl_gui_alv_gri

        read table itab_0201 index e_row-index into record_0201.

        perform recd_display_201 using record_0201.

      when grid_0202.

        read table itab_0202 index e_row-index into record_0202.

        perform recd_display_202 using record_0202.

(...)

Regards,

Raymond

0 Kudos

Hey Raymond, i am a bit in doubt about:

when grid_0201

Because this is what sender contains:

{O:64*\CLASS=CL_SALV_EVENTS_TABLE}

/Kenneth

0 Kudos

Use the field defined for reference to cl_gui_alv_grid :

(The sample comes from an actual productive program )

DATA:

(...)

      grid_0201 type ref to cl_gui_alv_grid,

      grid_0202 type ref to cl_gui_alv_grid,

(...)

Adapt the code if you use another class like CL_SALV_TABLE. Use the ref to CL_SALV_EVENTS_TABLE associated to the grid, look for a code like

<ref_to_event> = <ref_to_alv>->get_event().

Regards,

Raymond

0 Kudos

Ahh, i needed to do the "when" on my cl_salv_events_table

Now it works, thanks 🙂

Former Member
0 Kudos

Hi,

One way to do this could be, you can use object of the custom container that is the object of class CL_GUI_CUSTOM_CONTAINER. call method GET_NAME of this class. this returns the name of the custom container, so in turn you know which alv you have place in that particular container, and that is the one which was double clicked.