Search code examples
abapgetselectionalv

get_selected_rows from alv after handler PAI logic


I have an ALV in container on screen 0100. It's created via class CL_SALV_TABLE.

The problem is that I can't get selected row via go_alv_dms->get_selections( )->get_selected_rows( ) after pressing a button on the screen (2 on the screenshot).

I can access the selected rows with no problem if the button is in the ALV status bar (1 on the screenshot) though. It seems like pressing the button outside of ALV cleans selections of it.

enter image description here

Register selection when show ALV:

  ...
  lo_selections = go_alv_dms->get_selections( ).
  lo_selections->set_selection_mode( if_salv_c_selection_mode=>row_column ).
  lo_events = go_alv_dms->get_event( ).
  CREATE OBJECT go_handler.
  SET HANDLER go_handler->on_user_command2 FOR lo_events.
  ...

PAI of the screen button logic:

 go_handler->on_user_command2( gv_ok_0100 ).

Method on_user_command2:

    case gv_ok_0100.
      when 'OK'.
         ...
         lt_rows = go_alv_dms->get_selections( )->get_selected_rows( ).
         ...
    ENDCASE.

Solution

  • After listening to the opinions of colleagues and searching for an answer on the Internet, I came to the conclusion that this is class CL_SALV_TABLE restriction. I rewrote the program on class CL_ALV_GRID and it's earned. I like CL_SALV_TABLE and will be glad if someone refutes my statement.