REUSE_ALV_GRID_DISPLAY¶
Display an internal table as an ALV grid — the classic, function-module-based approach.
Purpose¶
REUSE_ALV_GRID_DISPLAY is the original ALV display function module, present in virtually all existing ABAP reports. It accepts a field catalog or a DDIC structure name and an internal table, then renders a full interactive grid with sorting, filtering, totals, and layout management.
Legacy vs. modern
This FM is still perfectly functional and mandatory knowledge for maintaining legacy code.
For new development, use CL_SALV_TABLE instead —
it requires no PERFORM callbacks and is easier to test.
Signature (key parameters)¶
| Parameter | Type | Direction | Description |
|---|---|---|---|
I_CALLBACK_PROGRAM |
SY-REPID |
Importing | Report name — always pass SY-REPID |
I_CALLBACK_USER_COMMAND |
SLIS_FORMNAME |
Importing | Name of FORM to handle toolbar actions |
I_STRUCTURE_NAME |
DD02L-TABNAME |
Importing | DDIC structure — builds field catalog automatically |
IT_FIELDCAT |
SLIS_T_FIELDCAT_ALV |
Importing | Manual field catalog (alternative to I_STRUCTURE_NAME) |
I_DEFAULT |
CHAR1 |
Importing | 'X' = show default layout button |
I_SAVE |
CHAR1 |
Importing | 'A' = allow saving layouts |
T_OUTTAB |
STANDARD TABLE |
Tables | The data — pass your internal table here |
TABLES, not EXPORTING
T_OUTTAB is a TABLES parameter (pass-by-reference). Do not pass it under
EXPORTING.
Example¶
Minimal call using I_STRUCTURE_NAME¶
REPORT zalv_demo.
TYPES: BEGIN OF ty_material,
matnr TYPE matnr,
maktx TYPE maktx,
meins TYPE meins,
END OF ty_material.
DATA gt_data TYPE STANDARD TABLE OF ty_material.
START-OF-SELECTION.
SELECT matnr maktx meins
FROM mara
INNER JOIN makt ON mara~matnr = makt~matnr
WHERE makt~spras = sy-langu
INTO CORRESPONDING FIELDS OF TABLE gt_data
UP TO 100 ROWS.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
i_callback_program = sy-repid
i_structure_name = 'MARA' " DDIC structure drives field catalog
TABLES
t_outtab = gt_data
EXCEPTIONS
program_error = 1
OTHERS = 2.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
Building a field catalog entry manually¶
DATA gt_fcat TYPE slis_t_fieldcat_alv.
DATA gs_fcat TYPE slis_fieldcat_alv.
" --- MATNR column ---
CLEAR gs_fcat.
gs_fcat-fieldname = 'MATNR'.
gs_fcat-tabname = 'GT_DATA'.
gs_fcat-seltext_m = 'Material'.
gs_fcat-key = 'X'. " mark as key column
APPEND gs_fcat TO gt_fcat.
" --- MAKTX column ---
CLEAR gs_fcat.
gs_fcat-fieldname = 'MAKTX'.
gs_fcat-tabname = 'GT_DATA'.
gs_fcat-seltext_m = 'Description'.
APPEND gs_fcat TO gt_fcat.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
i_callback_program = sy-repid
it_fieldcat = gt_fcat
TABLES
t_outtab = gt_data.
Handling user commands (toolbar / double-click)¶
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
i_callback_program = sy-repid
i_callback_user_command = 'USER_COMMAND'
i_structure_name = 'MARA'
TABLES
t_outtab = gt_data.
FORM user_command USING r_ucomm TYPE sy-ucomm
rs_selfield TYPE slis_selfield.
CASE r_ucomm.
WHEN '&IC1'. " double-click
READ TABLE gt_data INDEX rs_selfield-tabindex
ASSIGNING FIELD-SYMBOL(<ls_row>).
IF sy-subrc = 0.
" act on <ls_row>
ENDIF.
ENDCASE.
ENDFORM.
Common pitfalls¶
- Missing PF-STATUS / USER-COMMAND: if you specify
I_CALLBACK_USER_COMMAND, the namedFORMmust exist in the program. A missing form causes a syntax-time or runtime error. - Field catalog mismatch: column names in
IT_FIELDCATmust exactly match field names in the internal table. Mismatches causePROGRAM_ERROR. I_STRUCTURE_NAMEvs.IT_FIELDCAT: pass one or the other, not both.IT_FIELDCATtakes precedence.- Column texts: without
SELTEXT_M/SELTEXT_Lset, columns show the raw field name. UseREUSE_ALV_FIELDCATALOG_MERGEto auto-populate texts from DDIC.
New development
Avoid REUSE_ALV_GRID_DISPLAY in new reports. Use CL_SALV_TABLE,
which has no PERFORM callbacks and works cleanly in OO contexts.
See also¶
CL_SALV_TABLE— modern OO ALVREUSE_ALV_FIELDCATALOG_MERGE— auto-build field catalog from DDICSLIS_T_FIELDCAT_ALV— field catalog type definition (SE11)