SAP: SALV Grid 单元格颜色
1、SAP: SALV Grid 单元格颜色
2、详细程序代码
*&---------------------------------------------------------------------* *& Report Z17_43 *& *&---------------------------------------------------------------------* *& SALV单元格颜色 *& *&---------------------------------------------------------------------* REPORT Z17_43. INCLUDE <color>. *& 定义内表结构体 TYPES: BEGIN OF g_type_itab. INCLUDE type sflight. TYPES: t_color type lvc_t_scol, "单元格颜色 类型 end of g_type_itab. " g_type_itab 结构体 DATA: gt_itab TYPE TABLE OF g_type_itab. DATA: gs_itab TYPE g_type_itab, gr_table TYPE REF TO cl_salv_table. *& SELECT * FROM sflight into CORRESPONDING FIELDS OF TABLE gt_itab up to 25 rows. FIELD-SYMBOLS: <ls_outtab> type g_type_itab. DATA: lt_color type lvc_t_scol, ls_color type lvc_s_scol. LOOP AT gt_itab ASSIGNING <ls_outtab>. CLEAR: ls_color, lt_color. " 占据的座位数量大于 90时, 红色 。" IF <ls_outtab>-seatsocc >= 90 . ls_color-fname = 'SEATSOCC'. ls_color-color-col = col_negative. ls_color-color-int = 0 . ls_color-color-inv = 0. APPEND ls_color to lt_color. "小于50 常规色 elseIF <ls_outtab>-seatsocc >= 50 . ls_color-fname = 'SEATSOCC'. ls_color-color-col = col_normal. ls_color-color-int = 0 . ls_color-color-inv = 0. APPEND ls_color to lt_color. " 其他情况 为绿色 " else . ls_color-fname = 'SEATSOCC'. ls_color-color-col = col_positive. ls_color-color-int = 0 . ls_color-color-inv = 0. APPEND ls_color to lt_color. ENDIF. <ls_outtab>-t_color = lt_color. ENDLOOP. *& cl_salv_table=>factory( IMPORTING r_salv_table = gr_table CHANGING t_table = gt_itab ). *& DATA: lr_columns TYPE REF TO cl_salv_columns_table, lr_column TYPE REF TO cl_salv_column_table. lr_columns = gr_table->get_columns( ). lr_columns->set_color_column( 'T_COLOR' ). gr_table->display( ). *&
3、效果图
优质生活从拆开始