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: 

Problem in FTP_Command_list

Former Member
0 Kudos

Hi,

Iam able to connect to remote server but the FTP_Command_list gives a error.

I have to put the file into the 😧 directory of the remote server.

This is my code:-

call function 'FTP_COMMAND_LIST'

exporting

handle = p_handle "is '1'

importing

command_index = l_cmd_index

tables

data = l_i_data

commands = l_i_commands " is 'cd D:\'

exceptions

tcpip_error = 1

command_error = 2

data_error = 3

others = 4.

if sy-subrc <> 0.

message id sy-msgid type sy-msgty number sy-msgno

with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

endif.

call function 'FTP_R3_TO_SERVER'

exporting

handle = p_handle

fname = p_files

character_mode = 'X'

tables

text = ifile.

I get the following error:-

cd D:\

550 D:\: The filename, directory name, or volume label syntax is incorrect.

Please send your suggestions,

Thanks,

Rajesh

5 REPLIES 5

raja_thangamani
Active Contributor
0 Kudos

Hi,

Try this code. I tested its working fine.

*&---------------------------------------------------------------------*
*& Report  ZLAMFTP_P                                       *
*&                                                                     *
*&---------------------------------------------------------------------*

REPORT  ZLAMFTP_P                               .
* Transport File from Presentation Server To FTP

PARAMETERS:
  I_L_PATH(64)  LOWER CASE TYPE C,        " Local File path
  I_L_FILE(250)   LOWER CASE TYPE C,      "Local File Name
  I_USERID(64)  LOWER CASE TYPE C,        " FTP User ID
  I_PWD(64)   LOWER CASE TYPE C,          "FTP PWD
  I_R_HOST(64)  TYPE C,                   " Host Address (FTP IP)
  I_DEST(32)   TYPE C  DEFAULT 'SAPFTP',  "SAP RFC
  I_R_PATH(64)  LOWER CASE TYPE C,        " Destination Path
  I_R_FILE(250)   LOWER CASE TYPE C.      " Destination File Name


DATA: MC_PASSWORD(20) TYPE C,
MI_KEY TYPE I VALUE 26101957,
MI_PWD_LEN TYPE I.

MC_PASSWORD = I_PWD.
DESCRIBE FIELD MC_PASSWORD LENGTH MI_PWD_LEN IN CHARACTER MODE.

*-- 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.
DATA:L_FILESPEC(100).
DATA:R_FILESPEC(100).
DATA:    FTP_HANDLE TYPE I.

*Set FTP File Paths

CONCATENATE I_L_PATH I_L_FILE INTO L_FILESPEC.
CONCATENATE I_R_PATH I_R_FILE INTO R_FILESPEC.

*----------------------------------------------------------------------*
*FTP Connect
*----------------------------------------------------------------------*

CALL FUNCTION 'FTP_CONNECT'
  EXPORTING
    USER            = I_USERID
    PASSWORD        = MC_PASSWORD
*    ACCOUNT         = '<Your Domain Name>'
    HOST            = I_R_HOST
    RFC_DESTINATION = I_DEST
  IMPORTING
    HANDLE          = FTP_HANDLE
  EXCEPTIONS
    NOT_CONNECTED   = 1
    OTHERS          = 2.

IF SY-SUBRC <> 0.
  MESSAGE ID SY-MSGID TYPE 'S' NUMBER SY-MSGNO WITH
  SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4
  RAISING NOT_CONNECTED.
ENDIF.
*----------------------------------------------------------------------*

*----------------------------------------------------------------------*
*FTP Command
*----------------------------------------------------------------------*


DATA: L_COMMAND(50).                         "Unix Command

CONCATENATE 'put' L_FILESPEC R_FILESPEC
INTO L_COMMAND SEPARATED BY SPACE.

DATA: BEGIN OF T_FTP_RESPONSE OCCURS 0,
      LINE(80) TYPE C,
      END OF T_FTP_RESPONSE.

CALL FUNCTION 'FTP_COMMAND'
  EXPORTING
    HANDLE        = FTP_HANDLE
    COMMAND       = L_COMMAND
  TABLES
    DATA          = T_FTP_RESPONSE
  EXCEPTIONS
    TCPIP_ERROR   = 1
    COMMAND_ERROR = 2
    DATA_ERROR    = 3
    OTHERS        = 4.

*----------------------------------------------------------------------*
*FTP Close
*----------------------------------------------------------------------*
* Close Connection

CALL FUNCTION 'FTP_DISCONNECT'
  EXPORTING
    HANDLE = FTP_HANDLE
  EXCEPTIONS
    OTHERS = 1.


LOOP AT T_FTP_RESPONSE.
  WRITE / T_FTP_RESPONSE-LINE.ENDLOOP.

Raja T

Former Member
0 Kudos

Hi raja,

I want to open a directory like c: or d: drive in the remote server and put the file in it. My program works fine for unix directory.

Thanks,

Rajesh.

0 Kudos

Rajesh,

Did you look at the code which i posted?

Raja T

Former Member
0 Kudos

Hi raja,

I get the same error. The file is not downloaded into remote server.

Obtained Error:

put D:\zur2.xls D:\zur2.xls

200 PORT command successful.

550 D:\zur2.xls: The filename, directory name, or volume label

syntax is incorrect.

Thanks,

Rajesh

0 Kudos

Hi,

From the error message i can see below lines

put D:zur2.xls D:zur2.xls

, Why do you do copy into same directory with same file name"

Like D:\zur2.xls --> D:\zur2.xls. I feel due to this reason also it may fail. Try to give different directory or File name.

Raja T

Message was edited by:

Raja T