Upload Picture to application server

95 阅读1分钟

Created by Jerry Wang on Jun 08, 2014 Go to start of metadata

使用tcode tcode SMW0, 选择Binary data for WebRFC applications:
clipboard1

点击创建button:
clipboard2

输入technical name和description:
clipboard3

点击import icon 从本地load picture:
clipboard4
import完成之后可在server端看到上传完毕的picture:
clipboard5

使用下列代码可以从server端consume picture binary data并将其重新下载至本地:

REPORT zget_picture.
DATA: query_table    LIKE w3query OCCURS 1 WITH HEADER LINE,
     html_table     LIKE w3html OCCURS 1,
     return_code    LIKE  w3param-ret_code,
     content_type   LIKE  w3param-cont_type,
     content_length LIKE  w3param-cont_len,
     pic_data       LIKE w3mime OCCURS 0,
     pic_size       TYPE i.
query_table-name  = '_OBJECT_ID'.
query_table-value = 'ZLOGO'.
APPEND query_table.
CALL FUNCTION 'WWW_GET_MIME_OBJECT'
 TABLES
   query_string        = query_table
   html                = html_table
   mime                = pic_data
 CHANGING
   return_code         = return_code
   content_type        = content_type
   content_length      = content_length
 EXCEPTIONS
   object_not_found    = 1
   parameter_not_found = 2
   OTHERS              = 3.
CALL FUNCTION 'GUI_DOWNLOAD'
 EXPORTING
   bin_filesize            = content_length
   filename                = '\\TSHomeServer\TSHome$\i042416\Desktop\11.jpg'
   filetype                = 'BIN'
 TABLES
   data_tab                = pic_data
 EXCEPTIONS
   file_write_error        = 1
   no_batch                = 2
   gui_refuse_filetransfer = 3
   invalid_type            = 4
   no_authority            = 5
   unknown_error           = 6
   header_not_allowed      = 7
   separator_not_allowed   = 8
   filesize_not_allowed    = 9
   header_too_long         = 10
   dp_error_create         = 11
   dp_error_send           = 12
   dp_error_write          = 13
   unknown_dp_error        = 14
   access_denied           = 15
   dp_out_of_memory        = 16
   disk_full               = 17
   dp_timeout              = 18
   file_not_found          = 19
   dataprovider_exception  = 20
   control_flush_error     = 21
   OTHERS                  = 22.