Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

How to send ASCII file by FTP ?

former_member644785
Participant
0 Kudos

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

4 REPLIES 4

Former Member
0 Kudos

This message was moderated.

Florian
Active Contributor
0 Kudos

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

Tomas_Buryanek
Active Contributor
0 Kudos

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

-- Tomas --

tolga_polat
Active Participant
0 Kudos

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