CL_SALV_TABLE¶
The modern ALV grid. Replaces
REUSE_ALV_GRID_DISPLAYand the older OO classes.
Purpose¶
Display an internal table as a sortable, filterable, exportable grid — fullscreen or as a control inside a screen — with a fraction of the boilerplate that the old function-module approach required.
Minimum working example¶
REPORT z_salv_demo.
DATA: lt_users TYPE STANDARD TABLE OF usr02,
lo_alv TYPE REF TO cl_salv_table.
START-OF-SELECTION.
SELECT *
FROM usr02
INTO TABLE lt_users
UP TO 100 ROWS.
TRY.
cl_salv_table=>factory(
IMPORTING r_salv_table = lo_alv
CHANGING t_table = lt_users ).
lo_alv->display( ).
CATCH cx_salv_msg INTO DATA(lx_salv).
MESSAGE lx_salv->get_text( ) TYPE 'E'.
ENDTRY.
That's it. Run it — you get a fully functional grid with sort, filter, sum, layout management, and export to Excel.
No WRITE statement needed for fullscreen SALV
When factory() is called without r_container, display() creates and manages its own fullscreen SAP screen internally — no WRITE: / space. is required beforehand. A WRITE is only needed when using cl_gui_container=>default_screen, because that container requires an existing list screen to attach to.
Common customisations¶
" 1) Mark a column as a hotspot
" get_column() returns CL_SALV_COLUMN_LIST — must cast to CL_SALV_COLUMN_TABLE
" to access set_cell_type
DATA(lo_columns) = lo_alv->get_columns( ).
DATA(lo_col) = CAST cl_salv_column_table(
lo_columns->get_column( 'BNAME' ) ).
lo_col->set_cell_type( if_salv_c_cell_type=>hotspot ).
" 2) Register an event handler
DATA(lo_events) = lo_alv->get_event( ).
SET HANDLER lo_handler->on_link_click FOR lo_events.
" → see CL_SALV_EVENTS_TABLE for the full handler class pattern
Common pitfalls¶
Don't pass a sorted/hashed table
t_table must be a standard internal table. If yours is sorted or hashed, copy it: lt_display = lt_source.
Editable grids — different class
CL_SALV_TABLE is read-only. For editable cells you still need CL_GUI_ALV_GRID. SAP has signalled CL_SALV_GUI_TABLE_IDA (with IDA) for high-volume scenarios, but plain editable ALV is still the older grid.
- Empty table message: by default the grid shows nothing helpful. Set it explicitly:
- Currency / quantity columns: they need a reference field for correct formatting. Use
set_currency_column( )/set_quantity_column( )on the column object.
Variants¶
| Need | Use |
|---|---|
| Fullscreen grid | cl_salv_table=>factory( ... )->display( ) |
| Embedded in a screen | pass r_container to factory |
| Hierarchical (tree) display | cl_salv_tree |
| Massive datasets (paged) | cl_salv_gui_table_ida |
See also¶
CL_SALV_COLUMNS_TABLE,CL_SALV_FUNCTIONS_LIST,CL_SALV_SORTS,CL_SALV_EVENTS_TABLE- Demo programs:
SALV_DEMO_TABLE_SIMPLE,SALV_DEMO_TABLE_EVENTS,SALV_DEMO_TABLE_HIERSEQ