[英]get_selected_rows from alv after handler PAI logic
我在屏幕0100
上的容器中有一個 ALV。 它是通過類CL_SALV_TABLE
創建的。
問題是我無法通過go_alv_dms->get_selections( )->get_selected_rows( )
在按下屏幕上的按鈕(屏幕截圖上的 2 go_alv_dms->get_selections( )->get_selected_rows( )
后獲得選定的行。
如果按鈕位於 ALV 狀態欄(屏幕截圖上的 1)中,我可以毫無問題地訪問所選行。 似乎按下 ALV 外部的按鈕會清除它的選擇。
顯示 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:
go_handler->on_user_command2( gv_ok_0100 ).
方法on_user_command2
:
case gv_ok_0100.
when 'OK'.
...
lt_rows = go_alv_dms->get_selections( )->get_selected_rows( ).
...
ENDCASE.
聽了同事的意見,在網上找了個答案,得出的結論是,這是CL_SALV_TABLE
類的限制。 我在類CL_ALV_GRID
上重寫了程序,它是賺來的。 我喜歡CL_SALV_TABLE
,如果有人反駁我的陳述,我會很高興。
DATA gr_alv TYPE REF TO cl_salv_table.
DATA it_rows TYPE salv_t_row.
...
gr_alv->get_metadata( ). " Call this method before getting selected rows
it_rows = gr_alv->get_selections( )->get_selected_rows( ).
參考: https : //answers.sap.com/questions/4693234/getselectedrows-returns-nothing.html
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.