Skip to Content

How to send ASCII file by FTP ?

Hello,

Since we upgraded our BI plateform from AS400 to SQL Server, the files sent outside by FTP are in binary format.

Does anybody knows how to send them in ASCII format ?

We use 'FTP_COPY' command.

Thanks you in advance for your help.

Best regards,

Nicolas

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

4 Answers

  • author's profile photo Former Member
    Former Member
    Posted on Jan 06, 2014 at 09:27 AM

    This message was moderated.

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Jan 06, 2014 at 09:37 AM

    Hi,

    what is the problem. I do not see the mistake here. Does it matter, in which format the the file is transported?

    I mean, if you got an ASCII-File it will be an ASCII when moving to another location?

    Anyway, here is a link to the official helpportal how to configure an adapter. Maybe this help you out

    SAP Library - SAP NetWeaver Exchange Infrastructure

    Regards

    Florian

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Jan 06, 2014 at 02:07 PM

    Hi Nicolas,

    I am not sure about FTP_COPY FM functionality, but you can try archieve it by FTP_COMMAND FM calls.

    With 'ascii' as a command you can set FTP transfer to ASCII mode.

    And with other standard FTP commands like cd, ls, put, lcd... you can copy file, change dir... There are many examples on SCN and on other sites.

    By the way command to set binary mode is 'binary'.

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Jan 06, 2014 at 03:19 PM

    Hi,

    This is FTP code I wrote :

    CALL FUNCTION 'HTTP_SCRAMBLE'
         EXPORTING
           source      = lv_pass
           sourcelen   = lv_lenght
           key         = lv_key
         IMPORTING
           destination = lv_pass.
    
       CALL FUNCTION 'FTP_CONNECT'
         EXPORTING
           user            = lv_user
           password        = lv_pass
           host            = lv_host
           rfc_destination = lv_dest
         IMPORTING
           handle          = lv_handle
         EXCEPTIONS
           not_connected   = 1
           OTHERS          = 2.
    
       CHECK sy-subrc EQ 0.
    
       CONCATENATE vbeln " Sales order number is the file name
                   '.txt'
              INTO lv_fname.
    
       CALL FUNCTION 'FTP_R3_TO_SERVER'
         EXPORTING
           handle         = lv_handle
           fname          = lv_fname
           character_mode = 'X'
         TABLES
           text           = lt_lines " table with ASCII data
         EXCEPTIONS
           tcpip_error    = 1
           command_error  = 2
           data_error     = 3
           OTHERS         = 4.
       IF sy-subrc <> 0.
     * Implement suitable error handling here
       ENDIF.
    
    CALL FUNCTION 'FTP_DISCONNECT' EXPORTING handle = lv_handle. CALL FUNCTION 'RFC_CONNECTION_CLOSE' EXPORTING destination = lv_dest EXCEPTIONS OTHERS = 1.

    You can find more example from SCN just search this functions.

    Regards

    Tolga

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.