<?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: Rqd ABAP program in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/rqd-abap-program/m-p/3948056#M944036</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;First upload the CSV file into Internal table and then write the internal table data into Application server&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;TYPES:  BEGIN OF tys_dummy,
                 dummy TYPE char1000,
             END OF tys_dummy.
DATA: gt_dummy   TYPE STANDARD TABLE OF tys_dummy ,
      gs_dummy    TYPE tys_dummy.

  CLEAR gv_file.
  gv_file = pa_file.

  CALL FUNCTION 'GUI_UPLOAD'
    EXPORTING
      filename                = gv_file
      filetype                = gc_asc
      has_field_separator     = gc_x
    TABLES
      data_tab                = gt_dummy
    EXCEPTIONS
      file_open_error         = 1
      file_read_error         = 2
      no_batch                = 3
      gui_refuse_filetransfer = 4
      invalid_type            = 5
      no_authority            = 6
      unknown_error           = 7
      bad_data_format         = 8
      header_not_allowed      = 9
      separator_not_allowed   = 10
      header_too_long         = 11
      unknown_dp_error        = 12
      access_denied           = 13
      dp_out_of_memory        = 14
      disk_full               = 15
      dp_timeout              = 16
      OTHERS                  = 17.
  IF sy-subrc NE gc_zero_num.
    MESSAGE i006.
    LEAVE LIST-PROCESSING.
  ENDIF.

* Check if the input file is blank
  IF gt_dummy[] IS INITIAL.
    MESSAGE i007.
    LEAVE LIST-PROCESSING.
  ENDIF.
* To remove quotes in the table
  LOOP AT gt_dummy INTO gs_dummy.                  
    gv_tabix = sy-tabix.
    DO.
      IF gs_dummy CA '"'.
        REPLACE '"' WITH space INTO gs_dummy.
      ELSE.
        WRITE gs_dummy TO gs_dummy NO-GAP.
        CONDENSE gs_dummy.
        MODIFY gt_dummy INDEX gv_tabix FROM gs_dummy.
        EXIT.
      ENDIF.
    ENDDO.
  ENDLOOP.

Here use
 OPEN DATASET '/tmp/csv.txt' IN TEXTMODE DEFAULT ENCODING. 
