*&---------------------------------------------------------------------* *& Report ZTEST00001 *&---------------------------------------------------------------------* *& *&---------------------------------------------------------------------* REPORT ztest00001. "使用xml的下载方式 DATA: lv_path TYPE rlgrap-filename. DATA: lt_xml_table TYPE STANDARD TABLE OF string, lv_xmlstr TYPE string. DATA: lv_count TYPE n LENGTH 10. FIELD-SYMBOLS: <fs_value> TYPE any. "弹出窗口选择保存路径 PERFORM frm_save_path CHANGING lv_path. TYPES:BEGIN OF ty_data, psttr TYPE string, END OF ty_data. DATA:gt_data TYPE TABLE OF ty_data, gs_alv_out TYPE ty_data. DO 1000000 TIMES. gs_alv_out-psttr = 'SFDFSFS'. APPEND gs_alv_out TO gt_data. ENDDO. ********关键代码部分***************************************** DESCRIBE TABLE gt_data LINES lv_count. lv_count = lv_count + 3. CALL TRANSFORMATION zfir045_1 SOURCE root = gt_data[] RESULT XML lv_xmlstr. REPLACE FIRST OCCURRENCE OF 'encoding="utf-16"' IN lv_xmlstr WITH 'encoding="gbk"'."显示中文 REPLACE FIRST OCCURRENCE OF 'cs_count' IN lv_xmlstr WITH lv_count."行数,替代xml文件里的cs_count APPEND lv_xmlstr TO lt_xml_table. ********关键代码部分***************************************** DATA: lv_file TYPE string. lv_file = lv_path. CALL FUNCTION 'GUI_DOWNLOAD' EXPORTING filename = lv_file filetype = 'ASC' TABLES data_tab = lt_xml_table EXCEPTIONS file_write_error = 1 no_batch = 2 gui_refuse_filetransfer = 3 invalid_type = 4 OTHERS = 5. MESSAGE '数据下载成功!' TYPE 'S'. FORM frm_save_path CHANGING pv_path TYPE rlgrap-filename. DATA:lv_filename TYPE string, lv_path TYPE string. "名字指定 CONCATENATE '进耗存报表_明细_' sy-datum '.XLS' INTO lv_filename. CALL FUNCTION 'WS_FILENAME_GET' EXPORTING def_filename = lv_filename def_path = 'D:W' mask = '.XLS' mode = 'S' title = 'DOWNLOAD' IMPORTING filename = pv_path * RC = EXCEPTIONS inv_winsys = 1 no_batch = 2 selection_cancel = 3 selection_error = 4 OTHERS = 5. IF pv_path IS INITIAL. "选择取消的情况 MESSAGE e000(su) WITH '已取消操作!'. ENDIF. ENDFORM.
<?sap.transform simple?> <tt:transform xmlns:tt="http://www.sap.com/transformation-templates"> <tt:root name="ROOT"/> <tt:template> <?mso-application progid="Excel.Sheet"?> <Workbook xmlns="urn:schemas-microsoft-com:office:spreadsheet" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:x="urn:schemas-microsoft-com:office:excel" xmlns:ss="urn:schemas-microsoft-com:office:spreadsheet" xmlns:html= "http://www.w3.org/TR/REC-html40"> <DocumentProperties xmlns="urn:schemas-microsoft-com:office:office"> <Author>马宇</Author> <LastAuthor>马宇</LastAuthor> <Created>2019-07-29T09:17:10Z</Created> <LastSaved>2019-07-29T09:41:41Z</LastSaved> <Version>16.00</Version> </DocumentProperties> <OfficeDocumentSettings xmlns="urn:schemas-microsoft-com:office:office"> <AllowPNG/> </OfficeDocumentSettings> <ExcelWorkbook xmlns="urn:schemas-microsoft-com:office:excel"> <WindowHeight>7500</WindowHeight> <WindowWidth>20490</WindowWidth> <WindowTopX>32767</WindowTopX> <WindowTopY>32767</WindowTopY> <ProtectStructure>False</ProtectStructure> <ProtectWindows>False</ProtectWindows> </ExcelWorkbook> <Styles> <Style ss:ID="Default" ss:Name="Normal"> <Alignment ss:Vertical="Center"/> <Borders/> <Font ss:Color="#000000" ss:FontName="等线" ss:Size="11" x:CharSet="134"/> <Interior/> <NumberFormat/> <Protection/> </Style> <Style ss:ID="s62"> <Alignment ss:Vertical="Top"/> </Style> <Style ss:ID="s63"> <Alignment ss:Vertical="Top"/> <NumberFormat ss:Format="@"/> </Style> <Style ss:ID="s64"> <Alignment ss:Horizontal="Right" ss:Vertical="Top"/> <NumberFormat ss:Format="#,##0.000"/> </Style> <Style ss:ID="s65"> <Alignment ss:Horizontal="Right" ss:Vertical="Top"/> <NumberFormat ss:Format="[$-F400]h:mm:ss\ AM/PM"/> </Style> <Style ss:ID="s66"> <Alignment ss:Horizontal="Right" ss:Vertical="Top"/> <NumberFormat ss:Format="Short Date"/> </Style> <Style ss:ID="s67"> <Alignment ss:Vertical="Top"/> <Borders> <Border ss:LineStyle="Continuous" ss:Position="Bottom" ss:Weight="1"/> <Border ss:LineStyle="Continuous" ss:Position="Left" ss:Weight="1"/> <Border ss:LineStyle="Continuous" ss:Position="Right" ss:Weight="1"/> <Border ss:LineStyle="Continuous" ss:Position="Top" ss:Weight="1"/> </Borders> <Interior ss:Color="#C0C0C0" ss:Pattern="Solid"/> </Style> </Styles> <Worksheet ss:Name="Sheet1"> <Table ss:DefaultColumnWidth="54" ss:DefaultRowHeight="14.25" ss:ExpandedColumnCount="29" ss:ExpandedRowCount="cs_count" x:FullColumns="1" x:FullRows="1"> <Row> <Cell ss:StyleID="s67"> <Data ss:Type="String">计划日期</Data> </Cell> </Row> <tt:loop ref=".ROOT"> <Row> <Cell ss:StyleID="s66"> <Data ss:Type="String"> <tt:value ref="PSTTR"/> </Data> </Cell> </Row> </tt:loop> </Table> <WorksheetOptions xmlns="urn:schemas-microsoft-com:office:excel"> <PageSetup> <Header x:Margin="0.3"/> <Footer x:Margin="0.3"/> <PageMargins x:Bottom="0.75" x:Left="0.7" x:Right="0.7" x:Top="0.75"/> </PageSetup> <Selected/> <Panes> <Pane> <Number>3</Number> <ActiveRow>4</ActiveRow> <ActiveCol>1</ActiveCol> </Pane> </Panes> <ProtectObjects>False</ProtectObjects> <ProtectScenarios>False</ProtectScenarios> </WorksheetOptions> </Worksheet> </Workbook> </tt:template> </tt:transform>
标签:XML,count,STRANS,data,lv,ABAP,path,filename,TYPE From: https://www.cnblogs.com/ZJY-1314/p/17584434.html