<?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: Uploading CSV file into internal table in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/uploading-csv-file-into-internal-table/m-p/5789070#M1309559</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;As long as there can be a comma in a text literal you are right that the spilt command doesn't help. However there is one possibility how to attack this under one assumption:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;- A comma outside a text delimiter is always considered a separator&lt;/P&gt;&lt;P&gt;- A comma inside a text delimiter is always considered a comma as part of the text&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You have to read you file line by line and then travel along the line string character by character and setting a flag or counter for the text delimiters:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;e.g.&lt;/P&gt;&lt;P&gt;"Text","Text1, Text2",NULL,NULL,"Text"&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;String Index  1: EQ " =&amp;gt; lv_delimiter = 'X'&lt;/P&gt;&lt;P&gt;String Index  2: EQ T =&amp;gt; text literal (because lv_delimiter = 'X')&lt;/P&gt;&lt;P&gt;String Index  3: EQ e =&amp;gt; text literal (because lv_delimiter = 'X')&lt;/P&gt;&lt;P&gt;String Index  4: EQ x =&amp;gt; text literal (because lv_delimiter = 'X')&lt;/P&gt;&lt;P&gt;String Index  5: EQ t =&amp;gt; text literal (because lv_delimiter = 'X')&lt;/P&gt;&lt;P&gt;String Index  6: EQ " =&amp;gt; lv_delimiter = ' ' (because it was 'X' before)&lt;/P&gt;&lt;P&gt;String Index  7: EQ , =&amp;gt; This is a separator because lv_delimiter = ' '&lt;/P&gt;&lt;P&gt;String Index  8: EQ " =&amp;gt; lv_delimiter = 'X' (because it was ' ' before)&lt;/P&gt;&lt;P&gt;String Index  9: EQ T =&amp;gt; text literal (because lv_delimiter = 'X')&lt;/P&gt;&lt;P&gt;String Index 10: EQ e =&amp;gt; text literal (because lv_delimiter = 'X')&lt;/P&gt;&lt;P&gt;String Index 11: EQ x =&amp;gt; text literal (because lv_delimiter = 'X')&lt;/P&gt;&lt;P&gt;String Index 12: EQ t =&amp;gt; text literal (because lv_delimiter = 'X')&lt;/P&gt;&lt;P&gt;String Index 13: EQ 1 =&amp;gt; text literal (because lv_delimiter = 'X')&lt;/P&gt;&lt;P&gt;String Index 14: EQ , =&amp;gt; text literal (because lv_delimiter = 'X')&lt;/P&gt;&lt;P&gt;String Index 15: EQ T =&amp;gt; text literal (because lv_delimiter = 'X')&lt;/P&gt;&lt;P&gt;  :&lt;/P&gt;&lt;P&gt;  :&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Whenever you hit a 'real' separator (lv_delimiter = ' ') you pass the value of the string before that up to the previous separator into the next structure field.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This is not an easy way to do it, but if you might have commas in your text literal and NULL values I gues it is probably the only way to go.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hope that helps,&lt;/P&gt;&lt;P&gt;Michael&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 29 Jun 2009 18:11:51 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2009-06-29T18:11:51Z</dc:date>
    <item>
      <title>Uploading CSV file into internal table</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/uploading-csv-file-into-internal-table/m-p/5789069#M1309558</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;I want to upload a CSV file into internal table.The flat file is having values as below:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;'AAAAA','2003-10-11 07:52:37','167','Argentina',NULL,NULL,NULL,NULL,NULL,'MX1',NULL,NULL,'AAAA BBBB',NULL,NULL,NULL,'1',NULL,NULL,'AR ',NULL,NULL,NULL,'ARGENT','M1V','MX1',NULL,NULL,'F','F','F','F','F',NULL,'1',NULL,'MX','MMI ',NULL&lt;/P&gt;&lt;P&gt;'jklhg','2004-06-25 08:01:57','456','hjllajsdk','MANAGUA   ',NULL,NULL,'265-5139','266-5136 al 38','MX1',NULL,NULL,'hjgkid GRÖBER','sdfsdf dfs asdfsdf 380 ad ased,','200 as ads, sfd sfd abajao y 50 m al sdf',NULL,'1',NULL,NULL,'NI ',NULL,NULL,NULL,'sdfdfg','M1V','dds',NULL,NULL,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Here I can not even split at ',' because some of the values are having value like NULL and some have values with comma too,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The delimiter is a quote and the separator is a comma here.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Can anyone help on this?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Edited by: Ginger on Jun 29, 2009 9:08 AM&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 29 Jun 2009 13:07:47 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/uploading-csv-file-into-internal-table/m-p/5789069#M1309558</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-06-29T13:07:47Z</dc:date>
    </item>
    <item>
      <title>Re: Uploading CSV file into internal table</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/uploading-csv-file-into-internal-table/m-p/5789070#M1309559</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;As long as there can be a comma in a text literal you are right that the spilt command doesn't help. However there is one possibility how to attack this under one assumption:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;- A comma outside a text delimiter is always considered a separator&lt;/P&gt;&lt;P&gt;- A comma inside a text delimiter is always considered a comma as part of the text&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You have to read you file line by line and then travel along the line string character by character and setting a flag or counter for the text delimiters:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;e.g.&lt;/P&gt;&lt;P&gt;"Text","Text1, Text2",NULL,NULL,"Text"&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;String Index  1: EQ " =&amp;gt; lv_delimiter = 'X'&lt;/P&gt;&lt;P&gt;String Index  2: EQ T =&amp;gt; text literal (because lv_delimiter = 'X')&lt;/P&gt;&lt;P&gt;String Index  3: EQ e =&amp;gt; text literal (because lv_delimiter = 'X')&lt;/P&gt;&lt;P&gt;String Index  4: EQ x =&amp;gt; text literal (because lv_delimiter = 'X')&lt;/P&gt;&lt;P&gt;String Index  5: EQ t =&amp;gt; text literal (because lv_delimiter = 'X')&lt;/P&gt;&lt;P&gt;String Index  6: EQ " =&amp;gt; lv_delimiter = ' ' (because it was 'X' before)&lt;/P&gt;&lt;P&gt;String Index  7: EQ , =&amp;gt; This is a separator because lv_delimiter = ' '&lt;/P&gt;&lt;P&gt;String Index  8: EQ " =&amp;gt; lv_delimiter = 'X' (because it was ' ' before)&lt;/P&gt;&lt;P&gt;String Index  9: EQ T =&amp;gt; text literal (because lv_delimiter = 'X')&lt;/P&gt;&lt;P&gt;String Index 10: EQ e =&amp;gt; text literal (because lv_delimiter = 'X')&lt;/P&gt;&lt;P&gt;String Index 11: EQ x =&amp;gt; text literal (because lv_delimiter = 'X')&lt;/P&gt;&lt;P&gt;String Index 12: EQ t =&amp;gt; text literal (because lv_delimiter = 'X')&lt;/P&gt;&lt;P&gt;String Index 13: EQ 1 =&amp;gt; text literal (because lv_delimiter = 'X')&lt;/P&gt;&lt;P&gt;String Index 14: EQ , =&amp;gt; text literal (because lv_delimiter = 'X')&lt;/P&gt;&lt;P&gt;String Index 15: EQ T =&amp;gt; text literal (because lv_delimiter = 'X')&lt;/P&gt;&lt;P&gt;  :&lt;/P&gt;&lt;P&gt;  :&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Whenever you hit a 'real' separator (lv_delimiter = ' ') you pass the value of the string before that up to the previous separator into the next structure field.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This is not an easy way to do it, but if you might have commas in your text literal and NULL values I gues it is probably the only way to go.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hope that helps,&lt;/P&gt;&lt;P&gt;Michael&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 29 Jun 2009 18:11:51 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/uploading-csv-file-into-internal-table/m-p/5789070#M1309559</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-06-29T18:11:51Z</dc:date>
    </item>
    <item>
      <title>Re: Uploading CSV file into internal table</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/uploading-csv-file-into-internal-table/m-p/5789071#M1309560</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Ginger did you try to split the record like this:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;split &amp;lt;zcat_ingline&amp;gt; at ',' into wa_zcat_ingredients-sand_size
                                       wa_zcat_ingredients-cat_barcode
                                       wa_zcat_ingredients-article_no
                                       wa_zcat_ingredients-upsell_code
                                       lv_cating_qty_conv
                                       wa_zcat_ingredients-uom
                                       wa_zcat_ingredients-no_move
                                       wa_zcat_ingredients-description.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Edited by: TMM on Jun 29, 2009 7:52 PM&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Your spaces should just move to the right field.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Edited by: TMM on Jun 29, 2009 7:54 PM&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 29 Jun 2009 23:51:36 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/uploading-csv-file-into-internal-table/m-p/5789071#M1309560</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-06-29T23:51:36Z</dc:date>
    </item>
    <item>
      <title>Re: Uploading CSV file into internal table</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/uploading-csv-file-into-internal-table/m-p/5789072#M1309561</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
