事务代码:STRANS 启动转换器
步骤
1. 将参数填入模板,并另存为word 2003 xml文档
2.使用网页打开xml文档,并将xml拷贝到转换器tt:template中,添加参数
3.替换参数,部分xml可能存在错误或者跑偏根据实际情况检查修改
4.程序调用
FORM frm_export_proof .DATA:xml_str TYPE string,l_bindata TYPE xstring,l_cntbin TYPE sdokcntbins,w_len TYPE i,l_filename TYPE string,l_file_path TYPE string,l_full_path TYPE string,l_doc_name TYPE localfile.DATA: lo_xml_doc TYPE REF TO cl_xml_document.*调用STRANSCONCATENATE gs_alv-personid_ext gs_alv-ename gs_alv-zcomname '收入证明' INTO l_filename SEPARATED BY '-'.IF p_zmlx = TEXT-002 AND p_langu = TEXT-017.CALL TRANSFORMATION zword_proof_income_zhSOURCEgs_alv = gs_alvRESULT XML xml_str.ENDIF.IF p_zmlx = TEXT-002 AND p_langu = TEXT-018.DO 21 TIMES.CONCATENATE ' ' gs_alv-zdat02 INTO gs_alv-zdat02 SEPARATED BY '' .ENDDO.DO 4 TIMES.CONCATENATE ' ' gs_alv-zcomnature INTO gs_alv-zcomnature SEPARATED BY '' .ENDDO.DO 2 TIMES.CONCATENATE ' ' gs_alv-zcomname INTO gs_alv-zcomname SEPARATED BY ' ' .ENDDO.DO 11 TIMES.CONCATENATE ' ' gs_alv-zcontact INTO gs_alv-zcontact SEPARATED BY '' .CONCATENATE ' ' gs_alv-ztel INTO gs_alv-ztel SEPARATED BY '' .ENDDO.CALL TRANSFORMATION zword_proof_income_enSOURCEgs_alv = gs_alvRESULT XML xml_str.ENDIF.IF p_zmlx = TEXT-003.CALL TRANSFORMATION zword_proof_cpf_incomeSOURCEgs_alv = gs_alvRESULT XML xml_str.ENDIF.CALL FUNCTION 'SCMS_STRING_TO_XSTRING'EXPORTINGtext = xml_str
* MIMETYPE = ' 'IMPORTINGbuffer = l_bindataEXCEPTIONSfailed = 1OTHERS = 2.CLEAR w_len.CALL FUNCTION 'SCMS_XSTRING_TO_BINARY'EXPORTINGbuffer = l_bindataIMPORTINGoutput_length = w_lenTABLESbinary_tab = l_cntbin.CALL METHOD cl_gui_frontend_services=>file_save_dialog "调用保存对话框EXPORTINGdefault_extension = 'DOC' "把文件保存成.doc格式 (doc文档)default_file_name = l_filenameCHANGINGfilename = l_filenamepath = l_file_pathfullpath = l_full_pathEXCEPTIONScntl_error = 1error_no_gui = 2not_supported_by_gui = 3OTHERS = 4.IF sy-subrc NE 0.ELSE.l_doc_name = l_full_path.CREATE OBJECT lo_xml_doc.lo_xml_doc->parse_string( xml_str ).lo_xml_doc->export_to_file( l_doc_name ).ENDIF.ENDFORM.
预览
CALL SCREEN 0100.
PBO:
MODULE initial_0100 OUTPUT.IF go_html_control IS NOT BOUND."创建容器与组件对象PERFORM create_container_assembly."设置组件展示用的内容PERFORM set_assembly_data.ENDIF.ENDMODULE.*&---------------------------------------------------------------------*
*& Form CREATE_CONTAINER_ASSEMBLY
*&---------------------------------------------------------------------*
*& text
*&---------------------------------------------------------------------*
*& --> p1 text
*& <-- p2 text
*&---------------------------------------------------------------------*
FORM create_container_assembly .IF go_html_container IS INITIAL .CREATE OBJECT go_html_containerEXPORTINGcontainer_name = 'PDF'.CREATE OBJECT go_html_controlEXPORTINGparent = go_html_container.ENDIF.ENDFORM.
*&---------------------------------------------------------------------*
*& Form SET_ASSEMBLY_DATA
*&---------------------------------------------------------------------*
*& text
*&---------------------------------------------------------------------*
*& --> p1 text
*& <-- p2 text
*&---------------------------------------------------------------------*
FORM set_assembly_data .DATA:xml_str TYPE string,l_bindata TYPE xstring,l_cntbin TYPE sdokcntbins,w_len TYPE i,l_filename TYPE string,l_file_path TYPE string,l_full_path TYPE string,l_doc_name TYPE localfile.*调用STRANSIF p_zmlx = TEXT-002 AND p_langu = TEXT-017.CALL TRANSFORMATION zword_proof_income_zhSOURCEgs_alv = gs_alvRESULT XML xml_str.ENDIF.IF p_zmlx = TEXT-002 AND p_langu = TEXT-018.CALL TRANSFORMATION zword_proof_income_enSOURCEgs_alv = gs_alvRESULT XML xml_str.ENDIF.IF p_zmlx = TEXT-003.CALL TRANSFORMATION zword_proof_cpf_incomeSOURCEgs_alv = gs_alvRESULT XML xml_str.ENDIF.CALL FUNCTION 'SCMS_STRING_TO_XSTRING'EXPORTINGtext = xml_str
* MIMETYPE = ' 'IMPORTINGbuffer = l_bindataEXCEPTIONSfailed = 1OTHERS = 2.CLEAR w_len.CALL FUNCTION 'SCMS_XSTRING_TO_BINARY'EXPORTINGbuffer = l_bindataIMPORTINGoutput_length = w_lenTABLESbinary_tab = l_cntbin."展示PDF文件CALL METHOD go_html_control->load_data(EXPORTINGtype = 'application'subtype = 'PDF'IMPORTINGassigned_url = lv_urlCHANGINGdata_table = l_cntbinEXCEPTIONSdp_invalid_parameter = 1dp_error_general = 2cntl_error = 3OTHERS = 4 )."展示组件内容CALL METHOD go_html_control->show_url(url = lv_urlin_place = 'X' ).
ENDFORM.
PAI:
MODULE exit INPUT.LEAVE TO SCREEN 0.
ENDMODULE.
问题
notes:1146711