Chinaunix首页 | 论坛 | 博客
  • 博客访问: 458741
  • 博文数量: 199
  • 博客积分: 0
  • 博客等级: 民兵
  • 技术积分: 1902
  • 用 户 组: 普通用户
  • 注册时间: 2020-05-14 13:25
个人简介

代码5S

文章分类

全部博文(199)

文章存档

2021年(5)

2020年(194)

我的朋友

分类: 其他平台

2020-10-28 15:57:56

report ztest.

data begin of li_makt occurs 0,
         matnr type matnr,
         maktx type maktx,
       end of li_makt.

databegin of li_head occurs 0,
        field(30type c,
      end of li_head.

selection-screen begin of block b2 with frame title text-002.
parameters:
  p_file type rlgrap-filename obligatory.
selection-screen end of block b2.

at selection-screen on value-request for p_file.
  perform browse_file changing p_file.

start-of-selection.

  refresh li_head.

  define mc_head.
    li_head-field &1.
    append li_head.
  end-of-definition.

  select matnr maktx into table li_makt from makt up to 20 rows
    where spras sy-langu .

  mc_head '物料编码''物料名称'.

  call function 'EXCEL_OLE_STANDARD_DAT'
    exporting
      file_name                 p_file
      create_pivot              0
      data_sheet_name           'Data Material'
      pivot_sheet_name          ' '
      password                  '1234'
      password_option           1
    tables
      data_tab                  li_makt
      fieldnames                li_head
    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.
  if sy-subrc <> 0.
    message id sy-msgid type sy-msgty number sy-msgno
            with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
  endif.


*&---------------------------------------------------------------------*
*&      Form  browse_file
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*      <--P_FILE     text
*----------------------------------------------------------------------*
form browse_file changing p_file like rlgrap-filename.
  datafiletab   type filetable,
        rc        type i,
        lv_offset type i.

  free filetab.
  call method cl_gui_frontend_services=>file_open_dialog
    exporting
      window_title            'Choose File'
      default_extension       '*.*'
      default_filename        'c:\*.xls'
    changing
      file_table              filetab
      rc                      rc
    exceptions
      file_open_dialog_failed 1
      cntl_error              2
      error_no_gui            3
      others                  4.
  if sy-subrc 0.
    read table filetab into p_file index 1.
  endif.
endform" browse_file
阅读(1614) | 评论(0) | 转发(0) |
0

上一篇:S4 DEMO

下一篇:interface

给主人留下些什么吧!~~