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: 

FTP from app server to windows environment

Former Member
0 Kudos
1,374

I have a program that when it runs in background, creates a file on the app server. I would to be able to FTP the file to our network. I am testing the process with my C drive and I am not have much success. I am using the ftp_connect with the following parameters

USER = windows user

PASSWORD = windows password

ACCOUNT = blank

HOST = app server name

RFC_DESTINATION = IP address of my machine

GATEWAY parameters are all blank.

i am not able to create the connection. Do I have the parameters coded correctly?

thanks in advance for your help.

1 ACCEPTED SOLUTION

Former Member
0 Kudos
176

I was able to get a successful run for the RSFTP002 in background. I still can't get the file to FTP from the app server to the windows directory. I am running RSFTP002 with the following parameters

user = app ftp userid

password = app ftp user password

host - app server

cmd1 - cd DEV

cmd2 - get pwcextract.txt tim1012.txt

RFC destination - SAPFTPA

the background job shows the following spool

cd DEV

250 CWD command successful.

get pwcextract.txt tim1012.txt

200 PORT command successful.

150 Opening BINARY mode data connection for pwcextract.txt (900 bytes).

226 Transfer complete.

900 bytes received in 0.00 seconds (878.91 Kbytes/s)

I cannot use the LCD command because I get the following error message errno 2: No such file or directory.

question 1: where did this file get ftp-ed to ?

question 2 - is there a way for me to get this file onto a windows directory using the process explained or is there another way that I have to use to get a file from the app server to a windows directoy using a background process?

thanks for all the time already spent on this.

14 REPLIES 14

former_member181962
Active Contributor
0 Kudos
176

Try to create a RFc destination in sm59 transaction for your local PC and then use the name of the destination you have created for the RFC_DESTINATION.

have a look at this link for some idea:

https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/docs/library/uuid/9831750a-0801-0010-1d9e-f8c...

Regards,

ravi

Message was edited by: Ravi Kanth Talagana

Former Member
0 Kudos
176

Hi,

you can have a look at the standard program <b>'RSEPSFTP'</b>.

here is the sample code:-

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

Former Member
0 Kudos
176

sudheer,

I am using this code and I am getting the error.

I am not sure what the destination of 'SAPFTP'is.

Former Member
0 Kudos
176

i tried the FTP_CONNECT in sm37 with

USER = windows user

PASSWORD = windows password

ACCOUNT = blank

HOST = app server name

RFC_DESTINATION = SAPFTP

GATEWAY parameters are all blank

and

USER = app server user

PASSWORD = app server password

ACCOUNT = blank

HOST = app server name

RFC_DESTINATION = SAPFTP

GATEWAY parameters are all blank.

and both failed with message id = 04, message number 201,

Attempt to set up connection with <i>hostname</i> failed,

Former Member
0 Kudos
176

I am still confused on this process. I have looked at the link that was supplied and I have to wait for the basis person to get here. I am not comfortable with performing the tasks that have to do with the SAPRFC.INI file. Also I am confused on the sample code that is attached. I am trying to run the ftp_connect using se37. (see earlier replies) and I am still gettting the errors.

0 Kudos
176

Hi

Try ti see the demo program RSFTP00*

Max

Former Member
0 Kudos
176

Hi,

Seems you do not proper permissions or autorization to conect to FTP, make sure with your basis people whether you have the persion for that FTP and also passing the commands, sometimes we maynot have the autorizations on some commands and SAP also not supporting all the commands.

Regards

Sudheer

Former Member
0 Kudos
176

Sudheer,

the basis person gave me the user-id and the password for the app server. for starters, all i am trying to do is use ftp_connect thru se37 to try to connect to my machine.

I ran RSFTP001 which displays the SAPFTP information and below is the results

Path executable: C:\Program Files\SAP Clients\SAPGUI for Java 6.40rev6.8\bin\sapftp.exe

Version: 640

Current working directory: C:\Documents and Settings\thixson\Desktop

RFC path: C:\Program Files\SAP Clients\SAPGUI for Java 6.40rev6.8\bin\LIBRFC32.DLL

RFC version: 640

I am correct in assuming that any files that I transfer from the app server to my machine using SAPFTP will be stored in the current working directory

Former Member
0 Kudos
176

for RSFTP002 which executes a FTP command,

for the user, password and host - would this be the PC information or the app server information. the RFC destination is SAPFTP. if I put a DIR command in the <i>command 1</i> box would I see a dir listing from the app server or my PC.

Former Member
0 Kudos
176

I am able to ftp a file from the app server to the network drive using rsftp002. I have this program in my main program. when i set the sy_batch switch to X to simulate running in background the process works. when I actual run the process in background (I have another problem. when I run the job (execute in background F9) the process fails with the message "RFC to program SAPFTP failed ". I am little confused as to why this works with the sy-batch set to X and not in background processing.

thanks in advance

Former Member
0 Kudos
176

Hi,

Can you look at the below links

http://www.kabai.com/abaps/z104.htm

http://www.kabai.com/abaps/z07.htm

Regards

Sudheer

Former Member
0 Kudos
177

I was able to get a successful run for the RSFTP002 in background. I still can't get the file to FTP from the app server to the windows directory. I am running RSFTP002 with the following parameters

user = app ftp userid

password = app ftp user password

host - app server

cmd1 - cd DEV

cmd2 - get pwcextract.txt tim1012.txt

RFC destination - SAPFTPA

the background job shows the following spool

cd DEV

250 CWD command successful.

get pwcextract.txt tim1012.txt

200 PORT command successful.

150 Opening BINARY mode data connection for pwcextract.txt (900 bytes).

226 Transfer complete.

900 bytes received in 0.00 seconds (878.91 Kbytes/s)

I cannot use the LCD command because I get the following error message errno 2: No such file or directory.

question 1: where did this file get ftp-ed to ?

question 2 - is there a way for me to get this file onto a windows directory using the process explained or is there another way that I have to use to get a file from the app server to a windows directoy using a background process?

thanks for all the time already spent on this.

0 Kudos
176

Hi

You can't run the process in background if you have to get the file from your PC, because this is a frontend action and it doesn't work in background.

I believe if you need to run the process in background, the original path has to can seen by application server.

Max

Former Member
0 Kudos
176

Max

the file resides on the app server. I want to get it to the windows directory.

is there any way to get a file from the app server to a windows directory while running the job in background?