cancel
Showing results for 
Search instead for 
Did you mean: 

Removing duplicate message contexts based on several elements

Former Member
0 Kudos

I have a need to prevent an IDoc segment being mapped if several fields are the same as a segment already mapped (prevents duplicate segments). I looked at the node manipulation functions of the graphical mapper (I am not very good with this tool) and think I could do it much more easily with xsl.

If it is possible to do this with the graphical mapping tool, could somebody please advise me? Remember, it has to be a combination of several elements that determine if a segmetn is to be mapped.

BR,

Tony.

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi,

I was facing [same kind of issue |;before some days ago, so I created an udf for this.

Choose Cache as Context or Queue while creating the UDF, base on requirement.

String[] v_current = new String [var1.length];
v_current[0] = "";
 
for(int i = 0; i<var1.length ; i++)
{
	 if( var1.length == 1 )
	{
		result.addValue( var1<i> );
	}
                      else  if( var1<i>.compareTo(v_current[0]) != 0)
	{
		result.addValue( var1<i> );
		 v_current[0] = var1<i>;
	}
 
}

Regards,

Sarvesh

Answers (2)

Answers (2)

former_member732072
Active Participant
0 Kudos

Hi Anthony,

I have a link that might be helpful to you.

https://wiki.sdn.sap.com/wiki/pages/viewpage.action?pageId=79955426

Best Regards

Former Member
0 Kudos

Hi Anthony,

You can very well do with standard functions else you can use udfs to do this. If you can give an example payload somebody can help you out here.

Regards,

---Satish

Former Member
0 Kudos

As an example, suppose that I am going to map from a structure like this:


<HEAD>
  <ITEM>
    <number>10</number>
    <material>10014</material>
    <plant>FP24</plant>
    <due>20091010</due>
  </ITEM>
  <ITEM>
    <number>10</number>
    <material>10014</material>
    <plant>FP24</plant>
    <due>20091012</due>
  </ITEM>
<HEAD>

I want to map to say IDoc element <E1EDP01> ONLY if <material> and <plant> keys are different, otherwise do not construct a target <E1EDP01> element and sub elements. So the elements above only create one element below, because <MATNR> and <PLANT> are the same in both cases:


<E1EDP01>
  <POSNR>10</POSNR>
  <MATNR>10014</MATNR>
  <PLANT>FP24</PLANT>
</E1EDP01>

Can this be done?

Former Member
0 Kudos

hI

Try this

Use Collapsecontext on your mapping

number->Collapsecontext->target

material->Collapsecontext->target

plant->Collapsecontext->target