# ABAP ALV Layout, Field Catalog and Color Codes Reference

> Source: https://netray.co/tools/abap-alv-layout-fieldcatalog-color-codes-reference
> Publisher: Netray (netray.co), AI and integration engineering for ERP and manufacturing systems.
> Section: Free Tools

## Short answer

Side by side: how to do checkbox, hotspot, colors, subtotals, toolbar buttons, top of page and refresh in CL_GUI_ALV_GRID and in CL_SALV_TABLE, plus the C1 to C7 color codes.

## Category

developer

## Erp

SAP NetWeaver / Basis

## Audience

- ABAP developer
- SAP report developer

## Tool

**Kind:** worksheet

**Mode:** reference

**Columns:**

#### Feature

**Key:** feature

**Type:** text

#### CL_GUI_ALV_GRID (LVC)

**Key:** grid

**Type:** text

#### CL_SALV_TABLE

**Key:** salv

**Type:** text

#### Note

**Key:** note

**Type:** text

**Rows:**

**Feature:** Create and display

**Grid:** NEW cl_gui_alv_grid( i_parent = lo_container ), then set_table_for_first_display( EXPORTING is_layout = ls_layo CHANGING it_outtab = lt_data it_fieldcatalog = lt_fcat )

**Salv:** cl_salv_table=>factory( IMPORTING r_salv_table = lo_alv CHANGING t_table = lt_data ). lo_alv->display( ).

**Note:** The grid needs a container (custom control or docking container). SALV can run fullscreen with no screen.

**Feature:** Field catalog build

**Grid:** LVC_FIELDCATALOG_MERGE with I_STRUCTURE_NAME, then adjust LVC_S_FCAT rows

**Salv:** Built automatically from the table type. Change it with get_columns( ) and get_column( )

**Note:** For a local type with the grid, fill FIELDNAME, REF_TABLE and REF_FIELD yourself.

**Feature:** Column texts

**Grid:** LVC_S_FCAT-COLTEXT, SCRTEXT_L, SCRTEXT_M, SCRTEXT_S

**Salv:** column->set_long_text( ), set_medium_text( ), set_short_text( )

**Note:** Texts come from the data element when REF_TABLE or the DDIC type is set.

**Feature:** Checkbox column

**Grid:** LVC_S_FCAT-CHECKBOX = 'X' plus EDIT = 'X' for input

**Salv:** column_table->set_cell_type( if_salv_c_cell_type=>checkbox_hotspot ), handle event LINK_CLICK

**Note:** The field should be CHAR1. In SALV the checkbox changes only when your LINK_CLICK handler flips the value and calls refresh( ).

**Feature:** Editable column

**Grid:** LVC_S_FCAT-EDIT = 'X', register_edit_event( i_event_id = cl_gui_alv_grid=>mc_evt_modified )

**Salv:** Not supported as a standard feature

**Note:** Call check_changed_data( ) before you read the table, or the last change is lost.

**Feature:** Editable single cells

**Grid:** Table of LVC_S_STYL (FIELDNAME, STYLE) in each row, LVC_S_LAYO-STYLEFNAME, style cl_gui_alv_grid=>mc_style_enabled or mc_style_disabled

**Salv:** Not supported

**Note:** The style table component must be of type LVC_T_STYL.

**Feature:** Hotspot

**Grid:** LVC_S_FCAT-HOTSPOT = 'X', event HOTSPOT_CLICK (E_ROW_ID, E_COLUMN_ID, ES_ROW_NO)

**Salv:** column_table->set_cell_type( if_salv_c_cell_type=>hotspot ), event LINK_CLICK of get_event( ) (ROW, COLUMN)

**Note:** Register the handler with SET HANDLER before display.

**Feature:** Double click

**Grid:** Event DOUBLE_CLICK (E_ROW, E_COLUMN, ES_ROW_NO)

**Salv:** Event DOUBLE_CLICK of CL_SALV_EVENTS_TABLE (ROW, COLUMN)

**Note:** SALV event object: lo_alv->get_event( ).

**Feature:** Row color

**Grid:** LVC_S_LAYO-INFO_FNAME = name of a CHAR4 field holding Cxyz, e.g. 'C610'

