SAP Query : Save to file in XLS format in background

Hello everybody,
I used the enhancement SQUE0001 for saving result (an XLS file) of SAP query in background.
I used also the ABAP commands 'OPEN DATASET', 'TRANSFER' and 'CLOSE DATASET' as described in the SAP note 537735.
The execution of SAP query generated multiple columns. But when I go to see my downloaded file (.xls), all generated columns are condensed into 1  !!!
How to save the file (.xls) and keep the separated columns, please?
Thanks for your answers.

For saving the file in Excel format in the App server you have to first convert the data in XLS format and then use the transfer statement.
You can either use FM SAP_CONVERT_TO_XLS_FORMAT for that.
OR
Create a comma sepreated file which will open in excel.
  open dataset file for output in text mode.
  loop at itab.
    concatenate itab-field1 itab-field2 itab-field2 into str
                  separated by ','.
    transfer str to file.
  endloop.
  close dataset file.

Similar Messages

  • Save one file in different formats at once.

    Hello,
    I am a illustrator who needs to save files in different formats. Like 1 with a watermark, one small one for the website, another one for shop, a pdf file for the prints, etc. Is there a way to do all those things at once? Cause it really takes a lot of time.
    I make my illustrations in photoshop, but if it's nessecary to only do those thing in another adobe programm, than that's no problem.
    Please help, thank a lot!
    Renske

    Or try Image Processor Pro:
    http://blogs.adobe.com/jnack/2011/05/new-image-processor-pro-script-for-cs5.html

  • How to save a file in Java Format?

    Hello All,
    I want to save the files I'm writing in my program in java format?
    (I want the result files to end with .java).
    Is there a specific way to do this?
    Thnx in advance :)

    Wait. Are you saying that your java program is creating files, and you want the files to end in .java?
    Are you writing a program that creates other programs? Because otherwise that makes no sense.
    Or are you saying that you're writing Java source code in some editor, and you just want the editor to save the source code files with the appropriate extension? If so, how you do that will depend on the editor.

  • Do we have to save CWK files in another format

    I'm having to move on from my eMac (OS 10.3.9) which has useful Claris files and applications saved and accessed through Classic.
    I understand that the Intel based iMac (my replacement to the existing eMac) does not support Classic. So I am concerned about how to utilise my stored Claris data.
    Do I have to save prefered files in any special format so that they will be readable by the Intel ?
    And what about the old but very useful applications ?
      Mac OS X (10.3.9)  

    Install SheepShaver onto the Intel Mac as well as a full Mac OS 7.52 through 9.04 system, the Claris application, and the Claris documents. You can then use your old applications and documents as is.
    (12878)

  • When we save a file in excel format from the webpage, the alignment of columns is disturbed which does not happen in IE, P

    We are using Oracle Apps. wherein we have an options to export the contents of the web page. It default stores the file in .tsv format. if we choose to save the file in excel then the file is saved. however when we open the file in excel, the text is garbled. If we try the same option using IE, then the text is automatically aligned as required.

    Dear cor-el, wow you are quick. I understand you better now, but I'm not sure it's a good idea to write to you in dutch, only if you are Dutch yourself.
    Anyway, first the location bar is what I call the address bar.
    Second I work very simple and easy. I never use the address bar when I'm looking for a website.
    I just type the name of whatever I'm looking for in the empty bar on my google page and wait for the response.
    Third, most of the sellers I buy from on ebay, I just discovered by accident and I immediately saved them in my favorites bar.
    So if I need to go to their website(s) I just go to my favorites bar and click on the name of the seller(s) I'm looking for.
    Now to answer the question from your earlier letter, the URL's I'm trying to save are those from the webpage(s) I open on the websites I visit and not from the website(s) itself.
    The second part of your last letter from " You can modify......" is too difficult for me to understand.
    If it's important I'll ask a friend, a mainframe specialist to explain it to me.
    Thanks again for help. Regards, Ruiz

  • Downloading file in xls format

    Hi All,
    I have a program that downloads data from a server to the local machine in xls format, via a JSP. The data comes from a ResultSet which I read and convert to csv format, but using ";" as the separator (it works..) and "\n" for each new line I require. I then set the response to download the file. Eveything works fine when I run the web application locally, the file downloads and opens in Excel, BUT when I do the same accessing a remote server running on Solaris, I have a problem opening the downloaded xls. Everything works fine until I try to open the file, Excel tells me that it can't read the first record.
    Here's my code:
    String path = servlet.getServletContext().getRealPath("/");
    PrintWriter printWriter = new PrintWriter(new OutputStreamWriter( new FileOutputStream( path+ "upload/excel.csv" )));
    String data;
    String fileName; // a filename set when I read the data
    // read data, put ";" and "\n" where required
    printWriter.println(data);
    printWriter.close();
    response.setContentType("application/binary");
    response.setHeader("Content-Disposition","attachment" + ";fileName=\"" + filName + ".xls" + "\"");
    RequestDispatcher rd = request.getRequestDispatcher("destination.jsp");
    rd.include(request, response);
    It works from Windows to Windows, but something's amiss when I try it from Solaris to Windows.
    Any help is greatly appreciated!!

    Most probably it has to do with line.separator system property which is different between windows and unix.
    I noticed you using a printWriter.
    The println method will use the appropriate line separator for the platform it is running on. (from the System properties)
    I would try saving the file to disk rather than opening, to see if you can discern the differences.
    Also - what does the included jsp do? does it just include the newly created file?
    Do you need that file? Could you just stream it straight out to the user?
    ie instead of sending it to a FileOutputStream, send it to the ServletOutputStream.
    Hope this helps some,
    evnafets

  • Using "Save As" execCommand in IE8 to save XML file in ANSI format instead of UCS2-Little Endian

    I am currently trying to save an XML data using "SaveAs" execCommand  from Javascript in Internet Explorer 8 only.I am using document.write(xml) to write the xml content after i open a window.The document object in IE8 uses a saveAs Exec
    Command to allow the user to save the xml file in the local folder.The XML file is generated but it doesnt set the encoding to my preferred type  for a different interface where i need to send this XML which is ANSI/UTF-8   encoding.I can only save
    the XML in UCS2 little Endian encoding format.Below is the code i am using.
         var location = "D:\\export_to_MCT"+dateTime+".xml";
            var xml = tmpSelectedConfigurationXML.transformNode(xslDoc);// XML Is generated here
           alert(xml);
             **var testlink = window.open  ("about:blank","_blank","toolbar=no,status=no,menubar=no,scrollbars=no,resizable=no,left=10000, top=10000, width=10, height=10, visible=none");
             testlink.document.write(xml); //fileData has contents for the file
        testlink.document.close();
        testlink.document.execCommand('SaveAs', false, location);**
        testlink.close();
    My purpose is to save the xml  in ANSI/UTF-8 encoding without BOM format.I cant use Scripting.FileSystemObject method of ActiveX object.Please suggest

    @panda Boy--
    But my intention isnt that .I need to download the xml in ANSI format

  • How to save text file in same format for PC/Mac?

    I have a text file on my Macbook.  It doesn't have any special formatting.  I save it to Dropbox and open it on my PC (Vista).  All of the carriage returns are missing and text is a big run on.  How do I get carriage returns to transfer to the PC?

    Thanks Linc.  Looks like I need to start using TextWrangler.  I pasted from the TextEdit txt file into TextWrangler and carriage returns were missing.  I formatted the file, saved with Windows CRLF format and it looks fine on Windows.  Is that the correct format?

  • A website offers me to save a file as .xls, but when I try to save, it gets saved as .do file type?

    The service website offers 3 options:
    Save as csv
    Save as xls
    Save as xml
    All 3 options when tried to save, saved as a .do file. Why is it so?

    Did you try to add the correct file extension yourself when saving the file?
    *https://support.mozilla.org/kb/Downloads+window

  • FTP from SAP - how to make file UTF-8 format?

    We are collecting data from SAP on a 4.7 system  and sending it as an psv file to an external server using the FTP function modules . We do not have XI.  After being told we were missing the BOM id I added this to the first line of the file.
    DATA: l_len TYPE i.
      DATA: c_cr(1).
      DATA: c_bom(3)    TYPE x.
      CLASS cl_abap_char_utilities DEFINITION LOAD.
      c_cr = cl_abap_char_utilities=>cr_lf.
      c_bom = cl_abap_char_utilities=>byte_order_mark_utf8.
      gs_ftp = c_bom.
      APPEND gs_ftp TO gt_ftp.
      CLEAR gs_ftp.
      LOOP AT gt_survey INTO gs_survey.
    *create file
        CONCATENATE: gs_survey-division
                     gs_survey-bus_unit
                     gs_survey-site
                     gs_survey-survey
                     gs_survey-co_name
                     gs_survey-kunnr
                     gs_survey-first_name  INTO gs_ftp-record SEPARATED BY '|'.
    * Work out length of string in GS_FTP_RECORD and populate last character
    * with a carriage return.  This will denote the end of the line.
        l_len = STRLEN( gs_ftp-record ).
        SUBTRACT 1 FROM l_len.
        gs_ftp-record+l_len(1) = c_cr.
        APPEND gs_ftp TO gt_ftp.
      ENDLOOP.
    We then  scramble the password and open the FTP and then call commandFTP_COMMAND  before calling FTP_R3_TO_SERVER:
    * Find out how many lines exist in GT_FTP
        DESCRIBE TABLE gt_ftp LINES sy-tfill.
    * Width of table x no. of lines in GT_FTP
        l_blob = 1024 * sy-tfill.
        CONCATENATE: 'CSVC1_SO' sy-datum '_' sy-uzeit '.psv' INTO g_file.
    * Set command to transmit in ASCII
        CALL FUNCTION 'FTP_COMMAND'
          EXPORTING
           handle                = v_handle
            command               = 'ascii'
          TABLES
            data                  = result
    * EXCEPTIONS
    *   TCPIP_ERROR           = 1
    *   COMMAND_ERROR         = 2
    *   DATA_ERROR            = 3
    *   OTHERS                = 4
        IF sy-subrc <> 0.
    * MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    *         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
        ENDIF.
    * Send file onto FTP
        CALL FUNCTION 'FTP_R3_TO_SERVER'
          EXPORTING
            handle         = v_handle
            fname          = g_file
            blob_length    = l_blob
            character_mode = 'X'
          TABLES
            text           = gt_ftp
          EXCEPTIONS
            tcpip_error    = 1
            command_error  = 2
            data_error     = 3
            OTHERS         = 4.
    Any ideas?

    As far as I see, you are opening the FTP-Connection in ASCII-Mode.
    This means that the Data transfered is "converted" in a way as the FTP-Server think its correct.
    Try to open the FTP-Connection in Binary mode, hopefully this helps?
    Regards
    Rene

  • Error when save a file as .wav format

    I was trying to save some sound pressure data into .wav file.  I have a single wavform channel looks like this:
    Once saved as .wav file, the data becomes:
    What did I do wrong?

    The *.wav file specification says that the DBL data type may only be used if all the channel values are between -1 and +1.  That channel exceeds these limits slightly, therefore an integer data type is used.
    You can simply rescale the channel prior to saving-- either smaller in amplitude to use the DBL data type or larger in amplitude to use the full range of an Int16 or an Int32.

  • Will you save my file in another format for me?

    I will send you the file which is from CS5, and then you save it as CS2, send me it, then I can see it.
    Tell me your e-mail or e-mail me so I can see your e-mail. [email protected]
    Thanks
    BTW it's a small file.

    I only heard it in passing while reading some tut a while back.
    I've never personally tried it... never had the need or opportunity as we usually upgrade to the new CS tout de suite
    Re-Edit: Thanks ♥

  • Can i format the drive to ntfs - cant save large files

    i bought the TimeCapsole Extreeme AC but i cant save large files - can i format the drives to NTFS??
    is there any other soultion to this?
    Tx

    The thing is that in windows its a map drive that i can see the files but cant save large files(more then 4GB)
    Ok.. I am rather shocked but of course the problem is entirely windows.. The drive is formatted HFS+ and a 3TB drive has no file size limitation other than the drive size.
    Windows for some stupid reason when it maps drives has decided it must be FAT32 and applied that.
    Get rid of the drive mapping.. !!
    Try accessing it via network.. ie
    \\TCIPaddress and see if you can get around the 4GB file size barrier. If not I will take another look at the problem.. although I have to say windows is windows..
    It should see the TC as a NT Server and have no file size limitation at all.

  • To Download a file to XLS(default) format using KD_GET_FILENAME_ON_F4

    Hi,
    I want to download a file in XLS format.
    While using KD_GET_FILENAME_ON_F4 FM .
    When i get a pop up window ,i need the default filetype to be shown as XLS file type.

    I am declaring like this.
      CALL FUNCTION 'KD_GET_FILENAME_ON_F4'
           EXPORTING
             program_name        = syst-repid
             dynpro_number       = syst-dynnr
            FIELD_NAME          = 'rt'
            static              = 'X'
             mask                = ',.XLS,*.xls'
            CHANGING
              file_name           = lv_filepath
    EXCEPTIONS
       mask_too_long       = 1
       OTHERS              = 2.

  • How to Save a File in Oracle Forms 6 ?

    Dear All,
    I am using Oracle Forms 6. I need to save a file in .lst format.
    I am using,
    flnm:=get_file_name('E:\',file_filter=>'Text Files(*.lst|*.lst|');
    I f I use this, It prompts me to save the file. I want to save it automatically without asking me to enter the file name. We can get file name too from the above syntax
    flnm:=get_file_name('E:\','Test',file_filter=>'Text Files(*.lst|*.lst|');
    But i dont want the system to prompt me to save manually. It must be saved in the proper location as mentioned.
    Advance thanks for all.
    Kindly help me to overcome this issue

    Here's an example of a way to write out a file which writes out data from a particular block. The field names are hard coded so need to
    be customized:
    /* write out data as tab delimited file for import into
    excel etc */
    function write_file (myfile in varchar2) return varchar2 IS
      out_file          text_io.file_type;
      item_name varchar2(32);
      errnum number := ERROR_CODE;
      errtxt varchar2(80) := ERROR_TEXT;
      myblock varchar2(32) := 'MY_BLOCK';
      addrno integer := 0;
    BEGIN
      go_block(myblock);
      go_record(1);
      out_file := text_io.fopen(myfile,'w');
    /* output field header for excel or word */
      text_io.putf(out_file,'%s\n', 'notes' || chr(9) || 'subR' || chr(9)||'X' || 'someid' || chr(9)  ||
        'title' ||chr(9)||
            'first_name'||chr(9)||'last_name'||chr(9)||
          'home_address'||chr(9)||'home_city'||chr(9)||'home_state'||chr(9)||'home_zip');
      LOOP
            if (addrno > 0) then
                   text_io.putf(out_file,'\n');
            end if;
            addrno := addrno + 1;
            text_io.putf(out_file,'%s',:MY_BLOCK.some_notes || chr(9));
            text_io.putf(out_file,'%s',:MY_BLOCK.sub_ripple || chr(9));
            text_io.putf(out_file,'%s','X' || :MY_BLOCK.someid || chr(9));
            text_io.putf(out_file,'%s',:MY_BLOCK.title || chr(9) || :MY_BLOCK.first_name
                            || chr(9) || :MY_BLOCK.last_name || chr(9));
            text_io.putf(out_file,'%s',:MY_BLOCK.home_address || chr(9));
            text_io.putf(out_file,'%s',:MY_BLOCK.home_city || chr(9) || :MY_BLOCK.home_state ||
               chr(9) || :MY_BLOCK.home_zip);
            IF :SYSTEM.LAST_RECORD = 'TRUE' THEN
             EXIT;
         END IF;
         NEXT_RECORD;
      END LOOP;
    text_io.fclose (out_file);
    return 'Y';
       exception
         when others then
             message ('ERROR write_file '|| myfile || ' ' || :system.cursor_block || ' '
             || :system.cursor_record || ' ' ||:system.cursor_field || ' '
              || errnum || ' ' || errtxt);
             bell;
             synchronize;
             return 'N';
    END;

Maybe you are looking for