效果: carrid 列的第二行 设置为热键,
CONNID 第三行设置为button
code:
*&---------------------------------------------------------------------*
*& Report ZLM_ALV_009
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*
REPORT zlm_alv_009 .
*
CLASS lcl_report DEFINITION .
*
PUBLIC SECTION .
TYPES : BEGIN OF spfli_struc .
INCLUDE TYPE spfli .
TYPES : i_celltype TYPE salv_t_int4_column ,
END OF spfli_struc .
DATA : gt_spfli TYPE STANDARD TABLE OF spfli_struc .
* ALV reference
DATA : o_alv TYPE REF TO cl_salv_table .
METHODS :
get_data , " data selection
generate_output . " Generating output
*
PRIVATE SECTION .
METHODS :
set_columns . " Set columns
ENDCLASS . "lcl_report 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 .
*
METHOD get_data .
* data selection
SELECT *
FROM spfli
INTO CORRESPONDING FIELDS OF TABLE gt_spfli .
FIELD-SYMBOLS : 《lfs_spfli》 LIKE LINE OF gt_spfli .
DATA : lt_celltype TYPE salv_t_int4_column .
DATA : ls_celltype LIKE LINE OF lt_celltype .
LOOP AT gt_spfli ASSIGNING 《lfs_spfli》 .
CLEAR : lt_celltype .
* Only CARRID for 2nd record
IF sy -tabix = 2 .
ls_celltype -columnname = 'CARRID' .
ls_celltype - value = if_salv_c_cell_type => hotspot .
APPEND ls_celltype TO lt_celltype .
* Only CONNID for 3rd record
ELSEIF sy -tabix = 3 .
ls_celltype -columnname = 'CONNID' .
ls_celltype - value = if_salv_c_cell_type =>button .
APPEND ls_celltype TO lt_celltype .
* Entire 5th record
ELSEIF sy -tabix = 5 .
ls_celltype -columnname = ".
ls_celltype - value = if_salv_c_cell_type => hotspot .
APPEND ls_celltype TO lt_celltype .
ENDIF .
*& Report ZLM_ALV_009
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*
REPORT zlm_alv_009 .
*
CLASS lcl_report DEFINITION .
*
PUBLIC SECTION .
TYPES : BEGIN OF spfli_struc .
INCLUDE TYPE spfli .
TYPES : i_celltype TYPE salv_t_int4_column ,
END OF spfli_struc .
DATA : gt_spfli TYPE STANDARD TABLE OF spfli_struc .
* ALV reference
DATA : o_alv TYPE REF TO cl_salv_table .
METHODS :
get_data , " data selection
generate_output . " Generating output
*
PRIVATE SECTION .
METHODS :
set_columns . " Set columns
ENDCLASS . "lcl_report 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 .
*
METHOD get_data .
* data selection
SELECT *
FROM spfli
INTO CORRESPONDING FIELDS OF TABLE gt_spfli .
FIELD-SYMBOLS : 《lfs_spfli》 LIKE LINE OF gt_spfli .
DATA : lt_celltype TYPE salv_t_int4_column .
DATA : ls_celltype LIKE LINE OF lt_celltype .
LOOP AT gt_spfli ASSIGNING 《lfs_spfli》 .
CLEAR : lt_celltype .
* Only CARRID for 2nd record
IF sy -tabix = 2 .
ls_celltype -columnname = 'CARRID' .
ls_celltype - value = if_salv_c_cell_type => hotspot .
APPEND ls_celltype TO lt_celltype .
* Only CONNID for 3rd record
ELSEIF sy -tabix = 3 .
ls_celltype -columnname = 'CONNID' .
ls_celltype - value = if_salv_c_cell_type =>button .
APPEND ls_celltype TO lt_celltype .
* Entire 5th record
ELSEIF sy -tabix = 5 .
ls_celltype -columnname = ".
ls_celltype - value = if_salv_c_cell_type => hotspot .
APPEND ls_celltype TO lt_celltype .
ENDIF .