Hi expert,
I have seen plenty of subject about this but I have only found appropriate solution to send the content of an internal table into an XLS file.
I also tried the solution from following link:
However, it still remain the same. I have an error when opening my attachment "The file format and extension don't match. The file could be corrupted or unsafe..."
Here is the strategy I'm following:
1. I'm reading the file opening a dataset and store the content in a solix_tab:
l_file = 'E:\usr\sap\DE4\DVEBMGS00\work\template_att.xls'.
OPEN DATASET l_file FOR INPUT IN BINARY MODE.
IF sy-subrc <> 0.
MESSAGE s208(00) WITH 'Error in opening file'.
LEAVE LIST-PROCESSING.
ENDIF.
DO.
READ DATASET l_file INTO bin_file.
IF sy-subrc <> 0.
EXIT.
ENDIF.
CALL METHOD cl_bcs_convert=>string_to_solix
EXPORTING
iv_string = bin_file
IMPORTING
et_solix = it_attachXLS
ev_size = l_size.
ENDDO.
CLOSE DATASET l_file.
2. Finally I attach this to my message
TRY.
lo_document->add_attachment(
EXPORTING
i_attachment_type = 'xls'
i_attachment_subject = 'Excel'
i_attachment_size = l_size
i_att_content_hex = it_attachXLS ).
CATCH cx_document_bcs INTO lx_document_bcs.
ENDTRY.
Anyone of you have an example of code which is working for such kind of requirement?
Thanks in advance,
Regards,
Thomas