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: 

Command Error in FTP_COPY function module

Former Member
0 Kudos

I need to transfer file to non-sap server and I am using function modules FTP_CONNECT and FTP_COPY to do the same. FTP_CONNECT establishes connection to server but FTP_COPY fails with raising exception COMMAND_ERROR (CERROR = 2). We are unable to trace why exactly this exception is raised and what is the root cause for it.

Has anybody used these function modules to transfer file? Any experience or hints on mentioned error? Any kindly is very much appreciated. Thank you.

-Abhijit

3 REPLIES 3

Former Member
0 Kudos

Hello,

COMMAND_ERROR often means that the syntax of the FTP command is not correct and therefore the command fails.

I suggest that you first try the command at the prompt manually to see if is works, with the same user credentials (sidadm user).

If you have no OS access ask your basis guys to test the FTP maybe there is a security problem.

Also pass the handle parameter from the FTP_CONNECT function to the FTP_COPY function correctly.

Wim

0 Kudos

Hello Wim,

Thank you for your reply. Inside FM FTP_COPY there is call to 'FTP_COPY' (see below)

-


SET EXTENDED CHECK OFF.

CALL FUNCTION 'FTP_COPY' DESTINATION FTP_HANDLES-DESTINATION

EXPORTING HANDLES = HX-CONTROL FILES = FILE_SOURCE

HANDLED = FTP_HANDLES-CONTROL FILED = FILE_DESTINATION

IMPORTING ERROR = CERROR

TABLES DATA = DATA.

SET EXTENDED CHECK ON.

-


But while I am debugging my ABAP program, it doesn't step into 'FTP_COPY'. Instead it goes directly to next line in FM. Whatever command error I am getting, its inside occurring inside 'FTP_COPY'. But I cannot go inside it while debugging. Any ideas why?

-Abhijit

0 Kudos

Hello,

Did you use SAPFTP as RFC destination ?

What you also can do is take a look at the following SAP test programs who use the same function modules (FTP_CONNECT, FTP_COPY, ...):

RSFTP003 FTP put / get Test

RSFTP004 FTP Copy

RSFTP006 FTP command list

RSFTP007 Test FB:FTP_SERVER_TO_R3 / FTP_R3_TO_SERVER

RSFTP009 Test FTP put with Verify

RSFTP011 FTP Copy

I have always used these programs as a reference for FTP programmation with success.

Good luck.

Wim