cancel
Showing results for 
Search instead for 
Did you mean: 

Filter Idoc segment based on date in XSLT map

Former Member
0 Kudos

Hi,

In a Idoc to flat file XSLT mapping, I have a requirment to filter segment out of multiple segment occurance in HRMD_A idoc. Idoc has two date fields(actually string data, containing date in YYYYMMDD format) in the segment(end date and start date). I need to filter only one segment from multiple segments where current date falles within start and end dates (end date >= current date >= start date). Then map output fields from the filtered segment.

Its easy doing it in graphical mapping, but its difficult to use graphical mapping here as the message structure are enormous. I dont have much hands on in XSLT but think many of you have been through this kind of requirement using XSLT. So holding my hope high :). Please suggest a logic for this, will be highly appretiated.

Regards

Suman.

Accepted Solutions (0)

Answers (3)

Answers (3)

Former Member
0 Kudos

Hi,

use

<xsl:copy-of select here your xpath

instead of

<xsl:value-of select here your xpath

regards, Mario

madanmohan_agrawal
Contributor
0 Kudos

Suman Says..

Its easy doing it in graphical mapping, but its difficult to use graphical mapping

Hi Suman,

There is another way. Please give it a try if you want.

First Do the Message Mapping for the fields that are complex and then perform the XSLT mapping for the add-ons.

after developing both(Message Mapping and XSLT mapping), put them in a sequence (first MM and then XSLT Mapping) in your Interface Mapping.

regards,

Madan Agrawal

Former Member
0 Kudos

Hi,

please have a look here:

http://www.w3schools.com/Xpath/xpath_functions.asp

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

This will help to understand how the XSLT coding should look like!

Regards,

Kai

Former Member
0 Kudos

Hi Kai,

I refered this links but couldnot figure who to do date compare.

My current mapping is like below:

<xsl:element name="HeadcountStatus">
   <xsl:value-of select="E1PITYP[INFTY=0000]/E1P0000_*[date comparison should go here]*_/STAT1"/>
</xsl:element>

Now, I need to compare current system date with E1P0000-ENDDA and E1P0000-BEGDA before mapping E1P0000-STAT1.

Thanks for reply.

Regards

Suman

Former Member
0 Kudos

This functions will give you the current date:

fn:current-dateTime() => Returns the current dateTime (with timezone)

fn:current-date() => Returns the current date (with timezone)

fn:current-time() => Returns the current time (with timezone)

To compare:

fn:compare(comp1,comp2)

fn:compare(comp1,comp2,collation)

=> Returns -1 if comp1 is less than comp2, 0 if comp1 is equal to comp2, or 1 if comp1 is greater than comp2 (according to the rules of the collation that is used)

Example: compare('ghi', 'ghi')

Result: 0

Also I suggest working with an IF condition like this:

<xsl:if test="price &gt; 10">

<tr>

<td><xsl:value-of select="title"/></td>

<td><xsl:value-of select="artist"/></td>

</tr>

</xsl:if>

Edited by: Kai Lerch-Baier on Apr 14, 2009 10:21 AM

Former Member
0 Kudos

Problem resolved using for loop and then do comparison inside. Thanks