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 bname, ustyp, gltgv, gltgb
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.
Common customisations¶
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