Abap/4控制ALV表格(2)

*&---------------------------------------------------------------------*
*& Report  Z_CPT9_2                                                    *
*&                                                                     *
*&---------------------------------------------------------------------*
*&      选择列来生成ALV控件                     *
*&                                                                     *
*&---------------------------------------------------------------------*

REPORT  Z_CPT9_2                                                    .

TYPE-POOLS:SLIS.

DATA WA_ALV_FIELD TYPE SLIS_FIELDCAT_ALV.
DATA WA_ALV_FIELDCAT TYPE SLIS_T_FIELDCAT_ALV.

DATA WA_SPFLI LIKE TABLE OF SPFLI WITH HEADER LINE.
SELECT * FROM SPFLI INTO TABLE WA_SPFLI.

"定义字段
WA_ALV_FIELD-COL_POS = 1.
WA_ALV_FIELD-FIELDNAMe = 'CARRID'.
WA_ALV_FIELD-SELTEXT_M = '航线承运人'.
APPEND WA_ALV_FIELD TO WA_ALV_FIELDCAT.

WA_ALV_FIELD-COL_POS = 2.
WA_ALV_FIELD-FIELDNAMe = 'CONNID'.
WA_ALV_FIELD-SELTEXT_M = '航班连接'.
APPEND WA_ALV_FIELD TO WA_ALV_FIELDCAT.

WA_ALV_FIELD-COL_POS = 3.
WA_ALV_FIELD-FIELDNAMe = 'CITYFROM'.
WA_ALV_FIELD-SELTEXT_M = '起飞城市'.
APPEND WA_ALV_FIELD TO WA_ALV_FIELDCAT.

WA_ALV_FIELD-COL_POS = 4.
WA_ALV_FIELD-FIELDNAMe = 'CITYTO'.
WA_ALV_FIELD-SELTEXT_M = '目标城市'.
APPEND WA_ALV_FIELD TO WA_ALV_FIELDCAT.

"调用ALV控件显示数据
CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
    EXPORTING
        IT_FIELDCAT = WA_ALV_FIELDCAT
    TABLES
        T_OUTTAB = WA_SPFLI.

你可能感兴趣的:(Abap/4控制ALV表格(2))