<?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 How to upload .CSV file from Application Server in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/how-to-upload-csv-file-from-application-server/m-p/2790749#M651050</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Experts,&lt;/P&gt;&lt;P&gt;    How to upload .CSV file separated by ',' from Application server to an internal table.&lt;/P&gt;&lt;P&gt;Invoice No,Cust No,Item Type,Invoice Date,days,Discount Amount,Gross Amount,Sales Amount,Customer Order No.,Group,Pay Terms&lt;/P&gt;&lt;P&gt;546162,3233,1,9/4/2007,11,26.79,5358.75,5358.75,11264,HRS,11&lt;/P&gt;&lt;P&gt;546163,2645,1,9/4/2007,11,3.07,305.25,305.25,10781,C,11&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Actually I read some already answered posts. But still I have some doubts.&lt;/P&gt;&lt;P&gt;Can anybody please send me the code. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks in Advance.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 12 Sep 2007 04:45:34 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2007-09-12T04:45:34Z</dc:date>
    <item>
      <title>How to upload .CSV file from Application Server</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/how-to-upload-csv-file-from-application-server/m-p/2790749#M651050</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Experts,&lt;/P&gt;&lt;P&gt;    How to upload .CSV file separated by ',' from Application server to an internal table.&lt;/P&gt;&lt;P&gt;Invoice No,Cust No,Item Type,Invoice Date,days,Discount Amount,Gross Amount,Sales Amount,Customer Order No.,Group,Pay Terms&lt;/P&gt;&lt;P&gt;546162,3233,1,9/4/2007,11,26.79,5358.75,5358.75,11264,HRS,11&lt;/P&gt;&lt;P&gt;546163,2645,1,9/4/2007,11,3.07,305.25,305.25,10781,C,11&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Actually I read some already answered posts. But still I have some doubts.&lt;/P&gt;&lt;P&gt;Can anybody please send me the code. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks in Advance.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 12 Sep 2007 04:45:34 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/how-to-upload-csv-file-from-application-server/m-p/2790749#M651050</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-09-12T04:45:34Z</dc:date>
    </item>
    <item>
      <title>Re: How to upload .CSV file from Application Server</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/how-to-upload-csv-file-from-application-server/m-p/2790750#M651051</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;DATA: &lt;/P&gt;&lt;P&gt;   text1(30) TYPE c VALUE 'Beethoven', &lt;/P&gt;&lt;P&gt;   text2(3) TYPE c, &lt;/P&gt;&lt;P&gt;   file(30)  TYPE c VALUE '/usr/test.dat'. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;lt;b&amp;gt;To download file on application server&amp;lt;/b&amp;gt;&lt;/P&gt;&lt;P&gt;OPEN DATASET file IN TEXT MODE FOR OUTPUT ENCODING DEFAULT. &lt;/P&gt;&lt;P&gt;TRANSFER text1 TO file. &lt;/P&gt;&lt;P&gt;CLOSE DATASET file. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;lt;b&amp;gt;To read file from application server&amp;lt;/b&amp;gt;&lt;/P&gt;&lt;P&gt;OPEN DATASET file IN TEXT MODE FOR INPUT ENCODING DEFAULT. &lt;/P&gt;&lt;P&gt;READ DATASET file INTO text1 MAXIMUM LENGTH 4. &lt;/P&gt;&lt;P&gt;READ DATASET file INTO text2. &lt;/P&gt;&lt;P&gt;CLOSE DATASET file. &lt;/P&gt;&lt;P&gt;WRITE: / text1, / text2.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 12 Sep 2007 04:52:33 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/how-to-upload-csv-file-from-application-server/m-p/2790750#M651051</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-09-12T04:52:33Z</dc:date>
    </item>
    <item>
      <title>Re: How to upload .CSV file from Application Server</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/how-to-upload-csv-file-from-application-server/m-p/2790751#M651052</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;Define your internal table as &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt; begin of it_tab occurs 0, &lt;/P&gt;&lt;P&gt;  vbelnr  &lt;/P&gt;&lt;P&gt;  delimeter1,&lt;/P&gt;&lt;P&gt;  kunnr,&lt;/P&gt;&lt;P&gt;  delimeter2,&lt;/P&gt;&lt;P&gt;  item type,&lt;/P&gt;&lt;P&gt;  delimeter3&lt;/P&gt;&lt;P&gt;  ...&lt;/P&gt;&lt;P&gt;  ...&lt;/P&gt;&lt;P&gt; end   of it_tab.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Then open the file using below statement.&lt;/P&gt;&lt;P&gt;OPEN DATASET file IN TEXT MODE FOR INPUT ENCODING DEFAULT. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;do.&lt;/P&gt;&lt;P&gt;READ DATASET file INTO it_tab. &lt;/P&gt;&lt;P&gt;If sy-subrc = 0.&lt;/P&gt;&lt;P&gt;  append it_tab.&lt;/P&gt;&lt;P&gt;else.&lt;/P&gt;&lt;P&gt;  exit.&lt;/P&gt;&lt;P&gt;endif.&lt;/P&gt;&lt;P&gt;enddo.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;CLOSE DATASET file. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Satya.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 12 Sep 2007 05:03:43 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/how-to-upload-csv-file-from-application-server/m-p/2790751#M651052</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-09-12T05:03:43Z</dc:date>
    </item>
    <item>
      <title>Re: How to upload .CSV file from Application Server</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/how-to-upload-csv-file-from-application-server/m-p/2790752#M651053</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Priya,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Check this code&lt;/P&gt;&lt;P&gt;Yhe logic used here is as follows,&lt;/P&gt;&lt;P&gt;Get all the data into an internal table in the simple format ie: a row with one field contains an entire line&lt;/P&gt;&lt;P&gt;After getting the data, we split each line of the table on every occurrence of the delimiter (comma in your case)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Here, I have named the fields as field01, field02 etc, you could use your own names according to your requirement&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
