Hi everybody,
my requirement is like i need to send a mail attaching XML document in UTF-8 which can be displayed in the browser without errors.
Here for, I want to use the standard method SEND_WEB_MAIL from class CL_HRRCF_SERVICES_MAIL.
Currently the mail and the attachment are generated and sent, but clicking on the xml attachment, I got an error by my browser (Internet Explorer and Firefox), that something is not wellformed.
I try to generate the XML in UTF-8 format.
First, to generate an xstring I place a transformation call and replace all the substring UTF-16 to UTF-8.
Before call the already metioned method (at the top) I make a UTF conversion to get an xstring in UTF-8 from system.
data lo_conv type ref to cl_abap_conv_out_ce.
data lv_len type i.
data lv_doc type string.
data lx_xml_doc type xstring.
CALL METHOD cl_abap_conv_out_ce=>create
EXPORTING
encoding = 'UTF-8'
receiving
conv = lo_conv
.
CALL METHOD lo_conv->write
EXPORTING
data = me->p_xml_doc
IMPORTING
len = lv_len
.
CALL METHOD lo_conv->get_buffer
receiving
buffer = lx_xml_doc
ls_mail_atta_hex-content = lx_xml_doc.
ls_mail_atta_hex-extension = 'xml'.
ls_mail_atta_hex-name = 'filename'.
APPEND ls_mail_atta_hex TO lt_mail_attachments_x.
CALL METHOD cl_hrrcf_services_mail=>send_web_mail
EXPORTING
p_subject = me->doc_properties-subject
p_receiver = p_receiver
p_sender = me->sender->email_address
p_body_c = me->doc_properties-output_c_tab
pt_atta_hex = lt_mail_attachments_x
p_doc_type = 'RAW'.
It seems that the standard method SEND_WEB_MAIL is not able to generate a wellformed xml attachment.
What I also found out, is that open the file in editor - at the end of the xml there are some 'NUL' characters.
deleting it manually solves the problem. But regarding the xstring generation via debugger, there are no additional unknown characters added at the end.
Can someone help me in that topic?
Regards,
E.Bernard