如果用程序实现:
*&---------------------------------------------------------------------*
*& Report Z_BARRY_ALV_GRID
*&
*&---------------------------------------------------------------------*
*& FM方式 ALV 模板
*&
*&---------------------------------------------------------------------*
REPORT z_barry_alv_subtotal.
TYPE-POOLS: slis.
DATA: gd_fieldcat TYPE slis_t_fieldcat_alv.
DATA: sla TYPE slis_layout_alv ,
ivariant LIKE disvariant,
i_repid LIKE sy-repid ,
i_sort TYPE slis_t_sortinfo_alv WITH HEADER LINE ,
i_excluding TYPE slis_t_extab.
DATA: BEGIN OF itab OCCURS 0 .
INCLUDE STRUCTURE zscm_fee_origin.
DATA: END OF itab.
START-OF-SELECTION.
PERFORM getdata.
PERFORM outdata.
*&---------------------------------------------------------------------*
*& Form GETDATA
*&---------------------------------------------------------------------*
FORM getdata.
SELECT * INTO TABLE itab
FROM zscm_fee_origin.
ENDFORM. " GETDATA
*&---------------------------------------------------------------------*
*& Form outdata
*&---------------------------------------------------------------------*
FORM outdata.
PERFORM fieldcat_init .
sla-colwidth_optimize = 'X'.
sla-zebra = 'X'.
i_repid = sy-repid.
CLEAR i_sort.
i_sort-fieldname = 'BUKRS'.
i_sort-spos = 1.
i_sort-up = 'X'.
i_sort-subtot = 'X'.
APPEND i_sort.
CLEAR i_sort.
i_sort-fieldname = 'WERKS'.
i_sort-spos = 2.
i_sort-up = 'X'.
i_sort-subtot = 'X'.
APPEND i_sort.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
i_callback_program = i_repid
it_fieldcat = gd_fieldcat[]
it_sort = i_sort[]
is_layout = sla
TABLES
t_outtab = itab
EXCEPTIONS
program_error = 1
OTHERS = 2.
ENDFORM. " outdata
*---------------------------------------------------------------------*
* FORM fieldcat_init *
*---------------------------------------------------------------------*
FORM fieldcat_init .
PERFORM frm_catlg_set USING: 'LIFNR' 'LIFNR' ,
'BUKRS' 'BUKRS' ,
'WERKS' 'WERKS' ,
'DJAMON' 'DJAMON',
'SEQ' 'SEQ' ,
'CPUDT' 'CPUDT' ,
'DMBTRS' 'DMBTRS',
'FEES' 'FEES' .
ENDFORM. "fieldcat_init
*---------------------------------------------------------------------*
* FORM frm_catlg_set *
*---------------------------------------------------------------------*
FORM frm_catlg_set USING p_field
p_text.
DATA: ls_fieldcat TYPE slis_fieldcat_alv.
ls_fieldcat-fieldname = p_field.
ls_fieldcat-seltext_l = p_text.
IF p_field = 'DMBTRS'.
ls_fieldcat-do_sum = 'X'.
ENDIF.
APPEND ls_fieldcat TO gd_fieldcat .
CLEAR ls_fieldcat .
ENDFORM. "frm_catlg_set
阅读(6351) | 评论(0) | 转发(0) |