**Salv:** Color table column (LVC_T_SCOL) set with get_columns( )->set_color_column( 'T_COLOR' ) with no FNAME for the whole row

**Note:** Value format is C + color + intensified + inverse.

**Feature:** Cell color

**Grid:** LVC_S_LAYO-CTAB_FNAME = name of a LVC_T_SCOL field; each line has FNAME and COLOR (LVC_S_COLO: COL, INT, INV)

**Salv:** Same LVC_T_SCOL column with FNAME filled, set via set_color_column( )

**Note:** NOKEYCOL in LVC_S_SCOL lets the color override key column color.

**Feature:** Column color

**Grid:** LVC_S_FCAT-EMPHASIZE = 'C300' (CHAR4 Cxyz)

**Salv:** column_table->set_color( ls_color ) with LVC_S_COLO

**Note:** Key columns keep their key color unless set otherwise.

**Feature:** Optimize column width

**Grid:** LVC_S_LAYO-CWIDTH_OPT = 'X', or LVC_S_FCAT-COL_OPT per column

**Salv:** get_columns( )->set_optimize( abap_true )

**Note:** Fixed width: LVC_S_FCAT-OUTPUTLEN or column->set_output_length( ).

**Feature:** Zebra stripes

**Grid:** LVC_S_LAYO-ZEBRA = 'X'

**Salv:** get_display_settings( )->set_striped_pattern( abap_true )

**Note:** Ignored for rows that carry their own color.

**Feature:** Selection mode

**Grid:** LVC_S_LAYO-SEL_MODE: 'A', 'B', 'C', 'D' (space behaves as 'B')

**Salv:** get_selections( )->set_selection_mode( if_salv_c_selection_mode=>multiple ), also single, row_column, cell

**Note:** B single selection, C multiple, D cell selection, A rows and columns with row buttons. Read with get_selected_rows( ).

**Feature:** Grid title

**Grid:** LVC_S_LAYO-GRID_TITLE

**Salv:** get_display_settings( )->set_list_header( )

**Note:** Short single line.

**Feature:** Totals and subtotals

**Grid:** LVC_S_FCAT-DO_SUM = 'X'; sort table LVC_T_SORT with SUBTOT = 'X' passed in IT_SORT

**Salv:** get_aggregations( )->add_aggregation( columnname = 'NETWR' aggregation = if_salv_c_aggregation=>total ), get_sorts( )->add_sort( columnname = 'KUNNR' subtotal = abap_true )

**Note:** Currency amounts need CFIELDNAME (or a reference) or totals mix currencies.

**Feature:** Hide column

**Grid:** LVC_S_FCAT-NO_OUT = 'X' (user can show it) or TECH = 'X' (never shown)

**Salv:** column->set_visible( abap_false ) or set_technical( abap_true )

**Note:** Technical columns are not offered in the layout dialog.

**Feature:** Toolbar button

**Grid:** Event TOOLBAR: APPEND a STB_BUTTON to e_object->mt_toolbar; event USER_COMMAND gives E_UCOMM; call set_toolbar_interactive( ) to rebuild

**Salv:** Container mode: get_functions( )->add_function( name, icon, text, tooltip, position ); fullscreen: set_screen_status( pfstatus, report ) with a copied GUI status; event ADDED_FUNCTION

**Note:** In fullscreen SALV, add_function raises an exception; copy a standard SALV GUI status into your program and add your function codes.

**Feature:** Standard functions

**Grid:** IT_TOOLBAR_EXCLUDING with cl_gui_alv_grid=>mc_fc_* codes

**Salv:** get_functions( )->set_all( abap_true ) or set_default( )

**Note:** Without set_all SALV shows no toolbar functions.

**Feature:** Top of page

**Grid:** Event TOP_OF_PAGE (E_DYNDOC_ID type CL_DD_DOCUMENT); split the container and call list_processing_events( i_event_name = 'TOP_OF_PAGE' i_dyndoc_id = lo_doc )

**Salv:** Build CL_SALV_FORM_LAYOUT_GRID (create_label, create_text with row and column), then lo_alv->set_top_of_list( lo_grid )

**Note:** SALV also has set_top_of_list_print( ) for print output.

**Feature:** Refresh after data change

