Downloading xls file

i want to download the .xls file into the application server they give me
this path  :- /USER/REPORTS/MM
i  hv used  "ws_download " function.
but the errot  is that " Error in Downloading the file "
plz this prob argently ?

Hi,
for that you have to use dataset.
  Refer this code.
*-- Concatenate the file path retrived from the  function module
  with additonal directory 'mm/ptpi006/in/' and pass it to a
  variable.
  CONCATENATE lv_fname c_const INTO pv_input_file.
  CONCATENATE lv_fname c_const pv_flext INTO lv_file.
  lv_dsn = lv_file.
*-- Open Dataset
  OPEN DATASET lv_dsn FOR INPUT IN TEXT MODE ENCODING DEFAULT.
  IF sy-subrc NE 0.
File not found
    MESSAGE e503.
  ELSE.
  Read each line from the dataset and append to an internal table.
    DO.
      IF sy-subrc NE 0.
No records found in the file.
        MESSAGE e504.
      ENDIF.
*-- Read dataset and pass it to an internal table.
      READ DATASET lv_dsn INTO lv_line.
      CLEAR wa_eord.
      wa_eord-matnr = lv_line+0(18).
      wa_eord-werks = lv_line+18(4).
      wa_eord-vdatu = lv_line+22(8).
      wa_eord-bdatu = lv_line+30(8).
      wa_eord-lifnr = lv_line+38(10).
      wa_eord-ekorg = lv_line+48(4).
      wa_eord-meins = lv_line+52(3).
      wa_eord-autet = lv_line+55(1).
      wa_eord-feskz = lv_line+56(1).
      IF NOT wa_eord IS INITIAL.
        APPEND wa_eord TO pr_eord.
      ENDIF.
    ENDDO.
*-- Close Dataset .
    CLOSE DATASET lv_dsn.
  ENDIF.
Regards,
Prashant

