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: 

3 methodes in one class

aboooood
Participant
0 Kudos
1,036

Hello Experts, Im trying to call 3 methodes in one class. so i habe a report wich is SALV and there is 3 cells each one should be clickable. one with link_click and the others with double_click.

TERMN : link_click

LIGHT : double_click

Bearbeiter: double_click_pool

this how should it be but in my case Light calls double_click and double_click_pool when i click on it.

Bearbeiter calls link_click.

could u guys help or tell me where my problem is?

class def. 
CLASS lcl_handle_events DEFINITION.
PUBLIC SECTION.
METHODS:
on_double_click
FOR EVENT double_click OF cl_salv_events_table
IMPORTING
row
column .
METHODS: on_link_click FOR EVENT link_click OF
cl_salv_events_table
IMPORTING row column.
METHODS:
on_double_click_pool
FOR EVENT double_click OF cl_salv_events_table
IMPORTING
row
column .
ENDCLASS.
here where i create the objekt
SET HANDLER event_handler->on_link_click FOR gr_events.
lr_column ?= lr_columns->get_column( 'TERMN' ).
lr_column->set_cell_type( if_salv_c_cell_type=>hotspot ).


 CREATE OBJECT event_handler.
SET HANDLER event_handler->on_double_click FOR gr_events. lr_column ?= lr_columns->get_column( 'LIGHT' ). lr_column->set_cell_type( if_salv_c_cell_type=>hotspot ). CREATE OBJECT event_handler. SET HANDLER event_handler->on_double_click_pool FOR gr_events. lr_column ?= lr_columns->get_column( 'BEARBEITER' ). lr_column->set_cell_type( if_salv_c_cell_type=>hotspot ). lr_salv->display( ). Implement cLASS lcl_handle_events IMPLEMENTATION. METHOD on_double_click. #logic ENDMETHOD. METHOD on_link_click. #logic METHOD on_double_click_pool. #logic ENDMETHOD. ENDCLASS.
1 ACCEPTED SOLUTION

thkolz
Contributor
936

Your methods on_double_click and on_double_click_pool are both listening to event double_click.
That's why they're both called at the same time.

If you want a different behavior for double click for various fields, you need to handle it in one method:

METHOD on_double_click.
    CASE column.
      WHEN 'COLUMN1'.
        " Do something
      WHEN 'COLUMN2'.
        " Do something else
    ENDCASE.
ENDMETHOD.
10 REPLIES 10

DominikTylczyn
Active Contributor
936

Please, use the CODE button to format source code:

Otherwise it is hardly readable.

thkolz
Contributor
937

Your methods on_double_click and on_double_click_pool are both listening to event double_click.
That's why they're both called at the same time.

If you want a different behavior for double click for various fields, you need to handle it in one method:

METHOD on_double_click.
    CASE column.
      WHEN 'COLUMN1'.
        " Do something
      WHEN 'COLUMN2'.
        " Do something else
    ENDCASE.
ENDMETHOD.

0 Kudos
936

ok cool now Light column ist calling the wrong methode, but Bearbeiter still calling link_click

936

Maybe you can have a look at report SALV_DEMO_TABLE_EVENTS.

936

oh i sat the hotspot twice for the doubl_click cells it should be only one for light and bearbeiter. now it works thx alot

aboooood
Participant
936

3a9e4ce873a94034b33dc62b0ce600ee its har to use always takes a few lines into the Code layout.

now should be better i guess

abo
Active Contributor
936

There should be a hotkey to add this comment, really: remember to format the code with the CODE button above, to make it readable. Take care to copy from the editor in display mode (not edit), otherwise you get html nodes mixed in.

DominikTylczyn
Active Contributor
936

What works for me when pasting source code is Shift+Ctrl+V that pastes plain text only without any formating.

aboooood
Participant
936

c5e08e0478aa4727abc4482f5be390b2 ahh ok thx for the tip sir!

Sandra_Rossi
Active Contributor
936

After posting, you should systematically refresh the page and review the formatting (it's how to deal with the forum quirks).