我正在寻找一种Webdynpro方法将xstring文件上传到BDS(商业文档服务),大多数文件都是二进制或ZIP格式。我使用Webdynpro的文件上传功能。
我尝试使用 BDS 函数插入文件CREATE_WITH_AS_TABLE
但只有垃圾存储在 BDS 中。
有人可以帮助我解决这个小问题吗?
谢谢
嗨,
谢谢你的回答。
我找到了这个小问题的解决方案。我忘了将 xsting 转换为二进制格式以将文件插入 bds 系统。不幸的是,很多人都有同样的问题,但没有人发布片段。
重要的代码是:
CALL FUNCTION 'SCMS_XSTRING_TO_BINARY'
EXPORTING
buffer = im_xstr
IMPORTING
output_length = lv_size
TABLES
binary_tab = lt_data.
我的完整课程:
method WD_SAVE_NEW_FILE.
DATA: i_files TYPE sbdst_files,
wa_files LIKE LINE OF i_files,
i_signature TYPE sbdst_signature,
wa_signature LIKE LINE OF i_signature.
* prepare data for FM - COMPONENTS
DATA: i_components TYPE sbdst_components,
wa_components LIKE LINE OF i_components .
wa_components-doc_count = 1.
wa_components-comp_count = 1.
wa_components-comp_id = IM_FILE_NAME.
wa_components-mimetype = IM_FILE_MIME.
APPEND wa_components to i_components.
* set signature to intial = 1
wa_signature-doc_count = 1.
wa_signature-doc_ver_no = 1.
wa_signature-doc_var_id = 1.
wa_signature-doc_var_tg = ''.
wa_signature-comp_count = 1.
wa_signature-prop_name = 'BDS_DOCUMENTCLASS'.
wa_signature-prop_value = ''.
APPEND wa_signature TO i_signature.
CLEAR wa_signature.
wa_signature-doc_count = 1.
wa_signature-doc_ver_no = 1.
wa_signature-doc_var_id = 1.
wa_signature-doc_var_tg = ''.
wa_signature-comp_count = 1.
wa_signature-prop_name = 'DESCRIPTION'.
wa_signature-prop_value = im_file_comment.
APPEND wa_signature TO i_signature.
CLEAR wa_signature.
DATA lt_data TYPE sbdst_content.
DATA lv_size TYPE i.
DATA ls_xstring TYPE XSTRINGVAL.
* Fill ls_xstring
CALL FUNCTION 'SCMS_XSTRING_TO_BINARY'
EXPORTING
buffer = im_xstr
IMPORTING
output_length = lv_size
TABLES
binary_tab = lt_data.
CALL METHOD me->o_document_set->create_with_table
EXPORTING
classname = me->i_classname
classtype = me->i_classtype
content = lt_data
components = i_components
CHANGING
object_key = me->i_object_key
signature = i_signature
EXCEPTIONS
nothing_found = 1
parameter_error = 2
not_allowed = 3
error_kpro = 4
internal_error = 5
not_authorized = 6
OTHERS = 7.
CASE sy-subrc.
WHEN 0.
*
WHEN 1.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
WHEN 2.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
WHEN 3.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
WHEN 4.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
WHEN 5.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
WHEN 6.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
WHEN OTHERS.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDCASE.
*return values
endmethod.
我希望这些代码能帮助其他 Web Dynpro 新手。
干杯海因里希
你试过这个函数吗?
-BDS_BUSINESSDOCUMENT_CREATEF
此外,要将该文件存储在BDS中,您必须使用
-CL_BDS_DOCUMENT_SET=>CREATE_WITH_TABLE
希望它有帮助。