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

interface using ftp

Former Member
0 Likes
339

please give me an idea about the code of ftp interface.

can u give some code for customer data or any others?

1 REPLY 1
Read only

Former Member
0 Likes
307

Hi Abhijit Paul,

For Example :

data : v_handle TYPE i.

CONSTANTS: cs_key_500098 TYPE i VALUE '500098'.
DATA: it_itab(255) OCCURS 0 WITH HEADER LINE.
DATA: v_password(20) TYPE c,
i_key TYPE i VALUE 500098,
v_pwd_len TYPE i,
DATA: v_key TYPE i.

v_password = 'youreoneh'.
v_pwd_len = STRLEN( v_password ). and a constant key has to be passed.

CALL FUNCTION 'HTTP_SCRAMBLE'
EXPORTING
SOURCE = v_password
sourcelen = v_pwd_len
key = cs_key_500098
IMPORTING
destination = v_password.

Then :

CALL FUNCTION 'FTP_CONNECT'
EXPORTING
user = 'user_name'
password = v_password
host = '192.168.10.10' " for example
rfc_destination = 'SUNRFC' " for example
IMPORTING
handle = v_handle
EXCEPTIONS
not_connected = 1
OTHERS = 2.

Then : CONCATENATE sy-datum SY-TZONE '.txt' INTO v_filename.
CONCATENATE '//192.168.10.10/sap file/' v_filename INTO v_filename .

then use the 
CALL FUNCTION 'GUI_DOWNLOAD'
EXPORTING
filename = v_filename
write_field_separator = 'X'
TABLES
data_tab = ta_download
EXCEPTIONS
file_write_error = 1
no_batch = 2
gui_refuse_filetransfer = 3
invalid_type = 4
no_authority = 5
unknown_error = 6
header_not_allowed = 7
separator_not_allowed = 8
filesize_not_allowed = 9
header_too_long = 10
dp_error_create = 11
dp_error_send = 12
dp_error_write = 13
unknown_dp_error = 14
access_denied = 15
dp_out_of_memory = 16
disk_full = 17
dp_timeout = 18
file_not_found = 19
dataprovider_exception = 20
control_flush_error = 21
OTHERS = 22.

"Then finally Disconnect the connection:
CALL FUNCTION 'FTP_DISCONNECT'
EXPORTING
handle = v_handle
EXCEPTIONS
OTHERS = 1.

Regards,

Suneel G