ALV Reports Part 1: ALV Basics with REUSE_ALV_GRID_DISPLAY
Free sample lesson · open to everyone
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 sectionsHide sections
Visual overview
Expert visual walkthrough
ALV Basics with REUSE_ALV_GRID_DISPLAY
ALV Reports · Chapter-specific technical teaching map
Integration path
SELECT data
Build field catalog
REUSE_ALV_GRID_DISPLAY
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…
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
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?
Question 2 of 3
In a well-structured ALV report, where should the SELECT statements be executed?
Question 3 of 3
When building a classic ALV list with REUSE_ALV_GRID_DISPLAY, which function module is typically used to automatically generate the field catalog from a Dictionary structure?
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.
- Classic ALV report with REUSE_ALV_GRID_DISPLAY: field catalog and double click
- ABAP report with ALV (CL_SALV_TABLE): optimized columns and a clickable order id
- ABAP first steps: variables, IF, CASE and loops in a runnable class
- Run a report in the background: JOB_OPEN, SUBMIT VIA JOB, JOB_CLOSE and check it in SM37
Was this lesson helpful?
Keep exploring
Interview questions on this topic
Related SAP topics
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.