Skip to Content
author's profile photo Former Member
Former Member

Data transfer through FTP

HI Friends,

Can any one tell me what is FTP ???And how we use FTP for data transfer????

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

3 Answers

  • author's profile photo Former Member
    Former Member
    Posted on Apr 29, 2008 at 08:48 AM

    FTP is a file transfer protocol for exchanging files over any TCP/IP based network to manipulate files on another computer on that network regardless of which operating systems are involved (if the computers permit FTP access).

    Thanks,

    Vibha

    Please mark all the useful answers

    Add a comment
    10|10000 characters needed characters exceeded

    • Former Member Former Member

      To FTP using ABAP, you can have a look at the standard program 'RSEPSFTP'.

      Here is an example of how to FTP a file from the Application

      server to a remote server using standard SAP functions.

      REPORT Ztestftp 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.

      Also here is another one.

      DATA: W_USER(12) TYPE C ,

      W_PWD(20) TYPE C ,

      W_HOST(64) TYPE C.

      DATA: HDL TYPE I,

      KEY TYPE I VALUE 26101957,

      DSTLEN TYPE I.

      DATA: BEGIN OF RESULT OCCURS 0,

      LINE(100) TYPE C,

      END OF RESULT.

      DESCRIBE FIELD PWD LENGTH DSTLEN.

      CALL 'AB_RFC_X_SCRAMBLE_STRING'

      ID 'SOURCE' FIELD PWD ID 'KEY' FIELD KEY

      ID 'SCR' FIELD 'X' ID 'DESTINATION' FIELD PWD

      ID 'DSTLEN' FIELD DSTLEN.

      CALL FUNCTION 'FTP_CONNECT'

      EXPORTING

      USER = USER

      PASSWORD = PWD

      HOST = HOST

      RFC_DESTINATION = 'SAPFTP'

      IMPORTING

      HANDLE = HDL.

      LOOP AT COMMANDS.

      IF COMMANDS NE ' '.

      CALL FUNCTION 'FTP_COMMAND'

      EXPORTING

      HANDLE = HDL

      COMMAND = COMMANDS

      TABLES

      DATA = RESULT

      EXCEPTIONS

      COMMAND_ERROR = 1

      TCPIP_ERROR = 2.

      LOOP AT RESULT.

      WRITE AT / RESULT-LINE.

      IF RESULT CS 'error'.

      RAISE NO_SUCH_FILE.

      ENDIF.

      ENDLOOP.

      REFRESH RESULT.

      ENDIF.

      ENDLOOP.

      CALL FUNCTION 'FTP_DISCONNECT'

      EXPORTING

      HANDLE = HDL.

      I hope it helps.

      Thanks,

      Vibha

      Please mark all the useful answers

  • author's profile photo Former Member
    Former Member
    Posted on Apr 29, 2008 at 10:24 AM

    Through FTP you can send any kind of file to a remote FTP server.You have to call the FMs in the following sequence.

    1.'FTP_CONNECT' : To establish a connection to the FTP server. You have to pass the IP address of the FTP server along with the user id and password.

    2.FTP_COMMAND: pass the filename with path which you want to transfer.

    3.FTP_DISCONNECT : Disconnect the connection

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Apr 29, 2008 at 10:31 AM

    some function modules for the same and their uses

    dont forget to award points

    1) HTTP_SCRAMBLE --> It will change the Password to the FTP format

    2) FTP_CONNECT --> It will conect to the FTP server (We need to Provide the IP address)

    3) FTP_R3_TO_SERVER --> This SAP R3 to Other Server and we need to pass the commands in this one

    4) FTP_DISCONNECT --> It will disconent the FTP Conection

    5) RFC_CONNECTION_CLOSE --> It wil close the Entire lick and Application

    Here is the Sample program for FTP

    codeREPORT ZFTPSAP LINE-SIZE 132.

    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.

    Your SAP-UNIX FTP password (case sensitive)

    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

    Your SAP-UNIX FTP user name (case sensitive)

    USER = 'userid'

    PASSWORD = MC_PASSWORD

    Your SAP-UNIX server host name (case sensitive)

    HOST = 'unix-host'

    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.

    WRITE: / 'Error in FTP Command'.

    ENDIF.

    CALL FUNCTION 'FTP_DISCONNECT'

    EXPORTING

    HANDLE = MI_HANDLE

    EXCEPTIONS

    OTHERS = 1. [/code]

    please award points

    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.