EXCEL模板的上传个下载

基本流程:在BUTTON下载模板,添加数据到模板,保存,上载数据。

 

上传:SMW0      模板 *.XLS

 

下载:在程序中下载模板

 

FORM fm_excel .
  DATA:  lo_objdata LIKE wwwdatatab,
         lo_mime LIKE w3mime,
         lc_filename  TYPE string VALUE'TC' ,
         lc_fullpath  TYPE string  VALUE'c:/SapReport/' ,
         lc_path      TYPE  string VALUE'c:/SapReport/' ,
         ls_destination LIKE rlgrap-filename,
         ls_objnam TYPE string,
         li_rc LIKE sy-subrc,
         ls_errtxt TYPE string.
  DATA:p_objid TYPE wwwdatatab-objid,
       p_dest LIKE sapb-sappfad.
  p_objid = '模板名字.XLS'.
  CALL METHOD cl_gui_frontend_services=>file_save_dialog
    EXPORTING
      default_extension    = 'XLS'
      default_file_name    = lc_filename
    CHANGING
      filename             = lc_filename
      path                 = lc_path
      fullpath             = lc_fullpath
    EXCEPTIONS
      cntl_error           = 1
      error_no_gui         = 2
      not_supported_by_gui = 3
      OTHERS               = 4.
  IF lc_fullpath = ''.
    MESSAGE  '不能打开excel' TYPE 'E'.
  ENDIF.
  IF sy-subrc = 0.
    p_dest = lc_fullpath.
*    concatenate p_objid '.XLS' into ls_objnam.
    CONDENSE ls_objnam NO-GAPS.
    SELECT SINGLE relid objid FROM wwwdata INTO CORRESPONDING FIELDS OF lo_objdata
           WHERE srtf2 = 0 AND relid = 'MI' AND objid = p_objid.
    IF sy-subrc NE 0 OR lo_objdata-objid EQ space.
      CONCATENATE '模板文件' ls_objnam '不存在' INTO ls_errtxt.
      MESSAGE ls_errtxt TYPE 'I'.
    ENDIF.
    ls_destination = p_dest.
    CALL FUNCTION 'DOWNLOAD_WEB_OBJECT'
      EXPORTING
        key         = lo_objdata
        destination = ls_destination
      IMPORTING
        rc          = li_rc.
    IF li_rc NE 0.
      CONCATENATE '模板文件:' ls_objnam '下载失败' INTO ls_errtxt.
      MESSAGE ls_errtxt TYPE 'E'.
    ENDIF.
  ENDIF.
ENDFORM.             

 

PS: 在表wwwdata中有在SMW0上传的模板,有则可以下载,没有则显示不存在

 

上传:

如下:http://blog.csdn.net/leechirslcc/archive/2009/07/30/4394239.aspx

你可能感兴趣的:(String,Excel,dialog,Path,download,extension)