parameters: p_file(512).

  DATA : BEGIN OF ITAB OCCURS 0,
          COL1(1024) TYPE C,
         END OF ITAB,
         WA_ITAB LIKE LINE OF ITAB.

  DATA: BEGIN OF ITAB_2 OCCURS 0,
    FIELD01(256),
    FIELD02(256),
    FIELD03(256),
    FIELD04(256),
    FIELD05(256),
    FIELD06(256),
    FIELD07(256),
    FIELD08(256),
    FIELD09(256),
    FIELD10(256),
    FIELD11(256),
    FIELD12(256),
    FIELD13(256),
    FIELD14(256),
    FIELD15(256),
    FIELD16(256),
   END OF ITAB_2.

  DATA: WA_2 LIKE LINE OF ITAB_2.

    OPEN DATASET p_FILE FOR INPUT IN TEXT MODE ENCODING NON-UNICODE.
    IF SY-SUBRC = 8.
      WRITE:/ 'File' , p_FILE , 'cannot be opened'.
      LV_LEAVEPGM = 'X'.
      EXIT.
    ENDIF.
    WHILE SY-SUBRC &amp;lt;&amp;gt; 4.
      READ DATASET p_FILE INTO WA_ITAB.
      APPEND WA_ITAB TO ITAB.
    ENDWHILE.

    CLOSE DATASET p_FILE.

  LOOP AT ITAB INTO WA_ITAB.
    SPLIT WA_ITAB-COL1 AT ','    " where comma is ur demiliter
     INTO WA_2-FIELD01 WA_2-FIELD02 WA_2-FIELD03 WA_2-FIELD04
     WA_2-FIELD05 WA_2-FIELD06 WA_2-FIELD07 WA_2-FIELD08 WA_2-FIELD09
     WA_2-FIELD10 WA_2-FIELD11 WA_2-FIELD12 WA_2-FIELD13 WA_2-FIELD14
     WA_2-FIELD15 WA_2-FIELD16.
    APPEND WA_2 TO ITAB_2.
    CLEAR WA_2.
  ENDLOOP.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Message was edited by: &lt;/P&gt;&lt;P&gt;        Kris Donald&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 12 Sep 2007 05:18:41 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/how-to-upload-csv-file-from-application-server/m-p/2790752#M651053</guid>
      <dc:creator>former_member189059</dc:creator>
      <dc:date>2007-09-12T05:18:41Z</dc:date>
    </item>
  </channel>
</rss>

