Solved - Re - Send Mail With XML Document Attached - SAP Community
Solved - Re - Send Mail With XML Document Attached - SAP Community
Solved - Re - Send Mail With XML Document Attached - SAP Community
Go to solution
Former Member
10-19-2009 8:47 AM
0 Kudos
Hi ,
My requirement is like i need to send a mail attaching XML document. i am able to receive attchment but XML file is
not opening.
Regards,
Rajkumar
Reply 1 ACCEPTED
SOLUTION
Former Member
10-22-2009 8:36 AM
0 Kudos
Raj,
Create the FM with SO_XML with out any code in the FM and add the entry in the table TSOTD.
https://community.sap.com/t5/application-development-discussions/send-mail-with-xml-document-attached/m-p/6231876#M1380732 1/8
27/4/24, 19:57 Solved: Re: Send Mail with XML document attached - SAP Community
http://help.sap.com/erp2005_ehp_04/helpdata/EN/6c/69c3c5418d11d1896e0000e8322d00/frameset.htm
http://www.sapdb.info/abap-program-to-send-mail-with-attachment/
Reply 6 REPLIES
athavanraja
Active Contributor
10-20-2009 6:49 AM
0 Kudos
regarding sending mail with XML attachment check out the following code sample (in FM format)
import parameters:
tables parameter
https://community.sap.com/t5/application-development-discussions/send-mail-with-xml-document-attached/m-p/6231876#M1380732 2/8
27/4/24, 19:57 Solved: Re: Send Mail with XML document attached - SAP Community
FM Source.
FUNCTION y_email_xml_atta.
CLEAR: xl_content .
IMPORTING
buffer = xl_content
EXCEPTIONS
https://community.sap.com/t5/application-development-discussions/send-mail-with-xml-document-attached/m-p/6231876#M1380732 3/8
27/4/24, 19:57 Solved: Re: Send Mail with XML document attached - SAP Community
failed = 1
OTHERS = 2
.
IF sy-subrc <> 0.
ENDIF.
REFRESH binary_content .
REFRESH text .
CLEAR result_content .
CONCATENATE
'Please find attached your XML doc.'
'Regards'
' Team<' INTO result_content .
TRY.
CLEAR send_request .
send_request = cl_bcs=>create_persistent( ).
CLEAR document .
document = cl_document_bcs=>create_document(
i_type = 'HTM'
i_text = text
i_length = conlengths
i_subject = subject ).
CLEAR sender .
https://community.sap.com/t5/application-development-discussions/send-mail-with-xml-document-attached/m-p/6231876#M1380732 4/8
27/4/24, 19:57 Solved: Re: Send Mail with XML document attached - SAP Community
CLEAR wa_rec .
recipient = cl_cam_address_bcs=>create_internet_address(
wa_rec ).
COMMIT WORK.
ENDTRY.
ELSE .
ENDFUNCTION.
https://community.sap.com/t5/application-development-discussions/send-mail-with-xml-document-attached/m-p/6231876#M1380732 5/8
27/4/24, 19:57 Solved: Re: Send Mail with XML document attached - SAP Community
ABAP Development
Reply
Former Member
In response to athavanraja
10-20-2009 8:46 AM
0 Kudos
Hi Raja,
i tried your code by creating new function module , i got attchment but XML file not opening stillfacing same
error .
i opened XML file with notepad , contents are shown below .do we need to mention any separator ?
please suggest.
https://community.sap.com/t5/application-development-discussions/send-mail-with-xml-document-attached/m-p/6231876#M1380732 6/8
27/4/24, 19:57 Solved: Re: Send Mail with XML document attached - SAP Community
<CARRID>LH</CARRID><CONNID>0454</CONNID><FLDATE>1995-11-17</FLDATE>
<PRICE>1499.0</PRICE><CURRENCY>DEM</CURRENCY><PLANETYPE>A319</PLANETYPE>
<SEATSMAX>350</SEATSMAX><SEATSOCC>2</SEATSOCC>
<PAYMENTSUM>2949.0</PAYMENTSUM><SEATSMAX_B>0</SEATSMAX_B>
<SEATSOCC_B>0</SEATSOCC_B><SEATSMAX_F>0</SEATSMAX_F>
<SEATSOCC_F>0</SEATSOCC_F></SFLIGHT><SFLIGHT><MANDT>300</MANDT>
<CARRID>LH</CARRID><CONNID>0455</CONNID><FLDATE>1995-06-06</FLDATE>
<PRICE>1090.0</PRICE><CURRENCY>USD</CURRENCY><PLANETYPE>A319</PLANETYPE>
<SEATSMAX>220</SEATSMAX><SEATSOCC>1</SEATSOCC>
<PAYMENTSUM>1499.0</PAYMENTSUM><SEATSMAX_B>0</SEATSMAX_B>
<SEATSOCC_B>0</SEATSOCC_B><SEATSMAX_F>0</SEATSMAX_F>
<SEATSOCC_F>0</SEATSOCC_F></SFLIGHT><SFLIGHT><MANDT>300</MANDT>
<CARRID>LH</CARRID><CONNID>3577</CONNID><FLDATE>1995-04-28</FLDATE>
<PRICE>6000.0</PRICE><CURRENCY>LIT</CURRENCY><PLANETYPE>A319</PLANETYPE>
<SEATSMAX>220</SEATSMAX><SEATSOCC>1</SEATSOCC>
<PAYMENTSUM>600.0</PAYMENTSUM><SEATSMAX_B>0</SEATSMAX_B>
<SEATSOCC_B>0</SEATSOCC_B><SEATSMAX_F>0</SEATSMAX_F>
<SEATSOCC_F>0</SEATSOCC_F></SFLIGHT><SFLIGHT><MANDT>300</MANDT>
<CARRID>LH</CARRID><CONNID>9981</CONNID><FLDATE>2002-12-21</FLDATE>
<PRICE>222.0</PRICE><CURRENCY>EUR</CURRENCY><PLANETYPE>A330-300</PLANETYPE>
<SEATSMAX>320</SEATSMAX><SEATSOCC>12</SEATSOCC><PAYMENTSUM>0.0</PAYMENTSUM>
<SEATSMAX_B>20</SEATSMAX_B><SEATSOCC_B>1</SEATSOCC_B>
<SEATSMAX_F>0</SEATSMAX_F><SEATSOCC_F>0</SEATSOCC_F></SFLIGHT><SFLIGHT>
<MANDT>300</MANDT><CARRID>SQ</CARRID><CONNID>0026</CONNID><FLDATE>1995-02-
28</FLDATE><PRICE>849.0</PRICE><CURRENCY>DEM</CURRENCY><PLANETYPE>DC-10-
10</PLANETYPE><SEATSMAX>380</SEATSMAX><SEATSOCC>2</SEATSOCC>
<PAYMENTSUM>1684.0</PAYMENTSUM><SEATSMAX_B>0</SEATSMAX_B>
<SEATSOCC_B>0</SEATSOCC_B><SEATSMAX_F>0</SEATSMAX_F>
<SEATSOCC_F>0</SEATSOCC_F></SFLIGHT></FLIGHTS></asx:values></asx:abap>
SAP Managed Tags:
ABAP Development
Reply
Former Member
In response to athavanraja
10-21-2009 11:06 AM
0 Kudos
Hi Raja,
https://community.sap.com/t5/application-development-discussions/send-mail-with-xml-document-attached/m-p/6231876#M1380732 7/8
27/4/24, 19:57 Solved: Re: Send Mail with XML document attached - SAP Community
now i have added OPTIONS addition to the CALL TRANSFORMATION statement to avoid header
because of # key it is not able to open the file.still message Invalid at the top level of the
document is coming
Regards,
Rajkumar
https://community.sap.com/t5/application-development-discussions/send-mail-with-xml-document-attached/m-p/6231876#M1380732 8/8