**Grid:** refresh_table_display( is_stable = ls_stbl i_soft_refresh = 'X' ) with LVC_S_STBL ROW = 'X' COL = 'X'

**Salv:** lo_alv->refresh( s_stable = ls_stbl refresh_mode = if_salv_c_refresh=>soft )

**Note:** Stable keeps scroll position. Use full refresh after changing the field catalog.

**Feature:** Layout variants

**Grid:** IS_VARIANT (REPORT = sy-repid), I_SAVE = 'A', I_DEFAULT = 'X'

**Salv:** get_layout( )->set_key( ls_key ), set_save_restriction( if_salv_c_layout=>restrict_none ), set_default( abap_true )

**Note:** I_SAVE: space no saving, 'X' global only, 'U' user only, 'A' both.

**Feature:** F4 help on a column

**Grid:** LVC_S_FCAT-F4AVAILABL = 'X', register_f4_for_fields( ), event ONF4 (E_FIELDNAME, ES_ROW_NO, ER_EVENT_DATA)

**Salv:** Not used: SALV is display only

**Note:** Set er_event_data->m_event_handled = 'X' in ONF4 or the standard help also runs.

**Feature:** Data changed check

**Grid:** Event DATA_CHANGED (ER_DATA_CHANGED type CL_ALV_CHANGED_DATA_PROTOCOL)

**Salv:** Not applicable

**Note:** Use add_protocol_entry( ) to reject bad input per cell.

**Feature:** Color code C1 (COL_HEADING)

**Grid:** Gray-blue

**Salv:** LVC_S_COLO-COL = 1

**Note:** Headings.

**Feature:** Color code C2 (COL_NORMAL)

**Grid:** Light gray

**Salv:** LVC_S_COLO-COL = 2

**Note:** List body.

**Feature:** Color code C3 (COL_TOTAL)

**Grid:** Yellow

**Salv:** LVC_S_COLO-COL = 3

**Note:** Totals.

**Feature:** Color code C4 (COL_KEY)

**Grid:** Blue-green

**Salv:** LVC_S_COLO-COL = 4

**Note:** Key columns.

**Feature:** Color code C5 (COL_POSITIVE)

**Grid:** Green

**Salv:** LVC_S_COLO-COL = 5

**Note:** Positive values or OK status.

**Feature:** Color code C6 (COL_NEGATIVE)

**Grid:** Red

**Salv:** LVC_S_COLO-COL = 6

**Note:** Negative values or errors.

**Feature:** Color code C7 (COL_GROUP)

**Grid:** Purple in the ABAP FORMAT documentation; shown orange in many current GUI themes

**Salv:** LVC_S_COLO-COL = 7

**Note:** Control levels and groups.

**Feature:** Code format Cxyz

**Grid:** x = color 1 to 7, y = intensified 0 or 1, z = inverse 0 or 1, e.g. C610 bright red, C500 normal green

**Salv:** LVC_S_COLO: COL = x, INT = y, INV = z

**Note:** Inverse 1 colors the text instead of the background.

**Notes:** Field names are from DDIC structures LVC_S_FCAT, LVC_S_LAYO, LVC_S_SCOL, LVC_S_COLO, LVC_S_STYL and LVC_S_STBL; check them in SE11 on your release. Color names follow the ABAP keyword documentation for FORMAT COLOR; the exact shade depends on the SAP GUI theme.

## Content

**Intro:** This reference shows how to do the common ALV tasks in both CL_GUI_ALV_GRID and CL_SALV_TABLE, with the exact field catalog and layout field names and the meaning of the C1 to C7 color codes. It is for ABAP developers on SAP NetWeaver 7.x and S/4HANA SAP GUI reports.

**Sections:**

#### How to use it

**Body:** Search for the task, for example checkbox, hotspot, refresh or toolbar, and read the grid column if you build with CL_GUI_ALV_GRID and a container, or the SALV column if you use CL_SALV_TABLE. The grid is the right choice when users must edit data or you need per-cell styles. SALV is quicker for display-only reports and needs no field catalog. The last rows decode the four-character color value Cxyz used in INFO_FNAME and EMPHASIZE, and the COL, INT and INV fields used in LVC_S_COLO.

#### Where this lives in SAP

