Download File In Csv Format

Hi all,
    I want to create a file on the presentation server with csv format. i used gui_download function. The file is created but it is not csv format.
it is urgent please can you help e out in this
I used filetype as 'ASC' then CSV but in vain
GV_ERR_FNAME = '
SAM\ERRORFILE.CSV'
CALL FUNCTION 'GUI_DOWNLOAD'
  EXPORTING
    FILENAME                        = GV_ERR_FNAME
    FILETYPE                        = 'ASC'
    WRITE_FIELD_SEPARATOR           = 'X'
  TABLES
    DATA_TAB                        = GT_ERROR_TAX
THANKX IN ADV

Please check out this sample program.
report zrich_0001.
data: begin of itab occurs 0,
      fld1(10) type c,
      fld2(10) type c,
      fld3(10) type c,
      end of itab.
data: begin of iout occurs 0,
      rec(1000) type c,
      end of iout.
parameters: p_file type localfile default 'C:test.csv'.
data: file type string.
start-of-selection.
* Build the ITAB
  itab-fld1 = 'A'.
  itab-fld2 = 'B'.
  itab-fld3 = 'C'.
  append itab.
  itab-fld1 = 'D'.
  itab-fld2 = 'E'.
  itab-fld3 = 'F'.
  append itab.
  itab-fld1 = 'G'.
  itab-fld2 = 'H'.
  itab-fld3 = 'I'.
  append itab.
* Build the output internal table from ITAB
* Concatenate all fields into IOUT-REC
  loop at itab.
    concatenate itab-fld1 itab-fld2 itab-fld3 into iout-rec
                separated by ','.
    condense iout-rec no-gaps.
    append iout.
  endloop.
* Now Download
  file = p_file.
  call function 'GUI_DOWNLOAD'
       exporting
            filename = file
       tables
            data_tab = iout
       exceptions
            others   = 22.
Regards,
Rich Heilman

