Different order of XML nodes in a new solution
USE
In the migration projects, field names or structure of the payload may change (e.g., IDocs generated in SAP S/4HANA and previous SAP ECC systems). The new interface can also generate values differently. Int4 IFTT by default compares the node alphabetically, but the issue can occur when the order of the same nodes are different (for example, IDOC qualifiers)
In such a case, to compare the reference and current output, we should follow the procedure described below.
PROCEDURE
Let's take an example where we want to make an IDOC comparison. To validate the IDoc segments, including possible changes (segments may have been renamed, new ones may have been added or deleted), we need to perform an appropriate transformation for both the reference and the current message. For this purpose, we can take advantage of the XSLT transformation functionality.
In our example, we need to test IDocs generated with a different segment order than before (the message is still the same but contains a different sorting sequence for some of the segments). We will use the XSLT transformation (shown below), which adds qualified to the parent node name. With this approach, the comparison of IDoc segments is correct even if some node values are different. We can also easily compare missing or additional nodes.
<xsl:transform xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:sap="http://www.sap.com/sapxsl" version="1.0">
  <xsl:strip-space elements="*"/>
<!-- identity template - copy everything -->
  <xsl:template match="@*|node()">
    <xsl:copy>
      <xsl:apply-templates select="@*|node()"/>
    </xsl:copy>
  </xsl:template>
  <!-- Match segments with qualifiers. Value of first child node is appended to parent node name -->
  <xsl:template match="E1EDKA1|E1EDK02|E1EDK03">
    <xsl:variable name="qualifier" select="child::node()[1]/text()"/>
    <xsl:variable name="newName" select="concat(local-name(), '_', $qualifier)"/>
    <xsl:element name="{$newName}">
      <xsl:apply-templates/>
    </xsl:element>
  </xsl:template>
</xsl:transform>
The result of the transformation is as follows:
Before | After |
---|---|
<E1EDKA1 SEGMENT="1">Â Â Â Â Â Â <PARVW>RE</PARVW>Â Â Â Â Â Â <PARTN>1234</PARTN> </E1EDKA1> | <E1EDKA1_RE SEGMENT="1">Â Â Â Â Â Â <PARVW>RE</PARVW>Â Â Â Â Â Â <PARTN>1234</PARTN> </E1EDKA1> |
Please note that the presented approach can serve as a template. Depending on the case, the XSLT transformation (shown above) should be modified accordingly. The output in new interface solutions can be appropriately compared, including any relevant (also customer-specific) changes.
Â
© 2017 - 2022 Int4 AG All rights reserved