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

Similar Messages

  • Secure FTP from SAP

    Hi,
    How do you handle secure FTP from SAP without using scripting ?
    Is it possible to set up your RFC destination using the SSL option under the Logon/Security Tab ?
    Or is there another method ?
    Cheers
    Colin.

    Check out - Call   RSFTP020
    Here is an example of
    how to FTP a file from the Application server to a remote server using standard SAP functions.
    REPORT ZKBTST32 LINE-SIZE 132.
    Test SAP FTP functions
    DATA: BEGIN OF MTAB_DATA OCCURS 0,
    LINE(132) TYPE C,
    END OF MTAB_DATA.
    DATA: MC_PASSWORD(20) TYPE C,
    MI_KEY TYPE I VALUE 26101957,
    MI_PWD_LEN TYPE I,
    MI_HANDLE TYPE I.
    START-OF-SELECTION.
    MC_PASSWORD = 'password'.
    DESCRIBE FIELD MC_PASSWORD LENGTH MI_PWD_LEN.
    *-- FTP_CONNECT requires an encrypted password to work
    CALL 'AB_RFC_X_SCRAMBLE_STRING'
    ID 'SOURCE' FIELD MC_PASSWORD ID 'KEY' FIELD MI_KEY
    ID 'SCR' FIELD 'X' ID 'DESTINATION' FIELD MC_PASSWORD
    ID 'DSTLEN' FIELD MI_PWD_LEN.
    CALL FUNCTION 'FTP_CONNECT'
    EXPORTING
    USER = 'userid'
    PASSWORD = MC_PASSWORD
    HOST = 'servername'
    RFC_DESTINATION = 'SAPFTP'
    IMPORTING
    HANDLE = MI_HANDLE
    EXCEPTIONS
    NOT_CONNECTED = 1
    OTHERS = 2.
    CHECK SY-SUBRC = 0.
    CALL FUNCTION 'FTP_COMMAND'
    EXPORTING
    HANDLE = MI_HANDLE
    COMMAND = 'dir'
    TABLES
    DATA = MTAB_DATA
    EXCEPTIONS
    TCPIP_ERROR = 1
    COMMAND_ERROR = 2
    DATA_ERROR = 3
    OTHERS = 4.
    IF SY-SUBRC = 0.
    LOOP AT MTAB_DATA.
    WRITE: / MTAB_DATA.
    ENDLOOP.
    ELSE.
    do some error checking.
    ENDIF.
    CALL FUNCTION 'FTP_DISCONNECT'
    EXPORTING
    HANDLE = MI_HANDLE
    EXCEPTIONS
    OTHERS = 1.
    Hope this helps you,
    CHeers,
    THomas

  • How to make File Dialog in different color

    Hi to all,
    How to make File Dialog to appear in orange color.
    Regards
    khiz_eng

    I would like to know this also.....but it appears that there is not much you can do with an AWT FileDialog (not even moving it to the center of the screen).
    sigh....
    V.V.

  • How To Make File Association Changes Permenant

    I'm having a problem with file associations reverting back every time I turn of my computer.
    I'm using Finder "change all" function to change the file association.  It works until I turn off my computer.  Once rebooted file associations return.
    It's a real hassle.  For some reason MP4 files keep getting associated with Windows media player. Everytime I try to open one, parallalels loads up windows. 
    Any advise?

    ekohanowich wrote:
    how to make file able to open on pc
    I assume you mean Windows Computer.
    in Keynote:   file > export > PowerPoint
    Each Windows machine will need  Powerpoint or PowerPoint Viewer installed.

  • How to make file able to open on pc

    how to make file able to open on pc

    ekohanowich wrote:
    how to make file able to open on pc
    I assume you mean Windows Computer.
    in Keynote:   file > export > PowerPoint
    Each Windows machine will need  Powerpoint or PowerPoint Viewer installed.

  • Extracting a Report from SAP Spool into a Useful Excel 2010 Format

    Hi All,
    Extracting a Report from SAP Spool into a Useful Excel 2010 Format.  I'm currently running the following report in SAP  and would like the
    ability to set this report up as a recurring report running weekly and
    subsequently access this report in a useable Excel 2010 format without
    much data manipulation.  Can you please assist me.  Below, I've tried to
    provide an example of what I'm encountering.   Thanks, beforehand for
    your assistance.
    Here goes:
    Step one: Run 62 Report in SAP S_P99_41000062- Material List Price and
    Inventory
    Step 2. Select stored Variant "Weekly KPI", ok. Enter the enter  the
    desired company code and period I want thre report to run for and update
    the currency, if necessary. Having input my desired criteria, I believe
    I can either execute immediately, run in the background, preset to run
    at date in the future. For this example let's just execute, immediately.
    This is where the difference originates. Given, I run this report
    immediately, I'm able to simply extract the result to Excel via the list
    selection noted in the tool bar below.  The result is a data friendly
    excel 2007  report is automatically generated.
    Export to Excel via list:
    Select save and Excel 2007 opens automatically:
    That said, the method outlined above works perfectly fine if you want
    the report immediately.  Now let go back and run the exact same report
    with exceptoin of running it in the background and having to retrieve it
    from the Spool (SP01) uisng my user ID.  Given the report generated in
    the background,  I would now access the report via the spool and make
    the following selections:
    SP01 + execute to see my report
    I would hit the sunglasses to see the actual report, then want to
    extract this report to Excel by selecting the export option.
    I would at this point select spreadsheet and be given an option to save
    the spreadsheet to local file. However, upon trying to open the
    spreadsheet I will receive an error messageindicating that the format is
    different than that which the file I am currently trying to open it
    with.  I'm currently running Excel 2010 on my computer.  The currency
    format and other issues arrise with this extract.  Please help. 
    Thanks,
    Chowadary.

    Update to Latest GUI.
    Use   List -> Export -> Spreadsheet  to get the output to excel.
    I remember in ALV max length allowed is 1023 characters and the max no of columns supported is 90. Issue occurs when row size of exported data gets more than 1023 character. (This includes if Long/Medium Header Text used ) If it exceed 1023 character the columns splits and moves to next row.
    Check your fieldcatog for header lengths.
    -Satya

  • Idoc-xi-file scenario.  how to display file in html format

    I am not sure whether this is a valid question.........but want to confirm as it was asked by somebody
    In idoc-xi-file scenario.......  how to display file in html format ??
    Thanks in advance
    Kumar

    Hi Vijayakumar,
    Thanks for your reply !! You mean to say I got to use XSLT mapping and also .htm and .html extension together to produce the html file ?? or it is sufficient to use any one of them to produce the html file ??
    Regards
    Kumar

  • How do you send by secure ftp from SAP R/3 4.6C on iseries

    We have been using the SAP Standard program, RSFTP002, to ftp files to remote servers for many years. We have now had a requirement to send via secure ftp. We are using R/3 4.6C. Unfortunatley this is not a straight forward change and it seems we may need to install some client software to enable this.
    I have searched for any SAP notes and in several user groups but have not been too sucessful.
    Has anyone ever set this up before? What client software did you use?
    Any pointers / advice on this would be much appreciated.
    Many thanks,
    Steven

    Further to my initial post, I have now discovered that there are additional options on the ftp command on iseries, so I am hoping if I can perform this manaully, then a CL called from SAP would allow me to resolve this challenge.
    I am trying to use the command below but this will use the port 990.
    FTP RMTSYS(INTNETADR) INTNETADR('*.*.*.*') PORT(SECURE) SECCNN(*SSL)
    The vendor is requesting that we use port 443 for secure ftp with SSL and even specifying this in the command as below still does not work. It seems to me there may be an issue at the receiving end. Port 443 is normally used for https so not sure whether specifying this port could cause issues. The resultant error is below.
    FTP RMTSYS(INTNETADR) INTNETADR('*.*.*.*') PORT(443) SECCNN(SSL)
    Connecting to remote host 62.39.53.181 using port 443.  
    No response from remote host; all connections closed.
    Any other comments would be welcomed.
    Many thanks,
    Steven

  • Switching to MAC from Windows: How to open files in Office 2007  VMFusion?

    Dear all,
    Intro:
    I switched to MAC and now cannot find the solution to a simple problem.
    First: I need an Office 2007 PowerPoint FULLY compatible solution.
    What did not work: IWork, NeoOffice, Office 2008 (this is not fully compatible with Office 2007 Files)
    I also had problems with: Parallels (not stable, too many hangups), codeweaver crossover (office files do not even open sometimes, good idea but not suitable for serious office jobs)
    Now I have VMWare Fusion with WinXP and Office 2007 as this seems to be the only truly stable and best solution to run Office 2007 on Mac
    Question:
    How to open files in Office 2007 on MAC VMWare Fusion easily?
    It would be nice to spotlight the file and click and it opens in powerpoint or excel or word 2007 in Virtual Machine.
    The only known solution to me is to use the Windows explorer to navigate to the file and then open it from Fusion WinXP. This is very cumbersome and honestly makes me think of getting back to a windows machine as I work with office frequently.
    Thank you for your help.

    Thank you for the quick reply.
    Yes, I have Office 2007 installed. The problem is that to open files in Fusion virtual machine I have to use the windows explorer and navigate to the file to open it. Now that I have the mac I want to use the good feature of spotlight. So when I search and find the file I want to open I cannot click on it on the mac (or in finder) but I have to switch back to the virtual machine, locate the file again and open it from windows.
    You might think - ok, why not skip the first step of using spotlight, and look up the file in windows explorer before anything else?
    Correct, but I know from parallels that there is a file association possible to directly access the file in office 2007.
    This does not seem possible in Fusion - So the question is whether there is a possibility on the mac to associate the file and to click on it in finder/spotlight and the office 2007 application in fusion opens the file. So far I could not find anything.
    Thanks

  • How to make files read only

    I want to make files read only.  Any workaround is welcomed.

    t quinn wrote:
    ElMagoElGato,
    I am glad to give some help but I am still confused because we are having different experiences. I have been able to lock Tables on my mac and have that lock respected in iOS for a long while now. Easy to unlock, impossible to relock.  With the most recent upgrade I can lock tables after tapping the upper left dot to select the whole table and going to "arrange" in the paintbrush.
    When you say worksheet are you meaning the entire file? When you say file lock are you meaning password protection? You can see I am confused.
    quinn
    Based on what ElMagoElGato has described, password protecting would be of no value to him. Once the file is accessed, it is in edit mode. Unless I'm really missing something.
    Files I have imported from Mac iworks apps with elements locked stay locked for me in iOS. Not sure what the problem is.

  • Problem with hidden tabs working in CS5 from a converted page maker file

    I have run into some glitches with InDesign CS5 trying to convert my clients Page Maker file. I can open up the file but one of the most confusing issues is that it is not converting Page Maker’s tabs into an editable tab in InDesign. When I change the missing font to the font I am using for the layout design it creates these strange tabs. If I try to backspace to get rid of the tabs it will delete words on the previous line. When I reveal the hidden characters, no tab marks appear. I believe this might be because InDesign does not recognize the script Page Maker used to create it’s tabs? Does anyone have any recommendations for me?
    (above is a screen shot that shows the strange tabs)

    Those aren't tabs, they're a left indent on the paragraph coupled with a negative first line indent.

  • How to make file versioned automatically when it is created

    I am wondering it is possible to use the server side override to make file versioned when it is created. Does anyone have code to do it? Thanks a lot,
    Jean

    It might be possible. The difficult part is moving all the object creation code into an override. I did it by creating a new parser that always creates new documents as versioned (among other things) and have found that to work very well.

  • HT204382 Can anyone tell me how to open files in the format 'radio.ram' ?

    Can anyone tell me how to play files in radio.ram' format, as an add-on to QuickTime or whatever?

    Wow, that's a name from the past, Real Player. 
    And it worked.
    It's a product that I'd completely forgotten about going back to my days struggling with Windows on IBM clones and shows that I haven't tried listening to streaming Internet radio in a long, long time!
    Thank you very much, Varjak, for your help.
    Michael Young

  • 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.

  • XML Publisher - how to make column as date format in excel output

    Hi,
    I am having a XML publisher report , output is excel format. There are some date fields in reports, which are being displayed as "General" type in excel.
    Any way to restrict it in Date type only.
    Please explain the solution in detail. I am using rtf template.
    Regards
    Sandeep

    Hi Sandeep,
    I have the same issue. After looking at a lot of replies from various blogs, some suggest to use this format in your rtf.It did not work for me. You could try this and check if it works for you.
    <?format-date:datefied;’yyyy/MM/dd’?> where the format can be specific to your use.

