SAP R/3 removes trailing spaces from IDoc XML files
Asked Answered
D

3

11

I have a Java application that uses SAP JCo 3 libraries. One of the use cases consists of receiving a IDoc file from the SAP instance (R/3, ERP 6.0 EhP 7) and convert it to XML. The problem is that, during the conversion (executed by the IDoc library), the right spaces at the end of the fields get trimmed. Apparently, to reduce the message size. So far, I haven't found any configuration that can be done from the Java side.

Searching the net, I found the following suggestions from the SAP side:

  • setting whiteSpace=preserve from the XSD Editor
  • setting xml.fieldContentFormatting=nothing in the Sender File/FTP Adapter

However, I haven't been able to find those tools nor configure them accordingly.

I would appreciate any insights on these two approaches or any other solution.

Defeatism answered 5/10, 2015 at 17:24 Comment(2)
What is the effect of the spaces being trimmed? What does not work any more?Dumyat
IDoc data should to be converted to XML as is, preserving the white-spaces for later processing. Also, to keep consistence between the original IDoc field length and the actual XML field length.Defeatism
U
2

The SAP Java IDoc Class Library does not offer an option to preserve trailing SPACES in the IDoc fields.

Trailing SPACE characters in IDoc fields do not serve any purpose as long as the IDoc will be sent to another SAP system in the end again. In this case they really would only enlarge the XML message size without adding any value.

I currently cannot imagine for what reason you would like to keep those trailing SPACES? SPACE characters are the default initial value for ABAP CHAR type fields, so you also cannot know if some of these characters would have been set by intention or not.

Unconditional answered 26/12, 2016 at 23:31 Comment(0)
H
0

You can have a check where the total length of the field will be equal to that particular segment length. You can use RFC IDOCTYPE_READ_COMPLETE. In this pass IDOC type ,say MATMAs01. In table PT_SEGMENTS you can get the segment length.

You can pass this segment length to get the complete field length.

Hellman answered 17/11, 2015 at 9:25 Comment(0)
C
0

When working with the XML in ABAP, what you need to look at is the if_ixml_renderer (or if_ixml_parser) call set_normalizing. This is on by default, and you need to disable this.

"Convert XML to string: l_string
lif_ostream = sif_streamfactory->create_ostream_cstring( l_string ).
lif_renderer = sif_xml->create_renderer( ostream  = lif_ostream
                                         document = mif_xml_document ).
" this stops SAP from removing whitespace and doing spurious edits:
lif_renderer->set_normalizing( false ).

lif_renderer->render( ).
Collagen answered 15/12, 2017 at 16:25 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.