With ever changing world of integration one language that has stood the test of time is XML. Due to capabilities of XML and large number of system integration requirments, its impertinent for technical consultants to understand the XML transformation capabilities in SAP. SAP transformations are used to filter and recognize XML data.
SAP transformations can be used for,
Deserialization: Process of transforming XML documents to other XML, HTML, Text or ABAP data structures.
Serialization: Conversion of ABAP data structures to XML, HTML or text files.
There are several methods to create XML transformations in SAP.
Just like any other ABAP program, transformations are also repository objects which could be accessed via SE80. SAP has now provided a graphical tool to create transformations. Graphical transformation program creation wizard could be accessed through transaction XSLT_TOOL.
In this serialization example and we are creating a XML file in the application server with sales order information. XML file holds multiple sales order information with sales order number, sales order type and customer information.
Output file format:
You require access to these transaction codes to generate this XML transformation.
- SE11 – ABAP Dictionary
- SE38 – ABAP Editor
- XSLT_TOOL – Transformation Editor
Step by Step Guide on XML Serialization Using XSLT_TOOL.
1. Create table type.
2. Create transformation in XSLT_TOOL.
3. Create outbound program.
- Data selection logic. Program select sales order information on sales order creation date selection (Form select_data).
- Prepare data to XML format (form prepare_data).
- Call XML transformation created in XSLT_TOOL (Form download_xml). CALL TRANSACTION is a keyword in ABAP to call the transformation created in XSLT_TOOL.
- Download XML data to file (form download_xml).
If you have any questions on any of the XSLT_TOOL transformation configuration steps, please leave a comment below,
22 thoughts on “XML Transformation Example with XSLT_TOOL”
I have tried with above code and checked in AL11 but it is downloaded as single line. When I opend the file, the file displayed all the data in single line. Please help me.
Hi Mashesh, Download the file to your local PC and open it using Chrome, Firefox or any other browser. Make sure your file extension is correct.
Hi, how do I remove empty tag if any?
Hi, You should be able to ignore empty tags using Conditional Transformation expressions. Write a Conditional Transformation Expression to create the tag only if data is not null.
Hi I have a different format of xml.
which needs to be generated using sap code.
it has multiple tages with in the same line. how to write code for it
hi there ,
i have a very large xml transformation with several nodes and atributes , for any reason that i don’t know when i recieve the source xml of the transformation i just see a couple of fields but not the entire xml . do you know if exist any kind of variable or way to could obtain the entire xml?
Are you trying to convert a XML to ABAP data structure? Did you try debugging the transformation program?
I have a similar requirement , ABAP -> XML I have extract Master data related to PM Module based on the plants from the selection screen. Could you please assist?
I have a similar requirement , ABAP -> XML I have to extract Master data related to PM Module based on the plants(select options) from the selection screen. Could you please assist?
Hi fernando, can you advise how to.place a.condition? I have a requirement where color of a column will dynamic based on value. Example if value greater 10 color green. If less that 10 color red. Please advise. Thanks! Btw i’m using simple transformation in abap using tcode XSLT_TOOL. Thanks!
Hi fernando, can you advise how to.place a.condition? I have a requirement where color of a cell will dynamic based on value. Example if value greater 10 color green. If less that 10 color red. Please advise. Thanks! Btw i’m using simple transformation in abap using tcode XSLT_TOOL. Thanks!
I too have a requirement to color the particular cell could you please advice how we can do the same.
HI do you know how to add multiple items to one order in the xml? I trying to create a PO with multiple items, but all the time is repeating the header info and treating this like separate orders, thanks
How to declare Header and Item Details . I dont want to repeat Header details.
is possible generate a XML with prefix cac and cbc like ?
<cbc:ID schemeID="999" schemeName="asd">1162/10</cbc:ID>
<cbc:Value>/ | 64.720,00 / 1.000 UND</cbc:Value>
How can I convert XML with CDATA into ABAP?
EMPRESA PÚBLICA MUNICIPAL DE TELECOMUNICACIONESP
BENIGNO MALO 7-78 Y MARISCAL SUCRE
I have a requirement in which i have to populate the element based on some condition. How to achieve it in XSLT tool.Also, the prefix required is ns2. So can i manually enter ns2 as prefix for all the element/node.
i am using Simple transformation for multiple XML files as upload to sap system but XML has some optional tags how to handle in XSLT_TOOL ? ( ST).
EX: Want make it optional tag , if XML has attribute need to read if not skip to other tag to process..
please advise. below is the code:
I have one transformation issue.
Through Call Transformation statement I am able to convert internal table to XML format.
But I am unable to transfer internal table XML format to existing proxy generated XML file.
I am able to transfer single variables into existing proxy generated XML file through method CL_EDOC_UTIL_CO_UBL_21=>GET_ELEMENT_IN_XML_WITH_URI , but I dont know how to transfer or append internal table XML to existing proxy generated XML file.
Kindly please share your experience.
I want to debug XML file. When i place the debugger on CALL TRANSFORMATION ID source *** , it is going to next line by pressing F5. How to go into XML file?
If I add new field in any deep structure, how this will reflect in the tool? Do we have any refresh button.
Why we need to change field type to attribute and element. whats’ the difference?
Kindly help me with answers.
In header line of the xml generated from abap (that is 1st line in .xml file generated), how to add encoding =”utf-8″, currently using this logic, this is not coming, Please help.