cancel
Showing results for 
Search instead for 
Did you mean: 

Remove duplicates in a response

Former Member
0 Kudos

Hello,

I have a scenario where I map a response message from source to target.

And after the mapping in the target I have duplicate messages in a context.

Can you suggest, please, how it's possible to delete these duplicates? May be an adapter module? I use  http_aae->PI->XI  synch scenario

Thanks

Accepted Solutions (0)

Answers (3)

Answers (3)

Former Member
0 Kudos

Thank you for your attention, guys.

I think I didn't describe properly what I want to do.

Let say our response (in a synch scenario) from target system looks like this:

<SomeValues>

  <Item>

       <value1> 1 </value1>

       <value2> text1 </value2>

  </Item>

  <Item>

       <value1> 2 </value1>

       <value2> text2 </value2>

  </Item>

</SomeValues>

After mapping on PI side, the result looks like this:

<SomeValues>

  <Item>

       <value1> 1 </value1>

       <value2> text1 </value2>

  </Item>

  <Item>

       <value1> 1 </value1>

       <value2> text1 </value2>

  </Item>

</SomeValues>

And I want to send this to the sender as a response:

<SomeValues>

  <Item>

       <value1> 1 </value1>

       <value2> text1 </value2>

  </Item>

</SomeValues>

So, the question, how is it possible to implement?

Thanks

Former Member
0 Kudos

Hello,

Not sure how u are mapping response target fields, but what i can suggest u is that u can tweak the logic which is generating duplicate value1 and value2. For example u can use something similar kind of response mapping -

Thanks

Amit Srivastava

Former Member
0 Kudos

The context may not contain only 2 fields, but more, and mapping may be complex.

I'm wondering, it there simpler way to delete same nodes. May be using adapter module

Former Member
0 Kudos

Hello,

Yes, indeed u can write AM to truncate duplicate nodes or even JM or XSLT can also do the same for u, but i think it's quite easier to do this in graphical mapping in comparison to others.

In case u don't want to touch ur main mapping then u can create one intermediate mapping which would just delete duplicate nodes and call it after ur main response mapping (in OM).

Thanks

Amit Srivastava

Former Member
0 Kudos

Thanks!

and how exactly to do that? can you please show me the way

Former Member
0 Kudos

I guess u want to know about the intermediate mapping step? right?

So create one more graphical mapping and select response structure which sender is expecting as the sender and receiver message type and then in that mapping remove the duplicate nodes (u can refer the mapping which i have shown above) and for rest of the fields where duplicates are not expected u can do 1:1 mapping.

Eventually in the Operation mapping under response tab, add ur newly created graphical mapping as the second step just after ur main reponse mapping.

Thanks

Amit Srivastava

iaki_vila
Active Contributor
0 Kudos

Hi Kyril,

I disagree with module development for your problem, because mainly is a mapping problem. The key is to play with removeContexts and collapseContexts but you should more clear with the mapping. Do you want to skip the vaules of value1 or value2 repeated? why the second item is not desired to be mapping, this means that you only want the first item?

I think, may be i'm wrong that you don't want the value1 repeated (may be the vvalue2 also?), if you removeContexts, sort, splitByValue(value changed) and later collapseContext you can remove the duplicates, if you want the value as well it will be more complicated. May be this wiki can help you: Difference Between RemoveContext and CollapseContext. - Process Integration - SCN Wiki

Regards.

Former Member
0 Kudos

I want to delete all "Item" node, because after mapping I have two identical "Items"

nabendu_sen
Active Contributor
0 Kudos

Hi Kiryl,

use 'removeContext' function on "Items" node and then 'collapseContext' function. It would pass only one "Items".

Difference Between RemoveContext and CollapseContext. - Process Integration - SCN Wiki

Regards,

Nabendu.

iaki_vila
Active Contributor
0 Kudos

Hi Kiryl,

I suppose the duplicate is not really the same message with the same ID, i think you have detected it because you have seen the payload with the same data. The problem can be in the sender system you will need to check with sender developers if they are sending the same data twice or several time.

Inside PI you haven't any standard function to avoid messages with different ID but the same data.

A synchronous scenario can't retain the messages then the only solution that i imagine is to store via JDBC/RFC lookup the data or the key data and to check in the mapping stage, when you detect ot you can throw an exception via UDF for example or to prepare an alternative receiver to receive this messages but you need to have in mind that the sender will require a response.

Hope this helps.

Regards.

nabendu_sen
Active Contributor
0 Kudos

Hi Kriyl,

Why did you duplicate when you don't want that at the final Response back to Sender?

Regards,

Nabendu.