&———————————————————————*
*& Report Z01_DEMO_ALV_FIELDCATALOG
*&
*&———————————————————————*
*& Programmer: Vy Khang Ly
*& SAP FREE ABAP TUTORIALS
*& http://sapforbeginner.com
*&———————————————————————*
REPORT Z01_DEMO_ALV_FIELDCATALOG.
TYPE-POOLS: slis. ” SLIS contains all the ALV data types
*&———————————————————————*
*& Data Declaration
*&———————————————————————*
DATA: lt_sflight TYPE TABLE OF sflight.
DATA: lt_fieldcat TYPE slis_t_fieldcat_alv,
ls_fieldcat TYPE slis_fieldcat_alv.
DATA: g_repid TYPE sy-repid.
*&———————————————————————*
*& START-OF-SELECTION
*&———————————————————————*
START-OF-SELECTION.
g_repid = sy-repid.
*&—– Fetch data from the database —–*
SELECT *
FROM sflight
INTO TABLE lt_sflight.
*&—– Field Catalog —–*
ls_fieldcat-fieldname = ‘CARRID’.
ls_fieldcat-seltext_m = ‘Airline’.
APPEND ls_fieldcat TO lt_fieldcat.
ls_fieldcat-fieldname = ‘CONNID’.
ls_fieldcat-seltext_m = ‘FLight Number’.
APPEND ls_fieldcat TO lt_fieldcat.
ls_fieldcat-fieldname = ‘FLDATE’.
ls_fieldcat-seltext_m = ‘FLight Date’.
APPEND ls_fieldcat TO lt_fieldcat.
*Calculating total of bookings.
ls_fieldcat-fieldname = ‘PAYMENTSUM’.
ls_fieldcat-seltext_m = ‘Total of current bookings’.
ls_fieldcat-do_sum = ‘X’.
APPEND ls_fieldcat TO lt_fieldcat.
ls_fieldcat-fieldname = ‘CURRENCY’.
ls_fieldcat-seltext_m = ‘Currency’.
APPEND ls_fieldcat TO lt_fieldcat.
CALL FUNCTION ‘REUSE_ALV_GRID_DISPLAY’
EXPORTING
it_fieldcat = lt_fieldcat
TABLES
t_outtab = lt_sflight.
Serkan AKKAVAK
Computer Engineer
ABAP Developer & SAP S/4 HANA Logistics Team Lead
Contact : serkurumsal@yandex.com
Social Plugin