Downloading Excel File in CSV Format

Hi All,
How can I Download a file in .CSV Format?
I am using the below shown code.
CALL FUNCTION 'GUI_DOWNLOAD'
  EXPORTING
  BIN_FILESIZE                    =
    FILENAME                        = 'C:\Documents and Settings\sandeepp3\Desktop\sample.csv'
    FILETYPE                        = 'DAT'
  APPEND                          = ' '
    WRITE_FIELD_SEPARATOR           = ','
  HEADER                          = '00'
  TRUNC_TRAILING_BLANKS           = ' '
  WRITE_LF                        = 'X'
  COL_SELECT                      = ' '
  COL_SELECT_MASK                 = ' '
  DAT_MODE                        = ' '
  CONFIRM_OVERWRITE               = ' '
  NO_AUTH_CHECK                   = ' '
  CODEPAGE                        = ' '
  IGNORE_CERR                     = ABAP_TRUE
  REPLACEMENT                     = '#'
  WRITE_BOM                       = ' '
  TRUNC_TRAILING_BLANKS_EOL       = 'X'
  WK1_N_FORMAT                    = ' '
  WK1_N_SIZE                      = ' '
  WK1_T_FORMAT                    = ' '
  WK1_T_SIZE                      = ' '
  WRITE_LF_AFTER_LAST_LINE        = ABAP_TRUE
  SHOW_TRANSFER_STATUS            = ABAP_TRUE
IMPORTING
  FILELENGTH                      =
  TABLES
    DATA_TAB                        = ITAB
    FIELDNAMES                      = HTAB
EXCEPTIONS
  FILE_WRITE_ERROR                = 1
  NO_BATCH                        = 2
  GUI_REFUSE_FILETRANSFER         = 3
  INVALID_TYPE                    = 4
  NO_AUTHORITY                    = 5
  UNKNOWN_ERROR                   = 6
  HEADER_NOT_ALLOWED              = 7
  SEPARATOR_NOT_ALLOWED           = 8
  FILESIZE_NOT_ALLOWED            = 9
  HEADER_TOO_LONG                 = 10
  DP_ERROR_CREATE                 = 11
  DP_ERROR_SEND                   = 12
  DP_ERROR_WRITE                  = 13
  UNKNOWN_DP_ERROR                = 14
  ACCESS_DENIED                   = 15
  DP_OUT_OF_MEMORY                = 16
  DISK_FULL                       = 17
  DP_TIMEOUT                      = 18
  FILE_NOT_FOUND                  = 19
  DATAPROVIDER_EXCEPTION          = 20
  CONTROL_FLUSH_ERROR             = 21
  OTHERS                          = 22
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
        WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
I am getting the field separator as Tab(SPACE).
Please Advise

Hi Anil,
Try this way.
REPORT ztest_notepad.
"Declarations
TYPE-POOLS :truxs.
DATA : it_download TYPE truxs_t_text_data.
DATA: BEGIN OF it_data OCCURS 0,
        arbgb TYPE t100-arbgb,
        msgnr TYPE t100-msgnr,
        text TYPE t100-text,
      END OF it_data.
START-OF-SELECTION.
  "Select Data
  SELECT * FROM t100
  INTO CORRESPONDING FIELDS OF TABLE it_data UP TO 200 ROWS   WHERE sprsl = sy-langu.
  "Convert SAP to CSV format
  CALL FUNCTION 'SAP_CONVERT_TO_CSV_FORMAT'
    EXPORTING
      i_field_seperator    = ';'
    TABLES
      i_tab_sap_data       = it_data
    CHANGING
      i_tab_converted_data = it_download
    EXCEPTIONS
      conversion_failed    = 1
      OTHERS               = 2.
  IF sy-subrc = 0.
    "Download data using GUI_DOWNLOAD
    CALL FUNCTION 'GUI_DOWNLOAD'
      EXPORTING
        filename = 'C:\test.txt'
        filetype = 'ASC'
      TABLES
        data_tab = it_download.
  ENDIF.
Thanks
venkat.O

