Regarding download to text file

Dear ABAP Gurus,
I have requirement to download internal table to text file and put it on a strorade via ftp.
The problem is, when i try to write long text into the file, i cannot write euro currency character 'u20AC', the 'u20AC' replaced by other character like 'ä.¬'
But if I download to xls file (using GUI_DOWNLOAD to local storage), it works fine.
Is there any solution on this matter?
Are there other character that would replaced by characters just like euro currency character?
Thanks in advance.
Rgds.
-g-

Try this :
- cl_abap_char_utilities=>horizontal_tab  is tab delimited, it's depent what is your separator
- itab is your internal table, below is just sample
DATA :  filenamex TYPE char50,
DATA : l_string TYPE string.
filenamex = '/itf/zsmart/test.txt
  OPEN DATASET filenamex FOR INPUT IN TEXT MODE
               ENCODING DEFAULT.
  IF sy-subrc = 0.
    DO.
      CLEAR : l_string.
      READ DATASET filenamex INTO l_string.
      IF sy-subrc NE 0.
        EXIT.
      ELSE.
        SPLIT l_string AT cl_abap_char_utilities=>horizontal_tab
        INTO itab-key itab-otyp itab-sorg itab-dchl itab-div itab-soff
             itab-cust itab-pon itab-podt itab-docdt itab-pymtr
             itab-inco1 itab-inco2 itab-matnr itab-qty itab-batch
             itab-plant itab-sloc itab-shppt itab-promo itab-sprom
             itab-mpgrp itab-obtyp itab-objno.
        APPEND itab.
        CLEAR itab.
      ENDIF.
    ENDDO.
  ELSE.
    MESSAGE e000(zelog) WITH 'Error Reading File'.
  ENDIF.

