ERPClimb logoERPClimb
ALV Reports
ABAP Developmentbeginner 10 min read

ALV Reports Part 1: ALV Basics with REUSE_ALV_GRID_DISPLAY

Free sample lesson · open to everyone

Key takeaway

Build your first ALV report the classic way: read flight data, build a field catalog with REUSE ALV FIELDCATALOG MERGE or by hand, set a layout and display it with REUSE ALV GRID DISPLAY — and see how the three ALV technologies compare.

In this lessonShow sections

Visual overview

ALV Reports Part 1: ALV Basics with REUSE_ALV_GRID_DISPLAY — learning sheetFlow: Create report ZALV_FLIGHTS_CLASSIC with the code example → Run it and try sorting, filtering, totals and export → Save a layout (i_save = 'A') and reuse it → Remove a column from the field catalog and see it disappear. Key ideas: WHY ALV INSTEAD OF WRITE; THE THREE ALV TECHNOLOGIES; STEPS OF A CLASSIC ALV REPORT; FIELD CATALOG OPTIONS. Watch out: The field catalog must match the output table's field names exactly (uppercase), or columns are missing.ERPClimb.com / ABAP / LESSON 1/10 / LEARNING SHEETALV Reports Part 1: ALV Basics with REUSE_ALV_GRID_DISPLAY1 · HOW IT FLOWS1Create reportZALV_FLIGHTS_CLASSICwith the code…2Run it and trysorting,filtering…3Save a layout(i_save = 'A')and reuse it4Remove a columnfrom the fieldcatalog and see…2 · KEY IDEAS EXPLAINEDWhy ALV Instead Of WriteA WRITE list has fixed columns and nointeractivity. An ALV grid lets users sort,filter, hide columns, total amounts, save layouts…The Three ALV TechnologiesREUSE_ALV_GRID_DISPLAY / REUSE_ALV_LIST_DISPLAY —function modules, SLIS types(slis_t_fieldcat_alv). Quick; no screen needed…CL_GUI_ALV_GRID — control in a custom container onyour own screen (dynpro). Full control, events,editing.Steps Of A Classic ALV Report1. Define an output structure/table (TYPES +internal table).Field Catalog OptionsREUSE_ALV_FIELDCATALOG_MERGE with a dictionarystructure (i_structure_name = 'SFLIGHT') — labelsand types come from DDIC.Manual: fill slis_fieldcat_alv entries (fieldname,seltext_m, outputlen, do_sum …).3 · REMEMBER · WATCH OUTRememberALV (ABAP List Viewer) gives users sorting, filtering, totals, layoutsand Excel export for free.Classic function module REUSE_ALV_GRID_DISPLAY is still found in mostECC and S/4 on-premise reports.Three technologies: REUSE_ALV_* FMs (classic), CL_GUI_ALV_GRID (OOwith container), CL_SALV_TABLE (simple OO).!Watch outThe field catalog must match theoutput table's field names exactly(uppercase), or columns are missing.4 · IN A REAL PROJECTA finance team received a WRITE-based open items report every week and re-typed the figures into Excel to sortand subtotal by company code. Converting the report to REUSE_ALV_GRID_DISPLAY with DO_SUM on amounts and asaved user layout removed the manual work entirely. Later, a column went missing after a developer renamed a…Original ERPClimb learning sheet • Verify against your SAP release and edition

Expert visual walkthrough

ABAP DEVELOPMENT ACADEMY · Integration pathERPClimb.com

ALV Basics with REUSE_ALV_GRID_DISPLAY

ALV Reports · Chapter-specific technical teaching map

Integration path

1Concept

SELECT data

2Concept

Build field catalog

3Concept

REUSE_ALV_GRID_DISPLAY

4Concept

Grid result

Tutor's chapter takeaway

Build your first ALV report the classic way: read flight data, build a field catalog with REUSE_ALV_FIELDCATALOG_MERGE or by hand, set a layout and display it with REUSE_ALV_GRID_DISPLAY — and see how the three ALV technologies compare.

In a real project

A finance team received a WRITE-based open items report every week and re-typed the figures into Excel to sort and subtotal by company code. Converting the report to REUSE_ALV_GRID_DISPLAY with DO_SUM on amounts and a saved…

Watch out for

• Field catalog names not matching the output table fields (case sensitive, uppercase). • Missing cfieldname for amounts, so currency formatting is wrong. • Passing sy-repid directly instead of a variable to…

