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 Problem

Former Member
0 Likes
1,132

Dear All,

I need to FTP a file or internal table to a server. I believe there are functions like FTP_CONNECT, FTP_COMMAND and FTP_DISCONNECT, but whenever I am trying to connect, it gives an exception as NOT CONNECTED. Please also explain me how to use the ftp commands in FTP_COMMAND function module. Please reply as soon.

Thankyou

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,064

You might want to refer to the weblog https://weblogs.sdn.sap.com/pub/wlg/994. [original link is broken] [original link is broken] [original link is broken] [original link is broken] [original link is broken] [original link is broken] [original link is broken] [original link is broken] [original link is broken] It is a really good one on FTP.

Regards,

Anand Mandalika.

10 REPLIES 10
Read only

Former Member
0 Likes
1,065

You might want to refer to the weblog https://weblogs.sdn.sap.com/pub/wlg/994. [original link is broken] [original link is broken] [original link is broken] [original link is broken] [original link is broken] [original link is broken] [original link is broken] [original link is broken] [original link is broken] It is a really good one on FTP.

Regards,

Anand Mandalika.

Read only

0 Likes
1,064

Hi Poornanand,

Thanks for the Web Log. It was informative.

Using RSFTP002, I had tried to set up a RFC connection but it says "Attempt to connect to <host> failed". I have also tried using RSFTP005 to check for my RFC destinations. They are fine too. Please let me know how I can resolve this probelm.

Read only

0 Likes
1,064

Hi Shiv,

If you look closely into the weblog, there is a mention of the function module AB_RFC_X_SCRAMBLE_STRING which encrypts the password. It is that encrypted password that you need to pass on to the FTP_CONNECT function module.

An alternate to this approach would be to have your OS experts to write a small ftp script for you and you call the script from your ABAP. If you need help in this approach, let me know.

Regards,

Srinivas

Read only

0 Likes
1,064

Hi Srinivas,

Using the credentials given, I was able to login through command prompt of OS, but I was not able to do so via ABAP, though I used the function module you mentioned about encryption.

On debugging, I found that the function module "FTP_CONNECT" is throwing an exception of Not Connected. Please respond on how I can go about it.

Thanks.

Shiv

Read only

0 Likes
1,064

Hi Shiv,

Did you do the test for ftp from the command prompt's local drive(on your desktop) or from your SAP server box?

If you did the test from your local drive, then the reason could be that your SAP server is not open for

ftp-ing out and may be in also. Please let me know the following details.

What is the OS of your SAP server?

What is the OS of your destination box to which you are ftp-ing?

Talk to your basis person to see if ftp is allowed from and to the SAP server. Typically they will lock it down. The next thing to check is whether ftp is allowed to the destination box just about from any box or not. The destination box may allowing only certain ftp protocols or from certain IP addresses only.

Please let me know your findings.

Srinivas

Read only

0 Likes
1,064

HI !!

I hope can you help me. I need make an FTP transfer of files in Background JOB.

I´m using the function FTP_CONNECT with SAPFTP in RFC_DESTINATION when execute from GUI Terminal and works fine !!!

But, when execute in Background Job using SAPFTPA in RFC_DESTINATION doesn´t connect to remote server.

Can you tell me whats wrong??... Thanks so much for read this message

Regards

Read only

andreas_mann3
Active Contributor
0 Likes
1,064

Hi Shiv,

i'll guess the prg. from the weblog is the best solution.

-> here's a "quick and dirty" one :

REPORT <b>RSFTP004</b>

regards Andreas

Read only

andreas_mann3
Active Contributor
0 Likes
1,064

Hi Mario,

at first plz check the connection with TA SM59-Test connection

regards Andreas

Read only

0 Likes
1,064

Hi Andreas:

Thanks for the answer. The results of test connection for SAPFTPA are the following:

Test conexión SAPFTPA

Tipo conexión: Conexión TCP/IP

Acceso: 855 mseg

0 kByte 3 mseg

10 kByte 3 mseg

20 kByte 4 mseg

30 kByte 4 mseg

I think that is OK.

However, the test connection for SAPFTP failed. The message is:

"timeout during allocate / CPI-C error CM_PRODUCT_SPECIFIC_ERROR"

But, i don´t understand why if SAPFTP works fine in foreground, SAPFTPA doesn´t works in Background JOB

Thanks !!

Read only

andreas_mann3
Active Contributor
0 Likes
1,064

Mario,

here's a ftp-prog, that works fine in batch:

REPORT zsftp004 . "copy of RSFTP004 (just dialog-progr.)

*-> batch processing possible with dest SAPFTPA

PARAMETERS:

*source

suser(64) TYPE c LOWER CASE,"user

spwd(64) TYPE c LOWER CASE MODIF ID 1,"password

shost(64) TYPE c LOWER CASE ,"hostname

sfile(256) TYPE c LOWER CASE ,"file

*destination

duser(64) TYPE c LOWER CASE ,

dpwd(64) TYPE c LOWER CASE MODIF ID 1,

dhost(64) TYPE c LOWER CASE ,

dfile(256) TYPE c LOWER CASE ,

*rfc

dest LIKE rfcdes-rfcdest DEFAULT 'SAPFTPA'.

DATA: shdl TYPE i,

dhdl TYPE i,

key TYPE i VALUE 26101957,

dstlen TYPE i.

DATA: BEGIN OF response OCCURS 0,

line(80) TYPE c,

END OF response.

AT SELECTION-SCREEN OUTPUT.

PERFORM mod_scr.

START-OF-SELECTION.

MESSAGE s000(yp) WITH 'Quelldatei:' sfile.

ULINE.

  • Connect to Source

DESCRIBE FIELD spwd LENGTH dstlen.

CALL 'AB_RFC_X_SCRAMBLE_STRING'

ID 'SOURCE' FIELD spwd ID 'KEY' FIELD key

ID 'SCR' FIELD 'X' ID 'DESTINATION' FIELD spwd

ID 'DSTLEN' FIELD dstlen.

CALL FUNCTION 'FTP_CONNECT'

EXPORTING

user = suser

password = spwd

host = shost

rfc_destination = dest

IMPORTING

handle = shdl.

  • Connect to Destination

DESCRIBE FIELD dpwd LENGTH dstlen.

CALL 'AB_RFC_X_SCRAMBLE_STRING'

ID 'SOURCE' FIELD dpwd ID 'KEY' FIELD key

ID 'SCR' FIELD 'X' ID 'DESTINATION' FIELD dpwd

ID 'DSTLEN' FIELD dstlen.

CALL FUNCTION 'FTP_CONNECT'

EXPORTING

user = duser

password = dpwd

host = dhost

rfc_destination = dest

IMPORTING

handle = dhdl.

  • Copy Files

CALL FUNCTION 'FTP_COPY'

EXPORTING

handle_source = shdl

handle_destination = dhdl

file_source = sfile

file_destination = dfile

TABLES

data = response

EXCEPTIONS

command_error = 1.

  • Disconnect

CALL FUNCTION 'FTP_DISCONNECT'

EXPORTING

handle = shdl.

CALL FUNCTION 'FTP_DISCONNECT'

EXPORTING

handle = dhdl.

LOOP AT response.

WRITE / response-line.

ENDLOOP.

&----


*& Form mod_scr

&----


FORM mod_scr.

LOOP AT SCREEN.

IF screen-group1 = 1.

screen-invisible = 1.

MODIFY SCREEN.

ENDIF.

ENDLOOP.

ENDFORM. " mod_scr

regards Andreas