2020.03.01 [ABAP]エッセイ-Excel一括エクスポート-SAP_CONVERT_TO_XLS_FORMAT



2020 03 01 Essay Excel Bulk Export Sap_convert_to_xls_format



エクセル機能へのSAP_CONVERT_TO_XLS_FORMATバッチエクスポートについて今日書いてください



機能コードの一部は次のとおりです。

FORM frm_export_excel_1 . DATA li_filename TYPE rlgrap-filename. DATA ls_filename TYPE string. li_filename = p_file. ls_filename = p_file. CALL METHOD zcl_document_jxzhu=>download_template_to_frontend EXPORTING iv_fun = '2'' Select function FUN name_of_template = 'Item Master Data tabulation off'  iv_filepath = ls_filename 'When IV_FUN = 2, save path iv_filepath required so as not to play the selected block, the function can be an external reference path * iv_relid = 'MI' iv_objid = 'ZMMT001' IMPORTING rv_filepath = ls_filename EXCEPTIONS download_error = 1 OTHERS = 2. WAIT UP TO 2 SECONDS. 'Ensure saved templates downloaded from the server, and then re-open the input. li_filename = ls_filename. SELECT * INTO CORRESPONDING FIELDS OF TABLE @lt_zmmt001 FROM zmmt001. READ TABLE lt_zmmt001 into data(ls_zmmt001) INDEX 1 . 'In order to prevent the problem of format, this function is used, the output type is best to use char TYPES:BEGIN OF lty_excel, matnr TYPE char40, id TYPE char10, f1 TYPE char10, f2 TYPE char10, f3 TYPE char10, END OF lty_excel. DATA lt_zmmt001_excel TYPE TABLE OF lty_excel. MOVE-CORRESPONDING lt_zmmt001 TO lt_zmmt001_excel. INSERT INITIAL LINE INTO lt_zmmt001_excel ASSIGNING FIELD-SYMBOL() INDEX 1. DATA tablestructure TYPE REF TO cl_abap_structdescr. tablestructure ?= cl_abap_typedescr=>describe_by_data( ls_zmmt001 ). LOOP AT tablestructure->components INTO DATA(ls_comps). ASSIGN COMPONENT sy-tabix OF STRUCTURE TO FIELD-SYMBOL(). IF sy-subrc EQ 0 .  = ls_comps-name. ENDIF. ENDLOOP. CALL FUNCTION 'SAP_CONVERT_TO_XLS_FORMAT' EXPORTING * I_FIELD_SEPERATOR = i_line_header = 'X' i_filename = li_filename * I_APPL_KEEP = ' ' TABLES i_tab_sap_data = lt_zmmt001_excel * CHANGING * I_TAB_CONVERTED_DATA = EXCEPTIONS conversion_failed = 1 OTHERS = 2. ENDFORM.
We should mention, in order to solve the problem of output content format:
1. First an Excel cell unit property is set to a text format and saved with the EXCEL SMW0 uploaded to the server
2. Download down with zcl_document_jxzhu => download_template_to_fronten method in terms of template 

3. SAP_CONVERT_TO_XLS_FORMAT introduced into the table data to Excel

オン



zcl_document_jxzhu=>Methods download_template_to_frontend specific content: https://www.cnblogs.com/jxzhu/p/12359692.html 


-Tab Zhu do not read past afraid of the future