TYPE-POOLS: SLIS. " SLIS contains all the ALV data types
*&---------------------------------------------------------------------*
*& Data Declaration
*&---------------------------------------------------------------------*
DATA: IT_SBOOK TYPE TABLE OF SBOOK.
DATA: IT_FIELDCAT TYPE SLIS_T_FIELDCAT_ALV,
WA_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 * UP TO 500 ROWS FROM SBOOK INTO TABLE IT_SBOOK.
*Build field catalog
WA_FIELDCAT-FIELDNAME = 'CARRID'. " Fieldname in the data table
WA_FIELDCAT-SELTEXT_M = 'Airline'. " Column description in the output
APPEND WA_FIELDCAT TO IT_FIELDCAT.
CLEAR WA_FIELDCAT.
WA_FIELDCAT-FIELDNAME = 'CONNID'.
WA_FIELDCAT-SELTEXT_M = 'Con. No.'.
APPEND WA_FIELDCAT TO IT_FIELDCAT.
CLEAR WA_FIELDCAT.
WA_FIELDCAT-FIELDNAME = 'FLDATE'.
WA_FIELDCAT-SELTEXT_M = 'Date'.
APPEND WA_FIELDCAT TO IT_FIELDCAT.
CLEAR WA_FIELDCAT.
WA_FIELDCAT-FIELDNAME = 'BOOKID'.
WA_FIELDCAT-SELTEXT_M = 'Book. ID'.
APPEND WA_FIELDCAT TO IT_FIELDCAT.
CLEAR WA_FIELDCAT.
WA_FIELDCAT-FIELDNAME = 'FORCURAM'.
WA_FIELDCAT-SELTEXT_M = 'Price'.
WA_FIELDCAT-DO_SUM = 'X'.
WA_FIELDCAT-CFIELDNAME = 'FORCURKEY'.
APPEND WA_FIELDCAT TO IT_FIELDCAT.
CLEAR WA_FIELDCAT.
WA_FIELDCAT-FIELDNAME = 'FORCURKEY'.
WA_FIELDCAT-SELTEXT_M = 'Currency'.
APPEND WA_FIELDCAT TO IT_FIELDCAT.
CLEAR WA_FIELDCAT.
WA_FIELDCAT-FIELDNAME = 'LUGGWEIGHT'.
WA_FIELDCAT-SELTEXT_M = 'Weight'.
WA_FIELDCAT-DO_SUM = 'X'.
WA_FIELDCAT-QFIELDNAME = 'WUNIT'.
APPEND WA_FIELDCAT TO IT_FIELDCAT.
CLEAR WA_FIELDCAT.
WA_FIELDCAT-FIELDNAME = 'WUNIT'.
WA_FIELDCAT-SELTEXT_M = 'Unit'.
APPEND WA_FIELDCAT TO IT_FIELDCAT.
CLEAR WA_FIELDCAT.
*Pass data and field catalog to ALV function module to display ALV list
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
I_CALLBACK_PROGRAM = G_REPID
IT_FIELDCAT = IT_FIELDCAT
TABLES
T_OUTTAB = IT_SBOOK
EXCEPTIONS
PROGRAM_ERROR = 1
OTHERS = 2.
ABAP开发基础 根据货币单位,重量单位进行汇总合计
最新推荐文章于 2024-06-26 11:10:55 发布