cancel
Showing results for 
Search instead for 
Did you mean: 

Can anyone suggest me sending excel file with .xlsx format through ftp ?

0 Kudos
537

While sending .xls file to ftp server, when opening excel file, giving error file and the extension of document name (test.xls) doesn't match. The file could be corrupt or unsafe. Unless you trust its source, don't open it. Do you want to open any way.

While clicking on yes its getting display, but here in my case it should prompt for any message it should simply open the excel sheet without any prompting.

View Entire Topic
DanBB
Explorer
0 Kudos

Please try this one
First you have to convert data to xstring, then xstring to binary.
After that send the BIN data.
Below are necessary FM to do it. It worked for me!

* Convert table text to xstring

CALL FUNCTION 'SCMS_TEXT_TO_XSTRING'

EXPORTING

ENCODING = '4110'

IMPORTING

BUFFER = LW_XSTRING

TABLES

TEXT_TAB = IT_DATA

EXCEPTIONS

FAILED = 1 OTHERS = 2.

IF SY-SUBRC <> 0. ENDIF.

* Convert xstring to binary

CALL FUNCTION 'SCMS_XSTRING_TO_BINARY'

EXPORTING

BUFFER = LW_XSTRING

IMPORTING

OUTPUT_LENGTH = LW_BIN_LEN

TABLES

BINARY_TAB = LT_TRANSFER.

* Set passive on

CALL FUNCTION 'FTP_COMMAND'

EXPORTING

HANDLE = LW_HANDLE

COMMAND = 'set passive on'

TABLES

DATA = LT_RESULT

EXCEPTIONS TCPIP_ERROR = 1 COMMAND_ERROR = 2 DATA_ERROR = 3.

IF SY-SUBRC <> 0. ENDIF.

* Set bin mode

CALL FUNCTION 'FTP_COMMAND'

EXPORTING

HANDLE = LW_HANDLE COMMAND = 'bin'

TABLES

DATA = LT_RESULT

EXCEPTIONS TCPIP_ERROR = 1 COMMAND_ERROR = 2 DATA_ERROR = 3.

IF SY-SUBRC <> 0.
ENDIF.

* Send file to FTP server

CALL FUNCTION 'FTP_R3_TO_SERVER'

EXPORTING

HANDLE = LW_HANDLE

FNAME = LW_FTP_PATH

BLOB_LENGTH = LW_BIN_LEN

TABLES

BLOB = LT_TRANSFER

EXCEPTIONS TCPIP_ERROR = 1 COMMAND_ERROR = 2 DATA_ERROR = 3 OTHERS = 4.

IF SY-SUBRC <> 0. . ENDIF.