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.

John Slegers
  • 45,213
  • 22
  • 199
  • 169
CountD
  • 669
  • 2
  • 11
  • 34
  • 2
    What is the effect of the spaces being trimmed? What does not work any more? – Thomas Weller Oct 15 '15 at 20:26
  • 1
    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. – CountD Oct 19 '15 at 15:36

3 Answers3

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.

Trixx
  • 1,796
  • 1
  • 15
  • 18
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.

AKS
  • 39
  • 1
  • 8
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( ).
Marius
  • 3,372
  • 1
  • 30
  • 36