ERPClimb logoERPClimb
ALV Reports
ABAP Developmentbeginner 10 min read

ALV Reports Part 2: Quick ALV with CL_SALV_TABLE

Preview · a free account unlocks the full lesson

Key takeaway

Use the SALV object model: cl salv table= factory, functions (toolbar), columns (texts, hiding, optimizing), display settings, aggregations and layout saving — with error handling for CX SALV MSG and CX SALV NOT FOUND.

In this lessonShow sections

Visual overview

ALV Reports Part 2: Quick ALV with CL_SALV_TABLE — learning sheetFlow: Create ZALV_SALV_FLIGHTS from the code example → Remove set_all( ) and compare the toolbar → Misspell a column name and observe CX_SALV_NOT_FOUND being caught. Key ideas: THE FACTORY; FUNCTIONS (TOOLBAR); COLUMNS; AGGREGATIONS AND SORTS. Watch out: CL_SALV_TABLE is display-only — for editable grids use CL_GUI_ALV_GRID (Part 9).ERPClimb.com / ABAP / LESSON 2/10 / LEARNING SHEETALV Reports Part 2: Quick ALV with CL_SALV_TABLE1 · HOW IT FLOWS1Create ZALV_SALV_FLIGHTSfrom the code example2Remove set_all( ) andcompare the toolbar3Misspell a column nameand observeCX_SALV_NOT_FOUND being…2 · KEY IDEAS EXPLAINEDThe Factoryt_table is CHANGING — pass a global or long-livedtable (the ALV keeps a reference to it).Raises CX_SALV_MSG — always wrap in TRY/CATCH.Functions (Toolbar)go_alv->get_functions( )->set_all( abap_true). switches on sort, filter, sum, export, layoutbuttons. Without it, the full-screen grid shows…Columnsset_optimize( abap_true ) — optimize widths.lo_column = lo_columns->get_column( 'SEATSMAX'). — raises CX_SALV_NOT_FOUND for wrong names.Aggregations And Sortsgo_alv->get_aggregations()->add_aggregation( columnname = 'SEATSOCC' ).3 · REMEMBER · WATCH OUTRememberCL_SALV_TABLE creates a full ALV with a few lines:cl_salv_table=>factory( … ) then ->display( ).The field catalog is derived automatically from the internal table'stypes (DDIC data elements give labels).Settings are objects: get_functions( ), get_columns( ),get_aggregations( ), get_layout( ), get_display_settings( ).!Watch outCL_SALV_TABLE is display-only — foreditable grids use CL_GUI_ALV_GRID(Part 9).4 · IN A REAL PROJECTA logistics team needed 15 small display reports for warehouse supervisors. Using CL_SALV_TABLE, each reportneeded about 40 lines of ALV code with no manual field catalog, and labels came from the DDIC data elements.One report later needed editable quantity cells; the developer switched only that report to CL_GUI_ALV_GRID…Original ERPClimb learning sheet • Verify against your SAP release and edition

Explanation

Part 1 used the classic function module for building an ALV; SALV is the simpler object-oriented alternative for display-only reports, and it's widely used across both ECC 6.0 and S/4HANA on-premise. CL_SALV_TABLE lets you create a full ALV in just a few lines: call cl_salv_table=>factory( ... ) and then ->display( ).

Its field catalog is derived automatically from the internal table's own types, with DDIC data elements supplying the column labels. All of its settings are exposed as objects, reached through get_functions( ), get_columns( ), get_aggregations( ), get_layout( ), and get_display_settings( ).

One limit to keep in mind: CL_SALV_TABLE is display-only, so for an editable grid you need CL_GUI_ALV_GRID instead, which Part 9 covers.

The factory call itself looks like cl_salv_table=>factory( IMPORTING r_salv_table = go_alv CHANGING t_table = gt_out ). Note that t_table is CHANGING, so you should pass a global or otherwise long-lived table, since the ALV keeps a reference to it rather than copying it. The call can raise CX_SALV_MSG, so always wrap it in TRY/CATCH. Optional parameters include list_display = abap_true for a classic list-style display, and r_container to display the ALV inside a specific screen container instead of full-screen.

Free account

Create a free account to keep reading

You have read the opening of this lesson. A free ERPClimb account unlocks the rest of it, every other lesson and topic, and your learning history, so you can pick up exactly where you stopped. No card needed.

  • Full explanation
  • Code example
  • Real project scenario
  • Common mistakes
  • Best practices
  • Interview angle

One tap with Google works too. Every topic keeps its first lesson open to everyone.

Keep exploring

Check before use: lesson examples are educational, not a guarantee of correctness for your SAP edition or release. Sample code has not been executed on your SAP system. Confirm API availability, syntax, authorizations and business impact in an approved development or test environment.