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 not working

Former Member
0 Likes
1,307

Dear friends

I am trying to transfer a file from my c drive file name c:\test.csv into a ftp location . I am using the below function modules.

call 'AB_RFC_X_SCRAMBLE_STRING'

call function 'FTP_CONNECT'

call function 'FTP_COMMAND'

call function 'FTP_DISCONNECT'

The first two function modules are giving a sy-subrc value of 0 but the third where we need to specify the ftp command which in my case is " put c:\test.csv " , is not working.

it is giving a command error (sy-subrc = 1) .

Kindy advice me what needs to be done for this.

Expecting a quick help.

Thanks in advance.

Dear friends

I am trying to transfer a file from my c drive file name c:\test.csv into a ftp location . I am using the below function modules.

call 'AB_RFC_X_SCRAMBLE_STRING'

call function 'FTP_CONNECT'

call function 'FTP_COMMAND'

call function 'FTP_DISCONNECT'

The first two function modules are giving a sy-subrc value of 0 but the third where we need to specify the ftp command which in my case is " put c:\test.csv " , is not working.

it is giving a command error (sy-subrc = 1) .

Kindy advice me what needs to be done for this.

Expecting a quick help.

Thanks in advance.

7 REPLIES 7
Read only

Former Member
0 Likes
1,160

Is that command already defined in sm49?

Read only

0 Likes
1,160

Hi Ravi

Basically I am using "put" command in order to transfer a file from my pc or application server to ftp location.

I did not find any entries of " put" command in sm49.

can you guide me how to go about this issue.

Regards

Read only

0 Likes
1,160

Hi,

I think If you are using the FM : SXPG_COMMAND_EXECUTE, command has to be created in SM49, with FTP FM's you can directly pass the unix commands.

Laxman

Read only

0 Likes
1,160

Hi

I am using the below 4 function modules

call 'AB_RFC_X_SCRAMBLE_STRING'

call function 'FTP_CONNECT'

call function 'FTP_COMMAND'

call function 'FTP_DISCONNECT'

I am getting error with 'FTP_COMMAND' function module.

the error is "command error".

When I debugged the function module 'ftp_command' the error description was

FTP subcommand: Local error

Kindly suggest.

Thanks in advance.

Read only

Laxmana_Appana_
Active Contributor
0 Likes
1,160

Hi,

Check these reports.

RSFTP002

RSFTP003

Laxman

Read only

Former Member
0 Likes
1,160

Hi,

Sample program for FTP

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.

<b>CALL FUNCTION 'FTP_CONNECT'</b>
     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.

<b>CALL FUNCTION 'FTP_COMMAND'</b>
     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.

<b>CALL FUNCTION 'FTP_DISCONNECT'</b>
     EXPORTING
       HANDLE = MI_HANDLE
     EXCEPTIONS
       OTHERS = 1.

Thanks

Sudheer

Read only

Former Member
0 Likes
1,160

Hi,

can you look at the program <b>RSEPSFTP</b>, you will understand where you are doing wrong..

Thanks

Sudheer