<?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: internal table to csv file on application server in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/internal-table-to-csv-file-on-application-server/m-p/4221109#M1008559</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hii Rakhi!&lt;/P&gt;&lt;P&gt;  Check out this sample code&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
REPORT  z_FILE2.
DATA: fname(40),
      w_line TYPE i VALUE 1.
DATA:
  BEGIN OF fs_flight,
    carrid   LIKE sflight-carrid,
    connid   LIKE sflight-connid,
    fldate   LIKE sflight-fldate,
  END OF fs_flight.

DATA:
  t_flight LIKE
     TABLE OF
           fs_flight.
DATA:
  t_flight1 LIKE
      TABLE OF
            fs_flight.
SELECT-OPTIONS:
  s_carrid FOR fs_flight-carrid,
  s_connid FOR fs_flight-connid.
fname = '.\ztest4.csv'.
PERFORM get_flight_data.
OPEN DATASET fname FOR OUTPUT IN TEXT MODE ENCODING DEFAULT.
LOOP AT t_flight INTO fs_flight.
  TRANSFER fs_flight TO fname.
ENDLOOP.
IF sy-subrc EQ 0.
  WRITE: 'File Opened On Apps Server'.
ELSE.
  WRITE: 'File could not be opened'.
ENDIF.
CLOSE DATASET fname.




*&amp;amp;---------------------------------------------------------------------*
*&amp;amp;      Form  get_flight_data
*&amp;amp;---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  --&amp;gt;  p1        text
*  &amp;lt;--  p2        text
*----------------------------------------------------------------------*
form get_flight_data .
    SELECT carrid
           connid
           fldate
      FROM sflight
      INTO TABLE t_flight
     WHERE carrid IN s_carrid
       AND connid IN s_connid.
endform.                    " get_flight_data
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;Abhijeet&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 17 Jul 2008 06:45:55 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2008-07-17T06:45:55Z</dc:date>
    <item>
      <title>internal table to csv file on application server</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/internal-table-to-csv-file-on-application-server/m-p/4221101#M1008551</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;hi,&lt;/P&gt;&lt;P&gt;i have an internal table i_item ,,&lt;/P&gt;&lt;P&gt;i have to write the content of that internal table to a csv file on the apllication server.&lt;/P&gt;&lt;P&gt;can i have the code please?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 15 Jul 2008 10:22:01 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/internal-table-to-csv-file-on-application-server/m-p/4221101#M1008551</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-07-15T10:22:01Z</dc:date>
    </item>
    <item>
      <title>Re: internal table to csv file on application server</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/internal-table-to-csv-file-on-application-server/m-p/4221102#M1008552</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Convert data in internal table to a delimited text data&lt;/P&gt;&lt;P&gt;using a function module   'SAP_CONVERT_TO_TEX_FORMAT'&lt;/P&gt;&lt;P&gt;and then download the data from that text file using function module DOWNLOAD.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 15 Jul 2008 10:45:29 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/internal-table-to-csv-file-on-application-server/m-p/4221102#M1008552</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-07-15T10:45:29Z</dc:date>
    </item>
    <item>
      <title>Re: internal table to csv file on application server</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/internal-table-to-csv-file-on-application-server/m-p/4221103#M1008553</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;If the file is asved as ".xls" format then again open the file and change 'save as type' to ".CSV(Comma Delimited)".&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 15 Jul 2008 11:27:29 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/internal-table-to-csv-file-on-application-server/m-p/4221103#M1008553</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-07-15T11:27:29Z</dc:date>
    </item>
    <item>
      <title>Re: internal table to csv file on application server</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/internal-table-to-csv-file-on-application-server/m-p/4221104#M1008554</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;If the file is asved as ".xls" format then again open the file and change 'save as type' to ".CSV(Comma Delimited)".&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 15 Jul 2008 11:30:36 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/internal-table-to-csv-file-on-application-server/m-p/4221104#M1008554</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-07-15T11:30:36Z</dc:date>
    </item>
    <item>
      <title>Re: internal table to csv file on application server</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/internal-table-to-csv-file-on-application-server/m-p/4221105#M1008555</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;CSV file is a simple text file which has fields separated by ; sign. When you open files that has csv extension using excel , you can't see the ; signs. There will only be fields inside the excel columns wrapped from the ; sign .&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Code should be similar as below ;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;DATA : FILENAME(128) DEFAULT '/usr/......../file.csv'. "" Your path

DATA : lv_str type string.

* Open File
OPEN DATASET FILENAME FOR OUTPUT IN TEXT MODE.
CHECK sy-subrc EQ 0.

loop at i_item.

    CONCATENATE 
                i_item-FIELD_1
                i_item-FIELD_2
                i_item-FIELD_3
                i_item-FIELD_4
                i_item-FIELD_5
                
                into lv_str

                SEPARATED BY ';'.

transfer lv_str to filename.

endloop.