Loop at gt_dummy into gs_dummy.
TRANSFER gs_dummy to '/tmp/csv.txt' .
endloop.
CLOSE DATASET '/tmp/csv.txt' .&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Kannaiah&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 29 May 2008 06:30:11 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2008-05-29T06:30:11Z</dc:date>
    <item>
      <title>Rqd ABAP program</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/rqd-abap-program/m-p/3948051#M944031</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi all,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;              I want to write or upload the flat file(csv file) to the apllication server.for this i need ABAP program in order to write the file to Application server.could u plz provide the code with explanation?.i will assign points for the correct answers.....&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks &amp;amp; regards,&lt;/P&gt;&lt;P&gt;nani&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 29 May 2008 06:16:49 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/rqd-abap-program/m-p/3948051#M944031</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-05-29T06:16:49Z</dc:date>
    </item>
    <item>
      <title>Re: Rqd ABAP program</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/rqd-abap-program/m-p/3948052#M944032</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;Maintaining InfoSources (Flat File) &lt;/P&gt;&lt;P&gt;Purpose&lt;/P&gt;&lt;P&gt;You can load data from flat files (CSV or ASCII files) into BW.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You can load the following data types:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;       1.      Transaction Data&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;       2.      Master data, either directly or flexibly&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;¡        Attributes&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;¡        Texts&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;       3.      Hierarchies &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Prerequisites&lt;/P&gt;&lt;P&gt;Note the following with regard to CSV files:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;·        Excel files use delimiters to separate fields. In the European version, a semi-colon (&lt;SPAN __jive_emoticon_name="wink"&gt;&lt;/SPAN&gt; is used as a delimiter. In the American version, a comma (,) is used. You can use other delimiters. You must specify the delimiter used in the Scheduler.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;·        Fields that are not filled in a CSV file are filled with a blank space if they are character fields and with a zero (0) if they are numerical fields.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;·        If delimiters are used inconsistently in a CSV file, the u201Cwrongu201D delimiter is read as a character, and both fields are merged into one field and possibly shortened. Subsequent fields are no longer in the correct order.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Note the following with regard to CSV files and ASCII files:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;·        If your file contains headers that you do not want to be loaded, on the External Data  tab page in the Scheduler, specify the number of headers that you want the system to ignore during the data load. This gives you the option of keeping the column headers in your file.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;·        A conversion routine determines whether or not you have to specify leading zeros. See also Conversion Routines in BW.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;·        For dates, you usually use the format YYYYMMDD, without internal delimiters. Depending on the conversion routine, you can also use other formats.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;·        If you use IDocs to upload data, note the 1000 byte limit per data record length. This limit does not apply to data that is uploaded using the PSA.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Notes on Uploading&lt;/P&gt;&lt;P&gt;·        When you upload external data, you have the option of loading the data from any workstation into BW. For performance reasons, however, you should store the data on an application server and load it from there into BW. This also enables you to load the data in the background.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;·        If you want to upload a large amount of transaction data from a flat file, and you are able to specify the file type of the flat file, you should create the flat file as an ASCII file. For performance reasons, uploading the data from an ASCII file is the most cost-effective method. Under certain circumstances, generating an ASCII file might involve more work.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&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;&lt;/P&gt;&lt;P&gt;Jagadish&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 29 May 2008 06:18:24 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/rqd-abap-program/m-p/3948052#M944032</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-05-29T06:18:24Z</dc:date>
    </item>
    <item>
      <title>Re: Rqd ABAP program</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/rqd-abap-program/m-p/3948053#M944033</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;check this link&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="http://www.sap-img.com/java/downloading-a-csv-file.htm" target="test_blank"&gt;http://www.sap-img.com/java/downloading-a-csv-file.htm&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="http://www.sapfans.com/forums/viewtopic.php?t=244024" target="test_blank"&gt;http://www.sapfans.com/forums/viewtopic.php?t=244024&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;regards&lt;/P&gt;&lt;P&gt;prasanth&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 29 May 2008 06:20:16 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/rqd-abap-program/m-p/3948053#M944033</guid>
      <dc:creator>prasanth_kasturi</dc:creator>
      <dc:date>2008-05-29T06:20:16Z</dc:date>
    </item>
    <item>
      <title>Re: Rqd ABAP program</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/rqd-abap-program/m-p/3948054#M944034</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;If I remember correctly, when using OPEN DATASET, the file name can not have spaces in the name. Try renaming your file removing spaces and retry.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;For your code, you'll need to breakdown the CSV file by the delimiter.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This code makes an archive file while reading the main file.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;    OPEN DATASET filname IN TEXT MODE MESSAGE t_mesg.&lt;/P&gt;&lt;P&gt;    IF sy-subrc NE 0.&lt;/P&gt;&lt;P&gt;      MOVE 'X' TO t_error.&lt;/P&gt;&lt;P&gt;      MESSAGE e100(z0) WITH 'Error reading file:' t_mesg.&lt;/P&gt;&lt;P&gt;      EXIT.&lt;/P&gt;&lt;P&gt;    ENDIF.&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;    IF p_load = 'X'.&lt;/P&gt;&lt;P&gt;      OPEN DATASET archfilname FOR OUTPUT IN TEXT MODE MESSAGE t_mesg.&lt;/P&gt;&lt;P&gt;      IF sy-subrc NE 0.&lt;/P&gt;&lt;P&gt;        MOVE 'X' TO t_error.&lt;/P&gt;&lt;P&gt;        MESSAGE e100(z0) WITH 'Error opening achrive file:' t_mesg.&lt;/P&gt;&lt;P&gt;        EXIT.&lt;/P&gt;&lt;P&gt;      ENDIF.&lt;/P&gt;&lt;P&gt;    ENDIF.&lt;/P&gt;&lt;P&gt;    DO.&lt;/P&gt;&lt;P&gt;      READ DATASET filname INTO my_rec.&lt;/P&gt;&lt;P&gt;      IF sy-subrc NE 0.&lt;/P&gt;&lt;P&gt;        EXIT.&lt;/P&gt;&lt;P&gt;      ENDIF.&lt;/P&gt;&lt;P&gt;      IF p_load = 'X'.&lt;/P&gt;&lt;P&gt;        TRANSFER my_rec TO archfilname.&lt;/P&gt;&lt;P&gt;      ENDIF.&lt;/P&gt;&lt;P&gt;      SPLIT my_rec AT c_tab       " Here my delimter was a tab change to ',' for comma&lt;/P&gt;&lt;P&gt;        INTO  in_rec-id&lt;/P&gt;&lt;P&gt;              in_rec-fname&lt;/P&gt;&lt;P&gt;              in_rec-lname&lt;/P&gt;&lt;P&gt;              in_rec-addr&lt;/P&gt;&lt;P&gt;              in_rec-apt&lt;/P&gt;&lt;P&gt;              in_rec-city&lt;/P&gt;&lt;P&gt;              in_rec-state&lt;/P&gt;&lt;P&gt;              in_rec-zip&lt;/P&gt;&lt;P&gt;              in_rec-branch&lt;/P&gt;&lt;P&gt;              in_rec-phone1&lt;/P&gt;&lt;P&gt;              in_rec-phone2&lt;/P&gt;&lt;P&gt;              in_rec-phone3&lt;/P&gt;&lt;P&gt;              in_rec-phone3_ext&lt;/P&gt;&lt;P&gt;              in_rec-email&lt;/P&gt;&lt;P&gt;              in_rec-hear&lt;/P&gt;&lt;P&gt;              in_rec-prefcont&lt;/P&gt;&lt;P&gt;              in_rec-ownland&lt;/P&gt;&lt;P&gt;              in_rec-build&lt;/P&gt;&lt;P&gt;              in_rec-ownhome&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;             in_rec-get_promo&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;              in_rec-cmt1&lt;/P&gt;&lt;P&gt;              in_rec-subdate.&lt;/P&gt;&lt;P&gt;      APPEND in_rec TO it_input.&lt;/P&gt;&lt;P&gt;    ENDDO.&lt;/P&gt;&lt;P&gt;    CLOSE DATASET filname.&lt;/P&gt;&lt;P&gt;    IF p_load = 'X'.&lt;/P&gt;&lt;P&gt;      CLOSE DATASET archfilname.&lt;/P&gt;&lt;P&gt;      DELETE DATASET filname.&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;Refer This:&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="5119024"&gt;&lt;/A&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="5200788"&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;Shiva Kumar&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 29 May 2008 06:21:41 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/rqd-abap-program/m-p/3948054#M944034</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-05-29T06:21:41Z</dc:date>
    </item>
    <item>
      <title>Re: Rqd ABAP program</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/rqd-abap-program/m-p/3948055#M944035</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi prasant!,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;                thanks for ur reply.......i didn't understand actually iam new to ABAP..can u explain clearly.i want to know wheather this small code is enough to download a flat file in to application server from desktop.plz provide the full code.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;thanks&lt;/P&gt;&lt;P&gt;nani&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 29 May 2008 06:26:07 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/rqd-abap-program/m-p/3948055#M944035</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-05-29T06:26:07Z</dc:date>
    </item>
    <item>
      <title>Re: Rqd ABAP program</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/rqd-abap-program/m-p/3948056#M944036</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;First upload the CSV file into Internal table and then write the internal table data into Application server&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;TYPES:  BEGIN OF tys_dummy,
                 dummy TYPE char1000,
             END OF tys_dummy.
