Skip to main content

Module 13: ALV Reporting

ALV (ABAP List Viewer) is the standard SAP framework for tabular data display.
It provides sorting, filtering, aggregation, layouts, and events out of the box, making it the preferred reporting approach in ABAP.


1. Why ALV?

Compared to classical WRITE output, ALV provides:

  • Sorting & filtering
  • Totals & subtotals
  • Layout variants
  • Export to Excel
  • User interaction
Modern Rule

In ABAP 7.5+, never build reports using WRITE unless maintaining legacy code.


2. Classic ALV (Function Module Based)

Classic ALV is based on function modules such as:

  • REUSE_ALV_GRID_DISPLAY
  • REUSE_ALV_LIST_DISPLAY

2.1 Basic Example (Classic ALV)

CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
i_structure_name = 'SPFLI'
TABLES
t_outtab = lt_spfli.

2.2 Characteristics

  • Procedural

  • Uses field catalog

  • Limited OO extensibility

  • Still found in legacy systems

Legacy Status

Classic ALV should not be used in new developments.

3. Field Catalog (ALV Metadata)

The field catalog controls:

  • Column labels

  • Visibility

  • Output length

  • Editability

  • Hotspots

3.1 Field Catalog Structure

DATA gt_fcat TYPE slis_t_fieldcat_alv.

Example entry:

DATA gs_fcat TYPE slis_fieldcat_alv.
gs_fcat-fieldname = 'CARRID'.
gs_fcat-seltext_m = 'Carrier'.
APPEND gs_fcat TO gt_fcat.
Why Field Catalog Exists

Field catalogs decouple data structure from presentation logic.

4. OO ALV (CL_GUI_ALV_GRID)

OO ALV uses class CL_GUI_ALV_GRID and is more flexible than classic ALV.

4.1 Basic OO ALV Flow

  1. Create container

  2. Create ALV grid object

  3. Set table & field catalog

  4. Register events

DATA lo_alv TYPE REF TO cl_gui_alv_grid.

CREATE OBJECT lo_alv
EXPORTING
i_parent = lo_container.

lo_alv->set_table_for_first_display(
EXPORTING
is_layout = ls_layout
CHANGING
it_outtab = lt_data
it_fieldcatalog = lt_fcat
).

4.2 Characteristics

  • Fully object-oriented

  • Supports custom events

  • Flexible UI control

  • Complex to implement

Reality Check

OO ALV is powerful but verbose and UI-heavy. For simple reports, prefer SALV.

SALV (Simple ALV) is the modern, lightweight ALV framework.

5.1 Why SALV?

  • No field catalog required

  • Minimal code

  • OO-based

  • Clean and readable

  • Ideal for reports

Modern Recommendation

Use SALV by default unless you need editable grids or custom containers.

5.2 Basic SALV Example

DATA lo_alv TYPE REF TO cl_salv_table.

cl_salv_table=>factory(
IMPORTING
r_salv_table = lo_alv
CHANGING
t_table = lt_spfli
).

lo_alv->display( ).

5.3 Column Customization (SALV)

DATA lo_columns TYPE REF TO cl_salv_columns_table.
lo_columns = lo_alv->get_columns( ).

DATA lo_column TYPE REF TO cl_salv_column.
lo_column = lo_columns->get_column( 'CARRID' ).
lo_column->set_long_text( 'Carrier ID' ).

6. Events & Layout Handling

6.1 ALV Events (OO / SALV)

Common events:

  • Double click

  • User command

  • Toolbar action

Example (SALV event handler):

SET HANDLER lo_handler->on_double_click FOR lo_alv.
Event Usage

Events enable interactive reports (drill-down, navigation).

6.2 Layout Handling

Layouts allow users to:

  • Save column order

  • Apply filters

  • Store variants

SALV layout:

lo_alv->get_layout( )->set_save_restriction( if_salv_c_layout=>restrict_none ).
User Experience

Always allow layout saving for business users.

7. Comparison: ALV Approaches

FeatureClassic ALVOO ALVSALV
ParadigmProceduralOOOO
ComplexityMediumHighLow
Editable Grid
Field CatalogRequiredRequired
New Dev⚠️

8. Modern ABAP Reporting Strategy

Recommended Flow (7.5+)
  1. CDS View (data model)

  2. SALV for reporting

  3. Fiori / UI5 for UI

  1. Common Mistakes
Avoid These
  • Using WRITE instead of ALV

  • Building new classic ALVs

  • Over-customizing field catalogs

  • Ignoring layout variants

  • Mixing business logic into ALV code

10. Summary

  • ALV is the standard reporting framework

  • Classic ALV is legacy

  • OO ALV is powerful but complex

  • SALV is simple and modern

  • Field catalogs control presentation

  • Events enable interaction

  • Layouts improve usability

11. Practice Exercises

  • Create a SALV report using internal table data.

  • Customize column headings.

  • Enable layout saving.

  • Add a double-click event.

  • Compare SALV vs OO ALV complexity.

12. What’s Next?

➡️ Module 14: File Handling & Data Transfer

Learning Tip

Strong ALV skills are mandatory for ABAP interviews and daily work.