cancel
Showing results for 
Search instead for 
Did you mean: 

CPI Mapping-Script to filter Compound Employee response

foufou
Explorer
0 Kudos

Hello Experts,

In my scenario ,I have the following XML input file (in a very shortened form):

When replicating employees with multiple records of "PersonalDetails, the mapping works intermittently.

How can I keep only the personal_information record where end_date > =current date ?

I have applied the below standard function :

Filter und XSLT mapping :

/queryCompoundEmployeeResponse/CompoundEmployee [xs:date(person/personal_information/end_date) ge xs:date(current-date())]
?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="3.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xs="http://www.w3.org/2001/XMLSchema">
  <xsl:mode on-no-match="shallow-copy" />
  <xsl:template match="/queryCompoundEmployeeResponse/CompoundEmployee[xs:date(person/personal_information/end_date) ge current-date()]"/>
</xsl:stylesheet>

<br>

But this is not woking for me.Please let me know how can resolve this issue ?(Using XSLT mapping or Custum Function...)

Regards,

Fathi

View Entire Topic
BhaskarY
Participant
0 Kudos

Hi Fathi,

You can achieve this in graphical mapping by standard functions. I think, the active record of personal information(end date greater than current date), will be the first record of multiple records of Personal details.
So, take the endDate, change the context to ‘person’, then use mapWithDefault and then use collapse context and then use splitByValue-EachValue and then assign it to target.

Regards,

Bhaskar.

foufou
Explorer
0 Kudos

Hi Bhaskar ,

Thank you for your help.

I implemented this and now I get this error:

com.sap.aii.mappingtool.tf7.IllegalInstanceException: Cannot produce target element /ns6:EmployeeCentralEmployeeReplicationRequest/EmployeeCentralEmployeeReplicationRequest/EmployeeCentralEmployee/PersonalDetails[3]/ValidityPeriod/EndDate. Queue has not enough values in context. Target xsd requires a value for this element, but target field mapping does not produce one. Probably the xml-instance is not valid to the source xsd, or the target field mapping does not fulfill the requirement of the target xsd. on the exchange: Exchange[ID-vsa1122708-1692422930108-75-1]

when I change the context to "person" ,it will display not only end_date of Personal details records but also the end_date of job_information in the source message Queue.

How can I fix it ?

thank you

Regards,

Fathi

BhaskarY
Participant
0 Kudos

Hi Fathi,

Please ignore the above mapping as it wont work for all the scenarios.

Regards,

Bhaskar.

BhaskarY
Participant
0 Kudos

Hi Fathi,

On a common note, when there is an update for the personal information, the enddate for the latest record will always be 9999-12-31, because personal information generally contains Name, Gender, marital status, etc and we expect that they wont be changed in near future. So, I think there is no point in writing an XSLT mapping or a script. Instead we can directly map a constant value ‘9999-12-31’ to end date in target.

Regards,

Bhaskar.