欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

【SAP】ABAP——ALV设置某一个单元格的颜色

程序员文章站 2022-07-13 15:20:40
...

当满足某些条件时,则某个字段的输出单元格显示为红色,当不满足时,则显示为原来的颜色。

DATA:BEGIN OF gs_out,
  matnr TYPE ekpo-matnr,"物料号
  werks TYPE mardh-werks,"工厂
  jszzt LIKE mardh-labst,"周转天
  color TYPE lvc_t_scol,"单元格颜色
END OF gs_out.
DATA:wa_out LIKE gs_out,
     gt_out LIKE TABLE OF gs_out.

loop at gt_out into wa_out.
"期间耗用量为0(准呆滞物料),或周转天>系统周转天,周转天显示为红色
    IF wa_data-erfmg = 0 OR wa_data-jszzt > wa_data-jhzzt.
      DATA: ls_color TYPE lvc_s_scol.
      ls_color-fname = 'JSZZT'."周转天字段
      ls_color-color-col = '6'.
      ls_color-color-int = '1'.
      ls_color-color-inv = '0'.
      ls_color-nokeycol = 'X'."覆盖码颜色
      APPEND ls_color TO wa_data-color.
    ENDIF.
ENDLOOP.

*ALV部分
 wa_layout-coltab_fieldname = 'COLOR'."此处需要设置
 wa_layout-zebra = 'X'.
 wa_layout-colwidth_optimize = 'X'.