<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: SAP_CONVERT_TO_CSV_FORMAT in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/sap-convert-to-csv-format/m-p/2329449#M512389</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Instead of the FM SAP_CONVERT_TO_CSV_FORMAT...You can use the FM SAP_CONVERT_TO_TEX_FORMAT...Which does the same thing..&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;lt;b&amp;gt;SAP_CONVERT_TO_TEX_FORMAT&amp;lt;/b&amp;gt;&lt;/P&gt;&lt;P&gt;This function module will take any internal table as input and convert the data accordingly, using various formatting options defined at data element level, and it will give you the output in text format. In addition, this function will make use of any delimiter you want. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The program below demonstrates the above functionality. Here, we are reading data from table EKKO and downloading the data as '|' delimited file. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;lt;b&amp;gt;Code&amp;lt;/b&amp;gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;REPORT y_ss_test_ekko .&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;To hold selection data&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;DATA: i_ekko TYPE STANDARD TABLE OF ekko.&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;To hold converted text data&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;DATA: i_text(4096) TYPE c OCCURS 0.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;Selection Screen&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;PARAMETERS: p_ebeln LIKE ekko-ebeln.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;Select data into an ITAB based on the selection Criteria &lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;SELECT * FROM ekko&lt;/P&gt;&lt;P&gt;INTO TABLE i_ekko&lt;/P&gt;&lt;P&gt;WHERE ebeln = p_ebeln.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;Process further only if found some data &lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;IF NOT i_ekko[] IS INITIAL.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;Convert data in internal table to a delimited text data&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;CALL FUNCTION 'SAP_CONVERT_TO_TEX_FORMAT'&lt;/P&gt;&lt;P&gt;EXPORTING&lt;/P&gt;&lt;P&gt;i_field_seperator = '|'&lt;/P&gt;&lt;P&gt;TABLES&lt;/P&gt;&lt;P&gt;i_tab_sap_data = i_ekko&lt;/P&gt;&lt;P&gt;CHANGING&lt;/P&gt;&lt;P&gt;i_tab_converted_data = i_text&lt;/P&gt;&lt;P&gt;EXCEPTIONS&lt;/P&gt;&lt;P&gt;conversion_failed = 1&lt;/P&gt;&lt;P&gt;OTHERS = 2.&lt;/P&gt;&lt;P&gt;IF sy-subrc &amp;lt;&amp;gt; 0.&lt;/P&gt;&lt;P&gt;WRITE: / 'Program failed to Convert data.'.&lt;/P&gt;&lt;P&gt;ELSE.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;Download convert data to Presentation Server&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;CALL FUNCTION 'DOWNLOAD'&lt;/P&gt;&lt;P&gt;TABLES&lt;/P&gt;&lt;P&gt;data_tab = i_text&lt;/P&gt;&lt;P&gt;EXCEPTIONS&lt;/P&gt;&lt;P&gt;OTHERS = 8.&lt;/P&gt;&lt;P&gt;IF sy-subrc &amp;lt;&amp;gt; 0.&lt;/P&gt;&lt;P&gt;WRITE: / 'Program failed to download data.'.&lt;/P&gt;&lt;P&gt;ENDIF.&lt;/P&gt;&lt;P&gt;ENDIF.&lt;/P&gt;&lt;P&gt;ENDIF. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You would have to modify the above code according to your requirements.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Padmam.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 15 Jun 2007 10:59:10 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2007-06-15T10:59:10Z</dc:date>
    <item>
      <title>SAP_CONVERT_TO_CSV_FORMAT</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/sap-convert-to-csv-format/m-p/2329445#M512385</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;     can any one plz tell me the functionality for the FM "SAP_CONVERT_TO_CSV_FORMAT" with example.........&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;vijay&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 15 Jun 2007 07:52:44 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/sap-convert-to-csv-format/m-p/2329445#M512385</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-06-15T07:52:44Z</dc:date>
    </item>
    <item>
      <title>Re: SAP_CONVERT_TO_CSV_FORMAT</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/sap-convert-to-csv-format/m-p/2329446#M512386</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;look here:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;A class="jive_macro jive_macro_message" href="https://community.sap.com/" __jive_macro_name="message" modifiedtitle="true" __default_attr="3281554"&gt;&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;regards, Dieter&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 15 Jun 2007 07:57:24 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/sap-convert-to-csv-format/m-p/2329446#M512386</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-06-15T07:57:24Z</dc:date>
    </item>
    <item>
      <title>Re: SAP_CONVERT_TO_CSV_FORMAT</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/sap-convert-to-csv-format/m-p/2329447#M512387</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Vijay,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;CSV means a text file, where the columns are separated by a character ";".&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The best way to change a list to CSV is to create an internal table in the ABAP, with the structure of the required CSV.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You have to fill in this internal table.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Because you are running the program in background, you can't download the file, the best would be to store the file on the server in a separated directory.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;1ST capture file from application server to internal table using open dataset and close data set.&lt;/P&gt;&lt;P&gt;Use the Function Module SAP_CONVERT_TO_CSV_FORMAT to convert the internal table into Comma separated format then download this internal table using the Function Module GUI_DOWNLOAD.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;EX-&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Coding -&lt;/P&gt;&lt;P&gt;TYPE-POOLS: truxs.&lt;/P&gt;&lt;P&gt;TYPES:&lt;/P&gt;&lt;P&gt;BEGIN OF ty_Line,&lt;/P&gt;&lt;P&gt;vbeln LIKE vbap-vbeln,&lt;/P&gt;&lt;P&gt;posnr LIKE vbap-posnr,&lt;/P&gt;&lt;P&gt;END OF ty_Line.&lt;/P&gt;&lt;P&gt;TYPES: ty_Lines TYPE STANDARD TABLE of ty_Line WITH DEFAULT KEY.&lt;/P&gt;&lt;P&gt;DATA: itab TYPE ty_Lines.&lt;/P&gt;&lt;P&gt;DATA: itab1 TYPE truxs_t_text_data.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;SELECT&lt;/P&gt;&lt;P&gt;vbeln&lt;/P&gt;&lt;P&gt;posnr&lt;/P&gt;&lt;P&gt;UP TO 10 ROWS&lt;/P&gt;&lt;P&gt;FROM vbap&lt;/P&gt;&lt;P&gt;INTO TABLE itab.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;CALL FUNCTION 'SAP_CONVERT_TO_CSV_FORMAT'&lt;/P&gt;&lt;P&gt;EXPORTING&lt;/P&gt;&lt;P&gt;i_field_seperator = ';'&lt;/P&gt;&lt;P&gt;TABLES&lt;/P&gt;&lt;P&gt;i_tab_sap_data = itab&lt;/P&gt;&lt;P&gt;CHANGING&lt;/P&gt;&lt;P&gt;i_tab_converted_data = itab1&lt;/P&gt;&lt;P&gt;EXCEPTIONS&lt;/P&gt;&lt;P&gt;conversion_failed = 1&lt;/P&gt;&lt;P&gt;OTHERS = 2.&lt;/P&gt;&lt;P&gt;IF sy-subrc &amp;lt;&amp;gt; 0.&lt;/P&gt;&lt;P&gt;MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno&lt;/P&gt;&lt;P&gt;WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.&lt;/P&gt;&lt;P&gt;ENDIF.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;CALL FUNCTION 'GUI_DOWNLOAD'&lt;/P&gt;&lt;P&gt;EXPORTING&lt;/P&gt;&lt;P&gt;filename = 'C:\TEMP\test.txt'&lt;/P&gt;&lt;P&gt;TABLES&lt;/P&gt;&lt;P&gt;data_tab = itab1&lt;/P&gt;&lt;P&gt;EXCEPTIONS&lt;/P&gt;&lt;P&gt;OTHERS = 1. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Reward If Helpful.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 15 Jun 2007 07:57:45 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/sap-convert-to-csv-format/m-p/2329447#M512387</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-06-15T07:57:45Z</dc:date>
    </item>
    <item>
      <title>Re: SAP_CONVERT_TO_CSV_FORMAT</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/sap-convert-to-csv-format/m-p/2329448#M512388</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Vijay,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Use the Function Module SAP_CONVERT_TO_CSV_FORMAT to convert the internal table into Comma seperated format then download this internal table using the Function Module GUI_DOWNLOAD.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;See a sample program below:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;TYPE-POOLS: truxs.
