XML formatting in ABAP – Single line issue in XML
When we pass XML file to out of SAP system sometimes the file details are in one single line and it is not formatted as below.
The detail of create XML and do pretty print is in the below link :
Here, XML formatting is done by calling SET_PRETTY_PRINT as ‘X’
This blog is to check other option than Set Pretty Print = X.
FM – SDIXML_DOM_TO_XML is used to convert DOM to XML, we use the XML as string in the FM and pass string variable as shown below. This creates the XML data in a single line.
So when we transfer this XML using Open Data set it places the file in one line as Ouput below
FM – SDIXML_DOM_TO_XML has option ( tables ‘XML_AS_TABLE’ ) where we can get the detail of DOM in XML formatted form in internal table like LT_XML here.
Once we have details in LT_XML then while placing the file in Open data set, we loop at this table and Transfer each line to Dataset path. The output will be as shown below.
This approach of formatting XML is in addition to the Set pretty Print = X and take more use of the FM. I hope this may be of help.
I was looking for formatting of my XML output and found it out here. Thanks!