cancel
Showing results for 
Search instead for 
Did you mean: 

Integration Advisor: Lookup Value from Another Node Based on Current Source Node Value

Jovee
Advisor
Advisor
0 Kudos
189

Hi All,

Hope someone has encountered this before in MAG as it seems Integration Advisor is not as straightforward as using generic XSLT or XPATH.

Sample Input:

<DELVRY07>
<E1EDL20>
<E1EDL24>
<E1EDL24>
<POSNR>000010</POSNR>
<EAN11>EAN001</EAN11>
</E1EDL24>
<E1EDL24>
<POSNR>000020</POSNR>
<EAN11>EAN002</EAN11>
</E1EDL24>
</E1EDL24>
<E1EDL37>
<E1EDL44>
<E1EDL44>
<POSNR>000010</POSNR>
<KDMAT>KDMAT 1</KDMAT>
<CHARG>CHARG 1</CHARG>
</E1EDL44>
<E1EDL44>
<POSNR>000020</POSNR>
<KDMAT>KDMAT 2</KDMAT>
<CHARG>CHARG 2</CHARG>
</E1EDL44>
</E1EDL44>
</E1EDL37>
</E1EDL20>
</DELVRY07>

I am trying to figure out an XSLT function to get value of E1EDL24/EAN11 if E1EDL24/POSNR = E1EDL44/POSNR. I've tried the following ways below already but nothing works:

a. <xsl:value-of select="$nodes_in/E1EDL24[POSNR = $nodes_in/POSNR]/EAN11"/> 
--No error but just blank.

b. <xsl:value-of select="/DELVRY07/E1EDL20/E1EDL24/E1EDL24[POSNR='$nodes_in/POSNR']/EAN11"/> 
--ERROR: Failed to simulate MAG: Leading '/' selects nothing: the context item is absent

c. <xsl:key name="eanbyposnr" match="$nodes_in/E1EDL24" use="POSNR"/>
<xsl:value-of select="key('eanbyposnr', $nodes_in/POSNR)/EAN11"/>
--ERROR: Failed to simulate MAG: An xsl:function element must not contain an xsl:key element, Element xsl:key must be top-level (a child of xsl:stylesheet, xsl:transform, or xsl:package)

d. Using template, but it's not allowed at xslt function.


Ryan-Crosby
Active Contributor
The only way I have been able to manage this type of thing in IA is to generate a variable sequence and process the entries in a for-each loop. My scenario is index based so it's one less step than matching by key, but with sequences as inputs it can be tricky for something like this.
View Entire Topic
Jovee
Advisor
Advisor
0 Kudos

I got it worked already referencing @dharamverma's post in using the node position. Thanks.

<xsl:variable name="vPOSNR" select="$nodes_in/POSNR24"/>
<xsl:variable name="vEAN11" select="$nodes_in/EAN11"/>

<xsl:for-each select="$nodes_in/POSNR24">
<xsl:variable name="vPOS" select="position()" />
<xsl:if test="$vPOSNR[$vPOS] = $nodes_in/POSNR44">
<xsl:value-of select="$vEAN11[$vPOS]"/>
</xsl:if>
</xsl:for-each>

Jovee_0-1721219502073.png