效果:
本来应该定义一个check box字段,懒得鼓捣了,就直接用client当check box用了,代码里自己注意一下
code:
*&---------------------------------------------------------------------*
*& Report ZLM_ALV_006
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*
REPORT zlm_alv_006
.
*
*----------------------------------------------------------------------*
* CLASS lcl_report DEFINITION
*----------------------------------------------------------------------*
CLASS lcl_report
DEFINITION
.
*
PUBLIC
SECTION
.
*
DATA
: gt_spfli
TYPE
STANDARD
TABLE
OF spfli
.
*
* ALV reference
DATA
: o_alv
TYPE
REF
TO cl_salv_table
.
*
METHODS
:
* data selection
get_data
,
*
* Generating output
generate_output
.
*
*
ENDCLASS
.
"lcl_report DEFINITION
*
CLASS lcl_event_handler
DEFINITION
.
*
PUBLIC
SECTION
.
METHODS
:
on_link_click
FOR
EVENT link_click
OF cl_salv_events_table
IMPORTING row column
.
*
ENDCLASS
.
"lcl_event_handler DEFINITION
*
*
START-OF-SELECTION
.
DATA
: lo_report
TYPE
REF
TO lcl_report
.
*
CREATE OBJECT lo_report
.
*
lo_report
->get_data
(
)
.
*
lo_report
->generate_output
(
)
.
*
*----------------------------------------------------------------------*
* CLASS lcl_report IMPLEMENTATION
*----------------------------------------------------------------------*
CLASS lcl_report
IMPLEMENTATION
.
*
METHOD get_data
.
* data selection
SELECT *
FROM spfli
INTO
TABLE gt_spfli
.
ENDMETHOD
.
"get_data
*
*.......................................................................
METHOD generate_output
.
*
* exception class
"display setting
DATA
: lr_display
TYPE
REF
TO cl_salv_display_settings
.
DATA
: lx_msg
TYPE
REF
TO cx_salv_msg
.
TRY
.
cl_salv_table
=>factory
(
IMPORTING
r_salv_table
= o_alv
CHANGING
t_table
= gt_spfli
)
.
CATCH cx_salv_msg
INTO lx_msg
.
ENDTRY
.
*
*...Get all the Columns
DATA
: lo_cols
TYPE
REF
TO cl_salv_columns
.
lo_cols
= o_alv
->get_columns
(
)
.
*
* set the Column optimization
lo_cols
->set_optimize
(
'X'
)
.
*
*...Process individual columns
DATA
: lo_column
TYPE
REF
TO cl_salv_column_list
.
*
* Change the properties of the Columns KUNNR
TRY
.
lo_column ?= lo_cols->get_column( 'MANDT' ).
* lo_column ?= lo_cols->get_column( 'CHECK' ).
lo_column
->set_cell_type
( if_salv_c_cell_type
=>checkbox_hotspot
)
.
lo_column
->set_output_length
(
10
)
.
CATCH cx_salv_not_found
.