Internal Table data to Excel Sheet

Hi All,
I have an internal table have some data , which I have to populate and save  excel sheet on presentation server and application server both according to options, with column heading and header text through program.
could any one help me how to do it, if possible a sample code.
thanks
bobby

HI bobby,
Transferring Data from ABAP Internal Table to Excel Sheet
If you wish to transfer data from ABAP internal table to EXCEL you can use the following function module.
MS_EXCEL_OLE_STANDARD_DAT
This function module populates an existing excel sheet with the data from the ABAP internal table. Please find below code which shows hwo to declare and populate the import and important parameters. In the next section we will see in depth how this function module operates.
REPORT ZEX_DATATOEXCEL .
Parameters: P_file like RLGRAP-FILENAME.
data : begin of int_head occurs 0,
Filed1(20) type c,                     " Header Data
end of int_head.
data : begin of int_data occurs 0,
Field1(20) type c,                     " Data
Field2(20) type c,
Field3(20) type c,
Field4(20) type c,
end of int_data.
int_head-Filed1 = 'Sales Ord'.
APPEND int_head.
CLEAR  int_head.
int_head-Filed1 = 'Sold-to-Party'.
APPEND int_head.
CLEAR  int_head.
int_head-Filed1 = 'Purchase Ord'.
APPEND int_head.
CLEAR  int_head.
int_head-Filed1 = 'Ship-to-Party'.
APPEND int_head.
CLEAR  int_head.
int_data-field1 = '1JOHN'.
int_data-field2 = '2TOM'.
int_data-field3 = '3BRAD'.
int_data-field4 = '4PETER'.
Append int_data.
Clear int_data.
CALL FUNCTION 'MS_EXCEL_OLE_STANDARD_DAT'
EXPORTING
file_name = p_file " path offile where u need to download
CREATE_PIVOT = 0
DATA_SHEET_NAME = ' '
PIVOT_SHEET_NAME = ' '
PASSWORD = ' '
PASSWORD_OPTION = 0
TABLES
PIVOT_FIELD_TAB =
data_tab = int_data "internal table with data
fieldnames = int_head "internal table with header
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.
thanks
karthik

