效果图:
定义的status
code:
REPORT
zlm_alv_002 .
DATA :
gt_spfli
TYPE
TABLE
OF
spfli .
DATA :
ls_spfli
TYPE
spfli .
DATA :
gr_table
TYPE
REF
TO
cl_salv_table .
DATA :
gr_functions
TYPE
REF
TO
cl_salv_functions_list .
DATA :
gr_events
TYPE
REF
TO
cl_salv_events_table .
DATA :
gr_selections
TYPE
REF
TO
cl_salv_selections .
CLASS
lcl_handle_events
DEFINITION .
PUBLIC
SECTION .
METHODS :
on_user_command
FOR
EVENT
added_function
OF
cl_salv_events
IMPORTING
e_salv_function ,
on_double_click
FOR
EVENT
double_click
OF
cl_salv_events_table
IMPORTING
row
column .
ENDCLASS .
"lcl_handle_events
DEFINITION
DATA :
event_handler
TYPE
REF
TO
lcl_handle_events .
START-OF-SELECTION .
SELECT
*
INTO
CORRESPONDING
FIELDS
OF
TABLE
gt_spfli
FROM
spfli
UP
TO
100
ROWS .
CALL
METHOD
cl_salv_table =>factory
IMPORTING
r_salv_table
=
gr_table
CHANGING
t_table
=
gt_spfli .
gr_table ->set_screen_status (
pfstatus
=
'SALV_TABLE_STANDARD'
report
=
sy -repid
set_functions
=
gr_table ->c_functions_all
) .
gr_events
=
gr_table ->get_event (
) .
CREATE
OBJECT
event_handler .
SET
HANDLER
event_handler ->on_user_command
FOR
gr_events .
SET
HANDLER
event_handler ->on_double_click
FOR
gr_events .
*
Set
up
selections.
gr_selections
=
gr_table ->get_selections (
) .
gr_selections ->set_selection_mode (
1
) .
"Single
*
Display
gr_table ->display (
) .
CLASS
lcl_handle_events
IMPLEMENTATION .
METHOD
on_user_command .
"Get
the
selection
rows
DATA :
lr_selections
TYPE
REF
TO
cl_salv_selections .
DATA :
lt_rows
TYPE
salv_t_row .
DATA :
ls_rows
TYPE
i .
DATA :
message
TYPE
string .