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

ftp_command

Former Member
0 Likes
2,302

When i tried to call ftp_command fn module This is the error mentioned in the SAP job log:

Attempting to perform FTP transfer

Command Error

ascii

FTP transfer failed !

6 REPLIES 6
Read only

Former Member
0 Likes
1,492

Hi,

Here is the sample Program


REPORT 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.    

Regards

Sudheer

Read only

Former Member
0 Likes
1,492

hi,

Following are the ftp commands,

-? - use -? by itself to display a list of commands or add the -? switch to any command to obtain help on the syntax and use

dir - displays contents of the directory

cd - change directory

get - the command get \<filename> allows the download of a file

mget - allows download of multiple files – this command and those above may be performed with read permissions

put - the command put \<filename> uploads a file from the client host to the server. This and all subsequent commands require appropriate user permissions to write to the directory

mput - allows upload of multiple files

delete - entered as delete \<filename>

mkdir - entered as mkdir \<directoryname>

rename - entered as rename \<old_filename>

Hope it helps.

<b>rewards pint if helpful....</b>

Regards,

AbhaySingh

Read only

Former Member
0 Likes
1,492

Plz give point if u feel that our answer is satisfying....

Thanks

Abhay SIngh.

Read only

Former Member
0 Likes
1,492

First Check with Standard program : RSFTP002 and RSFTP00*

then see if ftp is connecting there ..

if not then there some correct parameter input error..

Regards

Prax

Read only

Former Member
0 Likes
1,492

To the ftp command module i am passing the handle as 1 and command as

put physicalfilename ftppath and verify as X . Now it is giving command error .

Please reply its urgent

Read only

Former Member
0 Likes
1,492

The error is : FTP subcommand: Server reports error