I am trying to attach a content of internal table as CSV file to e-mail. However, I have a problem with special characters (French in this case) when the file is opened by Excel application. If I open it with Notepad everything looks OK so I thought it is a PC issue. However, if I create a CSV file directly from Notepad, then those characters are OK both in Notepad and Excel which indicates that it could be ABAP problem after all. However, I am not sure.
Here is what I tried:
LV_LINE_STR is a comma-separated string, while line breaks are CL_ABAP_CHAR_UTILITIES=>CL_LF constants.
Attempt 1: Straightforward: handling pure text - result is good, except special characters
CALL FUNCTION 'SCMS_STRING_TO_FTEXT' EXPORTING text = lv_line_str IMPORTING length = lv_length TABLES ftext_tab = lt_att_content_text. lo_document->add_attachment( i_attachment_type = CONV #( 'CSV' ) i_attachment_subject = CONV #( p_attnam ) i_attachment_size = CONV #( lv_length ) i_att_content_text = lt_att_content_text ).
Attempt 2: Maybe UTF-8 conversion (must go through binary) would help? The result was exactly the same as above
DATA: lt_att_content_text_bin TYPE solix_tab. DATA(lv_line_str_conv) = cl_abap_codepage=>convert_to( source = lv_line_str codepage = 'DEFAULT' "'UTF-8' ). CALL FUNCTION 'SCMS_XSTRING_TO_BINARY' EXPORTING buffer = lv_line_str_conv IMPORTING OUTPUT_LENGTH = lv_length tables binary_tab = lt_att_content_text_bin . lo_document->add_attachment( i_attachment_type = CONV #( 'CSV' ) i_attachment_subject = CONV #( 'Item list' ) i_attachment_size = CONV #( lv_length ) i_att_content_hex = lt_att_content_text_bin ).
Thanks in advance for your help!