File Upload ABAP WebDynpro

webdynpro snippet to upload a file(xstring) into the BDS (Business Document Service)

Like it? Share it!
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.

>_ Author

>_ last updated 5 yearss ago

>_ Language: ABAP

Webdynpro file upload