DATA:
lo_cols TYPE REF TO cl_salv_columns,
lo_events TYPE REF TO cl_salv_events_table,
lo_column TYPE REF TO cl_salv_column_list,
cxroot TYPE REF TO cx_root.
TRY.
cl_salv_table=>factory(
IMPORTING
r_salv_table = go_salv "导出ALV的容器对象
CHANGING
t_table = gt_likp ). "内容表
CATCH cx_root INTO cxroot.
ENDTRY.
lo_cols = go_salv->get_columns( ).
lo_column ?= lo_cols->get_column( 'CBOX' ).
lo_column->set_cell_type( if_salv_c_cell_type=>checkbox_hotspot ).
lo_column->set_output_length( 10 ).
lo_events = go_salv->get_event( ).
* event handler
SET HANDLER go_event->on_link_click FOR lo_events.
"重新设置列名称
go_salv->get_columns( )->get_column( 'CBOX' )->set_long_text( TEXT-023 )."
IF go_salv IS BOUND."设置窗口大小与位置-
go_salv->set_screen_popup(
start_column = 30
end_column = 100
start_line = 5
end_line = 20 ).
go_salv->display( ).
ENDIF.
单击事件
METHODS on_link_click FOR EVENT link_click OF cl_salv_events_table
IMPORTING row column.
FORM frm_on_link_click USING row.
READ TABLE gt_likp ASSIGNING FIELD-SYMBOL(<fs_likp>) INDEX row.
IF sy-subrc = 0.
<fs_likp>-cbox = COND #( WHEN <fs_likp>-cbox IS INITIAL THEN 'X'
ELSE '' ).
ENDIF.
go_salv->refresh( ).
ENDFORM.