ALV Reports
ABAP Developmentintermediate

ALV Reports Part 7: Colors, Icons and Traffic Lights

Key takeaway

Highlight what matters in an ALV: column colors (emphasize), row colors (info field), cell colors (LVC T SCOL), icons with ICON constants, and exception columns (traffic lights) — for REUSE ALV and CL GUI ALV GRID.

Explanation

📌 KEY POINTS
✅ Column color: field catalog emphasize = 'C510' (C + color 1–7 + intensified + inverse).

✅ Row color: a 4-char field in the output table named in layout info_fname; cell color: an LVC_T_SCOL field named in layout ctab_fname.

✅ Traffic lights: a 1-char field with 1 = red, 2 = yellow, 3 = green, named in layout excp_fname.

⚠️ Colors must carry meaning users understand — and should not be the only signal (color-blind users); add icons or text.

━━━━━━━━━━━━━━━━━━━━
▶ WHERE WE ARE

The drill-down from Part 6 helps users find details. Colors and icons help them see problems before clicking.

━━━━━━━━━━━━━━━━━━━━
▶ 1. COLOR CODES

Format Cxyz: x = color (1 gray-blue, 2 light gray, 3 yellow, 4 blue-green, 5 green, 6 red, 7 orange), y = intensified (0/1), z = inverse (0/1). Example: C610 = intensified red.

━━━━━━━━━━━━━━━━━━━━
▶ 2. COLUMN COLOR

Field catalog: gs_fcat-emphasize = 'C300'. The whole column gets the color.

━━━━━━━━━━━━━━━━━━━━
▶ 3. ROW COLOR

  • Add ROWCOLOR TYPE char4 to the output structure.
  • Fill it per row (e.g. 'C610' for overbooked flights).
  • Layout: info_fname = 'ROWCOLOR' (LVC) or info_fieldname (SLIS).

━━━━━━━━━━━━━━━━━━━━
▶ 4. CELL COLOR

  • Add CELLCOLOR TYPE lvc_t_scol to the output structure (a table inside each row).
  • Append entries with fname = column and color-col / color-int / color-inv.
  • Layout: ctab_fname = 'CELLCOLOR' (LVC) or coltab_fieldname (SLIS).

━━━━━━━━━━━━━━━━━━━━
▶ 5. ICONS

  • Output field TYPE icon_d (4 chars) filled with constants from type group ICON (icon_green_light, icon_warning, icon_locked).
  • Field catalog: icon = 'X'. Add a tooltip text in a separate column or via quickinfo.

━━━━━━━━━━━━━━━━━━━━
▶ 6. TRAFFIC LIGHTS (EXCEPTION COLUMN)

  • Field LIGHT TYPE char1 with '1', '2' or '3'.
  • Layout: excp_fname = 'LIGHT' (LVC) or lights_fieldname (SLIS); excp_led = 'X' shows LEDs instead of lights.

━━━━━━━━━━━━━━━━━━━━
▶ STEP BY STEP

  1. Run the code example: seat utilisation with traffic lights, red rows for full flights and a colored cell.
  2. Change thresholds and watch the colors change.
  3. Add an icon column with a lock icon for flights in the past.

✅ CHECKPOINT: your ALV makes exceptions visible with colors, icons and traffic lights.

Code example

