Download internal table as text file with comma separation

hi all
I wanted text file separated by comma. I used the CSV function module, but the result is separeted by semicolon,instead i need comma.
Kindly suggest some solution.
Thanks
Subha

use this fm to convert to csv file
CALL FUNCTION 'SAP_CONVERT_TO_TEX_FORMAT'
    EXPORTING
      I_FIELD_SEPERATOR    = ','
    TABLES
      I_TAB_SAP_DATA       = ITAB_FINAL
    CHANGING
      I_TAB_CONVERTED_DATA = ITAB_OUTPUT
    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.
itab_output is of type ITAB_OUTPUT TYPE TRUXS_T_TEXT_DATA,
and then download using gui_download
CALL FUNCTION 'GUI_DOWNLOAD'
      EXPORTING
        FILENAME                = W_FILENAME
        FILETYPE                = 'ASC'
      TABLES
        DATA_TAB                = ITAB_OUTPUT
      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.

Similar Messages

  • Upload data from Internal table to text file with  '~' separator

    can anyone help me to download data from internal table to flat file with  ''  separator. GUI_DOWNLOAD is not working in my case ....like for ''  separator

    Here it is
    REPORT  zkb_test1.
    TYPE-POOLS: truxs.
    DATA: i_scarr TYPE TABLE OF scarr,
    i_conv_data TYPE truxs_t_text_data.
    SELECT * FROM scarr INTO TABLE i_scarr.
    CALL FUNCTION 'SAP_CONVERT_TO_TEX_FORMAT'
      EXPORTING
        i_field_seperator    = '~'
      TABLES
        i_tab_sap_data       = i_scarr
      CHANGING
        i_tab_converted_data = i_conv_data
      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 METHOD cl_gui_frontend_services=>gui_download
      EXPORTING
        filename                = 'C:\Test1.txt'
        filetype                = 'ASC'
      CHANGING
        data_tab                = i_conv_data
      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
        not_supported_by_gui    = 22
        error_no_gui            = 23
        OTHERS                  = 24.
    IF sy-subrc <> 0.
      MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
                 WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
    ENDIF.
    Regards
    Kathirvel

  • Download int table into csv file with each column in separate column in csv

    Hi All,
    I want to download the data in internal table to CSV file. but each column in the table should come as separate column in csv format.
      CALL FUNCTION 'GUI_DOWNLOAD'
        EXPORTING
          FILENAME                = GD_FILE
          FILETYPE                = 'ASC'
          WRITE_FIELD_SEPARATOR   = 'X'
        tables
          DATA_TAB                = I_LINES_NEW
        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 0.
        WRITE: 'Error ', SY-SUBRC, 'returned from GUI_DOWNLOAD SAP OUTBOUND'.
        SKIP.
      ENDIF.
    with the above values passd , I am getting csv file but all the columns in one column separated by some square symbol.
    How to separate them into different columns.
    Thanks in advance
    rgds,
    Madhuri

    Below example might help you understand on dowloading CSV file:
    TYPE-POOLS: truxs.
    DATA: i_t001 TYPE STANDARD TABLE OF t001,
          i_data TYPE truxs_t_text_data.
    SELECT * FROM t001 INTO TABLE i_t001 UP TO 20 ROWS.
    CALL FUNCTION 'SAP_CONVERT_TO_TEX_FORMAT'
      EXPORTING
        i_field_seperator          = ','
    *   I_LINE_HEADER              =
    *   I_FILENAME                 =
    *   I_APPL_KEEP                = ' '
      TABLES
        i_tab_sap_data             = i_t001
    CHANGING
       i_tab_converted_data       = i_data
    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.
    DATA: file TYPE string VALUE 'C:\testing.csv'.
    CALL METHOD cl_gui_frontend_services=>gui_download
      EXPORTING
        filename                = file
      CHANGING
        data_tab                = i_data[]
      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
        not_supported_by_gui    = 22
        error_no_gui            = 23
        OTHERS                  = 24.
    IF sy-subrc <> 0.
      MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
                 WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
    ENDIF.
    Regards
    Eswar

  • Downloading into a text file with comma seperation

    hey experts,
    well i want to download various fields of an internal table into a text file.but the hitch is that all the columns should be seperated by a comma.something like csv.
    could you please help me with this.?
    i have tried using gui download but the seperator field was not working.
    thanks in advance...
    regards,
    sandra.

    hey sandra,
    for comma seperation and downloading ,you can use the following fm.
    here the i_field seperator should be given as "," as in ur case.
    i_tab3 is the table from which the values are being fetched.
    and i_tab2 is the table conatining the comma seperated values.
    CALL FUNCTION 'SAP_CONVERT_TO_TEX_FORMAT'
       EXPORTING
         I_FIELD_SEPERATOR          = ','
      I_LINE_HEADER              =
      I_FILENAME                 =
      I_APPL_KEEP                = ' '
       TABLES
         I_TAB_SAP_DATA             = I_TAB3
       CHANGING
        I_TAB_CONVERTED_DATA       = I_TAB2
    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.
    after this u can use the gui download fm as required.
    CALL FUNCTION 'GUI_DOWNLOAD'
    EXPORTING
      BIN_FILESIZE                    =
        FILENAME                        = TESTFILNA
      FILETYPE                        = 'ASC'
      APPEND                          = ' '
        WRITE_FIELD_SEPARATOR           = 'x'
      HEADER                          = '123'
      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
    IMPORTING
      FILELENGTH                      =
    TABLES
          DATA_TAB                      = I_TAB2
      FIELDNAMES                      =
    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.
    hope this helps u.
    do reward points if useful.....:-)

  • How to Convert an internal table into Text File

    Hello friends,
    Can you help me to find out the way to convert an internal table data into a flat file.
    the problem is that my internal table contains fields with data type INT also.

    please  go through the code and the parameter passed to the  finction module  ... since  you didn't show your coding  i am giving you the sample code  also ..
    REPORT y_ss_test_ekko .
    * To hold selection data
    DATA: i_ekko TYPE STANDARD TABLE OF ekko.
    * To hold converted text data
    DATA: i_text(4096) TYPE c OCCURS 0.
    * Selection Screen
    PARAMETERS: p_ebeln LIKE ekko-ebeln.
    * Select data into an ITAB based on the selection Criteria
    SELECT * FROM  ekko
             INTO  TABLE i_ekko
             WHERE ebeln = p_ebeln.
    * Process further only if found some data
    IF NOT i_ekko[] IS INITIAL.
    * Convert data in internal table to a delimited text data
      CALL FUNCTION 'SAP_CONVERT_TO_TEX_FORMAT'
           EXPORTING
                i_field_seperator    = '|'
           TABLES
                i_tab_sap_data       = i_ekko
           CHANGING
                i_tab_converted_data = i_text
           EXCEPTIONS
                conversion_failed    = 1
                OTHERS               = 2.
      IF sy-subrc <> 0.
        WRITE: / 'Program failed to Convert data.'.
      ELSE.
    *   Download convert data to Presentation Server
        CALL FUNCTION 'DOWNLOAD'
             TABLES
                  data_tab = i_text
             EXCEPTIONS
                  OTHERS   = 8.
        IF sy-subrc <> 0.
          WRITE: / 'Program failed to download data.'.
        ENDIF.
      ENDIF.
    ENDIF.
    reward  points  if it is  usefull   ....
    Girish

  • Downloading internal table in excel file on application server

    Hi,
        I am trying to download ITAB into excel file on my application server . I am using FM 'SAP_CONVERT_TO_XLS_FORMAT' for that .
        When I run the report I can see file getting generated on APP server but no ITAB data is saved in that excel.
        After debugging I found that error code  'SAVE_DOCUMENT_FAILED'  is retuned in above FM.
        Could any one please suggest how to go about this?
    Regards,
    Ganesh

    Hi ganesh,
    Please have a look into the below link
    [Link1|How to Upload Excel file to Application Server]
    [Link2|Error in Downloading the Text file on Application Server]
    Hope this will be Helpful
    Thanks
    Kalyan

  • Uploading file with comma separator

    Hi firends,
    I have a text file in the format below.
    "abc","dedffrt","asd"
    The value of field is enclosed in double quotes and each values are separated by comma.
    I have tried with the function modules available for upload but of no use.
    Im aware of the methods uploading and splitting ...
    But i want to know is there any other function modules available to upload the file of this type.
    Keshav

    Hi KSD,
    Try this way.
    REPORT ztest_notepad.
    DATA: BEGIN OF it_t001 OCCURS 0,
            bukrs TYPE t001-bukrs,
            butxt TYPE t001-butxt,
          END OF it_t001.
    DATA: BEGIN OF it_file OCCURS 0,
            data TYPE char255,
          END OF it_file.
    START-OF-SELECTION.
      CALL FUNCTION 'GUI_UPLOAD'
        EXPORTING
          filename = 'C:\hor_file.txt'
          filetype = 'ASC'
        TABLES
          data_tab = it_file.
      REPLACE ALL OCCURRENCES OF '"' IN TABLE it_file WITH space.
      LOOP AT it_file.
        SPLIT it_file-data AT ',' INTO it_t001-bukrs it_t001-butxt.
        APPEND it_t001.
        CLEAR it_t001.
      ENDLOOP.
      LOOP AT it_t001.
        WRITE:/ it_t001-bukrs, it_t001-butxt.
      ENDLOOP.
    <li>Text file
    "CGH","CGH Hospital"
    "KKH","KKH hospital"
    "SGH","SGH Hospital"
    Thanks
    Venkat.O

  • Download internal table to excel with header

    Hi All,
    I have a requirement to download internal table contents to excel with field headings. I tried searching in forums before posting but didn't got much help.
    I have used GUI_DOWNLOAD, WS_DOWNLOAD and EXCEL_OLE_STANDARD_DAT.
    But unable to download the header in excel..along with data...
    EXCEL_OLE_STANDARD_DAT is getting field header in excel but not downloading automatically , need to save manually which is not the requirement.
    The data is huge with around 151 columns....I got 2 internal tables.
    One for the data and the other with field names.
    Many Thanks,
    Ravi K

    Hi Ravi,
    You need to have 2 different internal tables for achieving the needful. One internal table would be having your data and another would store your table field names i.e., declare a structure of length 100 characters,
    TYPES : BEGIN OF GTY_FIELDNAMES,
                    TITLE(100),
                  END   OF GTY_FIELDNAMES.
    DATA: GIT_FIELDNAMES TYPE STANDARD TABLE OF GTY_FIELDNAMES,
                GWA_FIELDNAMES TYPE GTY_FIELDNAMES.
    DATA : GD_FILENAME TYPE STRING,
                GD_PATH     TYPE STRING,
                GD_FULLPATH TYPE STRING,
                GD_RESULT   TYPE I.
    Now have a subroutine where by you append your headings into the internal table i.e.,GIT_FIELDNAMES
       CLEAR GWA_FIELDNAMES.
       GWA_FIELDNAMES-TITLE = 'Material Number'.
       APPEND GWA_FIELDNAMES TO GIT_FIELDNAMES.
       CLEAR GWA_FIELDNAMES.
       GWA_FIELDNAMES-TITLE = 'Material Description'.
       APPEND GWA_FIELDNAMES TO GIT_FIELDNAMES.
    Once you are done with it you can call up the save dialog
    * Display save dialog window
       CALL METHOD CL_GUI_FRONTEND_SERVICES=>FILE_SAVE_DIALOG
         EXPORTING
           WINDOW_TITLE           = 'Save File As...'
           DEFAULT_EXTENSION  = 'XLS'
           DEFAULT_FILE_NAME  = 'SalesPlan'
           INITIAL_DIRECTORY      = 'C:\'
         CHANGING
           FILENAME                      = GD_FILENAME
           PATH                               = GD_PATH
           FULLPATH                      = GD_FULLPATH
           USER_ACTION               = GD_RESULT.
    * Check user did not cancel request
       CHECK GD_RESULT EQ '0'.
       CALL FUNCTION 'GUI_DOWNLOAD'
         EXPORTING
           FILENAME              = GD_FULLPATH
           FILETYPE                = 'ASC'
    *     APPEND                = 'X'
           WRITE_FIELD_SEPARATOR = 'X'
    *     CONFIRM_OVERWRITE     = 'X'
         TABLES
           DATA_TAB                 = GIT_FINAL                  " Internal table having data
           FIELDNAMES            = GIT_FIELDNAMES     " Internal table having headings
         EXCEPTIONS
           FILE_OPEN_ERROR       = 1                         "#EC ARGCHECKED
           FILE_WRITE_ERROR      = 2
           OTHERS                           = 3.
    Hope this gets sorted your problem.
    Thanks & Regards,
    Varun Kumar Sahu

  • Downloading internal table.

    hi all,
    i need to down load an internal table to text file.
    i used fm upload ok its working fine.
    my text file is like this
    (line)
                                            abc company
    (line) 
                                      the following are the details
    here internal table data will come.
    i can display the internal table output in file,but i need code how to display that
    line,abc company ,the following are the details in text file.
    can any body provide some sample code for this.
    thanks in advance
    siva

    thanks for ur response.
    i will down load the data to text file from internal table using function module gui down load
    in text file on the top of it i need text like this
                              abc company
    itab-f1        itab-f2      itab-f3      itab-f4       itab-f5
    i want the text abc company on the top of my text file ,i can down load itab-f1,f2,f3 into text file,i am able to do that.how can i down load the text abc company to text file.
    thanks in advance
    siva

  • Error while downloading data from internal table into XML file

    hi all,
    i developed a program to download data from into internal table to xml file like this.
    tables: mara.
    parameters: p_matnr like mara-matnr.
    data: begin of itab_mara occurs 0,
                matnr like mara-matnr,
                ernam like mara-ernam,
                aenam like mara-aenam,
                vpsta like mara-vpsta,
          end of itab_mara.
    data: lv_field_seperator type c,     " value 'X',
          lv_xml_doc_name(30) type c,    " string value ‘my xml file’,
          lv_result type i.
          lv_field_seperator = 'x'.
          lv_xml_doc_name = 'my xml file'.
    types: begin of truxs_xml_line,
              data(256) type x,
          end of truxs_xml_line.
    types:truxs_xml_table type table of truxs_xml_line.
    data:lv_tab_converted_data type truxs_xml_line,
         lt_tab_converted_data type truxs_xml_table.
    data: lv_xml_file type rlgrap-filename value 'c:\simp.xml'.
    select matnr ernam aenam vpsta from mara into table itab_mara up to 5
           rows where matnr = p_matnr.
    CALL FUNCTION 'SAP_CONVERT_TO_XML_FORMAT'
    EXPORTING
       I_FIELD_SEPERATOR          = lv_field_seperator
      I_LINE_HEADER              =
      I_FILENAME                 =
      I_APPL_KEEP                = ' '
       I_XML_DOC_NAME             = lv_xml_doc_name
    IMPORTING
       PE_BIN_FILESIZE            = lv_result
      TABLES
        I_TAB_SAP_DATA             = itab_mara
    CHANGING
       I_TAB_CONVERTED_DATA       = lt_tab_converted_data
    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.
    open dataset lv_xml_file for output in binary mode.
    loop at lt_tab_converted_data into lv_tab_converted_data.
    transfer lv_tab_converted_data to lv_xml_file.
    endloop.
    close dataset lv_xml_file.
    this program is syntactically correct and getting executed, but when i open the target xml file it is showing the following error.
    The XML page cannot be displayed
    Cannot view XML input using style sheet. Please correct the error and then click the Refresh button, or try again later.
    XML document must have a top level element. Error processing resource 'file:///C:/simp.xml'.
    will anyone show me the possible solution to rectify this error
    thanks and regards,
    anil.

    Hi,
    Here is a small sample program to convert data in an internal table into XML format and display it.
    DATA: itab  TYPE TABLE OF spfli,
          l_xml TYPE REF TO cl_xml_document.
    * Read data into a ITAB
    SELECT * FROM spfli INTO TABLE itab.
    * Create the XML Object
    CREATE OBJECT l_xml.
    * Convert data in ITAB to XML
    CALL METHOD l_xml->create_with_data( name = 'Test1'
                                         dataobject = t_goal[] ).
    * Display XML Document
    CALL METHOD l_xml->display.
    Here are some other sample SAP programs to handle XML in ABAP:
    BCCIIXMLT1, BCCIIXMLT2, and BCCIIXMLT3.
    Hope this helps,
    Sumant.

  • Downloading data from internal table to xls file leading zeros are not disp

    Hai abap gurus,
    when i am downloading data from internal table to excle file. some field values in a column are with leading zeros and some others dont have leading zeros.but in the output it is showing without leading zeros. then how to get with exact values.
    Ex:
    <b>ECC Code.</b>
    045234
      88567
    098456 
    but output is giving like this:
    45234
    88567
    98456
    how to get the actual values.....
    plz help me in this matter.

    Dear Kiran,
    Those field in the internal table having Leading Zeroes, make those fields' datatype as character.
    Then use the function module to download the content of the internal table to the excel file.
    Regards,
    Abir
    Don't forget to Reward Points  *

  • Download data from internal table to flat file.

    I need to download the data from Internal table to Flat file. can any one suggest how to do it? i suppose WS_Download OR GUI_DOWNLOAD.
    but if it is please guide me how to use this.
    is thre any other F.M. please provide the information.
    Thanks in advance

    Hi,
    Try this,
    * File download, uses older techniques but achieves a perfectly
    * acceptable solution which also allows the user to append data to
    * an existing file.
      PARAMETERS: p_file like rlgrap-filename.
    * Internal table to store export data  
      DATA: begin of it_excelfile occurs 0,
       row(500) type c,
       end of it_excelfile.
      DATA: rc TYPE sy-ucomm,
            ld_answer TYPE c.
      CALL FUNCTION 'WS_QUERY'
           EXPORTING
                query    = 'FE'  "File Exist?
                filename = p_file
           IMPORTING
                return   = rc.
      IF rc NE 0.                       "If File alread exists
        CALL FUNCTION 'POPUP_TO_CONFIRM'
          EXPORTING
    *          TITLEBAR              = ' '
    *          DIAGNOSE_OBJECT       = ' '
               text_question         = 'File Already exists!!'
               text_button_1         = 'Replace'
    *          ICON_BUTTON_1         = ' '
               text_button_2         = 'New name'
    *          ICON_BUTTON_2         = ' '
    *          DEFAULT_BUTTON        = '1'
    *          DISPLAY_CANCEL_BUTTON = 'X'
    *          USERDEFINED_F1_HELP   = ' '
    *          START_COLUMN          = 25
    *          START_ROW             = 6
    *          POPUP_TYPE            =
          IMPORTING
               answer                = ld_answer
    *     TABLES
    *         PARAMETER              =
          EXCEPTIONS
              text_not_found         = 1
              OTHERS                 = 2.
    * Option 1: Overwrite
        IF ld_answer EQ '1'.
          CALL FUNCTION 'GUI_DOWNLOAD'
            EXPORTING
    *            BIN_FILESIZE            =
                 filename                = p_file        "File Name
                 filetype                = 'ASC'
    *       IMPORTING
    *            FILELENGTH              =
            TABLES
                data_tab                = it_excelfile   "Data table
            EXCEPTIONS
                file_write_error        = 1
                no_batch                = 2
                gui_refuse_filetransfer = 3
                invalid_type            = 4
                OTHERS                  = 5.
          IF sy-subrc <> 0.
            MESSAGE i003(zp) WITH
                     'There was an error during Excel file creation'(200).
            exit. "Causes short dump if removed and excel document was open 
          ENDIF.
    * Option 2: New name.
        ELSEIF ld_answer EQ '2'.
          CALL FUNCTION 'DOWNLOAD'
            EXPORTING
                 filename            = p_file          "File name
                 filetype            = 'ASC'           "File type
    *             col_select          = 'X'            "COL_SELECT
    *             col_selectmask      = 'XXXXXXXXXXXXXXXXXXXXXXXXXX'
    *                                                   "COL_SELECTMASK
                 filetype_no_show    = 'X'     "Show file type selection?
    *       IMPORTING
    *             act_filename        = filename_dat
            TABLES
                 data_tab            = it_excelfile    "Data table
    *            fieldnames          =
            EXCEPTIONS
                 file_open_error     = 01
                 file_write_error    = 02
                 invalid_filesize    = 03
                 invalid_table_width = 04
                 invalid_type        = 05
                 no_batch            = 06
                 unknown_error       = 07.
        ENDIF.
      ELSE.                               "File does not alread exist.
        CALL FUNCTION 'GUI_DOWNLOAD'
          EXPORTING
    *          BIN_FILESIZE            =
               filename                = p_file         "File name
               filetype                = 'ASC'          "File type
    *     IMPORTING
    *          FILELENGTH              =
          TABLES
               data_tab                = it_excelfile   "Data table
          EXCEPTIONS
               file_write_error        = 1
               no_batch                = 2
               gui_refuse_filetransfer = 3
               invalid_type            = 4
               OTHERS                  = 5.
        IF sy-subrc <> 0.
          MESSAGE i003(zp) WITH
                   'There was an error during Excel file creation'(200).
          exit. "Causes short dump if removed and excel document was open 
        ENDIF.
      ENDIF.
    Regards,
    Raghav

  • How to download leading zeros from internal table to XL file

    Hi,
    i am dowanloading data from interna table to XL file using GUI_DOWNLOAD FM. i want download the leading zeros  also into xl file
    EX: 012345
    at present only "12345" is down loading into XL file. But i want "012345" into XL file.
    Please help me.

    Hi,
    Can you try with DBF format(Pass FILETYPE = 'DBF'? I remember that in this format data will be downloaded in database storage format. Just check and update if it works!!!
    This is what FM documentation says.
    'DBF' :
    The data is downloaded in dBase format. With this format, the data types are stored as well, For this reason, import problems can be avoided - for example, problems with Microsoft Excel. In particular, you can avoid problems with the interpretation of numeric values.
    Thanks,
    Vinod.

  • Download Internal table to Excel with different Tabs -  ole2_object

    Hi All,
    I am using  ole2_object to download the data from internal table to Excel file. As per different values in sorting key, data will be downloading in different tab in same Excel file.
    In my internal table one field is of character type and some times contains number as value.
    e.g.  itab-code = ‘000002’.
    While downloading to Excel, Excel consider this value as numeric and remove the leading zero.
    Any suggestions for how to set format property as ‘Text’ for this cell, will highly appreciated.
    Sample  code -
       data: gs_excel type ole2_object,
             gs_wbooklist type ole2_object,
             gs_application type ole2_object,
             gs_wbook type ole2_object,
             gs_activesheet type ole2_object,
             gs_sheets type ole2_object,
             gs_newsheet type ole2_object,
             gs_cell type ole2_object.
       create object gs_excel 'EXCEL.APPLICATION'.
       get property of gs_excel 'workbooks' = gs_wbooklist.
       get property of gs_wbooklist 'Application' = gs_application.
       set property of gs_application 'SheetsInNewWorkbook' = 1.
       call method of gs_wbooklist 'Add' = gs_wbook.
       get property of gs_application 'ActiveSheet' = gs_activesheet.
       set property of gs_activesheet 'Name' = datasheet_name.
      call method of gs_excel 'Cells' = gs_cell exporting #1 = v_row           
                                              #2 = v_col.
      set property of gs_cell 'value' = <f>.
    GET PROPERTY OF gs_cell 'Font' = gs_Font.
    SET PROPERTY OF gs_Font 'Bold' = 1 .
    Thanks.
    Regards,
    Meenakshi.

    Hello,
    Just concatenate ' infont of the fields, which you want to treat as a text.
    Like,
    itab-code = '00002'.
    concatenate '''' itab-code  into itab-code.
    modify itab.
    You can also set the text properties of the cell by,
      SET PROPERTY OF gs_cell 'NumberFormat' = '@' .
    but, it will remove the leading zeros and set the format as text.
    Regards,
    Naimesh

  • How to download internal table data into xml file?

    Hi,
    Experts,
    I have downloaded internal table data into XLS format using GUI_DOWNLOAD Function module, But i didn't Know how to download internal table data into XML format please post some ideas/inputs on this issue.
    Thank you,
    Shabeer ahmed.

    check this
    data : gd_repid type sy-repid.
    GD_REPID = SY-REPID.
    DATA : L_DOM TYPE REF TO IF_IXML_ELEMENT,
           M_DOCUMENT TYPE REF TO IF_IXML_DOCUMENT,
           G_IXML TYPE REF TO IF_IXML,
           W_STRING TYPE XSTRING,
           W_SIZE TYPE I,
           W_RESULT TYPE I,
           W_LINE TYPE STRING,
           IT_XML TYPE DCXMLLINES,
           S_XML LIKE LINE OF IT_XML,
           W_RC LIKE SY-SUBRC.
    DATA: XML TYPE DCXMLLINES.
    DATA: RC TYPE SY-SUBRC,
          BEGIN OF XML_TAB OCCURS 0,
          D LIKE LINE OF XML,
          END OF XML_TAB.
    data : l_element           type ref to if_ixml_element,
           xml_ns_prefix_sf     type string,
           xml_ns_uri_sf        type string.
    CLASS CL_IXML DEFINITION LOAD.
    G_IXML = CL_IXML=>CREATE( ).
    CHECK NOT G_IXML IS INITIAL.
    M_DOCUMENT = G_IXML->CREATE_DOCUMENT( ).
    CHECK NOT M_DOCUMENT IS INITIAL.
    CALL FUNCTION 'SDIXML_DATA_TO_DOM'
    EXPORTING
       NAME = 'REPAIRDATA'
       DATAOBJECT = IT_FINAL_LAST1[]
    IMPORTING
       DATA_AS_DOM = L_DOM
    CHANGING
       DOCUMENT = M_DOCUMENT
    EXCEPTIONS
       ILLEGAL_NAME = 1
       OTHERS = 2.
    CHECK NOT L_DOM IS INITIAL.
    W_RC = M_DOCUMENT->APPEND_CHILD( NEW_CHILD = L_DOM ).
    *Start of code for Header
    * namespace
    t_mnr = sy-datum+4(2).
    CALL FUNCTION 'IDWT_READ_MONTH_TEXT'
      EXPORTING
        LANGU         = 'E'
        MONTH         = t_mnr
    IMPORTING
       T247          = wa_t247
    concatenate sy-datum+6(2)
                wa_t247-ktx
                sy-datum(4) into t_var1.
    concatenate sy-uzeit(2)
                sy-uzeit+2(2)
                sy-uzeit+4(2) into t_var2.
    clear : xml_ns_prefix_sf,
            xml_ns_uri_sf.
    l_element  = m_document->get_root_element( ).
    xml_ns_prefix_sf = 'TIMESTAMP'.
    concatenate t_var1 t_var2 into xml_ns_uri_sf separated by space.
    clear : t_var1,
            t_var2,
            t_mnr,
            wa_t247.
    l_element->set_attribute( name  = xml_ns_prefix_sf
                              namespace = ' '
                              value = xml_ns_uri_sf ).
    clear : xml_ns_prefix_sf,
            xml_ns_uri_sf.
    xml_ns_prefix_sf  = 'FILECREATOR'.
    xml_ns_uri_sf    =   'SAP'.
    l_element->set_attribute( name  = xml_ns_prefix_sf
                              namespace = ' '
                              value = xml_ns_uri_sf ).
    clear : xml_ns_prefix_sf,
            xml_ns_uri_sf.
    xml_ns_prefix_sf  = 'CLAIMGROUP'.
    xml_ns_uri_sf    = '1'.
    l_element->set_attribute( name  = xml_ns_prefix_sf
                              namespace = ' '
                              value = xml_ns_uri_sf ).
    clear : xml_ns_prefix_sf,
            xml_ns_uri_sf.
    xml_ns_prefix_sf  = 'CLAIMTYPES'.
    xml_ns_uri_sf    = 'W'.
    l_element->set_attribute( name  = xml_ns_prefix_sf
                              namespace = ' '
                              value = xml_ns_uri_sf ).
    *End of Code for Header
    CALL FUNCTION 'SDIXML_DOM_TO_XML'
    EXPORTING
      DOCUMENT = M_DOCUMENT
    IMPORTING
      XML_AS_STRING = W_STRING
      SIZE = W_SIZE
    TABLES
      XML_AS_TABLE = IT_XML
    EXCEPTIONS
      NO_DOCUMENT = 1
      OTHERS = 2.
    LOOP AT IT_XML INTO XML_TAB-D.
    APPEND XML_TAB.
    ENDLOOP.
    *Start of Code for File name
    concatenate p_file
                '\R'
                '000_119481'
                sy-datum+6(2) sy-datum+4(2) sy-datum+2(2)
                sy-uzeit(2)   sy-uzeit+2(2) sy-uzeit(2) '.xml' into p_file.
    *End of Code for File name
    CALL FUNCTION 'WS_DOWNLOAD'
    EXPORTING
      BIN_FILESIZE = W_SIZE
      FILENAME = p_file
      FILETYPE = 'BIN'
    TABLES
      DATA_TAB = XML_TAB
    EXCEPTIONS
      OTHERS = 10.
    IF SY-SUBRC  = 0.
                  MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
                  WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    ENDIF.

Maybe you are looking for

  • How to link apple reomote two one dock

    i have three apple remotes that are controlling both of my computers along with 4 universal docks how can i link the remote to just one dock

  • A long left click shows the right click menu

    When I hold down the left mouse button, the right click menu appears. I want to turn off this function, but can't remember which extension controls it or whether the function is built in to Firefox.

  • Syncing shared calendar

    I used to have an iphone 3G and could easily sync my 2010 outlook calendar along with a shared calendar that I would periodically email to my home account from work.  Now I have switched to an iphone 4S with an updated os and it no longer syncs my sh

  • Touch will not sync

    Mt Ipod touch will not sync or show up in Itunes. I talked to teh Support people and it still isn't working.

  • Airport and a wireless network

    I set up a wireless network via an Airport Extreme, then I extended it via a second Airport Extreme.  Now I have two wireless networks, one named  "Network" and the second one named "network 5Ghz"  both are working and both use the same password.   W