cancel
Showing results for 
Search instead for 
Did you mean: 

Remove unwanted employment_information from compound employee based on company in SAP CPI iflow

former_member91017
Discoverer
0 Kudos

Hi,

I am Querying the compound employee and getting the person data with multiple employment information. I would need the employment information where the 'company is 42' under job information node. The other company employment information should be removed. This is my requirement.

I tried to remove it using filter post request reply query but the filter sends both the employment data. Below I have updated the filter details.

queryCompoundEmployeeResponse/CompoundEmployee[((person) and ((person/employment_information/job_information/employee_class = '1_NLD' or person/employment_information/job_information/employee_class = '2_NLD' or person/employment_information/job_information/employee_class = '3_NLD' ) and (person/employment_information/job_information/company = '42') and ((person/employment_information/job_information/action = 'INSERT' or person/employment_information/job_information/action = 'CHANGE') and (person/employment_information/job_information/event = 'H' or person/employment_information/job_information/event = 'R') or (((person/employment_information/compensation_information/action = 'CHANGE') or (person/employment_information/compensation_information/action = 'INSERT')) and ((person/employment_information/compensation_information/paycompensation_recurring/action = 'CHANGE') and (person/employment_information/compensation_information/paycompensation_recurring/calculated_amount_previous))))))]

As the filter dint work I have tried to use another message mapping before the original data mapping.

I am using 'createif' node function to remove the unnecessary employment information but the issue is, the field company is under job information node which repeats many times under each employment information , so the employment information is getting created as many times the company field is present.

My output XML from request reply I have provided below , also updated the createif function image.

Can any one help me to resolve the issue, which way can help me to remove the unwanted data. Please suggest.

<queryCompoundEmployeeResponse>

<CompoundEmployee>

<person>

<action>INSERT</action>

<created_by>46174</created_by>

<person_id_external>99598</person_id_external>

<employment_information>

<action>INSERT</action>

<start_date>2020-01-03</start_date>

<user_id>99598</user_id>

<job_information>

<action>INSERT</action>

<business_unit>1BS35</business_unit>

<company>42</company>

<custom_string4>NL</custom_string4>

<custom_string9>C</custom_string9>

</job_information>

<job_information>

<action>INSERT</action>

<business_unit>1BS35</business_unit>

<company>42</company>

<custom_string4>NLDP</custom_string4>

<custom_string5>CSS</custom_string5>

<custom_string9>D</custom_string9>

</job_information>

<job_event_information>

<action>INSERT</action>

<event>H</event>

</job_event_information>

<compensation_information>

<paycompensation_recurring>

<action>INSERT</action>

<last_modified_on>2021-12-29T14:53:26.000Z</last_modified_on>

<pay_component>501</pay_component>

<pay_component_type>AMOUNT</pay_component_type>

<paycompvalue>0.0</paycompvalue>

<seq_number>3</seq_number>

<start_date>2021-12-29</start_date>

</paycompensation_recurring>

</compensation_information>

<compensation_information>

<paycompensation_recurring>

<action>INSERT</action>

<pay_component>5010</pay_component>

<pay_component_type>AMOUNT</pay_component_type>

<paycompvalue>0.0</paycompvalue>

<seq_number>3</seq_number>

<start_date>2021-12-29</start_date>

</paycompensation_recurring>

</compensation_information>

</employment_information>

<employment_information>

<action>INSERT</action>

<start_date>2020-01-03</start_date>

<user_id>99598</user_id>

<job_information>

<action>INSERT</action>

<business_unit>1BS35</business_unit>

<company>17</company>

<custom_string4>SP</custom_string4>

<custom_string7>A</custom_string7>

<custom_string9>D</custom_string9>

</job_information>

<job_information>

<action>INSERT</action>

<business_unit>1BS35</business_unit>

<company>17</company>

<custom_string4>SR</custom_string4>

<custom_string9>D</custom_string9>

</job_information>

<job_event_information>

<action>INSERT</action>

<event>H</event>

</job_event_information>

<compensation_information>

<paycompensation_recurring>

<action>INSERT</action>

<last_modified_on>2021-12-29T14:53:26.000Z</last_modified_on>

<pay_component>10</pay_component>

<pay_component_type>AMOUNT</pay_component_type>

<paycompvalue>0.0</paycompvalue>

<start_date>2021-12-29</start_date>

</paycompensation_recurring>

</compensation_information>

</employment_information>

</person>

</CompoundEmployee>

</queryCompoundEmployeeResponse>

Accepted Solutions (1)

Accepted Solutions (1)

nshivaprasad5334
Participant

Hi Saranya,

Below XSLT should do the job. It removes all the employment_information nodes where /job_information/company is not '42'.

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output omit-xml-declaration="yes" indent="yes"/>
<xsl:strip-space elements="*"/>

 <xsl:template match="node()|@*">
    <xsl:copy>
      <xsl:apply-templates select="node()|@*"/>
     </xsl:copy>
  </xsl:template>

 <xsl:template match="employment_information[not(job_information/company = '42')]"/>
 
</xsl:stylesheet>

Hope it helps!

Thanks,

Shivaprasad

former_member91017
Discoverer

Thank you so much for the response. I will test it and update you.

former_member91017
Discoverer
0 Kudos

Thank you Shivaprasad. It worked. Thank you so much for the response.

0 Kudos

Hey Shiva,

It did not work for me when I tried to use an 'or' to accommodate another condition. The code is not filtering out the unwanted nodes and the input xml is being passed on to the output as it is.

My template expression is:- <xsl:template match="/queryCompoundEmployeeResponse/CompoundEmployee/person/employment_information[not(job_event_information/event = '10' or job_event_information/event = '23')]"/>

Answers (1)

Answers (1)

0 Kudos

Hi Saranya,

just FYI. as you couldn't make it in mapping.

you can make it using mapping like below.

mapping.jpg