DATA: gt_dummy   TYPE STANDARD TABLE OF tys_dummy ,
      gs_dummy    TYPE tys_dummy.

  CLEAR gv_file.
  gv_file = pa_file.

  CALL FUNCTION 'GUI_UPLOAD'
    EXPORTING
      filename                = gv_file
      filetype                = gc_asc
      has_field_separator     = gc_x
    TABLES
      data_tab                = gt_dummy
    EXCEPTIONS
      file_open_error         = 1
      file_read_error         = 2
      no_batch                = 3
      gui_refuse_filetransfer = 4
      invalid_type            = 5
      no_authority            = 6
      unknown_error           = 7
      bad_data_format         = 8
      header_not_allowed      = 9
      separator_not_allowed   = 10
      header_too_long         = 11
      unknown_dp_error        = 12
      access_denied           = 13
      dp_out_of_memory        = 14
      disk_full               = 15
      dp_timeout              = 16
      OTHERS                  = 17.
  IF sy-subrc NE gc_zero_num.
    MESSAGE i006.
    LEAVE LIST-PROCESSING.
  ENDIF.

* Check if the input file is blank
  IF gt_dummy[] IS INITIAL.
    MESSAGE i007.
    LEAVE LIST-PROCESSING.
  ENDIF.
* To remove quotes in the table
  LOOP AT gt_dummy INTO gs_dummy.                  
    gv_tabix = sy-tabix.
    DO.
      IF gs_dummy CA '"'.
        REPLACE '"' WITH space INTO gs_dummy.
      ELSE.
        WRITE gs_dummy TO gs_dummy NO-GAP.
        CONDENSE gs_dummy.
        MODIFY gt_dummy INDEX gv_tabix FROM gs_dummy.
        EXIT.
      ENDIF.
    ENDDO.
  ENDLOOP.

Here use
 OPEN DATASET '/tmp/csv.txt' IN TEXTMODE DEFAULT ENCODING. 
Loop at gt_dummy into gs_dummy.
TRANSFER gs_dummy to '/tmp/csv.txt' .
endloop.
CLOSE DATASET '/tmp/csv.txt' .&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Kannaiah&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 29 May 2008 06:30:11 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/rqd-abap-program/m-p/3948056#M944036</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-05-29T06:30:11Z</dc:date>
    </item>
    <item>
      <title>Re: Rqd ABAP program</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/rqd-abap-program/m-p/3948057#M944037</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Nani,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Writing a file in file server is not a big deal once your internal table with data is ready.&lt;/P&gt;&lt;P&gt;All you need do is to use OPEN DATASET, TRANSFER and CLOSE DATASET.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;OPEN DATASET creates the file in fileserver.&lt;/P&gt;&lt;P&gt;TRANSFER - Transfers the ITab contents to file server.&lt;/P&gt;&lt;P&gt;CLOSE DATASET closes the file in the application server.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You can view the file in Application server using t-code Al11.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hope this explains you.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Arun&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 29 May 2008 06:34:06 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/rqd-abap-program/m-p/3948057#M944037</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-05-29T06:34:06Z</dc:date>
    </item>
  </channel>
</rss>

