ITPub博客

下载内表数据到excel

原创 作者:qiujun 时间:2010-07-21 13:56:14 0 删除 编辑

FORM excel_data .

DATA:
l_filename TYPE string,
l_path TYPE string,
l_fullpath TYPE string,
l_title TYPE string.

l_title = '开票信息下载'.
CALL METHOD cl_gui_frontend_services=>file_save_dialog
EXPORTING
window_title = l_title
default_extension = 'xls'
default_file_name = l_title
file_filter = '(电子表格EXCEL)'
CHANGING
filename = l_filename
path = l_path
fullpath = l_fullpath
EXCEPTIONS
cntl_error = 1
error_no_gui = 2
not_supported_by_gui = 3
OTHERS = 4.
IF sy-subrc <> 0.
STOP.
ENDIF.

DATA x_filename LIKE rlgrap-filename.
WRITE l_fullpath TO x_filename.

DATA: BEGIN OF itab_field OCCURS 0,
fname(40) TYPE c ,
END OF itab_field.

DATA: BEGIN OF lt_tab OCCURS 0,
kpsqh(12),
zcxdd(5),
tzkpfs(10),
datum(8),
uname(12),
kzwij(13),
zkpyq(100),
kunag(10),
name1(10),
extension1(40),
extension2(40),
remark(50),
zshr(12),
zshrq(8),
zswfph(30),
zkpbz(40),
zkpr(12),
zkpsj(8),
zkdgs(10),
zkddh(20),
zjjrq(8),
END OF lt_tab.

itab_field-fname = '开票申请号'.
APPEND itab_field.
itab_field-fname = '促销分开'.
APPEND itab_field.
itab_field-fname = '开票方式'.
APPEND itab_field.
itab_field-fname = '申请日期'.
APPEND itab_field.
itab_field-fname = '申请人'.
APPEND itab_field.
itab_field-fname = '金额'.
APPEND itab_field.
itab_field-fname = '开票特殊要求'.
APPEND itab_field.
itab_field-fname = '客户'.
APPEND itab_field.
itab_field-fname = '客户描述'.
APPEND itab_field.
itab_field-fname = '税务发票收件人'.
APPEND itab_field.
itab_field-fname = '税务发票收件电话'.
APPEND itab_field.
itab_field-fname = '税务发票收件地址'.
APPEND itab_field.
itab_field-fname = '审核人'.
APPEND itab_field.
itab_field-fname = '审核日期'.
APPEND itab_field.
itab_field-fname = '税务发票号'.
APPEND itab_field.
itab_field-fname = '开票备注'.
APPEND itab_field.
itab_field-fname = '开票人'.
APPEND itab_field.
itab_field-fname = '开票时间 '.
APPEND itab_field.
itab_field-fname = '快递公司'.
APPEND itab_field.
itab_field-fname = '快递单号'.
APPEND itab_field.
itab_field-fname = '寄件日期'.
APPEND itab_field.

LOOP AT it_tab.
MOVE-CORRESPONDING it_tab TO lt_tab.
APPEND lt_tab.
CLEAR lt_tab.
ENDLOOP.

CALL FUNCTION 'MS_EXCEL_OLE_STANDARD_DAT'
EXPORTING
file_name = x_filename
data_sheet_name = '开票信息'
create_pivot = 0
TABLES
data_tab = lt_tab
fieldnames = itab_field
EXCEPTIONS
file_not_exist = 1
filename_expected = 2
communication_error = 3
ole_object_method_error = 4
ole_object_property_error = 5
invalid_filename = 6
invalid_pivot_fields = 7
download_problem = 8
OTHERS = 9.

[@more@]

请登录后发表评论 登录
全部评论
  • 博文量
    107
  • 访问量
    846540