cancel
Showing results for 
Search instead for 
Did you mean: 

How to hide root element from payload

Former Member
0 Kudos

Hi all, I need to write an XML message to file but I need to transform tha payload hidding the root element from payload.

Eg:


<?xml version="1.0" encoding="UTF-8"?>

<ns0:DT_ITENS xmlns:ns0="urn:sap-com:document:sap:rfc:functions">
      <ITENS>
        <item>
          <DOCNUM>000018</DOCNUM> 
          <ITM_NUM>000010</ITM_NUM>
          <BUDAT></BUDAT>
          <UZEIT></UZEIT>
        </item>
      </ITENS>
</ns0:DT_ITENS>

I need to remove <b>ns0:DT_ITENS</b> like above:


<?xml version="1.0" encoding="UTF-8"?>

<ITENS>
    <item>
      <DOCNUM>000018</DOCNUM> 
      <ITM_NUM>000010</ITM_NUM>
      <BUDAT></BUDAT>
      <UZEIT></UZEIT>
    </item>
</ITENS>

There is any solution instead of XSL or Java Mapping?

Thanks in advance.

Accepted Solutions (1)

Accepted Solutions (1)

former_member189387
Active Contributor
0 Kudos

Hi Daniel ,

Please create the Target messsage Structer as u need then use Graphical mapping then map it with source then output will come from only the resultant target structure

The target structuer like

<ITENS>

<item>

<DOCNUM>000018</DOCNUM>

<ITM_NUM>000010</ITM_NUM>

<BUDAT></BUDAT>

<UZEIT></UZEIT>

</item>

</ITENS>

    • Asssign poits if found helpful

Regards.,

V.Rangarajan

Former Member
0 Kudos

Isn't work, I've created a data type ITENS and message type ITENS and then the message mapping, but the result still wrong.

I got the result above:


<?xml version="1.0" encoding="UTF-8"?>
<ns0:ITENS xmlns:ns0="urn:samples">
   <item>
      <DOCNUM>000018</DOCNUM>
      <ITM_NUM>000010</ITM_NUM>
      <BUDAT/>
      <UZEIT/>
   </item>
</ns0:ITENS>

Bu I need message without <b>ns0</b>, like above:


<?xml version="1.0" encoding="UTF-8"?>
<ITENS>
   <item>
      <DOCNUM>000018</DOCNUM>
      <ITM_NUM>000010</ITM_NUM>
      <BUDAT/>
      <UZEIT/>
   </item>
</ITENS>

I think in a XSL mapping to resolve this issue.

Former Member
0 Kudos

Hi,

If you don't want to have it. Please in your definition (xsd) add something like this:

<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified" attributeFormDefault="unqualified">

<xs:element name="ITENS">

....

Regards,

Wojciech

henrique_pinto
Active Contributor
0 Kudos

Daniel,

your approach is right, you don't need XSLT just for this.

Now, just remove the XML namespace in the message type (it can be blank, no problem).

Then, your message definition will not have any namespace prefixes.

Regards,

Henrique.

Former Member
0 Kudos

Thank you Henrique, I've just remove the XML Namespace from Message Type and it works.

Thanks again!

Daniel Torres

Answers (1)

Answers (1)

Former Member
0 Kudos

Hi Daniel,

you can do that also in graphical mapping easy map item to item

best,

wojciech