cancel
Showing results for 
Search instead for 
Did you mean: 

IDoc to XML

03-01-2023 9:23 AM
cathy_liang Contributor
17433 views 7 comments Go to solution
0 Likes
SAP Managed Tags
Subscribe

Hello experts,

I have checked the forum but still got 2 questions:

1. How to use the standard functionality to download IDoc into XML? Step by step along with screen shots will be highly appreciated because i have little idea about codes and do not have authorization to create port, etc.

2. What cause the invalid characters (highlighted in green below)? How to remove it?

0 Likes

Accepted Solutions (1)

Accepted Solutions (1)

Ulrich_Schmidt1
Product and Topic Expert
Product and Topic Expert
0 Likes

The answer provided by Neeraj above is very nice and answers the requirement completely, but you need to be able to do ABAP programming in the backend system. (E.g. your user needs to have a developer license, and you need to be familiar a bit with ABAP coding and development tools.)

If you are looking for an alternative solution, that doesn't require ABAP coding on the backend side, I can offer the following alternative:

  1. Download and install SAP Business Connector (can easily be installed on a laptop, Windows and Linux). See https://support.sap.com/sbc-download
  2. In the backend create an RFC Destination of type T (transaction SM59) and on the SAP BC create the corresponding "RFC Listener". (More detailed instructions for this are in the "SAPAdapterGuide.pdf" that can be downloaded from https://support.sap.com/en/product/connectors/bc/details.html)
  3. Go to transaction WE19, enter the DOCNUM of the IDoc that you would like to convert to XML, and hit F8. In the next screen, modify the IDoc Control Record, so that the receiver will be the destination from step 2, and then click "Standard Outbound Processing". (Ok, this probably requires some permissions for ALE customizing, and if you don't have those, then you have lost...)
    This will send a copy of the IDoc to the SAP BC.
  4. SAP BC will automatically convert it to XML (even without further customizing on the SAP BC), and it will automatically replace "invalid characters" by their proper XML escape sequence. (E.g. "&" will be converted to "& amp;" which is valid in XML files.)
    You can immediately view the XML file by opening the SAP BC UI in a browser on localhost:5555 and going to "Adapters --> Routing --> Transactions". Click on the TID of your IDoc and then on "View as XML".

The XML file can then be saved to local disc.

Answers (1)

Answers (1)

Neeraj_Jain1
Active Contributor
Ulrich_Schmidt1
Product and Topic Expert
Product and Topic Expert

I read the blog about the invalid chars, and it says that "the invalid characters need to be cleansed by replacing with blank spaces". Therefore I think that this would not be the best way for cleansing IDoc data for conversion to XML. Especially when it comes to "&" characters, which are invalid in XML data, but which often occur in "normal business data" like address records.

For example, if an IDoc contains a company name like "Procter & Gamble", it would be much better to replace that with the XML escape sequence for ampersand, than with a blank space "Procter Gamble".

Similarly, standard XML generators (like the one in SAP BC) will replace "<" and ">" characters with "& lt;" and "& gt;" escape sequences, which may be better than just having spaces. The question is, what would be best for control characters like TAB or NEWLINE, which I have also already encountered in IDoc data. These would be valid candidates for replacement with SPACE, but can also be replaced by hex entities, e.g. TAB would be replaced by "& x09;" by an XML generator, which may not necessarily be, would you want...

Neeraj_Jain1
Active Contributor
0 Likes

Thank you for more described on it.

Regards, Neeraj Jain