* Close File
CLOSE DATASET FILENAME.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hope it helps you.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 15 Jul 2008 19:30:12 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/internal-table-to-csv-file-on-application-server/m-p/4221105#M1008555</guid>
      <dc:creator>huseyindereli</dc:creator>
      <dc:date>2008-07-15T19:30:12Z</dc:date>
    </item>
    <item>
      <title>Re: internal table to csv file on application server</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/internal-table-to-csv-file-on-application-server/m-p/4221106#M1008556</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;  You can use above code of   ' Hüseyin Dereli ' , but I think CSV file is ','(Comma) seperator not ';' seperator.This the only change .&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 16 Jul 2008 03:30:42 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/internal-table-to-csv-file-on-application-server/m-p/4221106#M1008556</guid>
      <dc:creator>former_member761936</dc:creator>
      <dc:date>2008-07-16T03:30:42Z</dc:date>
    </item>
    <item>
      <title>Re: internal table to csv file on application server</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/internal-table-to-csv-file-on-application-server/m-p/4221107#M1008557</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Narendra ;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Open an empty txt document and fill it like below ;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;col11;col12;col13;col14&lt;/P&gt;&lt;P&gt;col21;col22;col23;col24&lt;/P&gt;&lt;P&gt;col31;col32;col33;col34&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;and than save as &lt;STRONG&gt;sample.csv&lt;/STRONG&gt; .&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Try to open it using excel.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 16 Jul 2008 06:45:49 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/internal-table-to-csv-file-on-application-server/m-p/4221107#M1008557</guid>
      <dc:creator>huseyindereli</dc:creator>
      <dc:date>2008-07-16T06:45:49Z</dc:date>
    </item>
    <item>
      <title>Re: internal table to csv file on application server</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/internal-table-to-csv-file-on-application-server/m-p/4221108#M1008558</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Hüseyin Dereli ,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Open some excel file , and give some data and save it as csv file.then open that csv file with note pad , you will find ',' between fields.Even when you saving excel as csv you can observe in brackets( Comma delimited)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 17 Jul 2008 05:52:36 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/internal-table-to-csv-file-on-application-server/m-p/4221108#M1008558</guid>
      <dc:creator>former_member761936</dc:creator>
      <dc:date>2008-07-17T05:52:36Z</dc:date>
    </item>
    <item>
      <title>Re: internal table to csv file on application server</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/internal-table-to-csv-file-on-application-server/m-p/4221109#M1008559</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hii Rakhi!&lt;/P&gt;&lt;P&gt;  Check out this sample code&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
REPORT  z_FILE2.
DATA: fname(40),
      w_line TYPE i VALUE 1.
DATA:
  BEGIN OF fs_flight,
    carrid   LIKE sflight-carrid,
    connid   LIKE sflight-connid,
    fldate   LIKE sflight-fldate,
  END OF fs_flight.

DATA:
  t_flight LIKE
     TABLE OF
           fs_flight.
DATA:
  t_flight1 LIKE
      TABLE OF
            fs_flight.
SELECT-OPTIONS:
  s_carrid FOR fs_flight-carrid,
  s_connid FOR fs_flight-connid.
fname = '.\ztest4.csv'.
PERFORM get_flight_data.
OPEN DATASET fname FOR OUTPUT IN TEXT MODE ENCODING DEFAULT.
LOOP AT t_flight INTO fs_flight.
  TRANSFER fs_flight TO fname.
ENDLOOP.
IF sy-subrc EQ 0.
  WRITE: 'File Opened On Apps Server'.
ELSE.
  WRITE: 'File could not be opened'.
ENDIF.
CLOSE DATASET fname.




*&amp;amp;---------------------------------------------------------------------*
*&amp;amp;      Form  get_flight_data
*&amp;amp;---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  --&amp;gt;  p1        text
*  &amp;lt;--  p2        text
*----------------------------------------------------------------------*
form get_flight_data .
    SELECT carrid
           connid
           fldate
      FROM sflight
      INTO TABLE t_flight
     WHERE carrid IN s_carrid
       AND connid IN s_connid.
