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

RFC not connecting

Former Member
0 Likes
551

Dear Gurus

this is my code but i am not able to make an rfc connectivity. give me a way to connect rfc

&----


*& Report ZTARA *

*& *

&----


*& *

*& *

&----


REPORT ZTARA.

data: m_pasword(20) type c,

mi_key type i ,

mi_pwd_len type i,

mi_handle type i,

m_usr(30),

m_hst(20).

m_pasword = ''.

m_usr = ''.

mi_pwd_len = '14'.

m_hst = ''.

CALL FUNCTION 'HTTP_SCRAMBLE'

EXPORTING

SOURCE = m_pasword

sourcelen = mi_pwd_len

key = mi_key

IMPORTING

destination = m_pasword.

translate m_usr to lower case.

*do 3 times.

CALL FUNCTION 'FTP_CONNECT'

EXPORTING

USER = m_usr

PASSWORD = m_pasword

HOST = m_hst

RFC_DESTINATION = 'SAPFTP'

IMPORTING

HANDLE = mi_handle

EXCEPTIONS

NOT_CONNECTED = 1

OTHERS = 2.

if sy-subrc = 0.

write : / 'FTP Connection Ok...'.

exit.

else.

write : / 'FTP Connection failed...'.

endif.

  • enddo.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
519

Hi,

Increase your m_password length to more than 30 or 35 characters it will definitly work.

As your FTP server's password length must be of more characters so after HTTP_scrambel, length will be more than 20 characters than you have declared.

So scrambled password is getting only 20 characters.

<removed by moderator>

All the best.

Edited by: Thomas Zloch on Sep 23, 2010 5:32 PM - do not ask for ...

Hi,

Increase your m_password length to more than 30 or 35 characters it will definitly work.

As your FTP server's password length must be of more characters so after HTTP_scrambel, length will be more than 20 characters than you have declared.

So scrambled password is getting only 20 characters.

<removed by moderator>

All the best.

Edited by: Thomas Zloch on Sep 23, 2010 5:32 PM - do not ask for ...

3 REPLIES 3
Read only

Former Member
0 Likes
520

Hi,

Increase your m_password length to more than 30 or 35 characters it will definitly work.

As your FTP server's password length must be of more characters so after HTTP_scrambel, length will be more than 20 characters than you have declared.

So scrambled password is getting only 20 characters.

<removed by moderator>

All the best.

Edited by: Thomas Zloch on Sep 23, 2010 5:32 PM - do not ask for ...

Read only

0 Likes
519

Use below code for your reference

DATA : e_commands TYPE ty_commands.

DATA : t_commands TYPE TABLE OF ty_commands,

t_results TYPE TABLE OF ty_results.

DATA :

w_ftp_handle TYPE i,

w_length TYPE i.

CONSTANTS : w_key TYPE i VALUE 26101957,

w_rfcdest TYPE rfcdes-rfcdest VALUE 'SAPFTPA'.

w_hostname = w_host.

  • Get the length of the password

w_length = STRLEN( w_password ).

DATA : l_pwd TYPE c LENGTH 30.

CALL FUNCTION 'HTTP_SCRAMBLE'

EXPORTING

SOURCE = w_password

sourcelen = w_length

key = w_key

IMPORTING

destination = l_pwd.

  • Establish FTP Connection

CALL FUNCTION 'FTP_CONNECT'

EXPORTING

user = w_userid

password = l_pwd

host = w_hostname

rfc_destination = w_rfcdest

IMPORTING

handle = w_ftp_handle

EXCEPTIONS

not_connected = 1

OTHERS = 2.

IF sy-subrc EQ 0.

e_spool_data-text = 'FTP Connection successful'.

ELSE.

e_spool_data-text = 'FTP Connection failed'.

ENDIF.

Read only

0 Likes
519

thnks