Similar Messages

  • App open Excel file using CSV format

    Actually I would like to find app open Excel file and add some date and save it again under CSV format

    Numbers will do that (using the export function). I'm sure many other Excel compatible apps will as well, but you will need to read the app store descriptions to verify. (I can verify that Quick Office does NOT).

  • Download the File in CSV format

    hI,
    Can any one tell me F.M to down load to CSV format in BW System.
    In BW system we donot have F.M SAP_CONVERT_TO_CSV_FORMAT.

    Hi,
    I hope you have GUI_DOWNLOAD function module
    Try this i had used this in BW before
    Data : w_file_path type string.
    file_path = 'c:\temp\abcd.csv'.
    Note: T_field is optional (If you want field names at the top row you can use it
    CALL FUNCTION 'GUI_DOWNLOAD'
        EXPORTING
          filename                = w_file_path
          filetype                = 'ASC'
          write_field_separator   = 'X'
          confirm_overwrite       = 'X'
        TABLES
          data_tab                = t_output
          fieldnames              = t_field.
    Regards
    Krishna

  • Upload an Excel file in CSV format  but still error please help?

    ORA-20001: Excel load run ddl error: drop table "SDF" ORA-00942: table or view does not exist ORA-20001: Excel load run ddl error:
    So can anybody help me in this regard !Table or views does not exist! So what should I do in this regard ?
    Thanks in advance

    hi muhammad--
    could you please send the following to [email protected], please:
    1) the spreadsheet you were trying to upload
    2) very specific information about the steps you took to get to this error (including the exact values you entered into the various fields)
    also, if this occurred on htmldb.oracle.com, please do let us know.
    thanks
    raj

  • Issue while downloading file in .CSV format

    Hi,
    I need to download the file in .CSV format.
    I hade used FM SAP_CONVERT_TO_CSV_FORMAT  and then used GUI_Download.
    Now when I am opening file which is downloaded, it gives all the data in a single column. If there are 5 fields in my table, the generated file gives the data of all the 5 fields in a single column.
    Could you please help?

    Hi try wi th the following code.
    TYPE-POOLS : truxs.
    DATA: t_file TYPE STANDARD TABLE OF type_file.
    data:t_conv_data TYPE truxs_t_text_data.
    CALL FUNCTION 'SAP_CONVERT_TO_TEX_FORMAT'
      EXPORTING
        i_field_seperator          = ', '
      TABLES
        i_tab_sap_data             = t_file
    CHANGING
       i_tab_converted_data       = t_conv_data
    EXCEPTIONS
       conversion_failed          = 1
       OTHERS                     = 2.
    CALL FUNCTION 'GUI_DOWNLOAD'
      EXPORTING
        filename                = 'C:\TESTCSV.CSV'
        filetype                = 'ASC'
        write_field_separator   = '  '
      TABLES
        data_tab                = t_file
       fieldnames              = names
      EXCEPTIONS
        file_write_error        = 1
        no_batch                = 2
        gui_refuse_filetransfer = 3
        invalid_type            = 4
        no_authority            = 5
        unknown_error           = 6
        header_not_allowed      = 7
        separator_not_allowed   = 8
        filesize_not_allowed    = 9
        header_too_long         = 10
        dp_error_create         = 11
        dp_error_send           = 12
        dp_error_write          = 13
        unknown_dp_error        = 14
        access_denied           = 15
        dp_out_of_memory        = 16
        disk_full               = 17
        dp_timeout              = 18
        file_not_found          = 19
        dataprovider_exception  = 20
        control_flush_error     = 21
        OTHERS                  = 22.

  • Proxy error when downloading report (IR) in csv format

    I'm getting the error below when downloading IR report in csv format. I'm getting that whenever the records is more than 108,000. Is there a limit in records to download? Is there a resolution.
    I am using apex 4.1, EXCEL 2010.
    Thanks,
    Pinky

    Since it is a text file it should have no limits within reason..
    See if you can recreate issue on Oracle's hosted site..
    Simple test, build a standard report on a table that has 101,000 rows and try downloading and then build a IR report on same table..
    Thank you,
    Tony Miller
    Dallas, TX

  • Converting flat files to csv format

    hi,
    Iam converting flat files to csv format..the problem is that iam running a script for inserting values.while i run this script it works fine .but while i open this csv file the datas in the excel sheet is not coming in a single line that is for a particular record its moving to second line .there is a break for a single record.so there is a problem in conversion.can anything be done in it this to avoid the breaking of lines
    thanks
    Ratheesh

    YOGenereally, you shouldn't convert from a lossy format AAC or MP3) to another lossy fomrat.
    It's called loss because you lose information when you convert it.
    If you only use these files on the computer and the iPod, I'd recommend AAC. Better quality at same bit rate as MP3.

  • BW System - F.M to down load the file to CSV format

    Hi All,
    Canm any one plz let me what is the F.M to down load the file to CSV format in BW system

    Hi,
    try using this FM  " /LICMAN/UT_CONVERT_ITAB_2_CSV" to conver the data to CSV. then call GUI_Download to download
    Regards,
    Aditya

  • Saving excel file as .csv via OLE program

    Hi all,
    in my abap OLE program i'd like to save an excel file as .csv file with ";" separator according to the frontend settings. Unfortunately the file is saved with "," separator (and not ";").
    Here is the code:
    <<...
         call method of e_newappl 'SAVEAS'
         exporting
           #1 = path
           #2 = '23' ....>>
    I also tried 6, 22, 24 as #2 parameter values, with the same result. Running the program in differents workstations (all with ";" separator in the general settings) sometimes i get a file with ";" and sometimes with ",".
    Is there a way to always get the .csv  file with ";"? Or at least to check what separator will be used?
    Thanks for replies.

    hi,
    please check this similar thread for the answer
    Sample code to download data to .CSV file using OLE method
    thanks

  • Need help in writing data to a flat file in .csv format

    Hi All,
    could you please show with a sample example to write data in .csv format using UTL_file.
    The result of the refcursor i want to write to a file in .csv format.
    How can i achieve this.
    Thx

    Hi,
    There are two ways to acheive this.
    First and which I prefer is creating a SQL script which will generate csv file at the specified location in CSV format. And then this SQL script can be called from your cron job similar to how you call stored procedure. Following is pseudo code that can be used -
    set linesize 500
    set echo off
    set feedback off
    set prompt off
    set pagesize 0
    spool <name of the csv file>.csv
    <Your select statement>;
    spool offPut select statement delimiting columns you want to use with ','. E.g. following query should create a CSV file named as abc.csv with one record and 2 columns delimited by comma. First column is ENO and second column is ENAME.
    set linesize 500
    set echo off
    set feedback off
    set prompt off
    set pagesize 0
    spool abc.csv
    select ENO || ',' || ENAME from employee;
    spool offSecond, you can write a PLSQL procedure and then call this procedure from cron job. There is a generic procedure shared by BluShadow some time back which is a very good example for this. Please refer to following link for this solution -
    REF Cursor creating CSV files
    I will suggest to use first method above if possible since it will be faster and less complicated in my opinion. Second method is recommended for scenarios where select statement is created dynamically and cannot be written during development.
    Hope this solves your purpose.
    Cheers,
    Anirudha

  • How to save an excel file as CSV with semi-colon as data separator?

    We are creating a flat data file to load the flat file data to our BW system with Excel.  When we save the file, there are three kinds of CSV types for selecting from the "Save as type" list box:
    CSV (Comma delimited)
    CSV (Macintosh)
    CSV (MS-DOS)
    There is no CSV (semi colon delimited) type.  If we pick CSV (Comma delimted) as the type, then when clicking the "Preview ..." picture icon under the "DataSource/Trans. Structure" tab of the InfoSource for this flat file (with the CSV radio button checked the Data separator default is ";"), the File Upload Preview window shows the data is messed up that some columns of the excel flat file are combined into one column.
    Since the save type we picked is "CSV (Comma delimited)", then we try to change the default Data separator from ";" to "," in the preview selection screen, but still not helpful!
    How to resolve the above problem?
    Thanks

    Hi Kevin,
    This "," is defined in your windows setting. If you want to have ";" as separator then go to control Panel, select Regional Options, go to Numbers Tab and define the List separator as ";". After that when you will save your excel file as CSV(MS-DOS) it will have ";" as separator. This will make sure that the amounts are not broken in to two different fields while loading.
    Else if you keep "," as separator then you can also go into the Excel and define all number fields as Number without thousand separator.
    Let me know if you have any doubts in this.
    Regards,
    Rohit

  • URL Link on downloaded Excel File

    Hi,
    I have got a requirement.
    For study and analysis purpose user download data on excel file from OCOD. Struture(Contents) of downloaded excel file is same as screen.
    But the problem is when user click on 'DETAIL' (which has URL link) he/she is directed to Live OCOD and asked for log in with ID and Password, even if
    user is logged in OCOD.
    What i want to do is.
    1) Download Excel file without any URL link.
    2) If 1) is not possible then do not want to have 'DETAIL' option of downloded file.
    3) Method for avoiding relog into OCOD.
    Thanks in Advance
    Yuj

    Yuj, within the application click on the Training and Support link in the upper right, then click on Add-On Applications, then click on Reports and Analysis for Excel Template. In order to take the webinar click on Browse Training, then click on Training Resources by Job, then click on All Users, then click on Using Mail Merge for Word and Reports and Analysis for Excel with Oracle CRM On Demand.

  • In SAP Webdynpro using ABAP,how to colour the downloaded excel file?

    Hi all Experts'
    I have downloaded the data from the webdynpro application into an excel file in the presentation server using a custom button in a layout of a view in the webdynpro component.
    Now the requirement is to colour the column heading names and the downloaded excel file should show the full column length.
    Could anybody help me on this how to do this two things.
    Thanks in advance.

    Hi,
    You can use this function GUI_EXEC.
    Let say you want to use winzip to zip the file then what you should do like this:
    use this command --> ' -min -a D:\WALCOTT.ZIP D:\MBARANG.TXT'
    D:\MBARANG.TXT --> path to the file you want to Zip
    D:\WALCOTT.ZIP --> result zip file
    The command above is depends on the software you use to zip.
    then
      DATA: cmdguiexec(150).
      cmdguiexec = cmd.
      CALL FUNCTION 'GUI_EXEC'
        EXPORTING
          command          = cmdguiexec.
    Hope this help you.
    Best Regards,
    Victor.

  • Download Excel file from  from a second server

    Hi,
    In our Java based web application (jsp pages) users need to download Excel files stored on a different server (business tier) than the first application server server that hosts only the presentation tier.
    For security reasons users don't access the second application server. From a technical point of view what's the best solution to answer this requirement ? The logic should be the following: the user clicks on a report name that is displayed on this browser, the request is sent to the first application server that will retrieve the report stored on a second server and will return it to the user.
    Thanks a lot.

    it's been a while since i've done ejb stuff, but i believe you can configure an ejb to "runas" a different user. so, you would configure an ejb on the accessible server to "runas" a user who has access to the secondary server.

  • Saving the output of a .sql file in .csv format

    Hi,
    I am saving the output of a .sql file in .csv format. But the problem is , the record of few columns have "new line" character in it, so when it is getting saved in .csv format, those records are coming in multiple rows, but they should come in one single row in single block. Please advise how to overcome this problem.
    Regards,
    Niraj

    Hi Guys,
    I guess, there is a misunderstanding.
    He is talking about the issue caused as a result of the data containing a "CRLF" ( Carriage return Line feed ) .
    That is mainly a data issue.
    The query i presume, must be right.
    I guess you should be able to fix it using some string functions.
    Some thing similar to this
    CREATE TABLE ASH (NAME VARCHAR2(10))
    SELECT REPLACE(NAME, CHR(13)||CHR(10), 'ISH') FROM ASH;
    SELECT REPLACE(NAME, CHR(10), 'ISH') FROM ASH;
    SELECT REPLACE(NAME, CHR(13), 'ISH') FROM ASH;
    depending on the type of new line whether it is CR or LF. or CRLF.
    Regards
    Ashish/-

Maybe you are looking for