Try below code,
DATA: l_user(30) TYPE c VALUE ' SAPABAPER', ',"" "user name of ftp server
l_pwd(30) TYPE c VALUE '84197Uq4'," 'Eicher@1236' "password of ftp server
l_host(64) TYPE c VALUE '10.111.4.124', "ip address of FTP server
l_dest LIKE rfcdes-rfcdest VALUE 'SAPFTPA'."Background RFC destination
SET EXTENDED CHECK OFF.
l_slen = STRLEN( l_pwd ).
CALL FUNCTION 'HTTP_SCRAMBLE' "For Scrambing the password
EXPORTING
SOURCE = l_pwd
sourcelen = l_slen
key = c_key
IMPORTING
destination = l_pwd
.
CALL FUNCTION 'FTP_CONNECT' "For FTP connection
EXPORTING
user = l_user
password = l_pwd
host = l_host
rfc_destination = l_dest
IMPORTING
handle = w_hdl
EXCEPTIONS
not_connected = 1
OTHERS = 2
.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
CALL FUNCTION 'FTP_R3_TO_SERVER' "For SAP to FTP file transfer
EXPORTING
handle = w_hdl
fname = wrk_file
character_mode = 'X'
TABLES
text = it_file
EXCEPTIONS
tcpip_error = 1
command_error = 2
data_error = 3
OTHERS = 4
.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
CALL FUNCTION 'FTP_DISCONNECT' "For disconnecting FTP
EXPORTING
handle = w_hdl.
CALL FUNCTION 'RFC_CONNECTION_CLOSE' "Closing RFC Connection
EXPORTING
destination = l_dest
EXCEPTIONS
OTHERS = 1.
IF sy-subrc = 0.
MESSAGE 'CSV File Successfully Generated' TYPE 'S'.
ENDIF.