Created by Jerry Wang, last modified on Oct 22, 2014
该工具可以用于模拟在webclient UI上点击了With Template button后选择一个支持web service的web template和web service response merge的操作.
按照consulting node 2047259 - Trouble shooting guide about word document merge with web service 的描述,将word template和web service response download至本地:
然后执行report,即可trigger word template与web service的merge操作.
REPORT tool_document_merge. PARAMETERS: file1 TYPE string OBLIGATORY DEFAULT 'C:\Users\i042416\Desktop\Note2047259.docx', file2 TYPE string OBLIGATORY DEFAULT 'C:\Users\i042416\Desktop\LV_XPAYLOAD.xml'. FORM upload_file USING iv_file_path CHANGING cv_file TYPE xstring. DATA: l_filename TYPE string, l_rawtab TYPE STANDARD TABLE OF raw255, l_len TYPE i. l_filename = iv_file_path. CLEAR: l_rawtab, l_len. CALL METHOD cl_gui_frontend_services=>gui_upload EXPORTING filename = l_filename filetype = 'BIN' IMPORTING filelength = l_len CHANGING data_tab = l_rawtab EXCEPTIONS file_open_error = 1 file_read_error = 2 no_batch = 3 gui_refuse_filetransfer = 4 invalid_type = 5 no_authority = 6 unknown_error = 7 bad_data_format = 8 header_not_allowed = 9 separator_not_allowed = 10 header_too_long = 11 unknown_dp_error = 12 access_denied = 13 dp_out_of_memory = 14 disk_full = 15 dp_timeout = 16 not_supported_by_gui = 17 error_no_gui = 18 OTHERS = 19. IF sy-subrc IS NOT INITIAL. WRITE:/ 'Error Occurred when Uploading file!' COLOR COL_NEGATIVE INTENSIFIED ON. RETURN. ENDIF. CALL FUNCTION 'SCMS_BINARY_TO_XSTRING' EXPORTING input_length = l_len IMPORTING buffer = cv_file TABLES binary_tab = l_rawtab EXCEPTIONS failed = 1 OTHERS = 2. ASSERT sy-subrc = 0. ENDFORM. START-OF-SELECTION. DATA: lv_template TYPE xstring, lv_response TYPE xstring, lv_wsdl_url TYPE string, lv_ws_name TYPE websname, lv_response_ns TYPE xstring, lv_wsdl_operation TYPE string, lv_namespace TYPE anyuri, lv_xdata TYPE xstring, lo_docx TYPE REF TO CL_DOCX_DOCUMENT, lo_main TYPE REF TO CL_DOCX_MAINDOCUMENTPART, lv_template_xdata TYPE xstring, lv_xpayload TYPE xstring, lv_data TYPE xstring. PERFORM upload_file USING file1 CHANGING lv_template. PERFORM upload_file USING file2 CHANGING lv_response. CALL METHOD cl_crm_oi_util=>get_ws_url_from_template EXPORTING iv_data = lv_template IMPORTING ev_wsdl_url = lv_wsdl_url ev_wsdl_operation = lv_wsdl_operation. ASSERT cl_crm_oi_docx_helper=>has_word_addin_format( lv_template ) = abap_true. ASSERT cl_crm_oi_docx_helper=>has_content_control_format( lv_template ) = abap_true. cl_crm_oi_docx_helper=>replace_vars_uuid_with_path( CHANGING cv_docx_doc = lv_template ). lo_docx = cl_docx_document=>load_document( lv_template ). lo_main = lo_docx->get_maindocumentpart( ). lv_template_xdata = lo_main->get_data( ). cl_crm_oi_docx_helper=>get_ws_info_from_template( EXPORTING iv_xdata = lv_template IMPORTING ev_ws_name = lv_ws_name ). IF ( lv_ws_name IS NOT INITIAL OR lv_wsdl_url IS NOT INITIAL ) AND lv_response IS NOT INITIAL. CALL TRANSFORMATION crm_office_int_rt_add_ns SOURCE XML lv_response RESULT XML lv_response_ns. lv_xpayload = lv_response_ns. ENDIF. ASSERT lv_xpayload IS NOT INITIAL. TRY. CALL METHOD cl_crm_oi_docx_transform_rt=>transform EXPORTING iv_xml_xstring = lv_response_ns iv_wordml_xstring = lv_template_xdata iv_uri = 'urn:sap-com:document:sap:soap:functions:mc-style' iv_contentcontrol_format = 'X' iv_cc_customxml = cl_crm_oi_docx_helper=>m_doc_customxml IMPORTING ev_wordml_xstring = lv_xdata. CATCH cx_oi_fault. WRITE: / 'merge error!'. RETURN. ENDTRY. lo_main->feed_data( lv_xdata ). lv_xdata = lo_docx->get_package_data( ). WRITE: / 'document merged successfully!'.