将本地文件上传到服务器上

*&---------------------------------------------------------------------*
*& Report  ZUPLOAD                                                     *
*&                                                                     *
*&---------------------------------------------------------------------*
*&                                                                     *
*&                                                                     *
*&---------------------------------------------------------------------*

REPORT  ZUPLOAD       message-id zmm                          .
DATA: fname TYPE rlgrap-filename,
      ftype TYPE rlgrap-filetype,
      fsize TYPE i.
data: fname_p type string,
      fname_n type string.
data: sfname_p type string .
data: sfname like RCGIEDIAL-IEFILE.
      sfname_p = 'c:/'.
data: r(1) type c.


DATA: DATA_TAB  LIKE RCGREPFILE OCCURS 10 WITH HEADER LINE.
DATA: LINES         TYPE I.

CALL FUNCTION 'UPLOAD'
     EXPORTING
*          codepage            = 'IBM'
          filename            = 'c:/'
          filetype            = 'BIN'
*          filemask_mask       = '*.XLS'
*          FILESMASK_TEXT      = 'XLS'
          FILETYPE_NO_CHANGE  = 'X'
*          SILENT              = 'X'
*          item                = ''
     IMPORTING
          filesize            = fsize
          act_filename        = fname
          act_filetype        = ftype
     TABLES
          data_tab            = data_tab
     EXCEPTIONS
          conversion_error    = 1
          invalid_table_width = 2
          invalid_type        = 3.

fname_n = fname.
do.
 split fname_n at '/' into fname_p fname_n.
 search fname_n for '/'.
 if sy-subrc = 4.
  exit.
 endif.
enddo.
fname_p = fname.
shift fname_p right deleting trailing fname_n.
shift fname_p left deleting leading space.
write:/,'fname_p=',fname_p,'|',
      /,'fname_n=',fname_n,'|'.
concatenate sfname_p fname_n into sfname.
write:/,'sfname=',sfname,'|'.
DESCRIBE TABLE DATA_TAB LINES LINES.

 CALL FUNCTION 'C13Z_RAWDATA_WRITE'
       EXPORTING
            I_FILE           = sfname
            I_FILE_SIZE      = fsize
            I_LINES          = LINES
       TABLES
            I_RCGREPFILE_TAB = DATA_TAB
       EXCEPTIONS
            NO_PERMISSION    = 1
            OPEN_FAILED      = 2
            OTHERS           = 3.

IF sy-subrc NE 0.
*  MESSAGE s000 WITH 'UPLOAD SUCC'.
write : 'upload success !'.
ENDIF.

WRITE: 'SY-SUBRC:', sy-subrc,
     / '上载的本地文件名:',  (60) fname,
     / '上载的远程文件名:',(60) sfname,
     / '文件类型:', ftype,
     / '文件大小:', fsize.

SKIP. 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值