首页 > 代码库 > ABAP WEBRFC

ABAP WEBRFC

通过WEBRFC实现在网页下载SMW0上传的文件

FUNCTION zhr_download_test.
*"----------------------------------------------------------------------
*"*"本地接口:
*"  TABLES
*"      QUERY_STRING STRUCTURE  W3QUERY
*"      HTML STRUCTURE  W3HTML
*"      MIME STRUCTURE  W3MIME
*"  CHANGING
*"     VALUE(CONTENT_TYPE) LIKE  W3PARAM-CONT_TYPE OPTIONAL
*"     VALUE(CONTENT_LENGTH) LIKE  W3PARAM-CONT_LEN OPTIONAL
*"     VALUE(RETURN_CODE) LIKE  W3PARAM-RET_CODE OPTIONAL
*"----------------------------------------------------------------------


  DATA: name TYPE string.

  SORT query_string DESCENDING.

  READ TABLE query_string WITH KEY name = _Name.

  name = query_string-value.

  DATA: ls_wwwdata   TYPE wwwdatatab.

  ls_wwwdata-relid = MI.
  ls_wwwdata-objid = name.

  CALL FUNCTION WWWDATA_IMPORT
    EXPORTING
      key    = ls_wwwdata
    TABLES
*     html   = html
      mime   = mime
    EXCEPTIONS
      OTHERS = 1.

  CLEAR content_type.
  content_type = application/vnd.ms-excel.

  DATA: lt_wwwparams LIKE TABLE OF wwwparams,
        ls_wwwparams TYPE wwwparams.

  SELECT * FROM  wwwparams INTO TABLE lt_wwwparams
   WHERE  relid       = MI
   AND    objid       = name.

  CLEAR ls_wwwparams.
  READ TABLE lt_wwwparams INTO ls_wwwparams WITH KEY name = filesize.
  content_length = ls_wwwparams-value.

ENDFUNCTION.

 

ABAP WEBRFC