Chinaunix首页 | 论坛 | 博客
  • 博客访问: 7185381
  • 博文数量: 655
  • 博客积分: 10264
  • 博客等级: 上将
  • 技术积分: 8278
  • 用 户 组: 普通用户
  • 注册时间: 2007-06-04 17:47
个人简介

ABAP顾问

文章分类

全部博文(655)

文章存档

2017年(2)

2014年(8)

2013年(3)

2012年(2)

2011年(18)

2010年(102)

2009年(137)

2008年(274)

2007年(134)

分类:

2008-01-08 11:49:24

 
如果用程序实现:
*&---------------------------------------------------------------------*
*& 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) |
给主人留下些什么吧!~~