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 field click using SALV

Former Member
0 Kudos

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.

1 ACCEPTED SOLUTION

franois_henrotte
Active Contributor

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.


2 REPLIES 2

franois_henrotte
Active Contributor

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.


DoanManhQuynh
Active Contributor
0 Kudos

The link you found is correct because you need to handle hotspot click event to do the submit thing