cancel
Showing results for 
Search instead for 
Did you mean: 

SAP CPI: Copy xml node and update value on xml element from same element name in xslt mapping

0 Kudos

Hi Expert.

I want to copy xml node and update value on specific element from higher same node name using xslt mapping.

original data

<S_QTY> <C_C186> <D_6063>21</D_6063> <D_6060>1</D_6060> </C_C186> </S_QTY>

expect outcome

<S_QTY> <C_C186> <D_6063>21</D_6063> <D_6060>1</D_6060> </C_C186> </S_QTY>

<S_QTY> <C_C186> <D_6063>12</D_6063> <D_6060>1</D_6060> ---> D_6060 field should be copy value above D_6060.

</C_C186>

</S_QTY>

Below is my xslt code

<xsl:template match="S_QTY"> <xsl:copy> <xsl:apply-templates select="@*|node()"/> </xsl:copy> <S_QTY> <C_C186> <D_6063>21</D_6063> <xsl:variable name="v3" select="string(S_QTY/C_C186/D_6063/D_6060/text())='12'" /> <xsl:if test="string($v3)='true'"> <D_6060> <xsl:value-of select="S_QTY/C_C186/D_6063/D_6060/text()" /> </D_6060> </xsl:if> </C_C186> </S_QTY> </xsl:template>


D_6060 value was not updated as below.

<S_QTY> <C_C186> <D_6063>21</D_6063> <D_6060>1</D_6060> </C_C186> </S_QTY>

<S_QTY> <C_C186> <D_6063>12</D_6063> <D_6060></D_6060> ---> D_6060 field should be copy value above D_6060.

</C_C186>

</S_QTY>

View Entire Topic
0 Kudos

Hi Ryan

Thanks for let me know . I adding QTY in MIG as you are suggested.

It is working . I have attached screenshot for everyone.