Conceptual study map, not an SAP configuration screenshot or a guaranteed runtime sequence. Consult the lesson for implementation prerequisites and exceptions.

The situation: a real project scenario

A finance team received a WRITE-based open items report every week and re-typed the figures into Excel to sort and subtotal by company code. Converting the report to REUSE_ALV_GRID_DISPLAY with DO_SUM on amounts and a saved user layout removed the manual work entirely.
Later, a column went missing after a developer renamed a field in the output structure but not in the field catalog. The team added a rule: build the catalog from the output structure (merge) and only adjust labels manually.

Explanation

This lesson opens a ten-part series on the ABAP List Viewer (ALV), starting with the classic REUSE_ALV_GRID_DISPLAY approach. The series continues with CL_SALV_TABLE in Part 2, OO ALV using CL_GUI_ALV_GRID and a custom container in Part 3, the field catalog in depth in Part 4, layout, sort, filter, totals and variants in Part 5, hotspot and double-click drill-down in Part 6, colors, icons and traffic lights in Part 7, toolbar, PF-STATUS and user commands in Part 8, editable ALV in Part 9, and authorization and sensitive data in Part 10.

The reason to reach for ALV instead of a plain WRITE list is interactivity: a WRITE list has fixed columns and no interactivity, whereas an ALV grid lets users sort, filter, hide columns, total amounts, save layouts and export to Excel — with no extra code required on your part. ALV (ABAP List Viewer) gives users sorting, filtering, totals, layouts and Excel export for free.

There are three distinct ALV technologies in use. REUSE_ALV_GRID_DISPLAY and REUSE_ALV_LIST_DISPLAY are function modules working with SLIS types such as slis_t_fieldcat_alv; they are quick to use, need no screen of their own, and are what most legacy reports rely on. Classic function module REUSE_ALV_GRID_DISPLAY is still found in most ECC and S/4 on-premise reports.

CL_GUI_ALV_GRID is a control placed in a custom container on your own screen (dynpro), giving full control over events and editing. CL_SALV_TABLE is the object-oriented model, usable full-screen or in a container, needing very little code, though it is not editable in the standard way.

A classic ALV report follows a fixed sequence of steps: define an output structure and internal table using TYPES, select data into it, build the field catalog — either automatically from the DDIC, manually, or a mix of both — set the layout, for example turning on zebra striping and optimizing column widths, and finally call REUSE_ALV_GRID_DISPLAY with the program name, field catalog, layout and output table.

The field catalog itself can be built in a couple of ways. REUSE_ALV_FIELDCATALOG_MERGE, called with a dictionary structure such as i_structure_name = 'SFLIGHT', pulls labels and types straight from the DDIC. Alternatively, you can fill slis_fieldcat_alv entries manually, setting fieldname, seltext_m, outputlen, do_sum and so on. The field catalog must match the output table's field names exactly (uppercase), or columns are missing. A common approach combines both: merge from the DDIC first, then adjust individual columns in a loop afterward.

Layout settings live in the slis_layout_alv structure: zebra = 'X' for striping, colwidth_optimize = 'X' for automatic column widths, and window_titlebar for a window title. Setting i_save = 'A' together with a variant lets users save and reuse their own layouts.

As an exercise, create a report ZALV_FLIGHTS_CLASSIC using the code example, run it and try sorting, filtering, totaling and exporting, save a layout with i_save = 'A' and reuse it, and then remove a column from the field catalog to see it disappear from the output.

Worth noting: for simple display-only reports, CL_SALV_TABLE (covered in Part 2) needs less code, and while S/4HANA's newer UIs are built in Fiori, ALV remains the standard for SAP GUI reports. By the end, you should be able to build a classic ALV report with a working field catalog and layout.

Code example

