ALV color setting practice and summary

ALV color setting practice and summary

1. Row color

    1. Add a field color(4) TYPE c to the result internal table to store four-digit color values.

    2. Assign a value to this field in the inner table loop, such as 'C310' yellow.

    3. The most critical point is to set the name of the color field in the layout structure, the code is as follows:

            is_layout-info_fieldname = 'COLOR'." row color field

        is_layout is the type slis_layout_alv structure of an ALV we declared.

2. Column color

   The column color is relatively simple. When we fill the structure it_fieldcat TYPE slis_t_fieldcat_alv, we can directly assign values ​​to each column.

three. cell color

    1. Add field cellcolor TYPE lvc_t_scol to the result internal table. This is an internal table used to store the color of the cell.

    2. Assign a value to the inner table in the inner table loop, the sample code is as follows:

       PERFORM fill_cellcolor CHANGING wa_result-cellcolor. " Cell highlight (yellow)

*&---------------------------------------------------------------- ---------------------*
*& Form fill_cellcolor
*&---------------------- -----------------------------------------------*
* Living单元格颜色数据
*--------------------------------------------- -------------------------*
FORM fill_cellcolor CHANGING p_cellcolor type lvc_t_scol.

  DATA wa_cellcolor TYPE lvc_s_scol . " Public keyword

  DEFINE set_color.
    wa_cellcolor-fname = &1.
    wa_cellcolor-color-col = '3'.
    wa_cellcolor-color-int = '1'.
    wa_cellcolor-color-inv = '0'.
    append wa_cellcolor to p_cellcolor.
  END -OF-DEFINITION.set_color

  'MATNR'.

  set_color 'MEINS'.
  set_color 'CNT_S'.
  set_color 'QUOTE1'.
  set_color 'QUOTE2'.

ENDFORM.                    " fill_cellcolor


 

    3. The most critical point is to set the name of the color field in the layout structure, the code is as follows:

             is_layout-coltab_fieldname = 'CELLCOLOR'." Cell color field

Summarize:

    When the row color and column color are set at the same time, the row color will cover the column color. Sometimes users do not want this result to appear. The solution is to set the cells of each row (of course not including setting the column color the color of the intersecting cells of the column).

Appendix: ABAP Color Codes

The color code in ABAP is composed of 4-bit words

Cxyz

C : Shorthand for color, the color codes all start with C

     x : standard color code, there are 7 standard colors in SAP

      y : invert colors on/off 1/0

      z : boost color on/off 1/0

Standard color code list

X

color

main purpose

1

gray blue

header, title bar

2

light grey

list content

3

yellow

summary

4

blue

keywords

5

green

correct

6

red

mistake

7

orange

control

Guess you like

Origin blog.csdn.net/agelee/article/details/113517300
Recommended