type-pools:slis.
TYPES:BEGIN OF ty_itab,
chk,
zhj(4),
carrid TYPE spfli-carrid,
connid TYPE spfli-connid,
distance TYPE spfli-distance,
END OF ty_itab.
DATA:lt_itab TYPE TABLE OF ty_itab.
DATA:ws_fieldcat TYPE slis_t_fieldcat_alv WITH HEADER LINE,
ws_fieldgroups_tab TYPE slis_t_sp_group_alv,
ws_layout TYPE slis_layout_alv,
ws_sortfields_tab TYPE slis_t_sortinfo_alv WITH HEADER LINE,
ws_events TYPE slis_t_event,
l_user_command TYPE slis_formname,
i_event TYPE slis_t_event..
FIELD-SYMBOLS:<fs> TYPE ty_itab.
DATA:i_sort TYPE slis_t_sortinfo_alv,
wa_sort TYPE slis_sortinfo_alv.
START-OF-SELECTION.
SELECT carrid connid distance
FROM spfli
INto CORRESPONDING FIELDS OF TABLE lt_itab.
LOOP AT lt_itab ASSIGNING <fs>.
<fs>-zhj = '合计'.
ENDLOOP.
DEFINE hout.
ws_fieldcat-fieldname = &1.
ws_fieldcat-seltext_m = &2.
ws_fieldcat-edit = &3.
ws_fieldcat-quantity = &4.
ws_fieldcat-ref_tabname = &5.
ws_fieldcat-ref_fieldname = &6.
ws_fieldcat-no_zero = &7.
ws_fieldcat-do_sum = &8.
if &1 = 'CHK'.
ws_fieldcat-checkbox = 'X'.
endif.
IF &1 = 'ZHJ'.
ws_fieldcat-tech = 'X'.
ws_fieldcat-no_out = 'X'.
* ws_fieldcat-do_sum = 'X'.
ENDIF.
IF &1 = 'DISTANCE'.
ws_fieldcat-do_sum = 'X'.
ENDIF.
append ws_fieldcat.
clear ws_fieldcat.
END-OF-DEFINITION.
hout:
'ZHJ' '' '' '' '' '' '' '' ,
'CARRID' '航班' '' '' '' '' '' '' ,
'CONNID' '航线' '' '' '' '' '' '' ,
'DISTANCE' '距离' '' '' '' '' '' '' .
ws_layout-zebra = 'X'.
ws_layout-get_selinfos = 'X'.
ws_layout-colwidth_optimize = 'X'.
ws_layout-detail_popup = 'X'.
ws_layout-box_fieldname = 'CHK'.
wa_sort-spos = '01' .
wa_sort-fieldname = 'ZHJ'.
wa_sort-tabname = 'LT_ITAB'.
wa_sort-down = 'X'.
wa_sort-subtot = 'X'. """""""""求和
APPEND wa_sort TO i_sort .
CLEAR wa_sort.
* wa_sort-spos = '02' .
* wa_sort-fieldname = 'CARRID'.
* wa_sort-tabname = 'LT_ITAB'.
* wa_sort-down = 'X'.
* wa_sort-subtot = 'X'. """""""""求和
* APPEND wa_sort TO i_sort .
* CLEAR wa_sort.
DATA:g_reid like sy-repid.
g_reid = sy-repid.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
i_callback_program = g_reid
* i_callback_top_of_page = 'SUB_ALV_TOP_OF_PAGE'
is_layout = ws_layout
it_fieldcat = ws_fieldcat[]
* it_events = i_event
* I_CALLBACK_USER_COMMAND = L_USER_COMMAND
* I_CALLBACK_PF_STATUS_SET = 'FRM_SET_STATUS'
* IT_SPECIAL_GROUPS = WS_FIELDGROUPS_TAB[]
it_sort = i_sort
* I_GRID_SETTINGS = GS_SETTINGS
i_default = 'X'
i_save = 'A'
TABLES
t_outtab = lt_itab
EXCEPTIONS
program_error = 1
OTHERS = 2.
TYPES:BEGIN OF ty_itab,
chk,
zhj(4),
carrid TYPE spfli-carrid,
connid TYPE spfli-connid,
distance TYPE spfli-distance,
END OF ty_itab.
DATA:lt_itab TYPE TABLE OF ty_itab.
DATA:ws_fieldcat TYPE slis_t_fieldcat_alv WITH HEADER LINE,
ws_fieldgroups_tab TYPE slis_t_sp_group_alv,
ws_layout TYPE slis_layout_alv,
ws_sortfields_tab TYPE slis_t_sortinfo_alv WITH HEADER LINE,
ws_events TYPE slis_t_event,
l_user_command TYPE slis_formname,
i_event TYPE slis_t_event..
FIELD-SYMBOLS:<fs> TYPE ty_itab.
DATA:i_sort TYPE slis_t_sortinfo_alv,
wa_sort TYPE slis_sortinfo_alv.
START-OF-SELECTION.
SELECT carrid connid distance
FROM spfli
INto CORRESPONDING FIELDS OF TABLE lt_itab.
LOOP AT lt_itab ASSIGNING <fs>.
<fs>-zhj = '合计'.
ENDLOOP.
DEFINE hout.
ws_fieldcat-fieldname = &1.
ws_fieldcat-seltext_m = &2.
ws_fieldcat-edit = &3.
ws_fieldcat-quantity = &4.
ws_fieldcat-ref_tabname = &5.
ws_fieldcat-ref_fieldname = &6.
ws_fieldcat-no_zero = &7.
ws_fieldcat-do_sum = &8.
if &1 = 'CHK'.
ws_fieldcat-checkbox = 'X'.
endif.
IF &1 = 'ZHJ'.
ws_fieldcat-tech = 'X'.
ws_fieldcat-no_out = 'X'.
* ws_fieldcat-do_sum = 'X'.
ENDIF.
IF &1 = 'DISTANCE'.
ws_fieldcat-do_sum = 'X'.
ENDIF.
append ws_fieldcat.
clear ws_fieldcat.
END-OF-DEFINITION.
hout:
'ZHJ' '' '' '' '' '' '' '' ,
'CARRID' '航班' '' '' '' '' '' '' ,
'CONNID' '航线' '' '' '' '' '' '' ,
'DISTANCE' '距离' '' '' '' '' '' '' .
ws_layout-zebra = 'X'.
ws_layout-get_selinfos = 'X'.
ws_layout-colwidth_optimize = 'X'.
ws_layout-detail_popup = 'X'.
ws_layout-box_fieldname = 'CHK'.
wa_sort-spos = '01' .
wa_sort-fieldname = 'ZHJ'.
wa_sort-tabname = 'LT_ITAB'.
wa_sort-down = 'X'.
wa_sort-subtot = 'X'. """""""""求和
APPEND wa_sort TO i_sort .
CLEAR wa_sort.
* wa_sort-spos = '02' .
* wa_sort-fieldname = 'CARRID'.
* wa_sort-tabname = 'LT_ITAB'.
* wa_sort-down = 'X'.
* wa_sort-subtot = 'X'. """""""""求和
* APPEND wa_sort TO i_sort .
* CLEAR wa_sort.
DATA:g_reid like sy-repid.
g_reid = sy-repid.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
i_callback_program = g_reid
* i_callback_top_of_page = 'SUB_ALV_TOP_OF_PAGE'
is_layout = ws_layout
it_fieldcat = ws_fieldcat[]
* it_events = i_event
* I_CALLBACK_USER_COMMAND = L_USER_COMMAND
* I_CALLBACK_PF_STATUS_SET = 'FRM_SET_STATUS'
* IT_SPECIAL_GROUPS = WS_FIELDGROUPS_TAB[]
it_sort = i_sort
* I_GRID_SETTINGS = GS_SETTINGS
i_default = 'X'
i_save = 'A'
TABLES
t_outtab = lt_itab
EXCEPTIONS
program_error = 1
OTHERS = 2.