老规矩,直接上菜食用。.
TYPE-POOLS:SLIS.
DATA: GT_SBOOK TYPE TABLE OF SBOOK.
DATA: GT_FIELDCAT TYPE SLIS_T_FIELDCAT_ALV,
GS_FIELDCAT TYPE SLIS_FIELDCAT_ALV.
DATA: GT_SORT TYPE SLIS_T_SORTINFO_ALV,
GS_SORT TYPE SLIS_SORTINFO_ALV.
DEFINE ADDFIELDCAT.
gs_fieldcat-FIELDNAME = &1.
gs_fieldcat-SELTEXT_M = &2.
gs_fieldcat-DO_SUM = &3.
APPEND gs_fieldcat TO gt_fieldcat.
clear gs_fieldcat.
END-OF-DEFINITION.
CLEAR GS_FIELDCAT.
START-OF-SELECTION.
SELECT *
INTO CORRESPONDING FIELDS OF TABLE GT_SBOOK
FROM SBOOK
UP TO 300 ROWS.
*Build sort catalog
CLEAR GS_SORT.
GS_SORT-SPOS = 1.
GS_SORT-FIELDNAME = 'CARRID'.
GS_SORT-UP = 'X'.
GS_SORT-SUBTOT = 'X'.
APPEND GS_SORT TO GT_SORT.
CLEAR GS_SORT.
GS_SORT-SPOS = 1.
GS_SORT-FIELDNAME = 'CONNID'.
GS_SORT-UP = 'X'.
GS_SORT-SUBTOT = 'X'.
APPEND GS_SORT TO GT_SORT.
ADDFIELDCAT 'CARRID' 'AIRLINE' ''.
ADDFIELDCAT 'CONNID' 'Con. No.' ''.
ADDFIELDCAT 'FLDATE' 'DATE' ''.
ADDFIELDCAT 'BOOKID' 'Book. ID' ''.
ADDFIELDCAT 'PASSNAME' 'Passenger Name' ''.
ADDFIELDCAT 'LOCCURAM' 'Price' 'X'.
ADDFIELDCAT 'LOCCURKEY' 'Currency' ''.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
IT_FIELDCAT = GT_FIELDCAT
IT_SORT = GT_SORT
TABLES
T_OUTTAB = GT_SBOOK
EXCEPTIONS
PROGRAM_ERROR = 1
OTHERS = 2.