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 file transfer

Former Member
0 Likes
734

Hi All,

I am using program to do FTP. Here I am specifying the IP address of the target server to do the file transfer.

Can I use the same program to do FTP by providing "Host name" instead of ip address.

Thank you

jaison

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
695

Hi jaison,

1. Normally it will work,

if the network supports hostnames.

regards,

amit m.

5 REPLIES 5
Read only

Former Member
0 Likes
696

Hi jaison,

1. Normally it will work,

if the network supports hostnames.

regards,

amit m.

Read only

andreas_mann3
Active Contributor
0 Likes
695

yes,

look sample-program <b>rsftp004</b>

A.

Read only

Former Member
0 Likes
695

HI,

you can use the HOST name also.

see the below program which is using Host name

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

0 Likes
695

Hi ,

Can u plz tell me in the code below what CALL 'AB_RFC_X_SCRAMBLE_STRING' this belongs to ie is it a function module, or any user defined subroutine , or SAP statement.

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

Read only

0 Likes
695

Hi,

I think some changes in above code are required as follows...

mi_pwd_len = STRLEN( mc_password ).

*-- FTP_CONNECT requires an encrypted password to work

CALL FUNCTION 'HTTP_SCRAMBLE'

EXPORTING

SOURCE = mc_password

sourcelen = mi_pwd_len

key = '26101957'

IMPORTING

destination = mc_password.

This is how it worked when I changed the code...

Thanks