SAP:SALV双击事件(Double Click)
*&---------------------------------------------------------------------*
*& Report Z17_30
*&
*&---------------------------------------------------------------------*
*& SALV 双击事件
*&
*&---------------------------------------------------------------------*
REPORT Z17_30.
*&---------------------------------------------------------------------*
*& Class (Definition) lcl_handle_events
*&---------------------------------------------------------------------*
* Text
*----------------------------------------------------------------------*
CLASS lcl_handle_events DEFINITION.
PUBLIC SECTION.
METHODS:
on_double_click FOR event double_click of cl_salv_events_table
IMPORTING row column.
ENDCLASS. "lcl_handle_events Definition .
*&---------------------------------------------------------------------*
*& Class (Implementation) lcl_handle_events
*&---------------------------------------------------------------------*
* Text
*----------------------------------------------------------------------*
CLASS lcl_handle_events IMPLEMENTATION.
METHOD ON_double_click .
PERFORM SHOW_CELL_INFO USING row column 'is selected.' .
ENDMETHOD. " ON_DOUBLE_CLICK
ENDCLASS. "lcl_handle_events IMPLEMENTATION.
*& 定义内表
DATA: gt_itab TYPE TABLE OF sflight,
gr_table type REF TO cl_salv_table,
gr_event TYPE REF TO lcl_handle_events.
*& 选择数据
START-OF-SELECTION.
SELECT * FROM sflight INTO CORRESPONDING FIELDS OF TABLE
gt_itab UP TO 25 ROWS.
cl_salv_table=>factory(
IMPORTING
r_salv_table = gr_table
CHANGING
t_table = gt_itab
).
*&
DATA: lr_event TYPE REF TO CL_salv_events_table.
lr_event = gr_table->get_event( ).
create object gr_event .
set handler gr_event->on_double_click for lr_event .
gr_table->display( ).
*&---------------------------------------------------------------------*
*& Form SHOW_CELL_INFO
*&---------------------------------------------------------------------*
* Text
* 双击单元格显示信息:(例子:第二行,预约总量 列)。
* I:OK:000 2 Line PAYMENTSUM Column is selected.
*
*----------------------------------------------------------------------*
FORM show_cell_info USING p_row TYPE i
p_column type lvc_fname
p_text type string.
data: l_row type char10.
WRITE P_ROW TO L_ROW LEFT-JUSTIFIED.
CONCATENATE l_row 'Line' p_column 'Column' p_text
into p_text separated by space .
MESSAGE i000(Ok) WITH P_TEXT .
ENDFORM. " SHOW_CELL_INFO .
*&
效果图: