2010 Aug 28 4:19 AM
HI i have to send xml as attachment in an email.
I am able create xml do is by below sample code:
Creating a ixml factory
l_ixml = cl_ixml=>create( ).
Creating the dom object model
l_document = l_ixml->create_document( ).
Fill root node with value flights
l_element_flights = l_document->create_simple_element(
name = 'root'
parent = l_document ).
l_element_airline = l_document->create_simple_element(
name = 'cartHeader'
parent = l_element_flights ).
l_value = wa_orderh-object_id.
l_rc = l_element_airline->set_attribute( name = 'cartNumber' value = l_value ).
l_value = wa_orderh-description.
l_rc = l_element_airline->set_attribute( name = 'cartDescription' value = l_value ).
l_value = wa_orderh-description.
l_rc = l_element_airline->set_attribute( name = 'cartDescription' value = l_value ).
READ TABLE t_partner INTO wa_partner WITH KEY ref_guid = wa_orderh-guid
partner_fct = '00000001'.
l_value = wa_partner-partner_no.
l_rc = l_element_airline->set_attribute( name = 'Soldto' value = l_value ).
READ TABLE t_cumulate INTO wa_cumulate WITH KEY guid = wa_orderh-guid.
l_value = wa_cumulate-net_value.
l_rc = l_element_airline->set_attribute( name = 'netValue' value = l_value ).
l_value = wa_cumulate-tax_amount.
l_rc = l_element_airline->set_attribute( name = 'tax' value = l_value ).
l_value = wa_cumulate-gross_value.
l_rc = l_element_airline->set_attribute( name = 'grossValue' value = l_value ).
DESCRIBE TABLE t_item LINES v_lines.
l_value = v_lines.
l_rc = l_element_airline->set_attribute( name = 'TotalItems' value = l_value ).
l_value = sy-datum.
l_rc = l_element_airline->set_attribute( name = 'extractDate' value = l_value ).
l_value = sy-uzeit.
l_rc = l_element_airline->set_attribute( name = 'extractTime' value = l_value ).
l_value = sy-zonlo.
l_rc = l_element_airline->set_attribute( name = 'extractTimeZone' value = l_value ).
LOOP AT t_item INTO wa_item.
l_element_airline = l_document->create_simple_element(
name = 'cartItems'
parent = l_element_flights ).
l_value = wa_item-ordered_prod.
l_rc = l_element_airline->set_attribute( name = 'productId' value = l_value ).
l_value = wa_item-description.
l_rc = l_element_airline->set_attribute( name = 'productDescription' value = l_value ).
READ TABLE t_schedlin INTO wa_schedlin WITH KEY item_guid = wa_item-guid.
l_value = wa_schedlin-quantity.
l_rc = l_element_airline->set_attribute( name = 'Quantity' value = l_value ).
l_value = wa_schedlin-quantity.
l_rc = l_element_airline->set_attribute( name = 'Quantity' value = l_value ).
READ TABLE t_product_i INTO wa_product_i WITH KEY guid = wa_item-guid.
l_value = wa_product_i-base_qty_unit.
l_rc = l_element_airline->set_attribute( name = 'UOM' value = l_value ).
l_value = wa_item-number_int.
l_rc = l_element_airline->set_attribute( name = 'itemNumber' value = l_value ).
READ TABLE t_item INTO wa_item1 WITH KEY parent = wa_item-guid.
l_value = wa_item1-number_int.
l_rc = l_element_airline->set_attribute( name = 'itemParentNumber' value = l_value ).
READ TABLE t_pricingi INTO wa_pricingi WITH KEY guid = wa_item-guid.
l_value = wa_pricingi-net_value.
l_rc = l_element_airline->set_attribute( name = 'netValue' value = l_value ).
l_value = wa_pricingi-tax_amount.
l_rc = l_element_airline->set_attribute( name = 'tax' value = l_value ).
l_value = wa_pricingi-gross_value.
l_rc = l_element_airline->set_attribute( name = 'grossValue' value = l_value ).
READ TABLE t_partner INTO wa_partner WITH KEY ref_guid = wa_orderh-guid
partner_fct = '00000001'.
l_value = wa_partner-partner_no.
l_rc = l_element_airline->set_attribute( name = 'Shipto' value = l_value ).
ENDLOOP.
Creating a stream factory
l_streamfactory = l_ixml->create_stream_factory( ).
Connect internal XML table to stream factory
l_ostream = l_streamfactory->create_ostream_itable( table = l_xml_table ).
Rendering the document
l_renderer = l_ixml->create_renderer( ostream = l_ostream
document = l_document ).
l_rc = l_renderer->render( ).
Saving the XML document
l_xml_size = l_ostream->get_num_written_raw( ).
Now l_xml_table has got some data which has got some numbers - something like this ...
1. 3C3F786D6C2076657273696F6E3D22312E30223F3E3C726F6F743E3C636172744865616465<
2. 3D224D38363638422F41222070726F647563744465736372697074696F6E3D225853455256< and so on records in internal table.
Now i want to send an emai with attachment as xml file. I am using so_object_send.. i used this FM and was successfully able to send pdf.. can anyboday help me in sending xml file..
thanks
Niraja
Edited by: Niraja on Aug 27, 2010 8:21 PM
HI i have to send xml as attachment in an email.
I am able create xml do is by below sample code:
Creating a ixml factory
l_ixml = cl_ixml=>create( ).
Creating the dom object model
l_document = l_ixml->create_document( ).
Fill root node with value flights
l_element_flights = l_document->create_simple_element(
name = 'root'
parent = l_document ).
l_element_airline = l_document->create_simple_element(
name = 'cartHeader'
parent = l_element_flights ).
l_value = wa_orderh-object_id.
l_rc = l_element_airline->set_attribute( name = 'cartNumber' value = l_value ).
l_value = wa_orderh-description.
l_rc = l_element_airline->set_attribute( name = 'cartDescription' value = l_value ).
l_value = wa_orderh-description.
l_rc = l_element_airline->set_attribute( name = 'cartDescription' value = l_value ).
READ TABLE t_partner INTO wa_partner WITH KEY ref_guid = wa_orderh-guid
partner_fct = '00000001'.
l_value = wa_partner-partner_no.
l_rc = l_element_airline->set_attribute( name = 'Soldto' value = l_value ).
READ TABLE t_cumulate INTO wa_cumulate WITH KEY guid = wa_orderh-guid.
l_value = wa_cumulate-net_value.
l_rc = l_element_airline->set_attribute( name = 'netValue' value = l_value ).
l_value = wa_cumulate-tax_amount.
l_rc = l_element_airline->set_attribute( name = 'tax' value = l_value ).
l_value = wa_cumulate-gross_value.
l_rc = l_element_airline->set_attribute( name = 'grossValue' value = l_value ).
DESCRIBE TABLE t_item LINES v_lines.
l_value = v_lines.
l_rc = l_element_airline->set_attribute( name = 'TotalItems' value = l_value ).
l_value = sy-datum.
l_rc = l_element_airline->set_attribute( name = 'extractDate' value = l_value ).
l_value = sy-uzeit.
l_rc = l_element_airline->set_attribute( name = 'extractTime' value = l_value ).
l_value = sy-zonlo.
l_rc = l_element_airline->set_attribute( name = 'extractTimeZone' value = l_value ).
LOOP AT t_item INTO wa_item.
l_element_airline = l_document->create_simple_element(
name = 'cartItems'
parent = l_element_flights ).
l_value = wa_item-ordered_prod.
l_rc = l_element_airline->set_attribute( name = 'productId' value = l_value ).
l_value = wa_item-description.
l_rc = l_element_airline->set_attribute( name = 'productDescription' value = l_value ).
READ TABLE t_schedlin INTO wa_schedlin WITH KEY item_guid = wa_item-guid.
l_value = wa_schedlin-quantity.
l_rc = l_element_airline->set_attribute( name = 'Quantity' value = l_value ).
l_value = wa_schedlin-quantity.
l_rc = l_element_airline->set_attribute( name = 'Quantity' value = l_value ).
READ TABLE t_product_i INTO wa_product_i WITH KEY guid = wa_item-guid.
l_value = wa_product_i-base_qty_unit.
l_rc = l_element_airline->set_attribute( name = 'UOM' value = l_value ).
l_value = wa_item-number_int.
l_rc = l_element_airline->set_attribute( name = 'itemNumber' value = l_value ).
READ TABLE t_item INTO wa_item1 WITH KEY parent = wa_item-guid.
l_value = wa_item1-number_int.
l_rc = l_element_airline->set_attribute( name = 'itemParentNumber' value = l_value ).
READ TABLE t_pricingi INTO wa_pricingi WITH KEY guid = wa_item-guid.
l_value = wa_pricingi-net_value.
l_rc = l_element_airline->set_attribute( name = 'netValue' value = l_value ).
l_value = wa_pricingi-tax_amount.
l_rc = l_element_airline->set_attribute( name = 'tax' value = l_value ).
l_value = wa_pricingi-gross_value.
l_rc = l_element_airline->set_attribute( name = 'grossValue' value = l_value ).
READ TABLE t_partner INTO wa_partner WITH KEY ref_guid = wa_orderh-guid
partner_fct = '00000001'.
l_value = wa_partner-partner_no.
l_rc = l_element_airline->set_attribute( name = 'Shipto' value = l_value ).
ENDLOOP.
Creating a stream factory
l_streamfactory = l_ixml->create_stream_factory( ).
Connect internal XML table to stream factory
l_ostream = l_streamfactory->create_ostream_itable( table = l_xml_table ).
Rendering the document
l_renderer = l_ixml->create_renderer( ostream = l_ostream
document = l_document ).
l_rc = l_renderer->render( ).
Saving the XML document
l_xml_size = l_ostream->get_num_written_raw( ).
Now l_xml_table has got some data which has got some numbers - something like this ...
1. 3C3F786D6C2076657273696F6E3D22312E30223F3E3C726F6F743E3C636172744865616465<
2. 3D224D38363638422F41222070726F647563744465736372697074696F6E3D225853455256< and so on records in internal table.
Now i want to send an emai with attachment as xml file. I am using so_object_send.. i used this FM and was successfully able to send pdf.. can anyboday help me in sending xml file..
thanks
Niraja
Edited by: Niraja on Aug 27, 2010 8:21 PM
2010 Aug 28 7:22 AM
2010 Aug 28 6:43 PM
i m pasting tghe code again. . pls help
{
Creating a ixml factory
l_ixml = cl_ixml=>create( ).
Creating the dom object model
l_document = l_ixml->create_document( ).
Fill root node with value flights
l_element_flights = l_document->create_simple_element(
name = 'root'
parent = l_document ).
l_element_airline = l_document->create_simple_element(
name = 'cartHeader'
parent = l_element_flights ).
l_value = wa_orderh-object_id.
l_rc = l_element_airline->set_attribute( name = 'cartNumber' value = l_value ).
l_value = wa_orderh-description.
l_rc = l_element_airline->set_attribute( name = 'cartDescription' value = l_value ).
l_value = wa_orderh-description.
l_rc = l_element_airline->set_attribute( name = 'cartDescription' value = l_value ).
READ TABLE t_partner INTO wa_partner WITH KEY ref_guid = wa_orderh-guid
partner_fct = '00000001'.
l_value = wa_partner-partner_no.
l_rc = l_element_airline->set_attribute( name = 'Soldto' value = l_value ).
READ TABLE t_cumulate INTO wa_cumulate WITH KEY guid = wa_orderh-guid.
l_value = wa_cumulate-net_value.
l_rc = l_element_airline->set_attribute( name = 'netValue' value = l_value ).
l_value = wa_cumulate-tax_amount.
l_rc = l_element_airline->set_attribute( name = 'tax' value = l_value ).
l_value = wa_cumulate-gross_value.
l_rc = l_element_airline->set_attribute( name = 'grossValue' value = l_value ).
DESCRIBE TABLE t_item LINES v_lines.
l_value = v_lines.
l_rc = l_element_airline->set_attribute( name = 'TotalItems' value = l_value ).
l_value = sy-datum.
l_rc = l_element_airline->set_attribute( name = 'extractDate' value = l_value ).
l_value = sy-uzeit.
l_rc = l_element_airline->set_attribute( name = 'extractTime' value = l_value ).
l_value = sy-zonlo.
l_rc = l_element_airline->set_attribute( name = 'extractTimeZone' value = l_value ).
LOOP AT t_item INTO wa_item.
l_element_airline = l_document->create_simple_element(
name = 'cartItems'
parent = l_element_flights ).
l_value = wa_item-ordered_prod.
l_rc = l_element_airline->set_attribute( name = 'productId' value = l_value ).
l_value = wa_item-description.
l_rc = l_element_airline->set_attribute( name = 'productDescription' value = l_value ).
READ TABLE t_schedlin INTO wa_schedlin WITH KEY item_guid = wa_item-guid.
l_value = wa_schedlin-quantity.
l_rc = l_element_airline->set_attribute( name = 'Quantity' value = l_value ).
l_value = wa_schedlin-quantity.
l_rc = l_element_airline->set_attribute( name = 'Quantity' value = l_value ).
READ TABLE t_product_i INTO wa_product_i WITH KEY guid = wa_item-guid.
l_value = wa_product_i-base_qty_unit.
l_rc = l_element_airline->set_attribute( name = 'UOM' value = l_value ).
l_value = wa_item-number_int.
l_rc = l_element_airline->set_attribute( name = 'itemNumber' value = l_value ).
READ TABLE t_item INTO wa_item1 WITH KEY parent = wa_item-guid.
l_value = wa_item1-number_int.
l_rc = l_element_airline->set_attribute( name = 'itemParentNumber' value = l_value ).
READ TABLE t_pricingi INTO wa_pricingi WITH KEY guid = wa_item-guid.
l_value = wa_pricingi-net_value.
l_rc = l_element_airline->set_attribute( name = 'netValue' value = l_value ).
l_value = wa_pricingi-tax_amount.
l_rc = l_element_airline->set_attribute( name = 'tax' value = l_value ).
l_value = wa_pricingi-gross_value.
l_rc = l_element_airline->set_attribute( name = 'grossValue' value = l_value ).
READ TABLE t_partner INTO wa_partner WITH KEY ref_guid = wa_orderh-guid
partner_fct = '00000001'.
l_value = wa_partner-partner_no.
l_rc = l_element_airline->set_attribute( name = 'Shipto' value = l_value ).
ENDLOOP.
Creating a stream factory
l_streamfactory = l_ixml->create_stream_factory( ).
Connect internal XML table to stream factory
l_ostream = l_streamfactory->create_ostream_itable( table = l_xml_table ).
Rendering the document
l_renderer = l_ixml->create_renderer( ostream = l_ostream
document = l_document ).
l_rc = l_renderer->render( ).
Saving the XML document
l_xml_size = l_ostream->get_num_written_raw( ). }
2010 Aug 28 10:21 PM
Hi Niraja,
switsch to prview tab before posting.
Regards,
Clemens
2010 Aug 28 11:43 PM
Hi Niraja,
You can use CL_BCS class to send emails with attachment. To send an XML file you need to have your data in BIN (type solix_tab) format. Refer to my article below for more details:
http://www.divulgesap.com/blog.php?p=ODI=
Please let me know if you have questions.
2010 Aug 29 3:40 AM
Hi Ravikiran
you have given a z fm and not sure what is happening in that FM...
basically i m using so_object_send, and I am able to send pdf perfectly..
and in same code, if teh format is xml i have to send xml file as attachment, how to send xml in so_object_send FM? could you please let me know?
2010 Aug 29 4:38 AM
Hi Neeraja,
The code for the Z FM can be found in the below link -
http://www.divulgesap.com/blog.php?p=NTA=
Basically I am using CL_BCS class methods to send the email.
Regards,
Ravi
2010 Aug 29 8:46 PM
Hi ravikiran,
I have reviewed your code, basically in your code, you are reading a file from your computer and the data is coming in lt_data internal table. that internal table you are finally passing in ls_attachments-attachx[] in method: CALL METHOD document->add_attachment.
My XML format is like below... how does this work? you have a string type field line - in lt_data...
Can u please give me a full example....
FYI: I am using XMLfactory : l_ixml = cl_ixml=>create( ) api's and am able to create below format, but i m not able to send xml file to email. but using cl_ixml api' i am able to download the below format in xml file using cl_gui_frontend_services=>gui_download.
{
<root>
- <cartHeader cartNumber="1" cartDescription="My first cart" validToDate="05/31/2010" soldTo="S000000001" user="testuser" country="US" language="EN" CRAD="06/15/2010" currency="USD" netValue="1000.00" tax="100.00" grossValue="1100.00" TotalItems="2" extractDate="04/30/2010" extractTime="113000" extractTimeZone="EST">
- <cartItems>
<cartItem productId="9117MC1" productDescription="IBM pSeries Server" quantity="1" uom="EA" itemNumber="10" parentItemNumber="0" contractNumber="100" contractLineNumber="10" CRAD="06/15/2010" netValue="600.00" tax="60.00" grossValue="660.00" shipTo="S000000002" installAt="S000000003" licenseTo="S000000004" Notes="Handle with care" />
<cartItem productId="TEST2" productDescription="Test Material 2" quantity="1" uom="EA" itemNumber="20" parentItemNumber="10" contractNumber="100" contractLineNumber="20" CRAD="06/15/2010" netValue="400.00" tax="40.00" grossValue="440.00" shipTo="S000000002" installAt="S000000003" licenseTo="S000000004" Notes="Deliver along with item 10" />
</cartItems>
</cartHeader>
</root>
{
2010 Aug 31 5:02 AM
how can i send the email body in below format.. i see internal table to be sent in the api cl_bcs or bcs* reports.. but how to send body of email in below format
{
-
Product-Id Product-Description Quantity UOM Item-Number Parent-Item-Number Contract-Number Contract-Item-Number CRAD Net-Value Tax Gross-Value Ship-To Install-At License-To
-
9117MC1 IBM pSeries Server 1 EA 10 0 100 10 06/15/2010 600.00 60.00 660.00 S000000002 S000000003 S000000004
Notes: Handle with care
-
}
2010 Nov 16 8:51 PM
| User | Count |
|---|---|
| 4 | |
| 2 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |