SAP 标准倒EXCEL的FM

来源:互联网 发布:老舍的人品 知乎 编辑:程序博客网 时间:2024/04/26 06:47

原文地址:http://www.erp100.com/93236/viewspace-6764344.html

不管是开发人员,还是用户。一定都非常熟悉下面的SAP报表功能

我们一般用这个按钮来倒显示报表到EXCEL。这控件能做到连报表的表头一起倒。
在之前我们介绍过几个倒内表到EXCEL的函数(WS_EXCEL,不能倒表头),或者OLE(速度太慢),现在XXL_FULL_API.能很好的解决上面两个问题。

实现代码如下:
check tab_head is not initial.
data:tmp_head like  zfi_headertab1.
data:show_bseg like table of st_bseg.
data:zstrucinfo type table of rstrucinfo with header line.
data:zsema like table of gxxlt_s with header line.
data:zhkey like table of gxxlt_h with header line.
data:zonline_text like table of gxxlt_o with header line.
data:zprint_text like table of gxxlt_p with header line.
data:zvkey like table of gxxlt_v with header line.
zhkey-col_no = 1.
zhkey-row_no = 1.
zhkey-col_name = '公司'.
append zhkey.
  zhkey-col_no = 2.
zhkey-row_no = 1.
zhkey-col_name = '会计凭证'.
append zhkey.
  zhkey-col_no = 3.
zhkey-row_no = 1.
zhkey-col_name = '年'.
append zhkey.
  zhkey-col_no = 4.
zhkey-row_no = 1.
zhkey-col_name = '行项目'.
append zhkey.
  zhkey-col_no = 5.
zhkey-row_no = 1.
zhkey-col_name = '金额'.
append zhkey.
  zhkey-col_no = 6.
zhkey-row_no = 1.
zhkey-col_name = '借/贷'.
append zhkey.
  zhkey-col_no = 7.
zhkey-row_no = 1.
zhkey-col_name = '科目类型'.
append zhkey.
  zhkey-col_no = 8.
zhkey-row_no = 1.
zhkey-col_name = '过账日期'.
append zhkey.
zhkey-col_no = 9.
zhkey-row_no = 1.
zhkey-col_name = '文本'.
append zhkey.
   zhkey-col_no = 10.
zhkey-row_no = 1.
zhkey-col_name = '数量'.
append zhkey.
  zhkey-col_no = 11.
zhkey-row_no = 1.
zhkey-col_name = '物料'.
append zhkey.
  zhkey-col_no = 12.
zhkey-row_no = 1.
zhkey-col_name = '产品层次'.
append zhkey.
zhkey-col_no = 13.
zhkey-row_no = 1.
zhkey-col_name = '科目'.
append zhkey.
  zhkey-col_no = 14.
zhkey-row_no = 1.
zhkey-col_name = '参考发票'.
append zhkey.
   zhkey-col_no = 15.
zhkey-row_no = 1.
zhkey-col_name = '凭证'.
append zhkey.
   zhkey-col_no = 16.
zhkey-row_no = 1.
zhkey-col_name = '汇总凭证'.
append zhkey.
zhkey-col_no = 17.
zhkey-row_no = 1.
zhkey-col_name = '是否是中心仓'.
append zhkey.
loop at tab_head into tmp_head.
  if p_matnr is not initial.
loop at it_bseg into wa_bseg where matnr = tmp_head-matnr and
   ( flag = '' or flag = 'X' ).
   append wa_bseg to show_bseg.
endloop.
  else.
  loop at it_bseg into wa_bseg where prodh = tmp_head-prdha.
   append wa_bseg to show_bseg.
  endloop.
  endif.
endloop.
do 17 times.
  zsema-col_no     = sy-tabix.
  zsema-col_typ    = 'STR'.
  zsema-col_ops    = 'DFT'.
  zsema-col_cur    = 0.
  if sy-tabix = 5 or sy-tabix = 10.
     zsema-col_typ    = 'NUM'.
     zsema-col_ops    = 'ADD'.
     zsema-col_cur    = 4.
  endif.
  append zsema.
enddo.
loop at show_bseg into wa_bseg.
  move-corresponding wa_bseg to api_bseg.
  append api_bseg.
endloop.
*API_BSEG[] = SHOW_BSEG.
            call function 'XXL_FULL_API'
              exporting
*               DATA_ENDING_AT          = -1
*               DATA_STARTING_AT        = 1
               filename                = 'XMPL0003'
               header_1                = 'Colour Corporation '
               header_2                = 'Overall Business Figures '
*               NO_DIALOG               = 'X'
*               NO_START                = ' '
                n_att_cols              = 17
                n_hrz_keys              = 1
                n_vrt_keys              = 0
*               SEMA_TYPE               = ' '
*               SO_TITLE                = ' '
              tables
                data                    = api_bseg
                hkey                    = zhkey
                online_text             = zonline_text
                print_text              = zprint_text
                sema                    = zsema
                vkey                    = zvkey.
clear:show_bseg,tab_head,api_bseg[].

原创粉丝点击