09-26-2018 3:51 PM
Dear friends,
i'm trying to get to the "on click" event of my ALV grid (cl_salv_table),
there i'll submit the field to another program.
Already defined the column as 'Hotspot' and the link is enabled, but where do i need to add the 'submit' statement?
I found something but looks like this guy over here implemented something much complicated than i need: https://archive.sap.com/discussions/thread/1817786
" Create Instance of ALV object
CALL METHOD cl_salv_table=>factory
IMPORTING
r_salv_table = lo_grid
CHANGING
t_table = lt_result.
lo_columns = lo_grid->get_columns( ).
" Optimizes the columns width
lo_columns->set_optimize( abap_true ).
lv_fname = 'PARTNER'.
TRY .
lo_column ?= lo_columns->get_column( lv_fname ).
CATCH cx_salv_not_found.
ENDTRY.
TRY .
lo_column->set_cell_type( value = if_salv_c_cell_type=>hotspot ).
CATCH cx_salv_data_error.
ENDTRY.
" All events
lo_events = lo_grid->get_event( ).
" Display table
lo_grid->display( ).
thanks for help, Ofir.
09-26-2018 3:59 PM
Hi, you need to create a listener for the event.
SET HANDLER ob_listener->on_simple_click FOR lo_grid->get_event( ).
The listener must have a method defined like this (the sender parameter is optional) :
METHODS: on_simple_click FOR EVENT link_click OF cl_salv_events_table
IMPORTING sender row column.
And the code inside the method will look like this :
METHOD on_simple_click.
IF column = lv_fname.
READ TABLE lt_result ASSIGNING FIELD-SYMBOL(<ls_result>) INDEX row.
CHECK sy-subrc EQ 0.
"Do something with the selected record
ENDIF.
ENDMETHOD.
09-26-2018 3:59 PM
Hi, you need to create a listener for the event.
SET HANDLER ob_listener->on_simple_click FOR lo_grid->get_event( ).
The listener must have a method defined like this (the sender parameter is optional) :
METHODS: on_simple_click FOR EVENT link_click OF cl_salv_events_table
IMPORTING sender row column.
And the code inside the method will look like this :
METHOD on_simple_click.
IF column = lv_fname.
READ TABLE lt_result ASSIGNING FIELD-SYMBOL(<ls_result>) INDEX row.
CHECK sy-subrc EQ 0.
"Do something with the selected record
ENDIF.
ENDMETHOD.
09-27-2018 2:50 AM
The link you found is correct because you need to handle hotspot click event to do the submit thing