cancel
Showing results for 
Search instead for 
Did you mean: 

How to remove or add the message type nodes ?

Former Member
0 Kudos

Hi Guys,

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

<MT_SAP_UPS_Address_Validation_In Attr="MT_SAP_UPS_Address_Validation_In">

<AccessRequest>

<AccessLicenseNumber>123</AccessLicenseNumber>

<UserId>xy</UserId>

<Password>AB</Password>

</AccessRequest>

</MT_SAP_UPS_Address_Validation_In>

Is it possible to remove the tag <MT_SAP_UPS_Address_Validation_In opening and clsoing tags

Thanks,

Srini

Accepted Solutions (1)

Accepted Solutions (1)

jan_krohn
Active Participant
0 Kudos

If you remove these elements, the result won't be a valid XML any longer. Any XML needs a root element.

Best wishes,

Jan

Former Member
0 Kudos

Hi Jan,

I agree with you, by removing the root noce it will be invalid document and i tried with the java mapping and i was able to remove it but when i use it in xi the result is always with the root node.

Thanks,

Srini

jan_krohn
Active Participant
0 Kudos

Hi Srini,

with XSLT it's definitely possible to create an invalid XML file. You schould try Henrique's solution. (However, he removes the AccessRequest element).

Try this XSLT:

<xsl:template match="@*|node()">

<xsl:copy>

<xsl:apply-templates select="@*|node()"/>

</xsl:copy>

</xsl:template>

<xsl:template match="MT_SAP_UPS_Address_Validation_In">

<xsl:apply-templates select="@*|node()"/>

</xsl:template>

For help on the transformation editor, go to http://help.sap.com/saphelp_nw04/helpdata/en/fd/9d7348389211d596a200a0c94260a5/frameset.htm

Best wishes,

Jan

Former Member
0 Kudos

Hi Jan,

Thanks Jan for the quick reply and it really solved the problem.

Thanks,

Srini

Edited by: Srinivas Reddy on Aug 20, 2008 4:53 PM

Edited by: Srinivas Reddy on Aug 20, 2008 4:54 PM

Answers (5)

Answers (5)

Former Member
0 Kudos

Hi,

Why you need to remove the node. See there are many ways you can do this if and only if the subelement of the root element also acts a Root Node.

1. If that is your business requirement you can alwas create another message type with root element as AccessRequest and map the source structure(the one with MT_SAP_UPS_Address_Validation_In ) to the structure i have mentioned using message mapping.

2. You can remove the root element by using Java Mapping.

3. You can use xslt mapping as well to remove it.

Thnaks

Amit

sunilchandra007
Active Contributor
0 Kudos

Hi,

The tag can be removed easily with XSLT or Java mapping. It is not possible with graphical mapping.

Regards,

Chandra

former_member187563
Contributor
0 Kudos

hi,

java mapping is also an option.You can use sax parser and change the begin document and end document events.

regards,

ujjwal kumar

Former Member
0 Kudos

Hi,

You can't remove the Message Type node as it will be leading as root node in the XML message.

You may able to alter the attributes with xslt mapping but not possible to remove it.

Thanks

swarup

henrique_pinto
Active Contributor
0 Kudos

Of course he can change the XML structure with XSLT.

what about:

<xsl:template match="/MT_SAP_UPS_Address_Validation_In/AccessRequest">

<xsl:copy-of select="."/>

</xsl:template>

?

Also, even in message mappings, if he define the target message accordingly, he can also remove the tags.

Of course, this is not dynamic, so he'll need to know the tags it prior to creating the mapping.

A dynamic XSLT could even be achieved, using parent/child logics.

Regards,

Henrique.

Former Member
0 Kudos

Hi

I am agree with Henrique, but Srinivas can you tell us the payload you specified in your question is at the source side or target side.

If its on the source side then definitely you can reomve them with the help of graphical mapping.

- lalit -

henrique_pinto
Active Contributor
0 Kudos

Not with message mappings (not in PI 7.0, at least).

You'll need xslt or java/abap mapping for that.

Henrique.