ABAP Code
REPORT zalv_flights_classic. TYPE-POOLS slis.                                   " needed in older releases * ===== Step 1: output structure and table =====TYPES: BEGIN OF ty_out,         carrid   TYPE s_carr_id,         connid   TYPE s_conn_id,         fldate   TYPE s_date,         price    TYPE s_price,         currency TYPE s_currcode,         seatsmax TYPE s_seatsmax,         seatsocc TYPE s_seatsocc,       END OF ty_out. DATA: gt_out      TYPE STANDARD TABLE OF ty_out,      gt_fieldcat TYPE slis_t_fieldcat_alv,      gs_fieldcat TYPE slis_fieldcat_alv,      gs_layout   TYPE slis_layout_alv,      gv_repid    TYPE sy-repid. PARAMETERS p_carr TYPE s_carr_id DEFAULT 'LH'. START-OF-SELECTION.* ===== Step 2: read data =====  SELECT carrid connid fldate price currency seatsmax seatsocc    FROM sflight INTO TABLE gt_out    WHERE carrid = p_carr.  IF gt_out IS INITIAL.    MESSAGE 'No data found' TYPE 'S' DISPLAY LIKE 'E'.    RETURN.  ENDIF. * ===== Step 3: field catalog - one entry per column =====  PERFORM add_field USING 'CARRID'   'Airline'     ' '.  PERFORM add_field USING 'CONNID'   'Connection'  ' '.  PERFORM add_field USING 'FLDATE'   'Flight date' ' '.  PERFORM add_field USING 'PRICE'    'Price'       'X'.     " X = total this column  PERFORM add_field USING 'CURRENCY' 'Currency'    ' '.  PERFORM add_field USING 'SEATSMAX' 'Capacity'    'X'.  PERFORM add_field USING 'SEATSOCC' 'Occupied'    'X'. * ===== Step 4: layout =====  gs_layout-zebra             = 'X'.  gs_layout-colwidth_optimize = 'X'.  gs_layout-window_titlebar   = 'Flights'. * ===== Step 5: display =====  gv_repid = sy-repid.  CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'    EXPORTING      i_callback_program = gv_repid      is_layout          = gs_layout      it_fieldcat        = gt_fieldcat      i_save             = 'A'                  " user may save layouts    TABLES      t_outtab           = gt_out    EXCEPTIONS      program_error      = 1      OTHERS             = 2.  IF sy-subrc <> 0.    MESSAGE 'ALV display failed' TYPE 'E'.  ENDIF. *----------------------------------------------------------------------*FORM add_field USING iv_field TYPE slis_fieldname                     iv_text  TYPE c                     iv_sum   TYPE c.  CLEAR gs_fieldcat.  gs_fieldcat-fieldname = iv_field.           " must match ty_out field (uppercase)  gs_fieldcat-seltext_m = iv_text.  gs_fieldcat-do_sum    = iv_sum.  IF iv_field = 'PRICE'.    gs_fieldcat-cfieldname = 'CURRENCY'.      " amount formatted by currency  ENDIF.  APPEND gs_fieldcat TO gt_fieldcat.ENDFORM. * Alternative: DDIC-based catalog* CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'*   EXPORTING i_structure_name = 'SFLIGHT'*   CHANGING  ct_fieldcat      = gt_fieldcat.

Watch out

Common mistakes

  • Field catalog names not matching the output table fields (case sensitive, uppercase).
  • Missing cfieldname for amounts, so currency formatting is wrong.
  • Passing sy-repid directly instead of a variable to i_callback_program.
  • No handling of empty result sets.
  • Duplicating the full field catalog manually when DDIC merge would do.

Do this

Best practices

  • Use a dedicated output structure for the ALV.
  • Build the catalog from DDIC and adjust only what is needed.
  • Link amounts to currency and quantities to units.
  • Allow saved layouts (i_save = 'A').
  • Consider CL_SALV_TABLE for new display-only reports.

In the interview

Interview angle

Questions: "Which ALV technologies do you know?", "What is a field catalog?", "How do you get totals in ALV?"
Strong answer: REUSE_ALV_GRID_DISPLAY (FM, SLIS types), CL_GUI_ALV_GRID (OO in container, events, editing), CL_SALV_TABLE (simple OO); the field catalog describes each column (fieldname, texts, output length, do_sum, cfieldname); built via FIELDCATALOG_MERGE/LVC_FIELDCATALOG_MERGE or manually; totals via do_sum or user action; layouts saved with i_save.

Practice this lesson

Quick check

0 of 3 questions attempted

Question 1 of 3

Which ALV technology is a function module using SLIS types and needs no own screen?

Practise this in an interview

Answer in your own words and get instant feedback, the way an interviewer would judge it.

1A finance ALV report selects data inside the display routine and mixes reconciliation logic with field catalog code. How would you structure it?

2What is ALV and why is it preferred over WRITE lists?

Try a related Code Lab

This published exercise covers the same SAP topic. Apply the ideas in a hands-on scenario, then return to review your answers.

Open: Add drill-down to a stock ALV report →

See it in code

Each example starts from a requirement, shows the design, then the code step by step with a plain-language explanation of every part.

Was this lesson helpful?

Keep exploring

Referenced SAP objects

Reviewed reference pages for the objects this page mentions.

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.