Similar Messages

  • Download internal table data into excel sheet with column heading and data

    Hi,
      I am having one internal table with column headings and other table with data.
    i want to download the data with these tables into an excel sheet.
    It should ask the user for file name to save it on their own name. They should give the file name in runtime and it should be downloaded into an excel sheet.
    Can anyone tell what is the right function module for downloading these two internal table data with column heading and data.
    what we have to do for storing the file name in runtime.
    Can anyone help me on this.
    Thanks,
    Rose.

    Hi Camila,
        Try this
    CALL FUNCTION 'GUI_DOWNLOAD'
      EXPORTING
        FILENAME                        = PATH2
       FILETYPE                        = 'XLS'
      TABLES
        DATA_TAB                        = IT_DATA
       FIELDNAMES                      = IT_HEADINGS
    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

  • Download internal table data to Excel in background

    Hi all ,
      Can anyone tell that how i can download internal table data
    into Excel sheet  in Backgroud Mode .
    I used both fun mod  ws and gui download but these are not working in background mod .
    Please help  issue is urgent .
    Answer is rewarded  by point .
    With Regards ,
    Nilesh Jain

    hi,
    you have to use  function module 'SAP_CONVERT_TO_XLS_FORMAT'.
    DATA:
    ITAB1 TYPE TRUXS_T_TEXT_DATA.
    CALL FUNCTION 'SAP_CONVERT_TO_XLS_FORMAT'
    EXPORTING
      I_FIELD_SEPERATOR          = ';'
      I_LINE_HEADER              =
       i_filename                 = filename
      I_APPL_KEEP                = ' '
    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.
    try this one.
    reward points if useful,
    thanks & regards,
    rajee.

  • Download internal table data in excel format

    Hi ,
      i have a requirement where i need to download the internal table data in excel format .. I tried using the FM SAP_CONVERT_TO_XLS_FORMAT  but this downloads to excel sheet  same as .txt file foemat without columns ...   i need to have the data in excel sheet with column heading and separated by each coulmn which should be similar as a general sheet with column names and the respective data in the columns . Appreciate any inputs .
    Thanks,
    Latha.

    Hi,
    you can this in Debugging mode,
    say,once you got entire data into ITAB
    salect the TABLE option and provide the table name
    now on the top most you can see excel icon,you click
    on that,now system will prompts you for to the file to be saved.
    Regards,
    Vijaya.

  • How to move large number of internal table data to excel by program

    Hi,
    Iam working on a classical report wherein my requirement is:
    Have around 25 internal tables which I am displaying using a selection screen.I need to transfer this all internal tables data to Excel file by executing.
    Now, let me know how can I transfer all those to excel by execution.
    P.S.: GUI_DOWNLOAD or any other excel download related FMs are used to transfer for single/fewer internal tables.
    But here I need to download 25 internal tables data through program.
    How can I meet the requirement..?
    Kindly advice.
    Thanks,
    Shiv.

    Hi,
    Refer to the following code:
    *& Report  ZDOWNLOAD_PROGRAM
    report  zdownload_program.
    parameter : p_path type rlgrap-filename default 'C:\Pdata.xls'.
    data : gt_output   type standard table of trdirt,
           wa_output   type trdirt,
           p_filen     type string.
    at selection-screen on value-request for p_path.
      clear p_path.
      call function 'F4_FILENAME'
        importing
          file_name = p_path.
    start-of-selection.
      select * from trdirt
               into table gt_output
               where name like 'Z%'
                  or name like 'Y%'.
    end-of-selection.
      move : p_path to p_filen.
      call function 'GUI_DOWNLOAD'
        exporting
      BIN_FILESIZE                    =
          filename                        = p_filen
       filetype                        = 'ASC'
      APPEND                          = ' '
       write_field_separator           =
    cl_abap_char_utilities=>horizontal_tab
      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
    IMPORTING
      FILELENGTH                      =
        tables
          data_tab                        = gt_output
      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.
    Regards
    Rajesh Kumar

  • How to convert internal table data into excel format?

    Hi all,
    I want to convert internal table data in excel format and then
    send it as email attachment in workflow.
    Please tell me how do i perform this.
    Regards,
    Arpita.

    Hi Arpita,
    Try this sample code::
    Send mail
    maildata-obj_name = 'TEST'.
    maildata-obj_descr = 'Test Subject'.
    loop at htmllines.
    mailtxt = htmllines.
    append mailtxt.
    endloop.
    mailrec-receiver = 'your receiver mail id'.
    mailrec-rec_type = 'U'.
    append mailrec.
    call function 'SO_NEW_DOCUMENT_SEND_API1'
    exporting
    document_data = maildata
    document_type = 'EXL'
    put_in_outbox = 'X'
    tables
    object_header = mailtxt
    object_content = mailtxt
    receivers = mailrec
    exceptions
    too_many_receivers = 1
    document_not_sent = 2
    document_type_not_exist = 3
    operation_no_authorization = 4
    parameter_error = 5
    x_error = 6
    enqueue_error = 7
    others = 8.
    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 it will help you.
    Regards,
    NIkita

  • Exporting table data to Excel sheet:

    Hi All
    My requirement is need to export table data to Excel sheet: for this
    I was done all, but I'm getting 500 Exception please contact u r system admin msg at run time, also Jxl/Workbook class not found msg but I downloaded Jxl.jar file and its showing in navigator>Lib>jxl.jar. There is no error signals in coding part.
    Thanks
    Polaka

    Hi,
    Copy your jxl.jar and open it with winzip. See if there is Workbook.class file inside it in the folder jxl.
    Try to download jxl.jar from this link
    http://www.java2s.com/Code/Jar/JKL/Downloadjxljar.htm
    and add.
    Best Wishes
    Idhaya R

  • Downloading table data into Excel sheet - Webdynpro Java

    Hi All,
    We have developed a custom webdynpro application that executes an RFC and displays data in Table UI element. We have provided a button to download the data in excel sheet. When data is huge like, total number of rows filled up in the table are around 11,000 & columns are 32, and when user tries to download whole 11000 rows in excel sheet, the timeout occurs after 20 mins due to huge data. But when I apply filtering on the same table data and then try to download some 700 rows out of 11000 into excel, it took me around 3.36 mins.
    If anyone encountered such scenario in past, please guide in this regard to speed-up the download to excel functionality or suggest any other alternative.
    We are using 7.3 Portal and tableUtilities java class for export to excel functionality.
    Thanks,
    Amol.

    hi monica ,
    sorry im not able to understand properly ,
    The server don't restarts automatically when we uploading a huge data, onlly we open the file instead of save the file.
    If we save the file the problem is that when we try to open this, the process can take hours and sometimes excel is blocked
    you mean that after saving the file to your desktop , having huge data you are not able to open the file i.e the excel file. your file gets blocked or consumes more time to open the file ,
    or else when you are prompted for saving or opening , on click of opening  you are facing the problem ?
    let me be clear with your part , here your application deals with uploading the data from webdynpro table to excel sheet and allowing the end user to save or open the file  right .
    Regards
    Govardan Raj S

  • Problem while Exporting Table Data to Excel Sheet

    Hi All,
    Im getting problem while downloading the table data to Excel.
    Steps i was fallowed:
    1)created Context node with four attributs.
    2)created one attribut(resource) type:  com.sap.ide.webdynpro.uielementdefinitions.Resource
    3)Taken one Filedownload UI and Property resource bounded to (resource)
    4)Added required jar file in the library and copied the same jar file in the navigator lib file
    written the necessary coding but showing the below  problem in the Browser
    You must Flush before accessing the resource content
    Please give me any suggestion  on this
    Regards
    Polaka

    Hi
    Check this might help with Brian Fernandes comments.
    Flush?
    Regards
    Arun Jaiswal

  • How to download internal table data to excel in WebUI

    Hi everyone,
    I am trying to download the contents of an internal table to excel in CRM Web UI.
    One way, would be to create a table view and use the export to excel button.
    However, wish to avoid this and directly download using code.
    Also tried converting to xstring and setting data in the response object. However, this works only when I execute the component directly from BSP_WD_CMPWB. In the UI framework however, when I click on custom button(for download), it navigates to a screen where the contents of string are shown directly on browser.
    Is there any other way of doing this?
    Thanks in advance.
    Regards,
    Deepak

    Hi,
    there are two ways to download excel from the webclient using table views. The first is a XML stream that is send to Excel directly. Only works for Excel 2003 and later. The second is the fall back to a .csv.
    I do not know if for the second option a direct connection is established as mentioned in the last post or there is actually a file stream send to the client.
    Anyway the SAP provides the excel download through a seperate webservice. Have a look at CL_CHTMLB_CONFIG_TAB_EXCEL_EXP->IF_HTTP_EXTENSION~HANDLE_REQUEST( ).
    I suppose going the same direction with your excel download will work. This service opens a new download stream with the excel content... Maybe it is even possible to copy it and adjust it to your needs...
    cheers Carsten

  • HOw to convert Oracle Table data to Excel Sheet

    I need to convert Some of fields from my table to Excell sheet. I dont want to use 3rd party tools. Is there any querry to generate Excell sheet????

    There is no direct path to make Excel file from query, instead you may generate a CSV file (comma-separated-values) or TAB separated values file.
    On SQL*Plus
    SQL> set heading off
    SQL> set newpage none
    SQL> set linesize 255 --could be more
    SQL> spool /path/filename.txt
    SQL> select column1||chr(<ascii for Tab>)||column2||...||columnK
    from table
    SQL> spool off
    Hope it helps

  • Possible to export Tuple data along with main table data in Excel sheet?

    Hi Expert,
    Wondering is it possible to export tuple table data from data manager along with main table data?
    Regards,
    Rajeev

    Rajeev,
    I am afraid that functionality of exporting tuples data using data manager is not available at the moment till MDM 7.1 SP08. Lets see if coming versions provides this functionality...
    - Shiv

  • Downloading different internal table data in a single excel with diff tabs.

    Hi gurs,
    I have 4 internal tables  with me i can able to display in 4 different excel sheets using   CALL FUNCTION 'EXCEL_OLE_STANDARD_DAT'
    But my requirement is i want to download 4 internal table in single excel sheets with different tabs. please send the code if u have.
    Thanks and regards.

    Hi,
    If you want to display the content of 4 internal table in different sheets of same workbook then go through below code,
    DATA : EXCEL         TYPE OLE2_OBJECT,
           WORKBOOKS     TYPE OLE2_OBJECT,
           WORKBOOK      TYPE OLE2_OBJECT,
           CELLS         TYPE OLE2_OBJECT,
           SHEET         TYPE OLE2_OBJECT,
           FONT          TYPE OLE2_OBJECT,
           H_COM1        TYPE OLE2_OBJECT,
           F             TYPE RLGRAP-FILENAME,
           FILEP         TYPE DRAW-FILEP,
           G_FILE_DEST   TYPE STRING,
           G_FILE_TEMP   TYPE STRING,
           G_SYSUBRC     TYPE SY-SUBRC,
           G_FILE_SRC    TYPE DRAW-FILEP.
    START THE EXCEL APPLICATION
      CREATE OBJECT excel 'EXCEL.APPLICATION'.
      CALL METHOD OF excel 'WORKBOOKS' = workbooks.
      SET PROPERTY OF excel  'VISIBLE' = 0.
      CALL METHOD OF workbooks 'OPEN' EXPORTING
                #1 = filep.
    For Sheet1
      CALL METHOD OF excel 'Worksheets' = sheet
       EXPORTING #1 = 1.
      CALL METHOD OF sheet 'Activate'.
      FREE  OBJECT sheet.
      CALL METHOD OF excel 'CELLS' = cells
          EXPORTING #1 = 1
                    #2 = 15.
      SET PROPERTY OF cells 'VALUE' = <value>
    CALL METHOD OF cells 'FONT' = font.
    SET PROPERTY OF font 'SIZE' = '20'.
      FREE OBJECT cells.
    For Sheet2
      CALL METHOD OF excel 'Worksheets' = sheet
       EXPORTING #1 = 2.
      CALL METHOD OF sheet 'Activate'.
      FREE  OBJECT sheet.
      CALL METHOD OF excel 'CELLS' = cells
          EXPORTING #1 = 1
                    #2 = 6.
      SET PROPERTY OF cells 'VALUE' = 'XYZ'.
      CALL METHOD OF cells 'FONT' = font.
      SET PROPERTY OF font 'SIZE' = '20'.
      GET PROPERTY OF excel 'ACTIVESHEET' = sheet.
      CALL METHOD OF sheet 'SAVEAS' EXPORTING
                      #1 = <destination file path where you want to store>
                      #2 = 1.
      CALL METHOD OF workbooks 'CLOSE'.
      CALL METHOD OF excel 'QUIT'.
      FREE OBJECT excel.
    Thanks!
    Brunda
    'Reward if useful'.

  • Internal table data 1E2 automatically convert to scientific format

    Dear all,
    I have been searched for solution moths from the forums and tried all possible methods, but still no way to solve my above problem.  I found a way to solve it partially for us, but may be very helpful for others who meet similly case like mine, so I posted here.
    my problem is when I export my internal table data to Excel, the Cell data with 1E2 auto becomes 1.00E02, and 1E8 becomes 1.00E08, we need it to be 1E2 and 1E8 in excel.
    you can recreate my problem by
    1,  input 1E2 into your Microsoft Excel, then Enter, it will auto change into scientific format. which is we do not want.
    2, use any of your SAP system open any table as long as there is a Char (>3) field in that table. add some
    data entry in that field in the form "any amount (<15) of numeric 1 to 9"E"any one or two numeric 1 to 9". such as, 123E2, 1234E12 etc. then save this table's data to local file spread sheet, or use any FM to download it to a Excel file, when you open this
    file by Excel, the cell with above form will display as scientific. but
    if you put three or more numeric after the "E", such as 123E123 it will
    display correctly.
    what I have done:
    I searched in SCN for similar thread:
        Export to Excel 2007 - item number problem
        Exceding the limit of numbers in Excel at target side
        Excel download cell format problem
        Formating as Text in excel through SAP
        Converting of amount field into excel file through GUI DOWNLOAD
        Data downloaded to excel gets converted to exponential format.
        Problem with Excel download   and scientific number
        Re: Issue in displaying numbers in Excel?
        CSV Flat File Data Problem (Number converting to Scientific Notation)
    Tested accordingly, But none of these works in our case. because our
    ultimate receiver of email attachment will be external third party, we cannot ask
    them to change anything in their Excel.
    Search Microsoft help about Excel, http://support.microsoft.com/kb/214233,
    and it says this "Automatic Number Formatting" is a normal behaviour of excel.
    no way to turn it off, the "work-around" way that Microsoft provides is not suitable for our
    case.
    We test CL_iXML recently arrording to weblog http://wiki.sdn.sap.com/wiki/display/Snippets/FormattedExcelasEmailAttachment
    it successful controled the format. so this could be a solution for others whose internal table size is small. but our 2MB internal table bocome 6MB when converted to xml file attachment, which cannot be received by our end user's mail box. too big.
    So please advise your ideas.
    Many thanks in advance!
    Peter Ding
    Thank you very much for your time!

    Hi,
    You can achieve this by describing the spreadsheet in XML with the help of the DOM classes.
    The later releases of Excel can read and save spreadsheets as XML, providing your release supports this you can achieve it.
    Check out the following Wiki
    [Excel - XML|https://www.sdn.sap.com/irj/sdn/wiki?path=/display/abap/exporting%2bdata%2bto%2bexcel%2b-%2bxml%2bto%2bthe%2brescue]
    Regards,
    Darren

  • How to send internal table data through mail from report in foreground

    hi all,
    iam trying  to convert the internal table data into excel format and sending it through mail by runnning the report in foreground.
    mail is going sucessfully with excel format,but iam facing the problem in the excel format of the material column as follows:
    the matrno shows the wrong format -2.63E+11  instead of displaying correct format-263215000000.
    Pls suggest the alternative process for the above mentioned problem.
    Thanks,
    Sivagopal R.

    Hi Siva,
      Try to copy 263215000000 in one of the cells of excel sheet and press enter.It will automatically convert into -2.63E+11 .
      This means the default formatting of the excel sheet makes this happen.If you convert the format of the cell to "NUMBER" then u will get the required result.
      But I doubt whether or not it is possible through ABAP programming.
    Regards,
    Vimal.

Maybe you are looking for

  • I can no longer use my HP Envy 410A printer

    ....with my iPad mini or my Apple laptop. All devices are on the same network. On the 'add printer' section the printer doesnt show up as an available printer to choose. I have noticed that on this recent update my iphone is buggy and crashes, now I

  • Mapping in PSE 5

    I am interested in the mapping feature of 5.0. Can I use PSE 5 to put GPS data into the exif header of the pictures? Is that a manual process, or can it be automated by say correlating timestamps with a GPS log file? Thanks, Dan

  • Errors in DDIC Activation phase during upgrade.

    Hi, Title: Errors in DDIC Activation phase during upgrade. During preprocessing phase (phase ACT_UPG) we got many DDIC activation errors such as: SAPup broke during phase ACT_UPG in module MAIN_SHDRUN / Shadow System Operations: SPDD and Activation.

  • Oracle 10g Enterprise Manager

    I recently upgraded one of my production databases to Oracle 10g from 9i. Everything was working perfectly. Now when I try to launch Enterprise manager I get "Server Error: Can't connect because of networking problems". I tried to stop and start the

  • Not geting IP address

    Hi all, My have connected my PC by DHCP.After 20 minutes I lost the connection.The LAN connection icon shows it connected but my PC gets no ip address.When I restart the PC I again get connected and after 15-20 minutes the same problem happens. Pleas