How to download files in jsp code {through save dialog}

can you help me to download files in jsp code {through save dialog}
i use the following code but it saves the jsp page instead of the downloaded file but with the name of the wanted file to be downloaded
response.setHeader("Pragma", "public");
response.setHeader("Cache-Control", "no-cache");
*** download file
if((trans !=null)&&(trans.equals("download")) )
response.setContentType ("application/x-download");
response.setHeader ("Content-Disposition","attachment;filename=\""+fileName+"\"");
%>
<script>
window.location.href=<%=gallerypath+fileName%>';
</script>
<%
trans="";
//System.out.print("download : "+fileName );
//***************************************

Can you try below code, It should work...
<%
String myFileName = request.getParameter("fileName");
response.setContentType("application/octet-stream");
response.setHeader("Content-Disposition", "attachment; filename=\"" + myFileName + "\"");
String root = "D:/";
InputStream in = null;
ServletOutputStream outs = response.getOutputStream();
try {
in = new BufferedInputStream
(new FileInputStream(root + myFileName));
int ch;
while ((ch = in.read()) != -1) {
outs.print((char) ch);
finally {
if (in != null) in.close(); // very important
outs.flush();
outs.close();
in.close();
%>

Similar Messages

  • How to download file in jsp

    Hi guys,
    I am a new member to this java community. I meet some problems in doing my project, hope you experts can help me.
    I want to add a download button in my jsp code. When users click the button, a file will be downloaded to his local computer. The files are ASCII files with .asc as extension. My server is Apache 1.3.19 with tomcat 3.2.1 . What kind of code should I add to my jsp?
    Anyone's quick response is greatly appreciated.

    Thanks for your reply.
    I have tried to use the hyper link in html. But since it's ASCII file with .asc extension, every time the link is clicked, the file is opened directly instead of offering save option. So maybe some special code is needed.
    Many software web site provides download page. When user clicks the download button, the file will be transfered to user's computer. Does anyone knows how to do it?
    Thanks.

  • How to download file from application server

    Hi Experts,
                  I developed report and execute in background mode. for this i used Open dataset transfer and close dataset . i got the requried output . But in this case user want downloaded file on presentation server so can anyone tell me How to download file from application server?
    i know it is possible through Tcode CG3Y. but i want code in program.

    This code will download a file to your Client package by package, so it will also work for huge files.
    *& Report  ZBI_DOWNLOAD_APPSERVER_FILE
    REPORT  zbi_download_appserver_file.
    PARAMETERS: lv_as_fn TYPE sapb-sappfad
    DEFAULT '/usr/sap/WBP/DVEBMGS00/work/ZBSPL_R01.CSV'.
    PARAMETERS: lv_cl_fn TYPE string
    DEFAULT 'C:\Users\atsvioli\Desktop\Budget Backups\ZBSPL_R01.CSV'.
    START-OF-SELECTION.
      CONSTANTS blocksize TYPE i VALUE 524287.
      CONSTANTS packagesize TYPE i VALUE 8.
      TYPES ty_datablock(blocksize) TYPE x.
      DATA lv_fil TYPE epsf-epsfilnam.
      DATA lv_dir TYPE epsf-epsdirnam.
      DATA ls_data TYPE ty_datablock.
      DATA lt_data TYPE STANDARD TABLE OF ty_datablock.
      DATA lv_block_len TYPE i.
      DATA lv_package_len TYPE i.
      DATA lv_subrc TYPE sy-subrc.
      DATA lv_msgv1 LIKE sy-msgv1.
      DATA lv_processed_so_far TYPE p.
      DATA lv_append TYPE c.
      DATA lv_status TYPE string.
      DATA lv_filesize TYPE p.
      DATA lv_percent TYPE i.
      "Determine size
      SPLIT lv_as_fn AT '/' INTO lv_dir lv_fil.
      CALL FUNCTION 'EPS_GET_FILE_ATTRIBUTES'
        EXPORTING
          file_name      = lv_fil
          dir_name       = lv_dir
        IMPORTING
          file_size_long = lv_filesize.
      "Open the file on application server
      OPEN DATASET lv_as_fn FOR INPUT IN BINARY MODE MESSAGE lv_msgv1.
      IF sy-subrc <> 0.
        MESSAGE e048(cms) WITH lv_as_fn lv_msgv1 RAISING file_read_error.
        EXIT.
      ENDIF.
      lv_processed_so_far = 0.
      DO.
        REFRESH lt_data.
        lv_package_len = 0.
        DO packagesize TIMES.
          CLEAR ls_data.
          CLEAR lv_block_len.
          READ DATASET lv_as_fn INTO ls_data MAXIMUM LENGTH blocksize LENGTH lv_block_len.
          lv_subrc = sy-subrc.
          IF lv_block_len > 0.
            lv_package_len = lv_package_len + lv_block_len.
            APPEND ls_data TO lt_data.
          ENDIF.
          "End of file
          IF lv_subrc <> 0.
            EXIT.
          ENDIF.
        ENDDO.
        IF lv_package_len > 0.
          "Put file to client
          IF lv_processed_so_far = 0.
            lv_append = ' '.
          ELSE.
            lv_append = 'X'.
          ENDIF.
          CALL FUNCTION 'GUI_DOWNLOAD'
            EXPORTING
              bin_filesize         = lv_package_len
              filename             = lv_cl_fn
              filetype             = 'BIN'
              append               = lv_append
              show_transfer_status = abap_false
            TABLES
              data_tab             = lt_data.
          lv_processed_so_far = lv_processed_so_far + lv_package_len.
          "Status display
          lv_percent = lv_processed_so_far * 100 / lv_filesize.
          lv_status = |{ lv_percent }% - { lv_processed_so_far } bytes downloaded of { lv_filesize }|.
          CALL FUNCTION 'SAPGUI_PROGRESS_INDICATOR'
            EXPORTING          "percentage = lv_percent - will make it fash
              text = lv_status.
        ENDIF.
        "End of file
        IF lv_subrc <> 0.
          EXIT.
        ENDIF.
      ENDDO.
      "Close the file on application server
      CLOSE DATASET lv_as_fn.

  • How to Download Sapscript Form's Code

    Dear All,
    I don't how to download the SAPscript form code and same if needed some othere time i can also upload into other form.
    Regrads.
    Alok

    run report RSTXSCRP in se38.
    Upload the SAPSCRIPT and to a copy from client to copy it to another name.
    Rishi
    PS: This is an editable text file. If you carefully replace the name of the old SAPScript, you can upload it into a different name.
    Message was edited by: Rishi Joseph

  • TS1538 how to download files from laptop to ipad air

    how to download files from laptop to ipad air

    Sync them via iTunes as you would with any other iDevice.

  • How to move downloaded files from download folder to other relevant folder or how to download files in relevant folders other than download folder

    how to move downloaded files from download folder to other relevant folder or how to download files in relevant folders other than download folder

    Just drag the file from the Download folder to the folder of your choice in Finder. If you are using Safari you can designate a new default download destination in Safari>Preferences>General tab, 'Save Downloads to...'. Other browsers should have a similar option in their preferences.

  • Sun JSC2 - How to download files to client

    Hi, imagine a document management site.
    I want to have a list of files with links that users can click to download them.
    Users can upload files (with handy File Upload component), and they get saved as byte streams to a file or database or whatever.
    Now, I have a page with a list of files the user can download. The file name, a link to save the file, and a link to download the file.
    File1.pdf . . . DOWNLOAD IT! . . . SAVE IT!
    The DOWNLOAD IT! link tries to use mime stuff to get the browser to open the file.
    The SAVE IT! link tells the browser to not process the file and always bring up the save as dialog. In both cases, I don't want the browser to open a new page.
    Starting with a byte[], what's the best way to do this? I searched the web, and these forums, but couldn't come up with anything that gave me a place to start from inside JSC2.
    Any ideas on where to start? Thanks in advance!
    Mike

    Hey Winston, here is what I came up with... Very similar, but a little different.
    Java Server Faces File Download Tutorial by Michael Cole
    Java Server Faces, abstracts much of the monotonous detail of web programming, letting application developers develop applications, instead of programming servers.
    This tutorial explains how to dip just a little under the covers to serve files to a browser. The browser can then interpret this binary data using MIME types. Some common MIME types are �text/plain�, �text/html�, or �application/pdf� or �application/x-unknown�.
    How the browser behaves when interacting with these MIME types is based on the client browser's configuration. Because this configuration is different for every browser, let's create two different behaviors:
    * First Behavior: When a link is clicked, the browser downloads and �opens� the file, either displaying the file itself, or choosing an appropriate program: zip file program, pdf program, etc.
    * Second Behavior: The browser always offers to save the file, no matter what.
    At the most basic level, we want to cause this chain of events:
    1. Cause browser to send a request to the server.
    2. Have the server create a response that sends the file to the client.
    For my purposes, the browser should not navigate to a new page for this behavior.
    A mockup might look like this:
    Files you can download:
    Secrets of the Universe.txt
    Open it!
    Save it!
    Perfect love and happiness.pdf
    Open it!
    Save it!
    Make a million dollars now.swf
    Open it!
    Save it!
    To accomplish this, we will execute this code on the server:
    // Find the HttpServletResponse object for this request.
    // With this object, we can create a response that sends the file.
    FacesContext faces = FacesContext.getCurrentInstance();
    HttpServletResponse response = (HttpServletResponse) faces.getExternalContext().getResponse();
    // We can also get information about what the browser requested.
    // This could tell us what data to send
    HttpServletRequest request = (HttpServletRequest) faces.getExternalContext().getRequest();
    // Your data can be stored in a database, generated at runtime, or whatever you choose.
    // We getSomeData() from an arbitrary location. This depends on your application.
    byte[] data = getSomeData(request);
    // In the response, we will specify a file name to present to the user.
    String filename = "myFile.txt";
    // Now we have the data to send, and the response object to send it with.
    // Next we give the browser some hints on what to do with the file.
    // Note that different browsers will behave differently and you have no control over this.
    // We'll use different mime types to implement the different "Open" and "Save" behaviors.
    // "application/x-unknown" will be the MIME type used for the "Save" behavior.
    response.setContentType(mimeType);
    // We tell the browser how much data to expect.
    response.setContentLength(data.length);
    // Cross-browser hack for Firefox 1.0.7 and IE 6 compatibility.
    // IE 6 ignores the MIME type and decides based on the "attachment" or "inline"
    if (mimeType.equals("application/x-unknown")) {
    // Show the "Save As..." dialog
    response.setHeader( "Content-disposition", "attachment; filename=\"" + filename + "\"");
    } else {
    // attempt to "open" the file
    response.setHeader( "Content-disposition", "inline; filename=\"" + filename + "\"");
    // Now we start sending data with the response object.
    // You might consider using a buffer if your data comes from a large file
    // or a database.
    try {
    ServletOutputStream out;
    out = response.getOutputStream();
    out.write(data);
    } catch (IOException e) {
    e.printStackTrace();
    // Lastly and very importantly, we tell Java Server Faces that
    // the request has been handled and not to process it any more.
    faces.responseComplete();
    Now all we have to do is put this code somewhere.
    Step 1: Build the page UI.
    * Create a new page in Java Studio Creator. Let's call it �download.jsp�
    * Make it the start page (right-click)
    * Add a hyperlink component and call it �Open!�
    * If you like, add a static text that describes your file.
    Step 2: Tell Java Server Faces what to do when the hyperlink is clicked.
    * Doubleclick the hyperlink and add this code to it's action:
    public String hyperlink1_action() {
    // TODO: Replace with your code
    DownloadBean d = new DownloadBean();
    d.sendFile("text/plain");
    return null;
    * Compile the download.java and get a �cannot find symbol for class DownloadBean�. Now we have a place to put our code to send the file!
    Step 3: Build the DownloadBean that will serve the file.
    * Go to your "Source Packages" folder and create a new Java class in the project's package. Call this class �DownloadBean�.
    * Copy this code into the class:
    public void sendFile(String mimeType) {
    FacesContext faces = FacesContext.getCurrentInstance();
    HttpServletResponse response = (HttpServletResponse) faces.getExternalContext().getResponse();
    HttpServletRequest request = (HttpServletRequest) faces.getExternalContext().getRequest();
    byte[] data = getSomeData(request);
    String filename = "myFile.txt";
    // Note that different browsers will behave differently and you have no control over this.
    // We'll use different mime types to implement the different "Open" and "Save" behaviors.
    // "application/x-unknown" will be the MIME type used for the "Save" behavior.
    response.setContentType(mimeType);
    response.setContentLength(data.length);
    // Cross-browser hack for Firefox 1.0.7 and IE 6 compatibility.
    // IE 6 ignores the MIME type and decides based on the "attachment" or "inline"
    if (mimeType.equals("application/x-unknown")) {
    // Show the "Save As..." dialog
    response.setHeader( "Content-disposition", "attachment; filename=\"" + filename + "\"");
    } else {
    // attempt to "open" the file
    response.setHeader( "Content-disposition", "inline; filename=\"" + filename + "\"");
    // Now we start sending data with the response object.
    try {
    ServletOutputStream out;
    out = response.getOutputStream();
    out.write(data);
    } catch (IOException e) {
    e.printStackTrace();
    faces.responseComplete();
    * Hit Ctrl-Shift-F to make the code pretty.
    * Try and compile DownloadBean.java. Build->Compile
    * As expected, you will get a variety of �cannot find symbol� errors.
    * Hit Ctrl-Alt-F to clean these up, by automatically adding the proper imports.
    * Try and compile again and you will get a �cannot find symbol� error for the getSomeData() function. That's ok cause we didn't write it yet.
    * Copy this code into the DownloadBean class:
    public byte[] getSomeData(Object o) {
    // ignore the HttpServletRequest object and return some data.
    return "Hello World!".getBytes();
    * Compile the file one last time to get a clean compile.
    Why didn't we put this code directly in the hyperlink1_action() function? Because we are separating the �model� from the "view" and "controller". DownloadBean can be reused in any page of your application now.
    Step 4: Test
    1. Run the project and open the page in the Firefox web browser.
    2. Click the �Open It!� hyperlink
    3. A text file should appear in Firefox that says �Hello World!�
    Great! We sent the file, Firefox interpreted the �text/plain� MIME type, and presented the text as a browser page. This covers our �Open It!� functionality.
    To serve other kinds of files, pass a different MIME type in the sendFile() function.
    For a list of MIME types, check out http://www.webmaster-toolkit.com/mime-types.shtml
    Step 5: Save It! Functionality.
    What if we always want the file to be saved, no matter what foolishness the browser wants to do with the file?
    * Go back to the Design of download.jsp.
    * Add another hyperlink to the page, label it �Save It!�
    * Double click the hyperlink and JSC2 will take you to its action function.
    * Add this code to the function
    public String hyperlink2_action() {
    // TODO: Replace with your code
    DownloadBean d = new DownloadBean();
    d.sendFile("application/x-unknown");
    return null;
    Notice the difference in the MIME type? We changed �text/plain� to �application/x-unknown�. Notice also in the sendFile() function the cross-browser hack to get IE 6.0 to save or open the file.
    * Run the project one last time.
    * Test with Firefox
    * Test with Internet Explorer
    Done!

  • How to download file from server to client's local ??

    How to download a file from the server to the client's local machine in a particular folder without users intervention ie. 'Save As" prompt of the browser should be avoided and if the client clicks on "Download" button, the file should get automaticaly downloaded to say, "c:/reports/' on his/her local machine. This is for Java based web appliaction.

    http://jguru.com/faq/view.jsp?EID=10646

  • How use class file in jsp(very urgent)

    i have class file called birds (birds is actually a xslt file transformed to java class file) now this class file i have to use in my jsp file. how can i use them. if possible can any one give me sample code please very urgent
    can any one help me

    java files
    import org.w3c.dom.*;
    import javax.servlet.http.*;
    import javax.xml.transform.*;
    import javax.xml.transform.stream.*;
    import java.io.*;
    public class XmlParser
         public String XmlParser()
              try
    String strXML= "employee.xml";
                   String xslFile = "employeeId.xsl";
                   TransformerFactory tFactory = TransformerFactory.newInstance();
                   StreamResult theTransformationResult = new StreamResult( new ByteArrayOutputStream() );
                   Transformer transformer = tFactory.newTransformer(new StreamSource(xslFile));
                   transformer.transform(new StreamSource(new StringReader(strXML)), theTransformationResult);
                   String output = theTransformationResult.getOutputStream().toString()
              catch(Exception e)
                   System.out.println(" ***** XmlParser.XmlParser ERROR ***** " + e);
    return output;
    using class files in jsp
    <%@ page import="com.qqqq.aaaa.XmlParser"%>
    <%
         XmlParser xmlParser          =     new XmlParser();
    out.println(xmlParser.XmlParser());
    %>
    i think it will help you.

  • Download file via jsp

    dear all,
    to download a *.txt-file via jsp i use following code:
    java.io.File file = new java.io.File("C:\\FileName.txt");
    response.setHeader("Content-Disposition", "attachment;filename=\""+file.getName()+"\";");
    response.setContentType("APPLICATION/OCTET-STREAM");
    response.setContentLength((int) file.length());
    if(file.isFile()){
         java.io.FileInputStream fis = new java.io.FileInputStream(file);
         java.io.BufferedOutputStream bos = new java.io.BufferedOutputStream(response.getOutputStream());
         byte b[] = new byte[(int)file.length()];
         int read = 0;
         while((read = fis.read(b)) != -1){
              bos.write(b,0,read);
         bos.flush();
         fis.close();
         bos.close();
    } the problem is:
    the file will be displayed in the browser IE6 (inline), but i want to open a save-dialog!
    any ideas?!
    thanks for help. andy

    up to now i tried another browser (mozilla firebird) and several settings about the contenttype like:
    - application/x-download
    - application/x-msdownload
    - application/x-octet-stream
    - application/octet-stream
    - application/download
    ... and the file-name like:
    *.zip
    *.txt
    *.exe
    but the browser shows the content of the file always inline (even *.zip and *.exe files!!).
    anyway, thank you for help.
    andy

  • How to download radio documentaries to ipod through computer.

    how do i download radio documentaries to ipod through computer. when i look at the doc site it has i tunes next to each documentary.thank you.

    I have to admit, both RTÉ and iTunes now make this a long-drawn-out procedure. However...
    evvyseamus wrote:
    the site is www.rte radio1/doconone/. hope this helps
    If you mean http://www.rte.ie/radio1/doconone/ - then presumably you clicked on this:
    which took you to this page: http://www.rte.ie/radio1/podcast/podcast_documentaryonone.xml .
    On that page, at the very bottom, is a section titled How to get this Podcast. Copy the Podcast URL (starting http://) and then in your iTunes, use CTRL+B to display the top menu bar. On that, click on File/Subscribe to Podcast and paste the URL into the box. That should subscribe you to their Podcast, despite being a longer process than it needs to be.
    If you are referring to another site, the procedure is still (basically) the same: find the Podcast's URL and paste it into the iTunes Subscribe to Podcast box. An efficient site will actually open iTunes to the "are you sure you want to subscribe" page. Perhaps RTÉ have a bit to learn.

  • How to execute again the JSP codes

    Dear Experts,
    I am having trouble to execute again the JSP codes in my abc.jsp page. The sequence of the codes are:
    [ JSP codes ]
    [ HTML codes]
    My JSP file is selecting from DB2 and display the results on the same page. The selecting is depending to the selection in the combo box and included the selection into the SQL statement.
    The problem is when I change the selection at the combo box, how can I refresh the page and fill in with the new results from database by selecting with the new keyword.

    You will have to do an onChange handler for the select box, that simply submits the form, and the action would be the current page.

  • How to compile and deploy JSP code from Unix server command line?

    I am new to JSP technology. We are thinking to modify some of JSP code to meet our need. But I am not sure what I should do after I change JSP code. How can I compile the changed code? How to deploy? How to publish on the web?

    All files are regenerated if changed.
    That goes for the .java and the .class files that are created. The jsp server checks to see if the current version is the latest. If it is, nothing gets changed or recompiled. If things are different, programs are recompiled.
    Youll notice that if you have a new jsp it always takes longer the first time. Or even when you change a jsp, the first time takes the longest for the page to come up in a browser. This is because of recompiling.
    Does this make any sense?
    Adam

  • ADF: how to download files?

    good day,
    does anyone know what the best way is to download a file to the client side using ADF? is this a trivial thing to do? i can find docs online on how to upload files using ADF but nothing for downloading files using ADF.
    initially, my thought was to use the FacesContext ResponseStream; but quickly realized that facesContext.getResponseStream returns a null with in my backend bean. so, i decided to bypass ADF and use HttpServletResponse's ServletOutputStream and simply write to this object. this works fine but ran into another problem, this comletely bypasses the ADF framework. after downloading the file ADF does not know what state it is in (i.e. my pages do not get updated). nothing gets updated via ADF.
    a second approach was to to kick off writing the Servlet OutputStream in a separate thread and have the backend bean return first. well... ran into another problem: java.lang.IllegalStateException: getOutputStream() has already been called!. obviously, i do not understand how the response mechanism works for servlets :-( it appears that per request the ouputstream can be only written to/flushed once.
    so if anyone has a way to correctly download a file using ADF please share.
    thank you

    Lius,
    thank you for the link. i read through it.
    for a existing file on the server a redirect works. but what if i do not have a physical file on the server and i simply want to write it from memory to the client side. i would like to write an outputstream object from the server directly to the user's browser.
    from the backend bean i do the following:
    ServletOutputStream out = response.getOutputStream();
    ByteArrayOutputStream outputStream = getOutputStream();
    // Reading the bytes through buffered input stream and writing the
    // presentation to the servlet output stream in the form of bytes
    // using
    // buffered output stream\
    while (-1 != (bytesRead = bis.read(buff, 0, buff.length))) {
    bos.write(buff, 0, bytesRead);
    // Flushing the buffers of Http Response. this is bad for ADF.
    response.flushBuffer();
    and once i flush the buffer here it returns to the client and the user can than download the file but it completely bypasses the ADF framework and i am unable to make any ADF callbacks (i.e. send messages or use adf progress bar) :-(
    is there a way to download a file to an ouputstream without having it on the server side as a file.
    thanks for you help,
    joon

  • How to download files from Application Server of Unix o.s to local director

    Hi All,
    I am trying to download files from Apllication server of Unix operating Systems to local file in excel sheet format using a z-program.but whenever I am trying to use OPEN dataset ........
    it is showing sy-subrc = 8.
    Can I have any clew please.
    Thanks in advance,
    Regards,
    AMEER.

    Hi Sreekanth,
    Thanks a lot for quick reply.I have to download that files from z-program only. I am giving you my code below.
    *& Report  ZTRAK_DOWNLOAD                                         *
    REPORT  ZTRAK_DOWNLOAD  MESSAGE-ID ZCT                   .
    SELECTION-SCREEN BEGIN OF BLOCK DOWNLOAD WITH FRAME TITLE TEXT1.
      PARAMETERS :
           SERDIR LIKE RLGRAP-FILENAME DEFAULT '/usr/trak',
           LOCDIR LIKE RLGRAP-FILENAME DEFAULT 'C:\Trak'.
    SELECTION-SCREEN END OF BLOCK DOWNLOAD .
    SELECTION-SCREEN BEGIN OF BLOCK INFO2 WITH FRAME.
           SELECTION-SCREEN COMMENT 1(79) TEXT2.
           SELECTION-SCREEN SKIP.
           SELECTION-SCREEN COMMENT 1(79) TEXT3.
    SELECTION-SCREEN END OF BLOCK INFO2 .
    SELECTION-SCREEN BEGIN OF BLOCK INFO3 WITH FRAME.
           SELECTION-SCREEN COMMENT 1(79) TEXT4.
           SELECTION-SCREEN SKIP.
           SELECTION-SCREEN COMMENT 1(79) TEXT5.
            SELECTION-SCREEN SKIP.
           SELECTION-SCREEN COMMENT 1(79) TEXT6.
           SELECTION-SCREEN SKIP 1.
           SELECTION-SCREEN COMMENT 1(79) TEXT7.
           SELECTION-SCREEN SKIP 2.
           SELECTION-SCREEN COMMENT 1(79) TEXT8.
    SELECTION-SCREEN SKIP 1.
           SELECTION-SCREEN COMMENT 1(79) TEXT9.
    SELECTION-SCREEN END OF BLOCK INFO3.
    *- Internal Table to output data in Excel
    DATA: BEGIN OF tab_excel OCCURS 0,
            col1(50),
            col2(132),
            col3(255),
            col4(100),
            col5(100),
            col6(50),
            COL7(60),
            col8(30),
            col9(30),
            col10(30),
            col11(20),
            col12(15),
            col13(15),
          END OF tab_excel.
    DATA: FILE LIKE RLGRAP-FILENAME .
    DATA: W_DATASET(80).
    INITIALIZATION.
      TEXT1  = 'Download Reports'.
      TEXT2 = 'The Program downloads the reports generated by Trak'.
      TEXT3 = 'Utility from Server to Local PC.'.
      TEXT4 = 'Check the following before executing the Program.'.
      TEXT5 = '     1. A valid Server path is provided.'.
      TEXT6 = '     2. A valid Local PC path is provided.'.
      TEXT7 = '     3. Local PC has 10 MB free space.'.
      TEXT8 = 'The report can be executed in the forground.'.
    TEXT9 =
    'The report should be executed after execution of Transaction TRAK'.
    AT SELECTION-SCREEN.
    IF SERDIR EQ ''.
    MESSAGE E001(ZCT).
    ENDIF.
    IF LOCDIR EQ ''.
    MESSAGE E002(ZCT).
    ENDIF.
    START-OF-SELECTION.
    Download ABAP Development Summary Report
    FILE =  '\ABAP_Report_Developments.XLS'.
    CONCATENATE LOCDIR FILE INTO FILE.
    W_DATASET = '/ABAP_Report_Developments.dat'.
    CONCATENATE SERDIR W_DATASET INTO W_DATASET.
    PERFORM INIT.
    Download BDC Development Report
    FILE =  '\BDC_Developments_Report.XLS'.
    CONCATENATE LOCDIR FILE INTO FILE.
    W_DATASET = '/BDC_Developments_Report.dat'.
    CONCATENATE SERDIR W_DATASET INTO W_DATASET.
    PERFORM INIT.
    Download Development Summary Report
    FILE = '\Developments_Summary_Report.XLS' .
    CONCATENATE LOCDIR FILE INTO FILE.
    W_DATASET = '/Developments_Summary_Report.dat'.
    CONCATENATE SERDIR W_DATASET INTO W_DATASET.
    PERFORM INIT.
    Download Enhancement Development Report
    FILE =  '\Enhancement_Developments_Report.XLS'.
    CONCATENATE LOCDIR FILE INTO FILE.
    W_DATASET = '/Enhancement_Developments_Report.dat'.
    CONCATENATE SERDIR W_DATASET INTO W_DATASET.
    PERFORM INIT.
    Download field exit Development Report
    FILE =  '\Field_Exit_Developments_Report.XLS'.
    CONCATENATE LOCDIR FILE INTO FILE.
    W_DATASET = '/Field_Exit_Developments_Report.dat'.
    CONCATENATE SERDIR W_DATASET INTO W_DATASET.
    PERFORM INIT.
    Download Frequency & Purpose Report
    FILE =  '\Frequency_And_Purpose_Report.XLS'.
    CONCATENATE LOCDIR FILE INTO FILE.
    W_DATASET = '/Frequency_And_Purpose_Report.dat'.
    CONCATENATE SERDIR W_DATASET INTO W_DATASET.
    PERFORM INIT.
    Download Function Group Developments Report
    FILE =  '\FunctionGroup_Developments_Report.XLS'.
    CONCATENATE LOCDIR FILE INTO FILE.
    W_DATASET = '/FunctionGroup_Developments_Report.dat'.
    CONCATENATE SERDIR W_DATASET INTO W_DATASET.
    PERFORM INIT.
    Download Function Module Developments Report
    FILE = '\FunctionModule_Developments_Report.XLS' .
    CONCATENATE LOCDIR FILE INTO FILE.
    W_DATASET = '/FunctionModule_Developments_Report.dat'.
    CONCATENATE SERDIR W_DATASET INTO W_DATASET.
    PERFORM INIT.
    Download Include Developments Report
    FILE =  '\Include_Developments_Report.XLS'.
    CONCATENATE LOCDIR FILE INTO FILE.
    W_DATASET = '/Include_Developments_Report.dat'.
    CONCATENATE SERDIR W_DATASET INTO W_DATASET.
    PERFORM INIT.
    Download UserGroup Developments Report
    FILE =  '\UserGroup_Developments_Report.XLS'.
    CONCATENATE LOCDIR FILE INTO FILE.
    W_DATASET = '/UserGroup_Developments_Report.dat'.
    CONCATENATE SERDIR W_DATASET INTO W_DATASET.
    PERFORM INIT.
    Download Modified_Standard_SAP_Objects_Report
    FILE = '\Modified_Standard_SAP_Objects_Report.XLS' .
    CONCATENATE LOCDIR FILE INTO FILE.
    W_DATASET = '/Modified_Standard_SAP_Objects_Report.dat'.
    CONCATENATE SERDIR W_DATASET INTO W_DATASET.
    PERFORM INIT.
    Download Include Developments Report
    *FILE =  '\Include_Developments_Report.XLS'.
    *CONCATENATE LOCDIR FILE INTO FILE.
    *W_DATASET = '/Include_Developments_Report.dat'.
    *CONCATENATE SERDIR W_DATASET INTO W_DATASET.
    *PERFORM INIT.
    Download SAP Script Developments Report
    FILE =  '\SAP_Scipt_Developments_Report.XLS'.
    CONCATENATE LOCDIR FILE INTO FILE.
    W_DATASET = '/SAP_Scipt_Developments_Report.dat'.
    CONCATENATE SERDIR W_DATASET INTO W_DATASET.
    PERFORM INIT.
    Download Transaction Developments Report
    FILE =  '\Transaction_Developments_Report.XLS'.
    CONCATENATE LOCDIR FILE INTO FILE.
    W_DATASET = '/Transaction_Developments_Report.dat'.
    CONCATENATE SERDIR W_DATASET INTO W_DATASET.
    PERFORM INIT.
    Download User Exits Developments Report
    FILE =  '\UserExits_Reports.XLS'.
    CONCATENATE LOCDIR FILE INTO FILE.
    W_DATASET = '/UserExits_Reports.dat'.
    CONCATENATE SERDIR W_DATASET INTO W_DATASET.
    PERFORM INIT.
    Download ABAP Query Developments Report
    FILE =  '\ABAPQuery_Developments_Reports.XLS'.
    CONCATENATE LOCDIR FILE INTO FILE.
    W_DATASET = '/ABAPQuery_Developments_Reports.dat'.
    CONCATENATE SERDIR W_DATASET INTO W_DATASET.
    PERFORM INIT.
    Download Functional Area Developments Report
    FILE =  '\FunctionalArea_Developments_Report.XLS'.
    CONCATENATE LOCDIR FILE INTO FILE.
    W_DATASET = '/FunctionalArea_Developments_Report.dat'.
    CONCATENATE SERDIR W_DATASET INTO W_DATASET.
    PERFORM INIT.
    MESSAGE S003(ZCT) WITH LOCDIR.
    END-OF-SELECTION.
    This routine checks whether file exists if yes downloads it to
    the Local PC
    FORM INIT.
    OPEN DATASET W_DATASET FOR INPUT IN TEXT MODE ENCODING DEFAULT.
    DO.
       IF SY-SUBRC <> 0.
          EXIT.
       ENDIF.
       READ DATASET W_DATASET INTO  tab_excel.
       APPEND tab_excel.
       CLEAR tab_excel.
    ENDDO.
         PERFORM DOWNLOAD_FILE.
    ENDFORM.
    This routine downloads the data in an XL format on local PC
    FORM Download_File .
      CALL FUNCTION 'WS_DOWNLOAD'
                EXPORTING
                     FILENAME                = FILE
                     FILETYPE                = 'DAT'
                TABLES
                     DATA_TAB                = tab_excel
                EXCEPTIONS
                     FILE_OPEN_ERROR         = 1
                     FILE_WRITE_ERROR        = 2
                     INVALID_FILESIZE        = 3
                     INVALID_TYPE            = 4
                     NO_BATCH                = 5
                     UNKNOWN_ERROR           = 6
                     INVALID_TABLE_WIDTH     = 7
                     GUI_REFUSE_FILETRANSFER = 8
                     CUSTOMER_ERROR          = 9
                     OTHERS                  = 10.
        IF sy-subrc <> 0.
         message ''.       " Error in file transfer
        ELSE.
          CLEAR TAB_EXCEL.
          REFRESH TAB_EXCEL.
          FILE = ''.
          W_DATASET = ''.
        ENDIF.
    ENDFORM.
    I have created those files in Application Server running in another z-program in background mode.Then I am trying to download those files using above the program.I am creating those trak/Trak files manually and I can able to see those files in A.S level.But when downloading the same files I am facing the problem.
    regards,
    Ameer

Maybe you are looking for

  • How do i move imovie projects from my internal hard drive to external hard

    When I import imovie projects or import imovies, the "save to" drop down box won't drop down to show any options other than the int hard drive (although the ext drive is recognized by finder. I read that the ext drive (a iTB western digital mybook) i

  • "USB Over Current" warnings worse in Leopard than Tiger

    Here's a tricky one: Just bought a 2006 MacBook Pro 2.16GHz, 2GB Ram, 120 GB HD It came with an openly disclosed problem: a consistent "USB Over Current" error message popping onto screen. (yes, I've read relevant threads and tried resetting PRAM, et

  • NiScope EX Multi Record

    Hi: I have a question on niScope EX Multi Record. I tried to put 10ohm in the BNC cable. See my attached graph. Then, I press the "Bark" button on my test fixture. It will generate the waveform using the niScopeEX Multi Record vi. But, if I use 100oh

  • Handling multiple Webview in iPhone

    i am not able to display multiple webviews in a window. can anyone have a answer for this. my code has method created 3 webviews and added to a view (void)webViewDidFinishLoad:(UIWebView *)webView [self addSubView:webView] ; which displays first webv

  • Writing a custom RMI Activator process

    Hello Group, I am in the process of implementing a custom RMI activation scheme, in which remote Activatable objects will be hosted in a custom EXE process, instead of the standard Java.exe/Javaw.exe. I intend to use JNI to create the JVM in this cus