TYPES:
  BEGIN OF ty_Line,
    vbeln LIKE vbap-vbeln,
    posnr LIKE vbap-posnr,
  END OF ty_Line.
  ty_Lines TYPE STANDARD TABLE of ty_Line WITH DEFAULT KEY.
DATA: itab   TYPE ty_Lines.
DATA: itab1  TYPE truxs_t_text_data.

SELECT
  vbeln
  posnr
  UP TO 10 ROWS
  FROM vbap
  INTO TABLE itab.

CALL FUNCTION 'SAP_CONVERT_TO_CSV_FORMAT'
  EXPORTING
    i_field_seperator    = ';'
  TABLES
    i_tab_sap_data       = itab
  CHANGING
    i_tab_converted_data = itab1
  EXCEPTIONS
    conversion_failed    = 1
    OTHERS               = 2.
IF sy-subrc &amp;amp;lt;&amp;amp;gt; 0.
  MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
  WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.

CALL FUNCTION 'GUI_DOWNLOAD'
  EXPORTING
    filename = 'C:TEMPtest.txt'
  TABLES
    data_tab = itab1
  EXCEPTIONS
    OTHERS   = 1.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;A class="jive_macro jive_macro_thread" href="https://community.sap.com/" __jive_macro_name="thread" modifiedtitle="true" __default_attr="130119"&gt;&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt; Sudheer&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 15 Jun 2007 08:00:51 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/sap-convert-to-csv-format/m-p/2329448#M512388</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-06-15T08:00:51Z</dc:date>
    </item>
    <item>
      <title>Re: SAP_CONVERT_TO_CSV_FORMAT</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/sap-convert-to-csv-format/m-p/2329449#M512389</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Instead of the FM SAP_CONVERT_TO_CSV_FORMAT...You can use the FM SAP_CONVERT_TO_TEX_FORMAT...Which does the same thing..&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;lt;b&amp;gt;SAP_CONVERT_TO_TEX_FORMAT&amp;lt;/b&amp;gt;&lt;/P&gt;&lt;P&gt;This function module will take any internal table as input and convert the data accordingly, using various formatting options defined at data element level, and it will give you the output in text format. In addition, this function will make use of any delimiter you want. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The program below demonstrates the above functionality. Here, we are reading data from table EKKO and downloading the data as '|' delimited file. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;lt;b&amp;gt;Code&amp;lt;/b&amp;gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;REPORT y_ss_test_ekko .&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;To hold selection data&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;DATA: i_ekko TYPE STANDARD TABLE OF ekko.&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;To hold converted text data&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;DATA: i_text(4096) TYPE c OCCURS 0.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;Selection Screen&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;PARAMETERS: p_ebeln LIKE ekko-ebeln.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;Select data into an ITAB based on the selection Criteria &lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;SELECT * FROM ekko&lt;/P&gt;&lt;P&gt;INTO TABLE i_ekko&lt;/P&gt;&lt;P&gt;WHERE ebeln = p_ebeln.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;Process further only if found some data &lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;IF NOT i_ekko[] IS INITIAL.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;Convert data in internal table to a delimited text data&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;CALL FUNCTION 'SAP_CONVERT_TO_TEX_FORMAT'&lt;/P&gt;&lt;P&gt;EXPORTING&lt;/P&gt;&lt;P&gt;i_field_seperator = '|'&lt;/P&gt;&lt;P&gt;TABLES&lt;/P&gt;&lt;P&gt;i_tab_sap_data = i_ekko&lt;/P&gt;&lt;P&gt;CHANGING&lt;/P&gt;&lt;P&gt;i_tab_converted_data = i_text&lt;/P&gt;&lt;P&gt;EXCEPTIONS&lt;/P&gt;&lt;P&gt;conversion_failed = 1&lt;/P&gt;&lt;P&gt;OTHERS = 2.&lt;/P&gt;&lt;P&gt;IF sy-subrc &amp;lt;&amp;gt; 0.&lt;/P&gt;&lt;P&gt;WRITE: / 'Program failed to Convert data.'.&lt;/P&gt;&lt;P&gt;ELSE.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;Download convert data to Presentation Server&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;CALL FUNCTION 'DOWNLOAD'&lt;/P&gt;&lt;P&gt;TABLES&lt;/P&gt;&lt;P&gt;data_tab = i_text&lt;/P&gt;&lt;P&gt;EXCEPTIONS&lt;/P&gt;&lt;P&gt;OTHERS = 8.&lt;/P&gt;&lt;P&gt;IF sy-subrc &amp;lt;&amp;gt; 0.&lt;/P&gt;&lt;P&gt;WRITE: / 'Program failed to download data.'.&lt;/P&gt;&lt;P&gt;ENDIF.&lt;/P&gt;&lt;P&gt;ENDIF.&lt;/P&gt;&lt;P&gt;ENDIF. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You would have to modify the above code according to your requirements.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Padmam.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 15 Jun 2007 10:59:10 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/sap-convert-to-csv-format/m-p/2329449#M512389</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-06-15T10:59:10Z</dc:date>
    </item>
  </channel>
</rss>

