REPORT ZEXAMPLE.

DATA: FTP_USER(64) VALUE 'FTPUSER',

FTP_PWD(64) VALUE 'FTPPWD',

FTP_HOST(50) VALUE 'FTPSERVER',

RFC_DEST LIKE RSCAT-RFCDEST VALUE 'RFC_SERVER'.

DATA: HDL TYPE I,

KEY TYPE I VALUE 26101957,

DSTLEN TYPE I.

DATA: BEGIN OF FTP_DATA OCCURS 0,

LINE(132) TYPE C,

END OF FTP_DATA.

DESCRIBE FIELD FTP_PWD LENGTH DSTLEN.

CALL 'AB_RFC_X_SCRAMBLE_STRING'

ID 'SOURCE' FIELD FTP_PWD

ID 'KEY' FIELD KEY

ID 'SCR' FIELD 'X'

ID 'DESTINATION' FIELD FTP_PWD

ID 'DSTLEN' FIELD DSTLEN.

CALL FUNCTION 'FTP_CONNECT'

EXPORTING

USER = FTP_USER

PASSWORD = FTP_PWD

HOST = FTP_HOST

RFC_DESTINATION = RFC_DEST

IMPORTING

HANDLE = HDL

EXCEPTIONS

NOT_CONNECTED = 1

OTHERS = 2.

IF SY-SUBRC NE 0.

WRITE:/ 'COULD NOT CONNECT TO', FTP_HOST.

ELSE.

WRITE:/ 'CONNECTED SUCCESSFULLY. SESSION HANDLE IS', HDL.

CALL FUNCTION 'FTP_COMMAND'

EXPORTING

HANDLE = HDL

COMMAND = 'DIR'

TABLES

DATA = FTP_DATA

EXCEPTIONS

TCPIP_ERROR = 1

COMMAND_ERROR = 2

DATA_ERROR = 3

OTHERS = 4.

IF SY-SUBRC NE 0.

WRITE:/ 'COULD NOT EXECUTE FTP COMMAND'.

ELSE.

LOOP AT FTP_DATA.

WRITE: / FTP_DATA.

ENDLOOP.

CALL FUNCTION 'FTP_DISCONNECT'

EXPORTING

HANDLE = HDL

EXCEPTIONS

OTHERS = 1.

IF SY-SUBRC NE 0.

WRITE:/ 'COULD NOT DISCONNECT FROM FTP SERVER'.

ELSE.

WRITE:/ 'DISCONNECTED FROM FTP SERVER'.

ENDIF.

ENDIF.

ENDIF.