首页 > 代码库 > ALV的颜色分为行的颜色、列的颜色和CELL的颜色

ALV的颜色分为行的颜色、列的颜色和CELL的颜色

ALV的颜色分为行的颜色列的颜色CELL的颜色
任务要求,将一定的Tabellenfeld 用黄色填充,也就是说
CELL的颜色


DATA:
ls_cellcolorTYPElvc_s_scol,
coltabTYPElvc_t_scol,
colorTYPElvc_s_colo.

DATA: BEGIN OFfield_struc, " 在表格结构中定义颜色
            ....
           CELLCOLORTYPElvc_t_scol,
END OFfield_struc.
view_tab ist eine Structur von field_struc.

* Farbe einsetzen
color-col = ‘3‘.
color-int = ‘1‘.
color-inv= ‘0‘.

LOOP ATxxx INTO view_tab.
   IF两表中数据值不等.
       ls_cellcolor-fname = ‘WEARS‘. " 指明列名
        ls_cellcolor-color = color.
        APPENDls_cellcolor TO coltab.
        CLEARls_cellcolor.
   ENDIF.
    view_tab-cellcolor = coltab.
   APPENDview_tabTOit_view.
ENDLOOP.

行的颜色[Quelle: http://blog.csdn.net/zltpc007/archive/2008/10/18/3095850.aspx]
 需要在要显示的内表中添加一个字段放置颜色信息,比如COLOR(4) TYPE C .

 ITAB-COLOR = ‘C700‘.

 

    此外,还要根据采用的FM方式还是CLASS方式设置一下显示颜色

  • FM方式:LS_LAYOUT-INFO_FIELDNAME = ‘COLOR‘.

              CALL FUNCTION ‘REUSE_ALV_GRID_DISPLAY‘

                       EXPORTING
                              IS_LAYOUT   = LS_LAYOUT
                               IT_FIELDCAT = LT_FIELDCAT
                           TABLES
                                T_OUTTAB    = ITAB.

·         CLASS方式: SLA-INFO_FNAME = ‘COLOR‘.

             CALL METHOD GO_GRID->SET_TABLE_FOR_FIRST_DISPLAY

                              EXPORTING
                                             IS_VARIANT                    = GS_VARIANT
                                             I_SAVE                             = ‘A‘
IS_LAYOUT                     =SLA
CHANGING
                                             IT_OUTTAB                     = ITAB[]
                                             IT_FIELDCATALOG       = GT_FIELDCAT[]
                              EXCEPTIONS
                                             INVALID_PARAMETER_COMBINATION = 1
                                             PROGRAM_ERROR              = 2
                                             TOO_MANY_LINES                = 3
                                             OTHERS                                   = 4.

列的颜色


设置FIELDCAT就可以了,如:TMP_FIELDCAT-EMPHASIZE = ‘C500‘.  "列的颜色