cancel
Showing results for 
Search instead for 
Did you mean: 

Sort idocs by field value that is in idoc

Former Member
0 Kudos

Hello,

I need to sort idocs in XI by value of a field that is in idoc. I can use SORTBYKEY in mapping, but I need to use this function in all fields of idoc. Is there a possibility to do this more easily?

I also tried to sort context, but it is not working.

Thanks in advance,

Cédric

Accepted Solutions (0)

Answers (4)

Answers (4)

former_member91687
Active Contributor
0 Kudos

Hi Cedric,

You can refer these links to get more info on XSLT mapping:

http://www.topxml.com/xsl/tutorials/intro/xsl10.asp

http://www.w3schools.com/xsl/default.asp

Cheers,

Chandra

Former Member
0 Kudos

Stefan, Prashant,

Have you got an example of XSLT code to sort, please?

stefan_grube
Active Contributor
0 Kudos

Here is a description for sort in XSLT:

http://www.w3schools.com/xsl/el_sort.asp

An example:

source XML:

<ORDERLIST>
   <ITEM>
      <ID>870</ID>
      <PRODUCT>Sulphuric Acid</PRODUCT>
   </ITEM>
   <ITEM>
      <ID>850</ID>
      <PRODUCT>Pyridine CDE</PRODUCT>
   </ITEM>
   <ITEM>
      <ID>880</ID>
      <PRODUCT>Diamino Toluene</PRODUCT>
   </ITEM>
   <ITEM>
      <ID>860</ID>
      <PRODUCT>Cyanuric Chloride</PRODUCT>
   </ITEM>
   <ITEM>
      <ID>890</ID>
      <PRODUCT>Sodium Nitrate</PRODUCT>
   </ITEM>
</ORDERLIST>

XSLT:


<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
  <xsl:template match="/">
    <ORDERLIST>
      <xsl:for-each select="ORDERLIST/ITEM">
        <<b>xsl:sort</b> select="ID"/>
        <xsl:copy-of select="."/>
      </xsl:for-each>
    </ORDERLIST>
  </xsl:template>
</xsl:stylesheet>

Hope that helps,

Stefan

Former Member
0 Kudos

Hi Cedric,

You can use XSL mapping for doing this easier. Try to sort using the value-of param in XSL.

cheers,

Prash

stefan_grube
Active Contributor
0 Kudos

Inside the mapping tool I see no possibility to sort nodes besides assigning the sortByKey function to all subnodes and elements.

What is the source/target of the mapping?

If you have flat file -> IDOC, it might be easier to sort the flat file before the conversion.

Another idea is: Create the IDOC structure with graphical mapping tool without sorting, then write a Java Mapping with DOM parser.

Regards

Stefan