‎2008 May 21 6:46 PM
Hello,
I'm calling an RFC from system A to system B.
In system B the RFC must read a flat file via FTP using FM 'FTP_CONNECT' and 'FTP_SERVER_TO_R3'.
The connection parameters (user, password, host...) are incrusted in the code. When I test the RFC in local machine it works perfectly, it reads the file and returns the result. But when I call it remotely it doesn't works fine.
I've generated a log of the execution and I've found that the problem is when I call 'FTP_CONNECT'. It gives me an EXCEPTION (NOT_CONNECED) but I don't know why... The parameters are the same when I test and when I call it remotely...
What can I do to solve that?
‎2008 May 21 6:48 PM
Check this sample code:-
REPORT ZKBTST32 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.Thanks,
Naren
‎2008 May 21 6:51 PM
Hi Naren,
I already know how to use FTP_CONNECT. I've programmed my Function module and it works OK. The problem is when I execute it remotely, I don't know why but FTP_CONNECT gives me an error when I use it via RFC...
‎2008 May 22 9:12 AM