Similar Messages

  • How to get Header in Downloaded .xls file using  GUI_Download function

    How to get Header in Downloaded .xls file using  GUI_Download function ???
    How to use the the Header parameter available in GUI_Download function .

    HI,
    see this sample code..
    data : Begin of t_header occurs 0,
           name(30) type c,
           end of t_header.
    data : Begin of itab occurs 0,
           fld1 type char10,
           fld2 type char10,
           fld3 type char10,
           end   of itab.
    DATA: v_pass_path TYPE string.
    append itab.
    itab-fld1 = 'Hi'.
    itab-fld2 = 'hello'.
    itab-fld3 = 'welcome'.
    append itab.
    append itab.
    append itab.
    append itab.
    append itab.
    t_header-name = 'Field1'.
    append t_header.
    t_header-name = 'Field2'.
    append t_header.
    t_header-name = 'Field3'.
    append t_header.
      CALL FUNCTION 'GUI_FILE_SAVE_DIALOG'
        EXPORTING
          default_extension     = 'XLS'
        IMPORTING
          fullpath              = v_pass_path.
      CALL FUNCTION 'GUI_DOWNLOAD'
        EXPORTING
          filename                        = v_pass_path
          filetype                        = 'DBF'
        TABLES
          data_tab                        = itab
          FIELDNAMES                      = t_header
    Cheers,
    jose.

  • Download(xls) file fm ABAP using background job

    Hi,
    My request is how to download(xls) file fm ABAP using background job. ( Daily 3 times download )
    Pls advise...

    Hello Rajesh,
    Actually it is not the function module WRITE_DATASET but command OPEN DATASET. Check this link for more info:
    http://help.sap.com/saphelp_nw04/helpdata/en/fc/eb3ca6358411d1829f0000e829fbfe/content.htm
    Also for this please contact your ABAP collegues. It is their job and they should have the expertise.
    Regards.
    Ruchit.

  • Issues to use GUI_LOAD to download xls file

    Hi Guru's, we are using the fm GUI_DOWNLOAD for downloading xls files to the physical system.  We are facing  following issues.
    1. File contains the currency fields. When downloaded the file to desktop or any location  after decimal zero's are not printing in currency field.
    how to get zero's after decimals in the currency fields. Please let us know the solution if any.
    2. If we click the open option under file tab on the opened xls file which is downloaded from SAP then one wizard popup is coming and prompting the user to click the 'FINISH' button.
    Please let me know how to avoid this wizard popup.
    Thanks in advance.
    Regards,
    j.p

    Myself

  • "Unable to read file" error in Excel 2010 when downloading .xls file from IE11

    We have lots of reports that have links for our users to be able to download report results in Excel format. We accomplish this by using the Excel mime type in our .asp pages. Sporadically, we are seeing "Unable to read file" errors in Excel 2010
    after choosing Open from the IE11 save dialog. Choosing Save/Save As and the file will open just fine.
    Also, we can sometimes cause the error to occur more frequently by switching windows during the time when the file is downloading.
    If the file is opened directly from /Temporary Internet Files then it opens just fine.
    Window 7 64-bit
    Thanks in advance!

    Hi,
    I found you replied in a similar thread, did you try the workaround (Reset the IE) that provided there? Did you change a browser to test?
    Then, I suggest we use Process Monitor to do further troubleshooting. Please collect all the actions of IE.exe and Excel.exe, and check the if there are some
    error message/code during you open XLS file from IE 11.
    Hope it's helpful.
    Regards,
    George Zhao
    TechNet Community Support
    It's recommended to download and install
    Configuration Analyzer Tool (OffCAT), which is developed by Microsoft Support teams. Once the tool is installed, you can run it at any time to scan for hundreds of known issues in Office
    programs.

  • Problem downloading .xls file

    Hi All,
    Im getting problem when trying to export a spread sheet. Initially teh filename was hardcoded and so it was working fine in IE. The code then was
    response.setHeader("Content-disposition", "attachment; filename=Details.xls");     
    outStream.write(Results.toString().getBytes());
    outStream.close();
    later the reqmt changed to some new naming conventions for the file and so i modified the code like
    SimpleDateFormat formatter = new SimpleDateFormat ("MM/dd/yyyy HH:mm:ss");
    java.util.Date currentDate = new java.util.Date();
    String dateString = formatter.format(currentDate);
    String fileName = dateString+".xls";
    response.setContentType("application/vnd.ms-excel");
    response.setHeader("Content-disposition", "attachment; filename="+fileName);
    the problem im facing now is the in the pop up for download the file name is my servlet name appended with some unknown string which includes numbers and characters. the file type shown is html.If you click save open then a new html page is been displayed with all the values.
    Please help me with this issue.
    Thanks
    Noufal

    Thank you so much Shanu. Its working now. It was my carelesness or rather my ignorance which caused this prob.
    But Im still having a query, the excel sheet is having a [1] appended to the file name for ex 19-Jun-2006 06-46-05[1] and the client is not happy with that.
    What is the reason for that square bracket and is there any way we can cut that off? your help will be greatly appreciated.
    Thanks
    Noufal

  • Download .XLS-File in Background

    Hallo
    I should download data from an internal table into a real .XLS-file. It should run as a job in background (without upcoming pop-ups). At the end a real .xls-file should be saved on my harddisk and/or on a Windows NT-server.
    Excel and file don't need to be openend during runtime of job.
    I'm trying with FM 'MS_EXCEL_OLE_STANDARD_DAT' , but I have following problems (code of testreport is below):
    1. Doesn't run in the background.
    2. .xls-file stays open, when running in the foreground.
    3. Strange formatted fields in .xls-file.
    I have nearly no knowledges object-oriented development. System is R/3 Release 4.6C.
    Can anybody help me?
    Thanks, Martin.
    Code:
    REPORT yr_0001_test .
    TYPES: BEGIN OF t_excel,
           fld1(20) TYPE c,
           fld2(20) TYPE c,
           fld3(20) TYPE c,
           END OF t_excel.
    DATA: it001 TYPE TABLE OF t001.
    DATA: xt001 TYPE t001.
    DATA: iexcel TYPE TABLE OF t_excel.
    DATA: flditab TYPE TABLE OF t_excel.
    DATA: xexcel TYPE t_excel.
    xexcel-fld1 = 1000.
    xexcel-fld2 = 'testtext1'.
    xexcel-fld3 = 'testplace1'.
    APPEND xexcel TO iexcel.
    xexcel-fld1 = 2000.
    xexcel-fld2 = 'testtext2'.
    xexcel-fld3 = 'testplace2'.
    APPEND xexcel TO iexcel.
    xexcel-fld1 = 'BUKRS'.
    APPEND xexcel TO flditab.
    xexcel-fld1 = 'BUTXT'.
    APPEND xexcel TO flditab.
    xexcel-fld1 = 'ORT'.
    APPEND xexcel TO flditab.
    CALL FUNCTION 'MS_EXCEL_OLE_STANDARD_DAT'
      EXPORTING
        file_name                       = 'C:TEMPSAPWORKDIRTEST'
    *   CREATE_PIVOT                    = 0
        data_sheet_name                 = 'SHEET1'
    *   PIVOT_SHEET_NAME                = ' '
    *   PASSWORD                        = ' '
    *   PASSWORD_OPTION                 = 0
      TABLES
    *   PIVOT_FIELD_TAB                 =
        data_tab                        = iexcel
        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.
    CLEAR: iexcel,flditab.
    REFRESH: iexcel,flditab.

    If you are downloading a true xls file, then you cannot avoid the pop-ups and you will not be able to create it in the background as the EXCEL interface is not available to the backend. Your only option is to download it as tab or comma delimited.
    Imagine it this way, excel is a user driven application that runs on the user's desktop and requires inputs from the user. The current mechanism of creating an excel file from SAP works on the same principle of user interaction. In the background, since there is no user interaction, it will not be possible.

  • Need to Add Field Name to the Downloaded XLS file

    Im using the function SAP_CONVERT_TO_TXT_FORMAT
    and downloading the contents by sending them as attachements in email.
    I need to add field names(column name) to excel fields.
    So that when fields are displayed in excel file they are displayed by their column names..
    How do I do this.? Any ideas.
    Answers will be rewarded with points..

    Hi
    You can manually insert the column names as the first row in your internal table to have them in .xls file as headers.
    Regards,
    Raj

  • Trying to download xls file with IE7 but browser tries to download as htm

    Hi!
    I have got a problem with downloading files using a hyperlink.
    I've got a hyperlink and i did set the url property to: /resources/file.xls
    when using IE7 and clicking Save As... the save as dialog appears and suggests file.htm as the filename and the file typ is shown as: HTML Document
    Firefox works fine, it suggests file.xls and the type as: Microsoft Office Excel 97-2003 Worksheet
    Next i typed in the url of the resource folder: http://localhost:29080/myProject/resources/
    The file was shown as file.xls in the directoy listing, but when i tried to download the file from here, both browsers behaved the same way as before.
    gif-files and others worked fine in both browsers.
    Does anyone have an idea?
    greets,
    Remi

    I'd first try downloading an installer from the Apple website using a different web browser:
    http://www.apple.com/itunes/download/
    If you use Firefox instead of IE for the download (or vice versa), do you get a working installer?

  • Downloading .xls file with multiple rows and Columns

    Hi ALL,
    I need to genarate .xls file with multiple rows and and Columns and sent as an email.Since our customer having Problem with .CSV files need to genarate .XLS file.
    Please do the needful.
    Thanks
    Madhu

    Hi Madhu,
    You might also consider using Excel Spreadsheet XML as the target structure (namespace is urn:schemas-microsoft-com:office:spreadsheet).  When you double-click the resulting xml on a PC it automatically opens with Excel. So, users don't see a difference.  It will open up a lot of options with formatting including creating multiple worksheets if you wanted to.  Best of all you can stick with XML.
    See my response in this thread:
    Re: Convert XML data into XLS 
    Thanks,
    -Russ

  • Weird..  New IMac when downloading XLS files changes the file type to XLT

    On my wife's IMac, when she downloads an excel file (attachment in an email) in the download folder the file name has been changed to XXX.xls.xlt. My desktop Mac does not do this.
    What's happening and what is the fix?
    Thanks for any direction.
    Joe

    You can try "Reset Download Actions": http://kb.mozillazine.org/File_types_and_download_actions
    You can also try to check the application/octet-stream key in the registry and the .zip key.
    HKEY_CLASSES_ROOT\MIME\Database\Content Type\application/octet-stream
    HKEY_CLASSES_ROOT\.zip

  • When I download .xls files they are always damaged I don't have this with Opara Has Anyone a solution ?

    I think this happende sinds Firefox 8.0 and now I use Firefox 10 but still have this problem
    I use windows 7.0

    Blookers,
    if those Web sites are using password validation techniques which are only supported by Internet Explorer, or which aren’t supported in Safari, then that could be one possible explanation. Try using the same browser (not the same executable) on both plaforms, e.g. Firefox or Opera, to see if it’s a browser-related issue or not.

  • Adding header to download local file

    Hi All!
    I am downloading .xls file onto the presentation server with column headings and the values following.Now I want to add a header to the downloaded file above the column headings in BOLD.Is it possible to append header/Title to the downloaded file.Please advise me with example code..
    Regards
    Praneeth

    Hi,
    Try using FM CREATE_XLS_HEADER_FROM_DDIC.
    or try using FM : 'EXCEL_OLE_STANDARD_DAT'
    ex code :
    DATA: BEGIN OF i_tab OCCURS 0,
          anlage(20) TYPE c,
          num(2) TYPE c,
          END OF i_tab.
    DATA: BEGIN OF i_head OCCURS 0,
          field(30) TYPE c,
          END OF i_head.
    i_tab-anlage = '0070002545'.
    i_tab-num   = '1'.
    APPEND i_tab.
    CLEAR i_tab.
    i_tab-anlage = '0070002546'.
    i_tab-num   = '2'.
    APPEND i_tab.
    CLEAR i_tab.
    i_tab-anlage = '0070002547'.
    i_tab-num   = '3'.
    APPEND i_tab.
    CLEAR i_tab.
    i_tab-anlage = '0070002548'.
    i_tab-num   = '4'.
    APPEND i_tab.
    CLEAR i_tab.
    i_head-field = 'Installation'.
    APPEND i_head.
    i_head-field =  'NO'.
    APPEND i_head.
    CLEAR i_head.
    CALL FUNCTION 'EXCEL_OLE_STANDARD_DAT'
      EXPORTING
      file_name  = 'C:\Documents and Settings\vepakom\Desktop\test1.xls'
       create_pivot                    = 0
       data_sheet_name                 = 'MY DATA'
      PIVOT_SHEET_NAME                = ' '
      PASSWORD                        = ' '
      PASSWORD_OPTION                 = 0
    TABLES
       pivot_field_tab                  = dlpivot
       data_tab                         = i_tab
       fieldnames                       = i_head
    EXCEPTIONS
       file_not_exist                  = 1
       filename_expected               = 2
       communication_error             = 3
       ole_object_method_error         = 4
       ole_object_property_error       = 5
       invalid_pivot_fields            = 6
       download_problem                = 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.
    Sharat
    ps : pls reward if helpful

  • Corrupted / overwritten XLS file

    Hi  Friends,
                    I am looking for a solution where in i am using 'GUI_DOWNLOAD' to download data into xls format , its working but when i am looking at the xls output  i am getting corrupted data , in short if u go to Transaction SE37 and test with Function Module by  passing
    1000194015000102 as input for TABLES  (data_tab) and u get (corrupted )output  1000194015000100 - check the downloaded xls file  only.
    check the last digit its '0' not '2'
    can any one please help me in getting it solved .

    Dear Srikanth,
    I'm providing you with the following piece of code ... Its working fine for me ... hopefully it suits your requirement ...
    D A T A D E C L A R A T I O N *
    TYPES: BEGIN OF TY_EXCEL,
    CELL_01(80) TYPE C,
    CELL_02(80) TYPE C,
    CELL_03(80) TYPE C,
    CELL_04(80) TYPE C,
    CELL_05(80) TYPE C,
    CELL_06(80) TYPE C,
    CELL_07(80) TYPE C,
    CELL_08(80) TYPE C,
    CELL_09(80) TYPE C,
    CELL_10(80) TYPE C,
    END OF TY_EXCEL.
    DATA: IT_EXCEL TYPE STANDARD TABLE OF TY_EXCEL,
    WA_EXCEL TYPE TY_EXCEL..
    E V E N T : S T A R T - O F - S E L E C T I O N *
    START-OF-SELECTION.
    Here you populate the Internal Table.
    Display - Top of the Page.
    PERFORM DISPLAY_TOP_OF_PAGE.
    E V E N T : E N D - O F - S E L E C T I O N *
    END-OF-SELECTION.
    SET PF-STATUS 'GUI_STATUS'.
    E V E N T : A T U S E R - C O M M AN D *
    AT USER-COMMAND.
    CASE SY-UCOMM.
    WHEN 'EXPORT'.
    Exporting the report data to Excel.
    PERFORM EXPORT_TO_EXCEL.
    ENDCASE.
    *& Form DISPLAY_TOP_OF_PAGE
    text
    --> p1 text
    <-- p2 text
    FORM DISPLAY_TOP_OF_PAGE .
    SKIP.
    WRITE: /05(128) SY-ULINE,
    /05 SY-VLINE,
    06(127) 'O R I C A'
    CENTERED COLOR 1,
    132 SY-VLINE.
    WRITE: /05(128) SY-ULINE,
    /05 SY-VLINE,
    06(127) 'Shift Asset Depreciation - Period/Year-wise Report.'
    CENTERED COLOR 4 INTENSIFIED OFF,
    132 SY-VLINE.
    WRITE: /05(128) SY-ULINE.
    E X C E L O P E R A T I O N
    CLEAR: IT_EXCEL[],
    WA_EXCEL.
    PERFORM APPEND_BLANK_LINE USING 1.
    WA_EXCEL-cell_02 = ' XYZ Ltd. '.
    APPEND WA_EXCEL TO IT_EXCEL.
    CLEAR: WA_EXCEL.
    WA_EXCEL-cell_02 = 'Shift Asset Depreciation - Period/Year-wise Report.'.
    APPEND WA_EXCEL TO IT_EXCEL.
    PERFORM APPEND_BLANK_LINE USING 1.
    ENDFORM. " DISPLAY_TOP_OF_PAGE
    *& Form APPEND_BLANK_LINE
    text
    -->P_1 text
    FORM APPEND_BLANK_LINE USING P_LINE TYPE I.
    DO P_LINE TIMES.
    CLEAR: WA_EXCEL.
    APPEND WA_EXCEL TO IT_EXCEL.
    enddo.
    ENDFORM.
    *& Form EXPORT_TO_EXCEL
    text
    --> p1 text
    <-- p2 text
    FORM EXPORT_TO_EXCEL .
    DATA: L_FILE_NAME(60) TYPE C.
    Create a file name
    CONCATENATE 'C:\' 'Shift_Depn_' SY-DATUM6(2) '.' SY-DATUM4(2)
    '.' SY-DATUM+0(4) INTO L_FILE_NAME.
    Pass the internal table (it_excel which is already populated )
    to the function module for excel download.
    CALL FUNCTION 'WS_EXCEL'
    exporting
    filename = L_FILE_NAME
    tables
    data = IT_EXCEL
    exceptions
    unknown_error = 1
    others = 2.
    if sy-subrc <> 0.
    message e001(ymm) with 'Error in exporting to Excel.'.
    endif.
    ENDFORM. " EXPORT_TO_EXCEL
    *~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    When you click the button - Export to Excel ( GUI-Status) you'll be able to export the content of the Internal Table to an Excel file .......
    Regards,
    Abir
    Please don't forget to award points *

  • APEX 4.0: error while opening a XLS file downloaded from interactive report

    Hi,
    I'm getting below error while opening a XLS file downloaded from an interactive report (APEX 4.0).
    "The file you trying to open, 'customer_2.xls', is in a different format than specified by the file extension.
    Verify that the is not corrupted and is from a trusted source before opening file. Do you want to open file."
    Yes No Help
    May be this one Apex 4.0 issue.
    please help me.
    Thanks
    Mukesh

    Hi,
    is the next part of the code correct.
    What i mean is packing of the attachment, finding out the size of pdf file and doc type as PDF.
    You can also try below link..
    Link: [http://wiki.sdn.sap.com/wiki/display/Snippets/SENDALVGRIDASPDFATTACHMENTTOSAPINBOXUSINGCLASSES]
    Hope this helps.
    Regards,
    -Sandeep

Maybe you are looking for