SAP - ABAP ALV Grid Sample Code using REUSE_ALV_GRID_DISPLAY
In this sample ABAP program we will work on listing SAP tables contents using ABAP ALV grid using reuse_alv_grid_display function.
The sample ABAP code used to display data in SAP SAPLANE table using ALV grid by function calls to REUSE_ALV_FIELDCATALOG_MERGE and REUSE_ALV_GRID_DISPLAY functions.
REPORT ZTEST_SAPLANE.
DATA:
gs_saplane TYPE saplane,
gt_saplane TYPE TABLE OF saplane.
SELECT * FROM saplane INTO TABLE gt_saplane.
TYPE-POOLS slis.
DATA:
gt_fieldcat TYPE slis_t_fieldcat_alv,
gv_title TYPE lvc_title.
gv_title = 'SAP Table SAPLANE contents'.
CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
EXPORTING
i_program_name = SY-REPID
i_structure_name = 'SAPLANE'
CHANGING
ct_fieldcat = gt_fieldcat.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
it_fieldcat = gt_fieldcat
i_grid_title = gv_title
TABLES
t_outtab = gt_saplane.
The output screen by using ABAP alv grid sample is as shown in the below ABAP program output screen.
You can add columns to the ALV grid or remove columns from the ALV grid by using APPEND ABAP command on the field catalog it_fieldcat parameter value.
We will work with ABAP samples on ALV grid for modifying the it_fieldcat field catalog in further ABAP tutorials examples.