下载CSV文件到本机(SAP_CONVERT_TO_TEX_FORMAT)
Posted china_wangxiaowen
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了下载CSV文件到本机(SAP_CONVERT_TO_TEX_FORMAT)相关的知识,希望对你有一定的参考价值。
CSV文件是逗号分隔符格式的文件。将内表数据下载成CSV文件到本机上要先将内表中的数据通过函数SAP_CONVERT_TO_TEX_FORMAT转换成CSV格式,然后再下载到本机。
REPORT z_download_csv. TYPE-POOLS: truxs. *&---------------------------------------------------------------------* *& Data Types *&---------------------------------------------------------------------* TYPES: BEGIN OF ty_spfli, carrid TYPE spfli-carrid, connid TYPE spfli-connid, countryfr TYPE spfli-countryfr, cityfrom TYPE spfli-cityfrom, airpfrom TYPE spfli-airpfrom, countryto TYPE spfli-countryto, cityto TYPE spfli-cityto, airpto TYPE spfli-airpto, END OF ty_spfli. *&---------------------------------------------------------------------* *& Data Declaration *&---------------------------------------------------------------------* DATA: gt_spfli TYPE TABLE OF ty_spfli. DATA: gt_text TYPE truxs_t_text_data. *&---------------------------------------------------------------------* *& Start-of-Selection *&---------------------------------------------------------------------* START-OF-SELECTION. SELECT carrid connid countryfr cityfrom airpfrom countryto cityto airpto UP TO 10 ROWS FROM spfli INTO TABLE gt_spfli. * 将内表数据转换成逗号分割符CSV文件 CALL FUNCTION \'SAP_CONVERT_TO_TEX_FORMAT\' EXPORTING i_field_seperator = \',\' " Comma seperator TABLES i_tab_sap_data = gt_spfli CHANGING i_tab_converted_data = gt_text EXCEPTIONS conversion_failed = 1 OTHERS = 2. IF sy-subrc <> 0. MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4. ENDIF. * 下载CSV文件 CALL METHOD cl_gui_frontend_services=>gui_download EXPORTING filename = \'c:\\temp\\test.csv\' CHANGING data_tab = gt_text EXCEPTIONS file_write_error = 1 no_batch = 2 gui_refuse_filetransfer = 3 invalid_type = 4 no_authority = 5 unknown_error = 6 header_not_allowed = 7 separator_not_allowed = 8 filesize_not_allowed = 9 header_too_long = 10 dp_error_create = 11 dp_error_send = 12 dp_error_write = 13 unknown_dp_error = 14 access_denied = 15 dp_out_of_memory = 16 disk_full = 17 dp_timeout = 18 file_not_found = 19 dataprovider_exception = 20 control_flush_error = 21 not_supported_by_gui = 22 error_no_gui = 23 OTHERS = 24. IF sy-subrc <> 0. MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4. ENDIF.
引用来自 http://www.baidusap.com/abap/function/2104
以上是关于下载CSV文件到本机(SAP_CONVERT_TO_TEX_FORMAT)的主要内容,如果未能解决你的问题,请参考以下文章
将 CSV 文件从 Google Drive 加载到 BigQuery
Linux服务器文件和windows本机文件互传方法(本地文件上传Linux,Linux文件下载到本机)
无法将 .json 文件从 CSV 下载到 JSON 转换并且无法将 JSON 转换为 CSV