Similar Messages

  • Downloading a text file from application server

    Hi Freinds,
    I am genarating a text file in our application server (Folder /usr/sap/dbi/) I need to download this text file in my destop pc or some other windows server.
    What do I have to do? What is the procedure, Pls help.
    If someone have sample code, pls send.
    We are running SAP ECC5.0 on an iSeries (AS/400) Database DB2/400.
    Regards
    Thanura

    Hi,
    try this:
    REPORT ZGRO_TEST.
    DATA: DATEI_A(30) TYPE C VALUE '/tmp/matnr.txt'.
    DATA: DATEI_PC TYPE STRING VALUE 'C:\MATNR.TXT'.
    DATA: ITAB        TYPE TABLE OF MARA WITH HEADER LINE.
    START-OF-SELECTION.
      PERFORM DATEI_EINLESEN.
      PERFORM DATEI_DOWNLOAD.
    FORM DATEI_EINLESEN.
      OPEN DATASET DATEI_A FOR INPUT IN TEXT MODE.
      IF SY-SUBRC NE 0. STOP. ENDIF.
      DO.
        READ DATASET DATEI_A INTO ITAB.
        IF SY-SUBRC <> 0. EXIT. ENDIF.
        APPEND ITAB.
      ENDDO.
      CLOSE DATASET DATEI_A.
      IF SY-SUBRC NE 0. STOP. ENDIF.
    ENDFORM.                    "DATEI_EINLESEN
    FORM DATEI_DOWNLOAD.
    Datei downloaden
      CALL METHOD CL_GUI_FRONTEND_SERVICES=>GUI_DOWNLOAD
        EXPORTING
          FILENAME                = DATEI_PC
          FILETYPE                = 'ASC'
        CHANGING
          DATA_TAB                = ITAB[]
        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 NE 0. STOP. ENDIF.
    ENDFORM.                    "DATEI_DOWNLOAD
    Regards, Dieter

  • How to download a text file using classes

    Hi Guys
    I want to download a text file using classes.
    Any idea how to do it ?
    Thanks
    Sameer

    HI sameer,
       It is no different from using a Function module.
    example:
      CALL METHOD cl_gui_frontend_services=>gui_download
        EXPORTING
          filename                  = w_fpath
        append                    = SPACE
          write_field_separator     = 'X'
        CHANGING
          data_tab                  = it_download
        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
    Regards,
    ravi

  • Error in Downloading the Text file on Application Server

    Hi All,
              I am working on ECC6.0. I have written a program in whcih I am downloading the text file on
              application server in UTF-8 format. However when I am opening this file in Excel I am getting
              garbage value for some characters(as Excel does not support UTF-8 format). So now I
              want to download the data on application server in text file in non unicode format(Like ANSI or
              other non unicode format) which is supported by excel. When I am writing the code as
              OPEN DATASET DN_FILE FOR OUTPUT IN LEGACY TEXT MODE it is giving me dump saying
              CHARACTER CONVERSION FROM CODE PAGE '4102' to CODEPAGE '1100' NOT POSSIBLE.
              Same in case if I add the code OPEN DATASET DN_FILE FOR OUTPUT IN LEGACY TEXT
              MODE CODE PAGE '8000' is also giving dump.
              So please let me know how can I download the file in non unicode format ?
              Any help would be greatly appricated.
    Thanks & Regards
    Jitendra Gujarathi.

    OPEN DATASET l_filename FOR INPUT IN TEXT MODE  ENCODING NON-UNICODE IGNORING CONVERSION ERRORS.
    CHECK sy-subrc EQ 0.
      DO.
        CLEAR wa_file_content.
        READ DATASET l_filename INTO wa_file_content.
        IF sy-subrc EQ 0.
          APPEND wa_file_content TO it_file_content.
        ELSE.
          EXIT.
        ENDIF.
      ENDDO.
      CLOSE  DATASET l_filename.
      t_filedata[] = it_file_content[].
    can you use like this.

  • How to download a text file from the server

    hi everyone,
    can anyone tell me how to download and read a text file from the server and saved in into resource folder.
    with regards
    pallavi

    its really easy
    To read from server, use something like:
    HttpConnection connector = null;
    InputStream inp_stream = null;
    OutputStream out_stream = null;
    void CloseConnection()
         if(inp_stream!=null)inp_stream.close();
         inp_stream=null;
         if(out_stream!=null)out_stream.close();
         out_stream=null;
         connector.close();
         connector = null;
    public void getResponse(String URL,String params)
      try
         if(connector==null)connector = (HttpConnection)Connector.open(URL);//URL of your text file / php script
         connector.setRequestMethod(HttpConnection.POST);
         connector.setRequestProperty("User-Agent","Profile/MIDP-2.0 Configuration/CLDC-1.1");
         connector.setRequestProperty("content-type", "application/x-www-form-urlencoded");
         //connector.setRequestProperty("charset","windows-1251");
         //*** If you need to send ("arg1=value&arg2=value") arguments to script use this:
         out_stream = connector.openOutputStream();
         byte postmsg[] = params.getBytes();
         out_stream.write(postmsg);
         int rc = connector.getResponseCode();//in any case here connection will be opened & closed
         if (rc != HttpConnection.HTTP_OK)
              CloseConnection();
              throw new IOException("HTTP response code: " + rc);
         inp_stream = connector.openInputStream();
         int pack_len = inp_stream.available();
         byte answ[]=new byte[pack_len];
         inp_stream.read(answ);
         CloseConnection();
         ProcAnswer(answ);//process received data
      catch(Exception ex)
         System.err.println("ERROR IN getResponse(): "+ex);
    } And you can read from resource file like
    public void loadFile(String filename)
        DataInputStream dis = new DataInputStream(getClass().getResourceAsStream("/"+filename));
        String str="";
        try
             while (true)
                ch = dis.read();//read character
                if(ch=='\r')continue;//if file made in windows
                if(ch=='\n' || ch==-1)//end of line or end of file
                    if(str.length()==0)continue;//if empty line
                    //do some thing with "str"
                    if(ch==-1)break;//it was last line
                    str="";//next line
                    continue;
                 str+=(char)ch;
           dis.close();
       catch (Exception e)
           System.err.println("ERROR in loadFile() " + e);
    }Welcome! =)
    Edited by: MorskoyZmey on Aug 14, 2008 3:40 AM

  • How to make the Open/Save dialogue download the text file instead of JSP

    I am currently coding on a JSP program, which searches the database and writes the resultset into a file on the server, and then allows the client to download this tab delimited text file onto their local machine. But I met a problem, when the default Open or Save dialogue appears, it shows that it's trying to download the running JSP file from my local host instead of the newly-created text file. Despite this, when I click OK to either Open or Save the file, a warning dialogue will appear saying: The explorer cann't download this file, it's unable to find this internet site or something like that. I get no error message from the server but I was always told that Javax.servlet.ServletException: getWriter() was already called. What does this mean?
    I guess maybe this is caused by the mix use of outputStreams in my program. I don't know if there is a way to directly read the resultset from the database and then send it through outputStream to the client. My solution is: first create a file on the server to hold the resultset, and then output this file to the client. I did all these in one JSP program: Create file on the server, search database, and then read file and output the contents to client. Is this correct? I attached my code, please feel free to correct any of my mistake? Thanks!
    //global.class is a class dealing with database connection
    <%@ page language="java" import="java.sql.*,java.util.*,java.math.*,java.io.*,ises.*,frmselection.*" %>
    <jsp:useBean id="global" scope="session" class="ises.Global" />
    />
    <!--start to process data-->
    <%
    //get query statement from the session
    String sQuery = "";
    if (session.getAttribute("sQuery")!=null && !(session.getAttribute("sQuery").toString()).equals(""))
    sQuery = session.getAttribute("sQuery").toString();
    String path = "c:/temp";
    String fileName = "temp.TXT";
    File file= null;
    FileOutputStream fo = null;
    PrintStream ps = null;
    try {
         file = new File(path,fileName);
         if(file.exists()) {
         file.delete();
         file.createNewFile();
         fo = new FileOutputStream(file);
         ps = new PrintStream(fo);
    }catch(IOException exp){
         System.out.println("IO Exception: " +exp.toString() );
    java.sql.ResultSet recResults     = null;
    java.sql.Statement STrecResults = null;
    STrecResults = global.getConnection().createStatement();
    recResults = STrecResults.executeQuery(sQuery);
    ResultSetMetaData meta = recResults.getMetaData();
    int columns = meta.getColumnCount();
    String [] tempColumnName = new String[columns];
    String [] ColumnName =null;
    int DisColumns = 0;
    int unDisCol = 0;
    String sLine = "";
    if(recResults.next()) {     //if_1
    for(int n=0;n<columns;n++) {
    String temp = meta.getColumnName(n+1);
    if(!temp.equals("PROJECTID")&&!temp.equals("BUILDINGID")&&!temp.equals("HAZMATPROFILEID")) {
    sLine = sLine + "'" + temp + "'" + " ";
    tempColumnName[DisColumns] = temp;
    DisColumns ++;
    ColumnName = new String[DisColumns];
    }else {
    unDisCol ++;
    }//end for
    for(int i=0;i<(columns-unDisCol);i++) {
    ColumnName[i] = tempColumnName;
    ps.println(sLine);
    do{
    sLine = "";
    for(int n=0;n<(columns-unDisCol);n++) {
    String tempColName = recResults.getString(ColumnName[n]);
    if(tempColName==null) {
    sLine = sLine + "" + " ";
    } else {
         sLine = sLine + "'"+tempColName+"'" + " ";
    ps.println(sLine);
    }while(recResults.next());
    }     //end if_1
    recResults.close();
    recResults = null;
    STrecResults.close();
    STrecResults = null;
    %>
    <!--end of processing data-->
    <!--start of download.jsp-->
    <%
    //set the content type to text
    response.setContentType ("plain/text");
    //set the header and also the Name by which user will be prompted to save
    response.setHeader ("Content-Disposition", "attachment;filename=temp.TXT");
    //Open an input stream to the file and post the file contents thru the servlet output stream to the client
    InputStream in = new FileInputStream(file);
    ServletOutputStream outs = response.getOutputStream();
    int bit = 256;
    try {
         while ((bit) >= 0) {
         bit = in.read();
    outs.write(bit);
    } catch (IOException ioe) {
    ioe.printStackTrace(System.out);
    outs.flush();
    outs.close();
    in.close();     
    %>
    <!--end of download -->

    Thanks. I believe something wrong with this statement
    in my program:
    You are correct there is something wrong with this statement. Seeing how you are doing this in a jsp, not really what they're made for but thats another topic, the output stream has already been called. When a jsp gets compiled it creates a few implicit objects, one of them being the outputstream out, and it does this by calling the response.getWriter(). getWriter or getOutputStream can only be called once, other wise you will get the exception you are experiencing. This is for both methods as well, seeing how the jsp compiles and calls getWriter means that you cannot call getOutputStream. Calling one makes the other throw the exception if called as well. As far as the filename problem in the browser goes I'm guessing that it's in IE. I've had some problems before when I had to send files to the browser through a servlet and remember having to set an inline attribute of some sort in the content-dis header inorder to get IE to see the real filename. The best way to solve this is to get the orielly file package and use that. It is very easy to use and understand and does all of this for you already. Plus it's free. Cant beat that.
    ServletOutputStream outs =
    response.getOutputStream();
    because I put a lot of printout statement within my
    code, and the program stops to print out exactly
    before the above statement. And then I get the
    following message, which repeats several times:
    ServletExec: caught exception -
    javax.servlet.ServletException: getWriter() was
    already called.

  • Remote function module to download the text file

    Hi Experts,
                   I have a requirement of text file should be downloaded from RFC connection by which function module.Can you please tell me whether this method is used to download text file (CALL METHOD cl_gui_frontend_services=>gui_upload).

    Hi Jaswanth,
    FM used to upload the data from the non sap system to the SAP sytem is the GUI_UPLOAD ans GUI_DOWLOAD is downloading the data from SAP to the presentation server .This file can be xls,tab or space deliminatior ettxt fiel.
    I think this was your requirement.
    Pooja

  • Download a text file to client machine

    Hello everyone,
    I'm trying to implement a report in EP6 SP2 version using Dynpage. I have it working perfectly, where in it displays the result in a Tree Format. But now the client wants a button, on clicking which it should download everything in a text file. I'm thinking of creating a text file and using FileOutputStream dumping the data into a text file. But I dont know how to open that text file or download it to the client machine ?
    Can someone helpme with this ?
    Thanks.

    Another thing you can do is create a table that you can insert the results of the UTL_FILE export. This table will basically track all of your UTL_file exports. You would just have to have three columns in the table. An ID, Filename, Directory. The ID would be your Primary Key, Filename would be the name of the file, and the Directory, would be directory in which the file is in. Then you can build a portal dynamic page that selects the results with a hyperlink. Then everything will work dynamically. Let me know if you have any questions.
    Thanks,
    Martin

  • Download a text file from JSP (Urgent Please!)

    Hi,
    I have a issue with this JSP, I need to download a txt file from my webserver to the pc client, the page shows the dialg box but appear the filename (list.jsp) of my jsp instead of the txt file.
    If I click the save buton save the list.jsp page; if I click in the open buton, then appear again the dialg box and now appear the url (download.jsp?filename=...) and if I click in the save button now I can save my txt file in the local pc.!!!!
    Any ideas ??
    list.jsp --> is the jsp from the download.jsp is run.
    download.jsp
    <%@ page import="java.io.*,javax.servlet.*,java.util.* "%><% String filename = request.getParameter("filename");
    response.setContentType("application/download");
    String value = "attachment; filename=\"" + filename + "\";" ;
    response.setHeader("Content-Disposition",value);
    int iRead;
    FileInputStream stream = null;
    try {
    File f = new File("C://test//" + filename);
    stream = new FileInputStream(f);
    while ((iRead = stream.read()) != -1) {
    out.write(iRead);
    out.flush();
    finally {
    if (stream != null) {
    stream.close();
    %>

    Maybe try no quotes around the content disposition header?
    Also, I'm not sure that application/download would be the best content type, maybe "application/octet-stream" instead. You should also probably explicitly set the Content-Length header to the file size.

  • Chinese characters GUI Download to text file

    hello
    i am facing the issue in my BP extraction program, which is extracting all the Business Partners from table BUT000
    to text file. I found related topic on the forum but it does not seem to work properly.
    I have a BP with name: 黄晖
    in SAP GUI.
    My code:
    CALL METHOD cl_gui_frontend_services=>gui_download
        EXPORTING
          filename                = wv_filename2
          filetype                = 'DAT'     
          append                  = 'X'
          write_field_separator   = 'X'
          col_select              = 'X'
          col_select_mask         = wv_file_mask
          codepage                = '4103'    
          write_bom               = 'X'       
        CHANGING
          data_tab                = wt_zessrin051_venex_new2
    after running my program, text file is generated, which I open in Excel (as simplified Chinese) with this result of the same BP name:
    臑Vf
    the result after extraction is not the same as in SAP.
    can anybody help on this?
    Thanks in advance

    works
    thanx

  • How to download a text file using jsp i

    I want to provide download facility in jsp page.
    if i have exe download is working . If I have a text / html file it is just displaying I want to make it download How to do it?
    regards
    subrahmanayma

    If you want to get an "Save as" dialogue, then you need to set the content-disposition in the header to "attachment". The default value is "inline".
    Best solution is to create kind of a FileServlet and let it stream the right file as a download to the client. You may find the downloadFile() snippets at the bottom of this article useful: http://balusc.xs4all.nl/srv/dev-jep-pdf.html Put it in a FileServlet and call it using for example .

  • Help with downloading pdf/text files itunes

    Hi,
    I am trying to download and view the text/pdf files from this link: https://itunes.apple.com/us/course/statistics-110-probability/id502492375 (files 1, 4, 11 and so on.. )
    However, I am not able to open the text/pdf file from the downloads window on itunes. I use itunes on mac.
    I would appreciate your help.
    Thanks
    Parang

    parangsaraf wrote:
    Hi,
    I am trying to download and view the text/pdf files from this link: https://itunes.apple.com/us/course/statistics-110-probability/id502492375 (files 1, 4, 11 and so on.. )
    However, I am not able to open the text/pdf file from the downloads window on itunes. I use itunes on mac.
    You don't open it in the download window.
    Select iTunes U in the left sidebar.
    If you don't see the left sidebar, iTunes menu View > View sidebar.

  • Html content download as text file

    In PL/SQL region, i get the result set like this
    <shesh>
    <deepak>
    <date>
    venkat
    sekar
    shanmuga
    when i try to export it as txt format, I get value like this
    "venkat"
    "sekar"
    "shanmuga"
    I get the values for <shesh>,<deepak>,<date> as double quotes only as specified above. Please do the needful
    Thank
    shesh

    Hello,
    Can you tell us how you do the export to txt?
    You could for ex create your own plsql procedure that provides you with the download in txt format and call that from a url.
    Regards,
    Dimitri
    http://dgielis.blogspot.com/
    http://www.apex-evangelists.com/
    http://www.apexblogs.info/

  • Download into text file

    Hi Abapers,
    i want to download the entries of "List of Quotations" ALV List in EXCEL file. Is it possible with any option ?
    "List of Quotation" appears by running transaction VA25. then press enter and then fill Sales Area and again press enter. Now the list appears I want to download this list in EXCEL File. also the same entries comes from Structure VBMTV.  So can I run this VBMTV structure.
    Plz help me out.
    Adams.

    Hi Adams,
    If its already a ALV list i think you can downlod the data into excel by the std functionality that comes with the ALV.
    Either you can use the download button from the applicationn tool bar or select from the Menu to download the data into excel.
    Cheers
    VJ

  • Download Text file to Local drive from BSP Application

    Hi Guys,
    I am new to BSP, and I am doing a BSP application in which i want to download a text file to local drive C: on click of button. For that I am having a data in Internal table and Onclick event, in model class method DO_HANDLE_EVENT i want to download text file to local machine drive.
    Can anybody provide me full code with all data declaration and all?
    Your help would be appriciable. Thanks in Advance.

    Hi Jessy ,
    You can download the file from BSP pages using the method
    CL_BSP_UTILITY=>download.
    Please follow the below mentioned steps.
    1.Convert the text to a text table ie Internal table with a line type char255 or some others.
    2.Convert the text table into a string.
    3.Convert the string to XSTRING.
    4.Download that XSTRING as text file using the method
       CL_BSP_UTILITY=>download.
    Parameters:
    OBJECT_S    - XSTRING data
    CONTENT_TYPE  =  ' application/download'
    CONTENT_DISPOSITION = 'attachment; file=test.txt'
    RESPONSE                   = runtime->server->response
    NAVIGATION                   = navigation
    OBJECT_T
    I dont have system to give a programatical explanation to u.
    If you have any doubt kindly post.
    Reward for every useful solutions..
    Best Regards
    Renga

Maybe you are looking for

  • Report generation toolkit help

    Hi, I have created a simple example to demonstrate my needs. Is it possible to write 16 numeric values (from my 16x for loop) "press and temp", to my new report (from my defined template). My two main issues are: Each time it iterates through the loo

  • Does new mini offer surround sound output?

    Earlier mini offered 5.1 surround sound output thru headphone jack.  Does new 2014 Mac mini offer surround sound through any of its' outputs, including the headphone jack?

  • Restoring iPhone 4 - help I dont want to lose my photos!

    iTunes is telling me my phone is in recovery mode and needs to be restored. I havent sync'd my phone in ages to iTunes so am worried if I restore it I will lose all my photos, data etc. Is there anyway around this??

  • Heterogeneous Connectivity to SQL Server from 8.0.5

    I read many topics in this forum relating to Heterogeneous Services (HS) but cannot find any documentation that details how to 'invoke' an HS connection through ODBC We need simple connectivity to a SQL-Server DB so there is no need to install Transp

  • SMS id shows 759-73; so no one can reply to an SMS...

    I have the caller id set to my cell number but when I send an SMS the receiver gets 759-73 as the sender. They can not respond to my SMS or figure who it is from? What good is that? HELP