Skip to main content

SAP ABAP ALV Report Using REUSE_ALV_GRID_DISPLAY – Complete Tutorial with Examples

 

πŸ“˜ SAP ABAP ALV Report Using REUSE_ALV_GRID_DISPLAY – Complete Step-by-Step Guide (With Real Examples)

SAP ABAP developers frequently use ALV (ABAP List Viewer) to present data in a clean and interactive format.
One of the most commonly used ALV function modules in classical reporting is:


This function module allows developers to create professional ALV reports with features such as sorting, filtering, totals, layout saving, and exporting to Excel.

In this guide, I will explain:

  • What REUSE_ALV_GRID_DISPLAY is

  1. How field catalogs work
  2. How to build an ALV report using MARC and KNA1 tables
  3. Real-time business examples
  4. Clean, fully working ABAP code

This post is written from my personal learning and hands-on experience while working on SAP ABAP reports.

🧩 What is REUSE_ALV_GRID_DISPLAY?

REUSE_ALV_GRID_DISPLAY is a function module-based ALV used in SAP ECC and compatible with S/4HANA systems.
It displays internal table data in a grid-style output, which is more user-friendly than standard write statements.

⭐ Key Features:

  1. Column sorting & filtering
  2. Totals and subtotals
  3. Export to Excel
  4. User layout variants
  5. Color coding & hotspots
  6. Fast and structured reporting

Because of these features, ALV grid reporting is still widely used in real-time SAP projects.

πŸ” Purpose

It displays a table with user-friendly features like:

  1. Column sorting and filtering
  2. Totals and subtotals
  3. Export to Excel
  4. Save layout variants
  5. Interactive buttons and more


🧱 Syntax of REUSE_ALV_GRID_DISPLAY

CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY' EXPORTING i_callback_program = sy-repid it_fieldcat = field_catalog_table i_structure_name = 'STRUCTURE_NAME' is_layout = layout_settings i_save = 'A' TABLES t_outtab = output_internal_table.


πŸ”‘ Important Parameters Explained

ParameterDescription
i_callback_programName of the calling program
it_fieldcatField catalog (defines ALV columns)
is_layoutOptional layout styles
i_saveAllows saving user layouts
t_outtabInternal table with output data

Field catalog is the most important part because it defines how the ALV columns will look.

🟦 Real-Time Example 1: ALV Report Using MARC Table

πŸ“Œ Business Requirement

A user wants to display Material Master Plant Level Data.
They enter a Plant (WERKS) on the selection screen.
The report should fetch:

  1. Material Number
  2. Material Status
  3. Plant

And display results in ALV Grid.

πŸ§‘‍πŸ’» ABAP Code – ALV Report for MARC Data

TYPES: BEGIN OF ty_marc, matnr TYPE marc-matnr, pstat TYPE marc-pstat, werks TYPE marc-werks, END OF ty_marc. DATA: it_marc TYPE TABLE OF ty_marc, wa_marc TYPE ty_marc. DATA: lt_fieldcat TYPE slis_t_fieldcat_alv, ls_fieldcat TYPE slis_fieldcat_alv. SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE TEXT-002. PARAMETERS p_werks TYPE marc-werks. SELECTION-SCREEN END OF BLOCK b1. AT SELECTION-SCREEN. IF p_werks IS INITIAL. MESSAGE 'Please enter a valid Plant' TYPE 'E'. ENDIF. START-OF-SELECTION. SELECT matnr pstat werks INTO TABLE it_marc FROM marc WHERE werks = p_werks UP TO 20 ROWS. " Field catalog for ALV CLEAR ls_fieldcat. ls_fieldcat-fieldname = 'MATNR'. ls_fieldcat-tabname = 'IT_MARC'. ls_fieldcat-seltext_m = 'Material Number'. ls_fieldcat-col_pos = 1. ls_fieldcat-key = 'X'. APPEND ls_fieldcat TO lt_fieldcat. CLEAR ls_fieldcat. ls_fieldcat-fieldname = 'PSTAT'. ls_fieldcat-tabname = 'IT_MARC'. ls_fieldcat-seltext_m = 'Material Status'. ls_fieldcat-col_pos = 2. APPEND ls_fieldcat TO lt_fieldcat. CLEAR ls_fieldcat. ls_fieldcat-fieldname = 'WERKS'. ls_fieldcat-tabname = 'IT_MARC'. ls_fieldcat-seltext_m = 'Plant'. ls_fieldcat-col_pos = 3. APPEND ls_fieldcat TO lt_fieldcat. CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY' EXPORTING i_callback_program = sy-repid it_fieldcat = lt_fieldcat TABLES t_outtab = it_marc.



SAP ABAP ALV REPORTS


THE OUTPUT IMAGE GIVEN BELOW