Similar Messages

  • 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.

  • 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

  • Is there a way to download data into CSV format?

    Is there a way to download data into CSV format?
    I can't do this using delimiter as ',' because user wants the decimal format in the ','s only.
    Any suggestions?

    go through this link...
    Download CSV file in presentation server through FM GUI_DOWNLOAD
    Re: how to create a CSV file
    type-pools:TRUXS.
    data: begin of itab occurs 0,
          vbeln like vbap-vbeln,
          posnr like vbap-posnr,
          end of itab.
    data:  itab1 type TRUXS_T_TEXT_DATA.
      select vbeln
             posnr
             up to 10 rows
             from vbap
             into table itab.
    CALL FUNCTION 'SAP_CONVERT_TO_CSV_FORMAT'
    EXPORTING
       I_FIELD_SEPERATOR          = ','
      TABLES
        I_TAB_SAP_DATA             = itab
    CHANGING
       I_TAB_CONVERTED_DATA       =  itab1
    EXCEPTIONS
       CONVERSION_FAILED          = 1
       OTHERS                     = 2
    IF SY-SUBRC <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
             WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    ENDIF.
       CALL FUNCTION 'GUI_DOWNLOAD'
        EXPORTING
          filename = 'C:TEMPtest.TXT'
        TABLES
          data_tab = itab1
        EXCEPTIONS
          OTHERS   = 1.

  • Downloading file - MS WORD FORMAT

    hi.
    I am trying to make a download on user request in MS-WORD format. I have already downloaded the file in CSV format successfully. What i want to know is how to arrange data in word file ... i.e there should be some tags, or keywords which will help me to make table in word file, bold specific font, alignment ... and such stuff.
    can you tell me how can i?

    You can try setting the content type.
    Search for the appropriate type and use it.
    - Subramanyam V

  • 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

  • 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

  • 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.

  • 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/-

  • DME output files in CSV format

    Hi,
    Can anybody please let me know whether we can get the DME output files in CSV format using program RFFOJP_L?
    Your help and time will be really appreciate.
    Thanks & Regards,
    Niki Shah
    Edited by: Niki Shah on Aug 5, 2009 10:14 AM

    No it will not work. You need full Photoshop (CS5)

  • Download files in excel format

    Hi,
    Can anyone help me for downloading file in excel format? I have scheduled a job repeated everyday at a particular time, but it dumps a text file, NOT in excel format. My programme is an ALV.
    Code snippet would be verymuch helpfull.
    Thank,
    Thushara.

    Hello Thushara,
    here is a code i am giving you . It will take the data from a database , and download it into the excel format..
    You just can customize this program to download the data from an ALV ....
    Here is the sample code...
    REPORT  ZKUN_FILE4                              .
    TABLES: USR03,DD02L.
    DATA: ZX030L LIKE X030L.
    DATA BEGIN OF ZDFIES OCCURS 0.
         INCLUDE STRUCTURE DFIES.
    DATA END OF ZDFIES.
    DATA: BEGIN OF FLDITAB OCCURS 0,
          FLDNAME(11) TYPE C,
          END OF FLDITAB.
    DATA ITABUSR03 LIKE USR03 OCCURS 0 WITH HEADER LINE.
    DATA TNAME LIKE DD02L-TABNAME.
    SELECT * FROM USR03 INTO TABLE ITABUSR03.
    TNAME = 'USR03'.
    PERFORM GETFIELEDS.
    PERFORM SHOW123.
    FORM GETFIELEDS.
         CALL FUNCTION 'GET_FIELDTAB'
          EXPORTING
              LANGU              = SY-LANGU
              ONLY               = SPACE
              TABNAME            = TNAME
              WITHTEXT           = 'X'
          IMPORTING
              HEADER             = ZX030L
          TABLES
              FIELDTAB           = ZDFIES
          EXCEPTIONS
              INTERNAL_ERROR      = 01
              NO_TEXTS_FOUND      = 02
              TABLE_HAS_NO_FIELDS = 03
              TABLE_NOT_ACTIV     = 04.
         CASE SY-SUBRC.
            WHEN 0.
              LOOP AT ZDFIES.
                   FLDITAB-FLDNAME = ZDFIES-FIELDNAME.
                   APPEND FLDITAB.
              ENDLOOP.
            WHEN OTHERS.
                 MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
                  with  SY-SUBRC.
          ENDCASE.
    ENDFORM.
    FORM SHOW123.
    CALL FUNCTION 'EXCEL_OLE_STANDARD_DAT'
         EXPORTING
              FILE_NAME                 = 'C:\USR03.XLS'
              DATA_SHEET_NAME           = 'USER LIST'
        TABLES
             DATA_TAB                  =  ITABUSR03
             FIELDNAMES                =  FLDITAB
        EXCEPTIONS
             FILE_NOT_EXIST            = 1
             FILENAME_EXPECTED         = 2
             COMMUNICATION_ERROR       = 3
             OLE_OBJECT_METHOD_ERROR   = 4
             OLE_OBJECT_PROPERTY_ERROR = 5
             INVALID_FILENAME          = 6
             INVALID_PIVOT_FIELDS      = 7
             DOWNLOAD_PROBLEM          = 8
             OTHERS                    = 9.
    IF SY-SUBRC <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
             WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    ENDIF.
    ENDFORM.
    Hope this solves your problem.
    Regards,
    Kunal.
    Note : Reward points if found useful.

  • 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

  • Need to download only in .csv format

    hi
    i need to download only in .csv file
    if any one gives the other format file then it must change to.csv onthe selectionscreen itself and then it is to be executed
    i mean the last 3 digits to be changed ' csv'
    urgent
    regards
    sachin

    Hi
    Check this code, maybe is helpful
        clear it_tabla2[].
        call function 'SAP_CONVERT_TO_CSV_FORMAT'
             exporting
                  i_field_seperator    = ';'
             tables
                  i_tab_sap_data       = empleados
             changing
                  i_tab_converted_data = it_tabla2
             exceptions
                  conversion_failed    = 1
                  others               = 2.
        call function 'WS_DOWNLOAD'
             exporting
                  filename                = emplea
    *              filetype                = 'DAT'
    *              mode                    = ' '
                  filetype_no_change      = 'X'
    *              item                    = 'Archivo de Empleados'
             tables
                  data_tab                = it_tabla2[]
             exceptions
                  invalid_filesize        = 1
                  invalid_table_width     = 2
                  invalid_type            = 3
                  no_batch                = 4
                  unknown_error           = 5
                  gui_refuse_filetransfer = 6
                  customer_error          = 7
                  others                  = 8.
    Regards
    Gregory

  • Downloading file in xls format

    Hi All,
    I have a program that downloads data from a server to the local machine in xls format, via a JSP. The data comes from a ResultSet which I read and convert to csv format, but using ";" as the separator (it works..) and "\n" for each new line I require. I then set the response to download the file. Eveything works fine when I run the web application locally, the file downloads and opens in Excel, BUT when I do the same accessing a remote server running on Solaris, I have a problem opening the downloaded xls. Everything works fine until I try to open the file, Excel tells me that it can't read the first record.
    Here's my code:
    String path = servlet.getServletContext().getRealPath("/");
    PrintWriter printWriter = new PrintWriter(new OutputStreamWriter( new FileOutputStream( path+ "upload/excel.csv" )));
    String data;
    String fileName; // a filename set when I read the data
    // read data, put ";" and "\n" where required
    printWriter.println(data);
    printWriter.close();
    response.setContentType("application/binary");
    response.setHeader("Content-Disposition","attachment" + ";fileName=\"" + filName + ".xls" + "\"");
    RequestDispatcher rd = request.getRequestDispatcher("destination.jsp");
    rd.include(request, response);
    It works from Windows to Windows, but something's amiss when I try it from Solaris to Windows.
    Any help is greatly appreciated!!

    Most probably it has to do with line.separator system property which is different between windows and unix.
    I noticed you using a printWriter.
    The println method will use the appropriate line separator for the platform it is running on. (from the System properties)
    I would try saving the file to disk rather than opening, to see if you can discern the differences.
    Also - what does the included jsp do? does it just include the newly created file?
    Do you need that file? Could you just stream it straight out to the user?
    ie instead of sending it to a FileOutputStream, send it to the ServletOutputStream.
    Hope this helps some,
    evnafets

  • Download data into .csv format ( ABAP webDynpro )

    Hi gurus ,
    I am new to WebDynpro .
    My requirement is that i need to download all my datas into csv format . But when i am using the function module
    GUI_DOWNLOAD , an error is coming " Couldnot ascertain code page "
    I have used the F.M  ' SAP_CONVERT_TO_CSV_FORMAT '
    call function 'SAP_CONVERT_TO_CSV_FORMAT'
    exporting
       i_field_seperator          = ';'
      I_LINE_HEADER              =
      I_FILENAME                 = ''
      I_APPL_KEEP                = ' '
      tables
        i_tab_sap_data             = it_fail
    changing
       i_tab_converted_data       = csv_converted_table
    exceptions
       conversion_failed          = 1
       others                     = 2
    when i am using GUI_DOWNLOAD i am getting the above error
    CALL FUNCTION 'GUI_DOWNLOAD'
      EXPORTING
    filename                        = 'C:\test.csv'
      tables
        data_tab                    = csv_converted_table.
      ENDIF.
    suggest me or provide some sample code to download the the csv_converted_table  that i got from the F.M
    'SAP_CONVERT_TO_CSV_FORMAT'  into .csv format to my local drive .
    Thanx Gurus .

    Heyy  Thanks for proving a new concept ..
    actually i was using the following code .
    DATA : lv_filename TYPE rlgrap-filename,
      lv_timestamp(55) TYPE c,
       lt_csv TYPE truxs_t_text_data,
      ls_csv TYPE LINE OF truxs_t_text_data,
      p_path TYPE string VALUE 'D:\Result'.
    Constants : lc_ex TYPE char4 VALUE '.csv'.
    CONCATENATE p_path lc_ex INTO lv_timestamp.
    lv_filename = lv_timestamp.
    CALL FUNCTION 'SAP_CONVERT_TO_TEX_FORMAT'
    EXPORTING
    i_field_seperator = ','
    i_filename = lv_filename
    TABLES
    i_tab_sap_data = it_fail       
    CHANGING
    i_tab_converted_data = lt_csv
    **-------Place the file in the required directory.
    OPEN DATASET lv_filename FOR OUTPUT IN TEXT MODE ENCODING DEFAULT.
    LOOP AT lt_csv INTO ls_csv.
    TRANSFER ls_csv TO lv_filename.
    ENDLOOP.
    But i m getting the following error  
    File "D:\Result.csv" is not open.
    Can u please tell me what needs to be done ...??
    Thanks

