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: 

Getting Data Error while calling FM FTP_R3_TO_SERVER

susrith2021
Explorer
0 Kudos

Hello experts,

I am getting exception code data error while calling FM: FTP_R3_TO_SERVER, below is the piece of code.

Could you please let me know what is wrong with the code ?

FORM download_xml.
IF d_xml IS NOT INITIAL.
slen = strlen( pswd ).
CALL FUNCTION 'HTTP_SCRAMBLE'
EXPORTING
source = pswd
sourcelen = slen
key = key
IMPORTING
destination = pswd.

CALL FUNCTION 'FTP_CONNECT'
EXPORTING
user = user
password = pswd
host = host
rfc_destination = dest
IMPORTING
handle = lv_handle
EXCEPTIONS
not_connected = 1
OTHERS = 2.

CONCATENATE wa_edidc-docnum '.xml'
INTO lv_command.

CALL FUNCTION 'FTP_R3_TO_SERVER'
EXPORTING
handle = lv_handle
fname = lv_command
character_mode = 'X'
TABLES
text = gt_data_tab
EXCEPTIONS
tcpip_error = 1
command_error = 2
data_error = 3
OTHERS = 4.
IF sy-subrc <> 0.
RAISE data_error.
ENDIF.

CALL FUNCTION 'FTP_DISCONNECT'
EXPORTING
handle = lv_handle.

CALL FUNCTION 'RFC_CONNECTION_CLOSE'
EXPORTING
destination = dest
EXCEPTIONS
destination_not_open = 1
OTHERS = 2.
ENDIF.
ENDFORM. "download_xml
1 REPLY 1

Sandra_Rossi
Active Contributor
0 Kudos

Communication error, password error, URL error, software error, authorization error, ... Who knows?

By the way, you don't handle all the exceptions, and you also lose information about the exact reason like tcpip_error, command_error, etc.

Check that the FTP works by using the program RSFTP001. There are other RSFTP* utility programs.