自定義輸出字段的ALV控件實例
程序员文章站
2022-04-18 15:50:04
...
*&---------------------------------------------------------------------*
*& Report YTEST00A
*&---------------------------------------------------------------------*
*&Violin 2021/3/10
*&---------------------------------------------------------------------*
REPORT ytest00a.
*第8章 表控件ALV控件的使用---------------------------------------------------------------------*
*8.2自定義輸出字段的ALV控件實例
*ALV使用到的類庫
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 * INTO TABLE WA_SPFLI FROM SPFLI.
*定義第一到第四個字段
CLEAR WA_ALV_FIELD.
WA_ALV_FIELD-COL_POS = 1.
WA_ALV_FIELD-FIELDNAME = 'CARRID'.
WA_ALV_FIELD-SELTEXT_M = '航線承運人'.
APPEND WA_ALV_FIELD TO WA_ALV_FIELDCAT.
CLEAR WA_ALV_FIELD.
WA_ALV_FIELD-COL_POS = 2.
WA_ALV_FIELD-FIELDNAME = 'CONNID'.
WA_ALV_FIELD-SELTEXT_M = '航班連接'.
APPEND WA_ALV_FIELD TO WA_ALV_FIELDCAT.
CLEAR WA_ALV_FIELD.
WA_ALV_FIELD-COL_POS = 3.
WA_ALV_FIELD-FIELDNAME = 'CITYFROM'.
WA_ALV_FIELD-SELTEXT_M = '起飛城市'.
APPEND WA_ALV_FIELD TO WA_ALV_FIELDCAT.
CLEAR WA_ALV_FIELD.
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
* I_INTERFACE_CHECK = ' '
* I_BYPASSING_BUFFER = I_BYPASSING_BUFFER
* I_BUFFER_ACTIVE = ' '
* I_CALLBACK_PROGRAM = ' '
* I_CALLBACK_PF_STATUS_SET = ' '
* I_CALLBACK_USER_COMMAND = ' '
* I_STRUCTURE_NAME = I_STRUCTURE_NAME
* IS_LAYOUT = IS_LAYOUT
IT_FIELDCAT = WA_ALV_FIELDCAT
* IT_EXCLUDING = IT_EXCLUDING
* IT_SPECIAL_GROUPS = IT_SPECIAL_GROUPS
* IT_SORT = IT_SORT
* IT_FILTER = IT_FILTER
* IS_SEL_HIDE = IS_SEL_HIDE
* I_DEFAULT = 'X'
* I_SAVE = ' '
* IS_VARIANT = IS_VARIANT
* IT_EVENTS = IT_EVENTS
* IT_EVENT_EXIT = IT_EVENT_EXIT
* IS_PRINT = IS_PRINT
* IS_REPREP_ID = IS_REPREP_ID
* I_SCREEN_START_COLUMN = 0
* I_SCREEN_START_LINE = 0
* I_SCREEN_END_COLUMN = 0
* I_SCREEN_END_LINE = 0
* IR_SALV_LIST_ADAPTER = IR_SALV_LIST_ADAPTER
* IT_EXCEPT_QINFO = IT_EXCEPT_QINFO
* I_SUPPRESS_EMPTY_DATA = ABAP_FALSE
* IMPORTING
* E_EXIT_CAUSED_BY_CALLER = E_EXIT_CAUSED_BY_CALLER
* ES_EXIT_CAUSED_BY_USER = ES_EXIT_CAUSED_BY_USER
TABLES
t_outtab = WA_SPFLI
EXCEPTIONS
PROGRAM_ERROR = 1
OTHERS = 2.
.
IF sy-subrc <> 0.
* Implement suitable error handling here
ENDIF.
推荐阅读