ABAP Code
REPORT zalv_colors. TYPE-POOLS icon. TYPES: BEGIN OF ty_out,         light     TYPE char1,          " traffic light: 1 red, 2 yellow, 3 green         status    TYPE icon_d,         " icon column         carrid    TYPE s_carr_id,         connid    TYPE s_conn_id,         fldate    TYPE s_date,         seatsmax  TYPE s_seatsmax,         seatsocc  TYPE s_seatsocc,         rowcolor  TYPE char4,          " row color code         cellcolor TYPE lvc_t_scol,     " cell colors       END OF ty_out. DATA: gt_out    TYPE STANDARD TABLE OF ty_out,      gt_fcat   TYPE lvc_t_fcat,      gs_fcat   TYPE lvc_s_fcat,      gs_layout TYPE lvc_s_layo,      gs_color  TYPE lvc_s_scol,      gv_pct    TYPE i.FIELD-SYMBOLS <ls_out> TYPE ty_out. START-OF-SELECTION.  SELECT carrid connid fldate seatsmax seatsocc    FROM sflight INTO CORRESPONDING FIELDS OF TABLE gt_out. * ===== Step 1: fill light, icon, row and cell colors =====  LOOP AT gt_out ASSIGNING <ls_out>.    IF <ls_out>-seatsmax > 0.      gv_pct = <ls_out>-seatsocc * 100 / <ls_out>-seatsmax.    ENDIF.    IF gv_pct >= 100.      <ls_out>-light    = '1'.                  " red      <ls_out>-rowcolor = 'C610'.               " whole row red    ELSEIF gv_pct >= 80.      <ls_out>-light = '2'.                     " yellow    ELSE.      <ls_out>-light = '3'.                     " green    ENDIF.     IF <ls_out>-fldate < sy-datum.      <ls_out>-status = icon_locked.            " past flight    ELSE.      <ls_out>-status = icon_date.    ENDIF.     IF <ls_out>-seatsocc = 0.                   " highlight a single cell      CLEAR gs_color.      gs_color-fname     = 'SEATSOCC'.      gs_color-color-col = 3.                   " yellow      gs_color-color-int = 1.      APPEND gs_color TO <ls_out>-cellcolor.    ENDIF.  ENDLOOP. * ===== Step 2: field catalog =====  PERFORM add_col USING 'STATUS'   'Status'     'X' ''.  PERFORM add_col USING 'CARRID'   'Airline'    ''  'C300'.   " yellow column  PERFORM add_col USING 'CONNID'   'Connection' ''  ''.  PERFORM add_col USING 'FLDATE'   'Date'       ''  ''.  PERFORM add_col USING 'SEATSMAX' 'Capacity'   ''  ''.  PERFORM add_col USING 'SEATSOCC' 'Occupied'   ''  ''. * ===== Step 3: layout tells ALV where colors and lights are =====  gs_layout-excp_fname = 'LIGHT'.  gs_layout-info_fname = 'ROWCOLOR'.  gs_layout-ctab_fname = 'CELLCOLOR'.  gs_layout-cwidth_opt = 'X'.   CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY_LVC'    EXPORTING      i_callback_program = sy-repid      is_layout_lvc      = gs_layout      it_fieldcat_lvc    = gt_fcat    TABLES      t_outtab           = gt_out    EXCEPTIONS      OTHERS             = 1. *----------------------------------------------------------------------*FORM add_col USING iv_field TYPE lvc_fname                   iv_text  TYPE lvc_txtcol                   iv_icon  TYPE char1                   iv_color TYPE lvc_emphsz.  CLEAR gs_fcat.  gs_fcat-fieldname = iv_field.  gs_fcat-coltext   = iv_text.  gs_fcat-icon      = iv_icon.  gs_fcat-emphasize = iv_color.  APPEND gs_fcat TO gt_fcat.ENDFORM.

Real project scenario

A production supervisor ALV listed 2,000 open orders; late orders were only visible by comparing two date columns. Adding a traffic light column (red = late, yellow = due within 2 days, green = on time) and a red row color for late high-priority orders let supervisors spot problems immediately.
One supervisor was red-green color-blind, so the team also added an icon column with distinct icons and a text column "Late/Due/On time" — accessibility was added to the team's ALV guidelines.

Common mistakes

  • Layout field names (info_fname, ctab_fname, excp_fname) not matching the output structure.
  • Using SLIS layout field names with LVC layouts.
  • Wrong color code format (must be Cxyz).
  • Forgetting icon = 'X' so the icon code appears as text.
  • Relying only on color to convey meaning.

Best practices

  • Define color rules with the business and keep them consistent across reports.
  • Combine colors with icons or text for accessibility.
  • Use traffic lights for status, cell colors for single problem values.
  • Keep color logic in one routine.
  • Avoid too many colors — highlight exceptions only.

Interview angle

Questions: "How do you color a row / cell / column in ALV?", "How do you show traffic lights?", "What does C610 mean?"
Strong answer: column via fieldcat emphasize; row via a char4 field named in layout info_fname; cell via lvc_t_scol field named in ctab_fname; traffic light via char1 field (1/2/3) named in excp_fname; icons via icon_d fields with ICON constants and icon = 'X'; Cxyz = color, intensified, inverse.

Practice this lesson

Quick check

1. A reconciliation ALV shows matches only as green and mismatches as red cells. What is the best improvement?

2. Which layout field tells CL_GUI_ALV_GRID the name of the column holding traffic light values 1/2/3?

3. How do you color a single cell in an LVC-based ALV?

Interview questions

1. A reconciliation ALV uses only green and red cell backgrounds to show matches and mismatches. What would you improve?

Answer it in your own words first, then compare.

2. ALV export to Excel loses leading zeros. Why?

Answer it in your own words first, then compare.

Practice more with Interview AI →

Reference-verified: the steps are checked against official SAP documentation and tutorials, and object and field names in the sample code are checked for consistency. The code has not been compiled or run on an SAP system by ERPClimb. Syntax marked release-dependent varies by SAP release, so check it in your own system.

More lessons in this topic

Interview questions on this topic

Related SAP topics