‎2009 Jul 08 9:05 PM
Hi,
My requirement is to send an xml document as an attachment to e-mail. I am getting the attachment in mail but when tried to open, the data is missing instead i am getting message as "The XML page cannot be displayed." Cannot view XML input using XSL style sheet. Please correct. I tried using fn. module "SO_DOCUMENT_SEND_API1" as well as using "add_attachment" method. In both the versions i am getting the attachment but not the xml data. Any solution is very much appriciated.
Thank You.
Ashok
‎2009 Jul 08 11:25 PM
HI,
In order to give exact soulution need to know how you are generating the xml?
1.If you are concatenating the tags for xml into itab and if your data is in readable format..
Make it to string format and use FMs' SCMS_STRING_TO_XSTRING and SCMS_XSTRING_TO_BINARY.
Then pass the binary tab to
DOCUMENT = CL_DOCUMENT_BCS=>CREATE_DOCUMENT(
I_TYPE = DOCUMENTS_LINE-TYPE
I_HEX = DOCUMENTS_LINE-CONTENT_HEX
I_SUBJECT = DOCUMENTS_LINE-SUBJECT
2. if you are using DOM concept and redering the XML doc, Need to calculate the exact size before creating the attachment and create attachment as beloew: Here l_xml_table is already a Binary table
Preparing contents of attachment with Change Log
l_con_pos = 0.
DESCRIBE FIELD wa_XML LENGTH l_xml_len IN BYTE MODE.
DESCRIBE FIELD wa_attachx LENGTH l_con_len IN BYTE MODE.
LOOP AT l_xml_table INTO wa_xml.
ASSIGN wa_xml TO <fs_con> CASTING.
CHECK sy-subrc EQ 0.
DO l_xml_len TIMES.
l_xml_pos = sy-index - 1.
IF l_con_pos = l_con_len.
APPEND wa_attachx TO i_attachx.
FREE wa_attachx.
l_con_pos = 0.
ENDIF.
MOVE <fs_con>l_xml_pos(1) TO wa_attachx-linel_con_pos(1).
ADD 1 TO l_con_pos.
ENDDO.
ENDLOOP.
Size of XML Document
l_size = L_XML_SIZE.
Adding Attachment
CALL METHOD lv_document->add_attachment
EXPORTING
i_attachment_type = c_ext
i_attachment_size = l_size
i_attachment_subject = C_TITLE
i_att_content_hex = i_attachx[].
‎2009 Jul 08 11:25 PM
HI,
In order to give exact soulution need to know how you are generating the xml?
1.If you are concatenating the tags for xml into itab and if your data is in readable format..
Make it to string format and use FMs' SCMS_STRING_TO_XSTRING and SCMS_XSTRING_TO_BINARY.
Then pass the binary tab to
DOCUMENT = CL_DOCUMENT_BCS=>CREATE_DOCUMENT(
I_TYPE = DOCUMENTS_LINE-TYPE
I_HEX = DOCUMENTS_LINE-CONTENT_HEX
I_SUBJECT = DOCUMENTS_LINE-SUBJECT
2. if you are using DOM concept and redering the XML doc, Need to calculate the exact size before creating the attachment and create attachment as beloew: Here l_xml_table is already a Binary table
Preparing contents of attachment with Change Log
l_con_pos = 0.
DESCRIBE FIELD wa_XML LENGTH l_xml_len IN BYTE MODE.
DESCRIBE FIELD wa_attachx LENGTH l_con_len IN BYTE MODE.
LOOP AT l_xml_table INTO wa_xml.
ASSIGN wa_xml TO <fs_con> CASTING.
CHECK sy-subrc EQ 0.
DO l_xml_len TIMES.
l_xml_pos = sy-index - 1.
IF l_con_pos = l_con_len.
APPEND wa_attachx TO i_attachx.
FREE wa_attachx.
l_con_pos = 0.
ENDIF.
MOVE <fs_con>l_xml_pos(1) TO wa_attachx-linel_con_pos(1).
ADD 1 TO l_con_pos.
ENDDO.
ENDLOOP.
Size of XML Document
l_size = L_XML_SIZE.
Adding Attachment
CALL METHOD lv_document->add_attachment
EXPORTING
i_attachment_type = c_ext
i_attachment_size = l_size
i_attachment_subject = C_TITLE
i_att_content_hex = i_attachx[].
‎2009 Oct 15 2:15 PM
About the solution below, would you send me a complete program?
‎2009 Jul 08 11:50 PM
if you are using a ST or XSLT transformation you might have been using some style sheet which does not exist in the person who is opening the attachment...
<Styles>
<Style ss:ID="Default" ss:Name="Normal">
<Alignment ss:Vertical="Bottom"/>
<Borders/>
<Font/>
<Interior/>
<NumberFormat/>
<Protection/>
</Style>
<Style ss:ID="s23">
<Font x:Family="Swiss" ss:Size="12" ss:Bold="1"/>
<Interior ss:Color="#C0C0C0" ss:Pattern="Solid"/>
</Style>
<Style ss:ID="s26">
<Font ss:FontName="Book Antiqua" x:Family="Roman"/>
</Style>
</Styles>
‎2009 Jul 30 6:13 PM
Thanks for support. Issue is resolved. This is because of some additional characters getting populated into the XML line.