cancel
Showing results for 
Search instead for 
Did you mean: 

XSLT mapping issue in parent child relation

Former Member
0 Kudos

Hi Guys,

i have one XSLT mapping issue. Mapping scenario is from IDoc to file.

IDoc structure is as below

<ZLOIPRO1>

<E1AFKOL>

<A></A>

<B></B>

<E1RESBL>

<MATNR>1</MATNR>

<CHARG>1</CHARG>

<ZSBL>

<MTART>ABC</MTART>

</ZSB>

</E1RESBL>

<E1RESBL>

<MATNR>2</MATNR>

<CHARG>2</CHARG>

<ZSBL>

<MTART>ZHA1</MTART>

</ZSB>

</E1RESBL>

<E1RESBL>

<MATNR>3</MATNR>

<CHARG>3</CHARG>

<ZSBL>

<MTART>ZHA1</MTART>

</ZSB>

</E1RESBL>

</E1AFKOL>

</ZLOIPRO1>

As you can see 'E1RESBL' is repeatative. Now my issue is i need to select 'MATNR' and 'CHARG' from 'E1RESBL' segment when first occurance of 'ZSBL/MTART' with value 'ZHA1' appears. i.e. my output would be MATNR = 2 and CHARG = 2.

I hope i am clear. Please let me know if any solution for this.

Accepted Solutions (0)

Answers (2)

Answers (2)

former_member206604
Active Contributor
0 Kudos

Hi,

Try this

<xsl:if test="./ZSBL/MTART == 'ZHA1'">
 <xsl:for-each select="./E1RESBL">
  <MATNR>
   <xsl:value-of select="./MATNR"/>
  </MATNR>
  <BATCH>
   <xsl:value-of select="./CHARG"/>
  </BATCH>
 </xsl:for-each>
</xsl:if>

You might need to do some changes in the above.

Thanks,

Prakash

moorthy
Active Contributor
0 Kudos

Hi YashPal,

First you can search for this in the entire document. Once you found you can write the output as required.

For this you can use <xsl:if> statements etc.

also go thru some examples http://www.w3schools.com/xsl/

Hope this helps,

Regards,

Moorthy