FIELD-SYMBOLS: &amp;lt;field&amp;gt; TYPE ANY.
  DATA : BEGIN OF i_dload OCCURS 0 ,
         dload(1000) ,
       END OF i_dload .

LOOP AT it_tab.
        DO.
          ASSIGN COMPONENT sy-index OF STRUCTURE it_tab TO &amp;lt;field&amp;gt;.
          IF sy-subrc &amp;lt;&amp;gt; 0.
            EXIT.
          ENDIF.
* Look for Commas in the field value.  If it exists, put quotes around
* value so that the file opens correctly with all the columns aligned
* in Excel.
          SEARCH &amp;lt;field&amp;gt; FOR c_cma IN CHARACTER MODE.   u201C(c_cma for ',')
* If search for commas are successful.
          IF sy-subrc = 0.
            CONCATENATE '"' &amp;lt;field&amp;gt; '"' INTO &amp;lt;field&amp;gt; IN CHARACTER MODE.
          ENDIF.
          IF sy-index = 1.
            i_dload-dload = &amp;lt;field&amp;gt;.
            SHIFT: i_dload-dload  LEFT DELETING LEADING space.
          ELSE.
* Put Comma as a separator for values in IT_DLOAD internal table
            SHIFT: i_dload-dload  LEFT DELETING LEADING space.
            CONCATENATE i_dload-dload &amp;lt;field&amp;gt; INTO i_dload-dload
                        SEPARATED BY c_cma IN CHARACTER MODE.     " c_cma for ','
          ENDIF.
        ENDDO.

        it_objbin = i_dload-dload.
        APPEND it_objbin. CLEAR it_objbin.

      ENDLOOP.

&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Krishna&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 30 Jun 2009 02:52:57 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/uploading-csv-file-into-internal-table/m-p/5789072#M1309561</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-06-30T02:52:57Z</dc:date>
    </item>
  </channel>
</rss>

