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 in ABAP

Former Member
0 Likes
548

Hi,

I need help to understand how FTP works on sending word files which is stored on UNIX server to WINDOWS server.

(The multiple word files are created in background job through RFC for the given input from ASP screen)

1. How can I do this from FTP?

2. Do I need to code in SAP to transfer that file or from the other end the ASP person needs to write the FTP code to read that file, for the UNIX path where I stored the file?

I read some of the topics in SDN on FTP, but I am not able to understand the 2nd point how it works, can any one explain me on this?

Thanks,

Kumar.

Hi,

I need help to understand how FTP works on sending word files which is stored on UNIX server to WINDOWS server.

(The multiple word files are created in background job through RFC for the given input from ASP screen)

1. How can I do this from FTP?

2. Do I need to code in SAP to transfer that file or from the other end the ASP person needs to write the FTP code to read that file, for the UNIX path where I stored the file?

I read some of the topics in SDN on FTP, but I am not able to understand the 2nd point how it works, can any one explain me on this?

Thanks,

Kumar.

3 REPLIES 3
Read only

Former Member
0 Likes
500

Try to run Unix commands in ABAP. Check the SDN-Download area where you will get the code to run Unix code in ABAP. Hope it helps.

Read only

Former Member
0 Likes
500

hi

good

go through these links, i hope these ll help you to solve your problem,

http://hoohoo.ncsa.uiuc.edu/ftp

http://abap4.tripod.com/Definitions.html

thanks

mrutyun^

Read only

Former Member
0 Likes
500

Hi,

See the below program,

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 <b>'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.

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

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

we use FTP_CONNECT function module to conect the UNIX system, for this we need to pass User name, password, Host name and the Destination, then we need to call FM FTP_COMMAND to pass a command to Unix, if you want to pass more commands then you need use this FM again, then we need to disconect this Conection.

See the below BLOG:

/people/thomas.jung3/blog/2004/11/15/performing-ftp-commands-from-abap

Regards

Sudheer