SAP ABAP ALV REPORT


🟦 Real-Time Example 2: Customer ALV Report Using KNA1 Table

This example is useful for SD (Sales & Distribution) requirements.

πŸ“ŒRequirement

Display the following customer details:

  1. Customer Number
  2. Customer Name
  3. Country
  4. City


πŸ§‘‍πŸ’» ABAP Code – ALV Report for Customer Master (KNA1)

TYPES: BEGIN OF ty_kna1,
kunnr TYPE kna1-kunnr,
name1 TYPE kna1-name1,
land1 TYPE kna1-land1,
ort01 TYPE kna1-ort01,
END OF ty_kna1.

DATA: it_kna1 TYPE TABLE OF ty_kna1,
wa_kna1 TYPE ty_kna1,
it_fcat TYPE slis_t_fieldcat_alv,
wa_fcat TYPE slis_fieldcat_alv.

" Step 1: Select data
SELECT kunnr name1 land1 ort01
INTO TABLE it_kna1
FROM kna1
UP TO 100 ROWS.

" Step 2: Build field catalog manually
CLEAR wa_fcat.
wa_fcat-fieldname = 'KUNNR'.
wa_fcat-seltext_m = 'Customer No'.
wa_fcat-tabname = 'IT_KNA1'.
wa_fcat-outputlen = 10.
APPEND wa_fcat TO it_fcat. CLEAR wa_fcat.

wa_fcat-fieldname = 'NAME1'.
wa_fcat-seltext_m = 'Customer Name'.
wa_fcat-tabname = 'IT_KNA1'.
wa_fcat-outputlen = 25.
APPEND wa_fcat TO it_fcat. CLEAR wa_fcat.

wa_fcat-fieldname = 'LAND1'.
wa_fcat-seltext_m = 'Country'.
wa_fcat-tabname = 'IT_KNA1'.
wa_fcat-outputlen = 5.
APPEND wa_fcat TO it_fcat. CLEAR wa_fcat.

wa_fcat-fieldname = 'ORT01'.
wa_fcat-seltext_m = 'City'.
wa_fcat-tabname = 'IT_KNA1'.
wa_fcat-outputlen = 20.
APPEND wa_fcat TO it_fcat.

CLEAR wa_fcat.

" Step 3: Display ALV

CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
i_callback_program = sy-repid
it_fieldcat = it_fcat
i_save = 'A'
TABLES
t_outtab = it_kna1.

SAP ABAP ALV REPORTS



PLEASE CLICK ON THE BELOW LINK TO GET ABAP ALV REPORTS

SAP ABAP ALV REAL TIME 














Comments

Popular posts from this blog

SAP ABAP SE11 Data Dictionary Tutorial | Step-by-Step Explanation with Real-Time Examples

    SAP ABAP Data Dictionary (SE11) – Complete Guide to Tables, Views, Domains & Data Elements    What is the ABAP Data Dictionary? The SAP ABAP data dictionary serves as a primary and structured source of data for creating objects. It is an independent database DDL (Data Definition Language) that primarily deals with creating, editing, and dropping database tables. The data dictionary allows you to define and maintain database-related items. The ABAP data dictionary is readily connected with the ABAP workbench, allowing all of the workbench's components to simply access the definitions contained in the dictionary. Functions of Data Dictionary The important functions of data dictionary objects are as follows. 1. Database tables 2. Domains 3. Data elements 4. Views 5. Search helps 6. Lock Objects 1. Database Tables: –  Database tables are collections of fields that store physical data. It is an object that holds data in the form of rows and columns. So databa...

SAP ABAP Control Break Statements – Complete Guide with AT FIRST, AT NEW & AT END OF Examples

πŸ“˜ SAP ABAP Control Break Statements – Complete Guide with Example Learn about Control Break Statements in SAP ABAP including AT FIRST, AT NEW, AT END OF, AT LAST, and ON CHANGE OF. Includes a real-time example program with explanation and output. Perfect for SAP ABAP beginners and developers. SAP ABAP Control Break Statements AT NEW ABAP example AT END OF ABAP tutorial ABAP loop control SAP ABAP report programming AT FIRST, AT LAST in ABAP SAP ABAP internal table sorted πŸ“˜ Introduction In SAP ABAP , control break statements are used to trigger events inside a loop . They are essential for creating grouped or hierarchical reports , especially when working with sorted internal tables. There are 5 main control break statements in ABAP: AT FIRST – ENDAT AT NEW – ENDAT AT END OF – ENDAT AT LAST – ENDAT ON CHANGE OF FIELD. SAP ABAP Loop Control Tutorial:  How to Use AT NEW, AT END OF, AT FIRST, AT LAST, & ON CHANGE OF  FIELD. 🧠 Key Control Break Statements Explai...