**Body:** The grid uses DDIC structures LVC_S_FCAT (field catalog line), LVC_S_LAYO (layout), LVC_S_SCOL and LVC_S_COLO (colors), LVC_S_STYL (cell styles) and LVC_S_STBL (stable refresh). Open them in SE11 to see every field for your release. The events TOOLBAR, USER_COMMAND, HOTSPOT_CLICK, DOUBLE_CLICK, TOP_OF_PAGE, ONF4 and DATA_CHANGED belong to CL_GUI_ALV_GRID; look at them in SE24. SALV wraps the same engine through CL_SALV_TABLE, CL_SALV_COLUMNS_TABLE, CL_SALV_COLUMN_TABLE and CL_SALV_EVENTS_TABLE. Demo programs starting with SALV_DEMO and BCALV in SE38 show working examples.

**Bullets:**

- SE11: LVC_S_FCAT, LVC_S_LAYO, LVC_S_SCOL.
- SE24: CL_GUI_ALV_GRID, CL_SALV_TABLE.
- SE38: SALV_DEMO_* and BCALV_* demo reports.

#### Worked example: color late orders red

**Body:** Add a component T_COLOR of type LVC_T_SCOL to the output structure. For each late order, append a line with FNAME = 'EDATU' and COLOR-COL = 6, COLOR-INT = 1, COLOR-INV = 0. In the grid, set LVC_S_LAYO-CTAB_FNAME = 'T_COLOR'. In SALV, call lo_alv->get_columns( )->set_color_column( 'T_COLOR' ). To color the whole row instead, leave FNAME empty in SALV, or in the grid use a CHAR4 field with value C610 and point INFO_FNAME at it. Call the refresh method with a stable LVC_S_STBL after you change colors at runtime.

#### Common mistakes

**Body:** The most common bug with editable grids is reading the internal table before calling check_changed_data( ), which leaves the last typed value out. In SALV fullscreen, add_function raises an exception: you need your own GUI status via set_screen_status. Checkbox columns in SALV do not toggle by themselves; your LINK_CLICK handler must flip the value and refresh. Totals on amount columns without a currency reference add up different currencies. TECH = 'X' hides a column from the layout dialog for good, so use NO_OUT when users may want it back.

**Cta:** If you want users to ask for these report results in plain English instead of waiting for a new ALV, Netray can add a private AI layer on your SAP system on your own servers.

**Faq:**

#### What are the ALV color codes?

**Answer:** Colors 1 to 7 follow the classic list colors: 1 gray-blue (heading), 2 light gray (normal), 3 yellow (total), 4 blue-green (key), 5 green (positive), 6 red (negative), 7 purple or orange depending on theme (group). In a Cxyz string, x is the color, y is intensified (0 or 1) and z is inverse (0 or 1).

#### How do I color a single cell in ALV?

**Answer:** Add a LVC_T_SCOL table to each row, append a line with FNAME set to the column and COLOR filled with COL, INT and INV. Set LVC_S_LAYO-CTAB_FNAME to that field for CL_GUI_ALV_GRID, or call set_color_column( ) on the SALV columns object.

#### How do I add a button to the ALV toolbar?

**Answer:** For CL_GUI_ALV_GRID, handle event TOOLBAR, append a STB_BUTTON with FUNCTION, ICON and TEXT to e_object->mt_toolbar, and handle USER_COMMAND for E_UCOMM. For SALV in a container use add_function( ); in fullscreen copy a GUI status and set it with set_screen_status( ), then handle ADDED_FUNCTION.

#### How do I refresh ALV without losing the scroll position?

**Answer:** Call refresh_table_display( ) on the grid with IS_STABLE filled as ROW = 'X' and COL = 'X', and I_SOFT_REFRESH = 'X' when only data changed. In SALV call refresh( ) with s_stable and refresh_mode if_salv_c_refresh=>soft. Use a full refresh if you changed the field catalog.

## Search terms

abap alv color codes, abap alv cell color, abap alv with checkbox, abap alv toolbar add button, abap alv top of page, abap alv refresh, lvc_s_fcat fields, cl_salv_table hotspot

---
Talk to an engineer: https://netray.co/contact?intent=erp_ai | Machine catalog: https://netray.co/agent/catalog.json
