matinal:ABAP ALV的总计和小计

如果用程序实现:

*&---------------------------------------------------------------------*
*& Report  ZMATINAL_ALV_GRID
*&
*&---------------------------------------------------------------------*
*&  FM方式 ALV 模板
*&
*&---------------------------------------------------------------------*

REPORT  z_matinal_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

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值