Maybe you are looking for

  • Can not open linked files - word documents

    Hi, Currently running SLED10sp1 with Adobe Reader 7.0.8 at a school. Some educational CDs use PDF documents with links to various files on the CD, especially word .doc files. For example, one of the CDs has a start.pdf file in the root of the CD. Whe

  • Need Acrobat 9 pro install/download files

    Over the years, my group has purchased Acrobat 7 Pro, 8 Pro, and 9 Pro...  I have serial numbers for all of the above listed in my My Adobe/My Products area.  I have disks for both 7 and 8 pro... Unfortunately, when our purchasing agent bought 9 pro,

  • [Solved] External Hard Drive mount point in fstab crashes launch

    Hi there, I have an external hard drive that I'd like to automount when I plug it in. Sometimes it seems to work, but other times I have to manually mount it. In order to make this a little easier, I copied the mounting info into my fstab file so tha

  • Invoice list cancellation

    Dear All, We have two issues when we would like to cancel an invoice list: 1- The cancellation document type (copied from the original billing type LRS - credit memo list - in transaction VOFA) doesn't reverse the FI posting in the generated accounti

  • Lightroom 3 not accessing printer profiles

    I'm not able to access newly installed Epson R3000 printer profiles when I go to print in Lightroom 3.  The profiles do show up when I to print in PS3. I'm operating under 10.5.8 on my imac.