REPORT Z_SIMPLE_ALV
TYPE-POOLS: slis. " SLIS contains all the ALV data types
*&---------------------------------------------------------------------*
*& Data Declaration
*&---------------------------------------------------------------------*
DATA :ls_address TYPE adrc, " We will still use this to hold each line/record
lt_address TYPE TABLE OF adrc. "Data Declaration this time - TABLE
DATA: lt_fieldcat TYPE slis_t_fieldcat_alv,
ls_fieldcat TYPE slis_fieldcat_alv.
*&---------------------------------------------------------------------*
*& START-OF-SELECTION
*&---------------------------------------------------------------------*
START-OF-SELECTION.
*Fetch data from the database
SELECT * FROM adrc
INTO TABLE lt_address
WHERE city1 = 'Hamburg'.
*** Choose the fields you want to display in output.
*** At a minimum we will have to fill the DATABASE TABLE field name
*** and Column name for display
"Seltext_m : is the column display name.
*Build field catalog
ls_fieldcat-fieldname = 'STREET'. " Fieldname in the data table
ls_fieldcat-seltext_m = 'Street'. " Column description in the output
APPEND ls_fieldcat TO lt_fieldcat.
ls_fieldcat-fieldname = 'CITY1'.
ls_fieldcat-seltext_m = 'City'.
APPEND ls_fieldcat TO lt_fieldcat.
ls_fieldcat-fieldname = 'POST_CODE1'.
ls_fieldcat-seltext_m = 'Zip Code'.
APPEND ls_fieldcat TO lt_fieldcat.
*Pass data and field catalog to ALV function module to display ALV list
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
it_fieldcat = lt_fieldcat
TABLES
t_outtab = lt_address
EXCEPTIONS
program_error = 1
OTHERS = 2.
**********************************************************************
*** END of PROGRAM
**********************************************************************
Output :