endform.                    " get_flight_data
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;Abhijeet&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 17 Jul 2008 06:45:55 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/internal-table-to-csv-file-on-application-server/m-p/4221109#M1008559</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-07-17T06:45:55Z</dc:date>
    </item>
    <item>
      <title>Re: internal table to csv file on application server</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/internal-table-to-csv-file-on-application-server/m-p/4221110#M1008560</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Narendra ,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt; I followed your instructions and i found ";" &lt;STRONG&gt;semi-colon&lt;/STRONG&gt; between columns. Because it depends on windows regional settings. Go to control panel -&amp;gt; regional and language options-&amp;gt; customize -&amp;gt; list separator ...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt; Well i could say CSV means Comma Separated Value BUT ";" semi-colon is preffed lately because of the problems related with "," comma delimiter.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt; Regards&lt;/P&gt;&lt;P&gt; Hüseyin DERELİ&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 17 Jul 2008 13:22:59 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/internal-table-to-csv-file-on-application-server/m-p/4221110#M1008560</guid>
      <dc:creator>huseyindereli</dc:creator>
      <dc:date>2008-07-17T13:22:59Z</dc:date>
    </item>
    <item>
      <title>Re: internal table to csv file on application server</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/internal-table-to-csv-file-on-application-server/m-p/4221111#M1008561</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;*this is parameter for selection file from presentation (or) appilication serever.&lt;/P&gt;&lt;P&gt;PARAMETERS:p_files        TYPE string.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;*here we delcaring one structure as per the presentation server file length and for that structuru we declaring the explicit work area (for header) and internal table for that structure&lt;/P&gt;&lt;P&gt;TYPES:BEGIN OF gty_itab1,&lt;/P&gt;&lt;P&gt;           abc(305),&lt;/P&gt;&lt;P&gt;           END OF gty_itab1.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;DATA: gt_itab1 TYPE STANDARD TABLE OF gty_itab1,&lt;/P&gt;&lt;P&gt;           gwa_itab1 TYPE gty_itab1.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;*here as per your flat file fields you declaring one structure accordingly for this stuructre one explicit work area (for header) and internal table.&lt;/P&gt;&lt;P&gt;TYPES :BEGIN OF gty_itab2,&lt;/P&gt;&lt;P&gt;             ktokd(4),        "customer account grp      kna1&lt;/P&gt;&lt;P&gt;             kunnr(10),       "customer                  kna1&lt;/P&gt;&lt;P&gt;             name1(35),       "name1                     kna1&lt;/P&gt;&lt;P&gt;             END OF gty_itab2.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;DATA: gt_itab2 TYPE STANDARD TABLE OF gty_itab2,&lt;/P&gt;&lt;P&gt;           gwa_itab2 TYPE gty_itab2.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;*here we are clling the function module GUI_UPLOAD for uploading the file from presentation into internaltable structure as we declared above as gt_itab1(once upload we are providing the file name and file tyep and datatable path as gt_itab1)&lt;/P&gt;&lt;P&gt;CALL FUNCTION 'GUI_UPLOAD'&lt;/P&gt;&lt;P&gt;  EXPORTING&lt;/P&gt;&lt;P&gt;    filename                = p_files&lt;/P&gt;&lt;P&gt;    filetype                  = 'ASC'&lt;/P&gt;&lt;P&gt;  TABLES&lt;/P&gt;&lt;P&gt;    data_tab                = gt_itab1&lt;/P&gt;&lt;P&gt;  EXCEPTIONS&lt;/P&gt;&lt;P&gt;    file_open_error         = 1&lt;/P&gt;&lt;P&gt;    file_read_error         = 2&lt;/P&gt;&lt;P&gt;    no_batch                = 3&lt;/P&gt;&lt;P&gt;    gui_refuse_filetransfer = 4&lt;/P&gt;&lt;P&gt;    invalid_type            = 5&lt;/P&gt;&lt;P&gt;    no_authority            = 6&lt;/P&gt;&lt;P&gt;    unknown_error           = 7&lt;/P&gt;&lt;P&gt;    bad_data_format         = 8&lt;/P&gt;&lt;P&gt;    header_not_allowed      = 9&lt;/P&gt;&lt;P&gt;    separator_not_allowed   = 10&lt;/P&gt;&lt;P&gt;    header_too_long         = 11&lt;/P&gt;&lt;P&gt;    unknown_dp_error        = 12&lt;/P&gt;&lt;P&gt;    access_denied           = 13&lt;/P&gt;&lt;P&gt;    dp_out_of_memory        = 14&lt;/P&gt;&lt;P&gt;    disk_full               = 15&lt;/P&gt;&lt;P&gt;    dp_timeout              = 16&lt;/P&gt;&lt;P&gt;    OTHERS                  = 17.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;IF sy-subrc &amp;lt;&amp;gt; 0.&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO&lt;/P&gt;&lt;/LI&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;        WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;ENDIF.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;*once uploaded we wil moving the uploaded data from gwa_itab1-abc(305) to gwa_iatb2&lt;/P&gt;&lt;P&gt;LOOP AT gt_itab1 INTO gwa_itab1.&lt;/P&gt;&lt;P&gt;  gwa_itab2 = gwa_itab1-abc(305).&lt;/P&gt;&lt;P&gt;  APPEND gwa_itab2 TO gt_itab2.&lt;/P&gt;&lt;P&gt;ENDLOOP.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;*here we are splitting with comma and miving individual field values into itab2 filed structure like below.&lt;/P&gt;&lt;P&gt;LOOP AT gt_itab2 INTO gwa_itab2.&lt;/P&gt;&lt;P&gt;  SPLIT gwa_itab2 AT ',' INTO gwa_itab2-ktokd&lt;/P&gt;&lt;P&gt;                                           gwa_itab2-kunnr&lt;/P&gt;&lt;P&gt;                                           gwa_itab2-name1 &lt;/P&gt;&lt;P&gt;                                           gwa_itab2-sortl.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;*now our filed values are in internal table so we can move these values into bapi structure and we cann call related BAPI&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;please let me know if you have any questions...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;reward if it is really helpfull.....&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Edited by: Srinivas on Jul 17, 2008 2:37 PM&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 17 Jul 2008 19:10:10 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/internal-table-to-csv-file-on-application-server/m-p/4221111#M1008561</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-07-17T19:10:10Z</dc:date>
    </item>
  </channel>
</rss>

