cancel
Showing results for 
Search instead for 
Did you mean: 

Regarding XSLT mapping querry

Former Member
0 Kudos

Hi,

I have an existing XSLT mapping which transforms the Idoc to the thirdparty required format.

1) Is it possible in SAP ECC to send IDoc segments with same qualifier multiple times.

Eg: E1EDK02 009 - Correction Item

E1EDK02 009 - Original Item

In the above example, E1EDK02 segment with qualifier 009 is appeared twice.

In this case, i want to get the 2nd occurance of the node (E1EDK02 009) in the XSLT mapping

I am trying using position() = 2... How to achieve this?

Any help would be appreciated

Thanks,

Varun

Accepted Solutions (0)

Answers (4)

Answers (4)

varun_k
Contributor
0 Kudos

Hi everyone,

I have couple of queries in XSLT

1) How to copy value of particular field (BELNR here) from 1 segment and use the value in another segment..

Eg: I have the Idoc structure like this

IDoc
  EDI_DC40
  E1EDK01
	field1
	field2.... 
	*BELNR* and so on other fieds
  E1EDKA1
  E1EDK02 (can be multiple segments for different/same qualifiers)
  E1EDK03 (can be multiple segments for different/same qualifiers) and so on other segments

I want to copy the BELNR field value from segment E1EDK02 qualifier 017 to BELNR in E1EDK01

2) I have some segments repeated for the same IDDAT like

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

in the above case, E1EDK03 012 is repeated twice for different DATUM value, but I need the segment for the second occurrence only i.e

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

I have tried using position but the segment is repeating twice

Any Inputs would be appreciated

Edited by: Varun Reddy on Sep 6, 2011 3:04 PM

varun_k
Contributor
0 Kudos

Hi all,

Thanks for replies.

I am able to get the values in the second position but the segment is repeating twice with the same value

Example

source

<E1EDK02 SEGMENT="1">
         <QUALF>009</QUALF>
         <BELNR>0550000067</BELNR>
         <DATUM>20110727</DATUM>
      </E1EDK02>
      <E1EDK02 SEGMENT="1">
         <QUALF>009</QUALF>
         <BELNR>0900000613</BELNR>
         <DATUM>20110727</DATUM>
      </E1EDK02>

output

<E1EDK02 SEGMENT="1">
			<QUALF>009</QUALF>
			<BELNR>0900000613</BELNR>
			<DATUM>20110727</DATUM>
		</E1EDK02>
		<E1EDK02 SEGMENT="1">
			<QUALF>009</QUALF>
			<BELNR>0900000613</BELNR>
			<DATUM>20110727</DATUM>
		</E1EDK02>

code:

<xsl:variable name="e1edk02">
				<xsl:for-each select="//IDOC/*">
					<xsl:if test="starts-with(name(), 'E1EDK02') and QUALF = '009'">
						<xsl:copy-of select="//IDOC/E1EDK02[2]"/>
					</xsl:if>	
				</xsl:for-each>
		</xsl:variable>

Please suggest. I need to do this for three qualifiers 002, 009,012

Regards

Edited by: Varun Reddy on Aug 16, 2011 3:39 PM

former_member854360
Active Contributor
0 Kudos

Hi varun,

if you ewant to remove the duplicates then create a simple one to one graphical mapping and use standard graphicakl function copyvalue[0] function to remove duplicates.\

http://help.sap.com/saphelp_nw04/helpdata/en/26/d22366565be0449d7b3cc26b1bab10/content.htm

OR USING XSLT

Input

<location>    
<state>xxxx</state>  
</location>   
<location>    
 <state>yyyy</state>
  </location>    
<location>   
  <state>xxxx</state>
  </location>

duplicate values of state should not be copy

<xsl:variable name="unique-list"      select="//state[not(.=following::state)]" />
        <xsl:for-each select="$unique-list">  
<xsl:value-of select="." />  
  </xsl:for-each>

baskar_gopalakrishnan2
Active Contributor
0 Kudos

>Any help would be appreciated

Example: To access the second position of the node1 element of the parent root element. The below syntax...

/root/node1[2]

Former Member
0 Kudos

You can try these-

/IDOC/../..../E1EDK02[2]
or 
/IDOC/../..../E1EDK02[position()=2] 

You need to include 'IF' condition to check qualifier value.

Edited by: nagarjuna _s on Aug 15, 2011 10:41 AM