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 site

Former Member
0 Kudos
83

Hi,

How to download the flat file on FTP server. If any once come accross the situation pls explain the steps in details

Thnaks

cheers,

Bala

1 ACCEPTED SOLUTION

athavanraja
Active Contributor
0 Kudos
61

check out the following weblog.

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

Regards

Raja

2 REPLIES 2

athavanraja
Active Contributor
0 Kudos
62

check out the following weblog.

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

Regards

Raja

Former Member
0 Kudos
61

See function group SFTP, it contain all the function module which will access FTP and find below simple example code

REPORT zsatya .

DATA: BEGIN OF T_DATA OCCURS 0,

LINE(132) TYPE C,

END OF T_DATA.

DATA:

W_KEY TYPE I VALUE 26101957,

W_PWD_LEN TYPE I,

W_HANDLE TYPE I.

parameters : p_bname(12) type c lower case default 'asadm'.

PARAMETERS : P_BCODE(20) TYPE C LOWER CASE DEFAULT 'asls'.

PARAMETERS : P_HOST(50) TYPE C LOWER CASE DEFAULT ' '. " application server

  • start-of-selection.

  • perform read_dataset.

  • FTP_CONNECT requires an encrypted password to work

DESCRIBE FIELD P_BCODE LENGTH W_PWD_LEN.

CALL 'AB_RFC_X_SCRAMBLE_STRING'

ID 'SOURCE' FIELD P_BCODE ID 'KEY' FIELD W_KEY

ID 'SCR' FIELD 'X' ID 'DESTINATION' FIELD P_BCODE

ID 'DSTLEN' FIELD W_PWD_LEN.

  • FTP Connect to server

CALL FUNCTION 'FTP_CONNECT'

EXPORTING

USER = P_BNAME

PASSWORD = P_BCODE

HOST = P_HOST

RFC_DESTINATION = 'SAPFTP'

IMPORTING

HANDLE = W_HANDLE

EXCEPTIONS

NOT_CONNECTED = 1

OTHERS = 2.

*

IF SY-SUBRC = 1.

MESSAGE ID SY-MSGID TYPE 'I' NUMBER SY-MSGNO "SY-MSGTY

WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

EXIT.

ELSE.

  • Send a DIR command to give a directory of the server

CALL FUNCTION 'FTP_COMMAND'

EXPORTING

HANDLE = W_HANDLE

COMMAND = 'ls'

TABLES

DATA = T_DATA

EXCEPTIONS

TCPIP_ERROR = 1

COMMAND_ERROR = 2

DATA_ERROR = 3

OTHERS = 4.

IF SY-SUBRC = 0.

LOOP AT T_DATA.

WRITE: / T_DATA.

ENDLOOP.

ELSE.

MESSAGE ID SY-MSGID TYPE 'I' "

NUMBER SY-MSGNO "SY-MSGTY

WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4. "

ENDIF.

  • close the session.

CALL FUNCTION 'FTP_DISCONNECT'

EXPORTING

HANDLE = W_HANDLE

EXCEPTIONS

OTHERS = 1.