Application Development and Automation 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: 
Read only

Data transfer through FTP

Former Member
0 Likes
2,203

HI Friends,

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

6 REPLIES 6
Read only

Former Member
0 Likes
1,847

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

Read only

0 Likes
1,847

Hi Vibha,

Could u be more clear how we use FTP in our program to transfer the data???

Read only

0 Likes
1,847

You can use FTP by writing a small script at the operating system level, not from within SAP. For example, in Windows NT, enter appropriate commands in a text file opened with Notepad.

Edited by: Harris Veziris on Apr 29, 2008 10:54 AM

Read only

0 Likes
1,847

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

Read only

Former Member
0 Likes
1,847

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

Read only

manubhutani
Active Contributor
0 Likes
1,847

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