cancel
Showing results for 
Search instead for 
Did you mean: 

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

07-17-2024 1:51 PM
Jovee Product and Topic Expert
1195 views 2 comments Go to solution
0 Likes
SAP Managed Tags
Labels
edifactidocIntegration Advisorintelligent lookupMAGmappingSAP B2BXSLT
Subscribe

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.


0 Likes

Accepted Solutions (1)

Accepted Solutions (1)

Jovee
Product and Topic Expert
Product and Topic Expert
0 Likes

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

Answers (0)