2011 Oct 24 3:48 PM
Hello All,
I have devloped one OOPS ALV report in that our requirement is on "SAVE" button the data of the report has to be downloaded in given XML format.Please check the format provided in Finnish language.The word "Value" specified as value which are coming in the ALV report against fields mentioned.
<?xml version="1.0" encoding="ISO-8859-1" ?>
<!u2014Aromi list -->
<!-- Copyright -->
<!-- Edited with Visual Basic 6 -->
<!-- Versio 1.0 -->
<Tiedot Lahettaja="Value" Yhteyshlo=" Value"
Yhteystieto=" Value " Asiakasnumero="">
<Raaka-aine Nimi="" Ryhma=" Value ">
<Tuotemerkki Nimi=" Value " Ean=" Value "
Ykspakkauskoko="1" Ykspakkaustyyppi="KPL" almistaja="Value">
<Toimittajatiedot Tuotekoodi="10" Sopimustuote="Y" Myyntierakoko="5"
Myyntieratyyppi="ME" Myyntierahinta="3,035" Hintapvm="value"
/>
</Tuotemerkki>
</Raaka-aine>
</Tiedot>
Could anybody help how to download the report data into above format.
Regards,
Sachin
2011 Oct 24 8:03 PM
Hi Sachin,
You can use any of the following approach to convert internal table data to XML.
1. Using FM - SAP_CONVERT_TO_XML_FORMAT
2. Using FM's - SDIXML_DATA_TO_DOM & SDIXML_DOM_TO_XML.
3. Using Interface - if_ixml_stream_factory~create_istream_itable.
4. Using Class - CL_XML_DOCUMENT
DATA : ITAB TYPE TABLE OF SPFLI,
L_XML TYPE REF TO CL_XML_DOCUMENT.
SELECT * FROM SPFLI INTO TABLE ITAB.
* CREATE THE XML OBJECT
CREATE OBJECT L_XML.
* CONVERT THE DATA TO XML
CALL METHOD L_XML->CREATE_WITH_DATA( DATAOBJECT = ITAB[] ).
* DATA IS CONVERTED TO XML; DISPLAY THE XML-DOCUMENT
CALL METHOD L_XML->DISPLAY.
5. Using XSLT Transformation - CALL TRANSFORMATION
Few links that might help you as well -
[http://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/b2dcbdfc-0801-0010-97bd-b3f39420759c?quicklink=index&overridelayout=true]
[http://www.sdn.sap.com/irj/scn/weblogs?blog=/pub/wlg/2657] [original link is broken] [original link is broken] [original link is broken] [original link is broken];
[http://erpgenie.com/abaptips/content/view/31/61/]
2011 Oct 25 6:47 AM
Hi Sachin,
I see the sample XML has field values embedded as XML element attributes.ie <Raaka-aine Ryhma=" Value ">. For such specific requirements:
1. Loop through the table and Use iXML library functions to build the complete XML, element by element. Help - http://help.sap.com/saphelp_nw04/helpdata/en/86/8280ba12d511d5991b00508b6b8b11/frameset.htm
2. You can create an XSLT Transformation that match the specific XML format, and use CALL TRANSFORMATION to convert internal table to that specific XML format.
Few Standard Function modules and class CL_XML_DOCUMENT may help for generic SAP XML conversions, where XML element names will be same as internal table field names. Not, sure if these can be used to generate specific XML formats.
Thanks,
Varun
Edited by: Varun VS on Oct 25, 2011 7:48 AM