cancel
Showing results for 
Search instead for 
Did you mean: 

Position function query in XSLT

Former Member
0 Kudos

I have a query regarding XSLT mapping

I have two E1EDK03 segments for the same qualifier. But I want the values based on posiotion

Example:

<E1EDK03 SEGMENT="1">
         <IDDAT>012</IDDAT>
         <DATUM>20110720</DATUM>
      </E1EDK03>
     <E1EDK03 SEGMENT="1">
         <IDDAT>012</IDDAT>
         <DATUM>20110905</DATUM>
      </E1EDK03>

If position = 1, I need the 1st set of E1EDK03

<E1EDK03 SEGMENT="1">
         <IDDAT>012</IDDAT>
         <DATUM>20110720</DATUM>
      </E1EDK03>

If position = 2, I need the 2nd set of E1EDK03

<E1EDK03 SEGMENT="1">
         <IDDAT>012</IDDAT>
         <DATUM>20110905</DATUM>
      </E1EDK03>

How to achieve that using XSLT

Thanks

Accepted Solutions (0)

Answers (3)

Answers (3)

varun_k
Contributor
0 Kudos

Hi Ramesh,

Source is the Orders Idoc and Target structure is also Idoc structure with a different structure required by third party as below

E1EDK01 (Header) Original

E1EDP01 (Item1)

E1EDS01 (Trailer)

E1EDK01 (Header) respective Correction

E1EDP01 (Item2)

E1EDS01 (Trailer)

E1EDK01 (Header) Original

E1EDP01 (Item3)

E1EDS01 (Trailer)....

Thanks,

Varun

Edited by: Varun Reddy on Sep 12, 2011 6:25 PM

Former Member
0 Kudos

Hey Varun,

As far as i can understand . You require header for each item ? am i correct

varun_k
Contributor
0 Kudos

Hi,

Since we have E1EDK03 with same qualifier 012, I don't have any other identifier to distinguish them, because at one instance I need 1st occurrence of E1EKD03 structure and another instance I need the 2nd occurrence of E1EDK03.

If you observe, only DATUM will have different values. I was trying to do that using position function

I have defined a variable to copy the segments and later trying to get the each segment based on position

<!--copying all the E1EDK03 qualifier 012 segments -->
        <xsl:variable name="e1edk03_qual_012">
			<xsl:for-each select="//IDOC/*">
				<xsl:if test="starts-with(name(), 'E1EDK03') and IDDAT = '012'">
					<xsl:copy-of select="."></xsl:copy-of>
				</xsl:if>
			</xsl:for-each>
        </xsl:variable>		

Now the above code has

<E1EDK03 SEGMENT="1">
         <IDDAT>012</IDDAT>
         <DATUM>20110720</DATUM>
      </E1EDK03>
     <E1EDK03 SEGMENT="1">
         <IDDAT>012</IDDAT>
         <DATUM>20110905</DATUM>
      </E1EDK03>

I want to split these into two E1EDK03 segments and use further in the XSLT mapping and populate in the target

Thanks

Former Member
0 Kudos

Hi,

Can you give me the sample target. like how you are expecting the target structure.

regards

Ramesh

Former Member
0 Kudos

Hi,

What do you mean by Position=1, are you passing value as 1,2... or do you need separate segments?

regards

Ramesh