Maybe you are looking for

  • Urgent: Regarding Runtime Error in FM

    hi, i had made a Function Module which will reterive the production order,but when i use it in the program it gives runtime error.Plzz help me how to solve this problem. 1st i am pasting the code which i had written:- FUNCTION ZFIND_PRDORD. ""Local I

  • Sales Order Block Report

    Hello Experts, Is ther any report wher i can get the information of all the Sales Order Header block data or item block. Its not the credit block ...i want only the order which are block due to reason of rejection. Suggest. Thanks Shri..

  • Focal length in Metadata panel

    I notice that in the metadata (Info) panel one can see the focal length used and below that, a blank field for the 35mm focal length.  Is there any way to get Aperture to fill in that empty field with the 35mm equivalent to the lens's actual focal le

  • How do you connect a 1.33 Gz Powerbook G4 12" to the iMac 17" Intel

    I recently got one of the new Apple iMac 17" Interl Core Duo. It is a very nice computer. I also have a 1.33 Gz Apple Powerbook G4 12" laptop. They both have OSX Tiger (10.4.5). I was wondering how I could display my Powerbook screen to my new iMac?

  • BT Vision Account and Billing

    If you need help with a BT Vision account or bill we have lots of billing information available online.  This covers topics such as billing details, payment options and updating your details. Retired BTCare Community Manager - StephanieG and SeanD ar