cancel
Showing results for 
Search instead for 
Did you mean: 

How to remove SUPPRESS and null in mapping contexts

Former Member
0 Kudos

Hi,

I am trying to find a way to suppress context changes (SUPPRESS or <null>) in a mapping.

To understand, this is what I get in my context :

http://www.tu-peux-pas-test.com/upload/2013_08/pimappingcontext1.jpg

http://www.tu-peux-pas-test.com/upload/2013_08/pimappingcontext1.jpg

And here is what I want as a result (I modified the test data to get this) :

http://www.tu-peux-pas-test.com/upload/2013_08/pimappingcontext2.jpg

http://www.tu-peux-pas-test.com/upload/2013_08/pimappingcontext2.jpg

I tried many UDFs like this one but I can't have the result as expected.

http://www.tu-peux-pas-test.com/upload/2013_08/pimappingcontext3.jpg

http://www.tu-peux-pas-test.com/upload/2013_08/pimappingcontext3.jpg

The result of this kind of UDFs is that I have a <null> instead of SUPPRESS but still don't have the expected result :

http://www.tu-peux-pas-test.com/upload/2013_08/pimappingcontext4.jpg

http://www.tu-peux-pas-test.com/upload/2013_08/pimappingcontext4.jpg

As I have n values in different contexts, I can't use a simple "removeContext" and "splitByValue"...

I hope my request is quite clear and somebody can help.

Thank you,

Jeremy.

Accepted Solutions (0)

Answers (7)

Answers (7)

former_member184789
Active Contributor
0 Kudos

Hi,

Try this code with execution Type All values of queue

    for(int i=1;i<a.length;i++)

if(a[i]!=ResultList.CC && a[i-1]==ResultList.CC)

result.addValue(a[i]);

              else if(a[i]!=ResultList.CC && a[i-1]!=ResultList.CC)

result.addValue(a[i]);

else if(a[i]==ResultList.CC && a[i-1]!=ResultList.CC)

result.addValue(a[i]);

         }

praveen_sutra
Active Contributor
0 Kudos

hi

Please use below two udf.

first removeSuppress

and then

Please keep note of execution type.

thanks and regards,

Praveen T

praveen_sutra
Active Contributor
0 Kudos

apologies just an update in the addNodeRem

for (int i=0; i<input.length;i++)

          if (input[i].equalsIgnoreCase("")) {

                                                  result.addValue("");

                    }else if(input[i].equalsIgnoreCase(ResultList.CC)) {

                                        if(i>0)

                                        result.addValue(ResultList.CC);

}

markangelo_dihiansan
Active Contributor
0 Kudos

Hello Jeremy,

It is a context change not suppress. Use

if(!a[i]equals(ResultList.CC)){

     result.addValue(a[i]);

}

instead. As was suggested in the link above.

Regards,

Mark

former_member184789
Active Contributor
0 Kudos

Hi Mark,

I think this code will have the same functionality as Remove Contexts. Seems like FormatByExample can be of help in this one.

markangelo_dihiansan
Active Contributor
0 Kudos

Hello Adarsh,

Thank you for pointing this out. Here is the modified code

UDF Type: Queue Type

for(int i=0;i<a.length;i++){

     if(i+1==a.length){

          result.addValue(a[i]);

     }

     else{

          if(!a[i].equals(ResultList.CC) & !a[i+1].equals(ResultList.CC)){

               result.addValue(a[i]);

          }

          else if(!a[i].equals(ResultList.CC) & a[i+1].equals(ResultList.CC)){

               result.addValue(a[i]);

               result.addContextChange();

          }

     }

}

Test input

former_member184789
Active Contributor
0 Kudos

Hi,

The Suppress shown above is Grey colored one, not a Green one which can be removed by your code. This is most likely caused by the missing field on which you have applied the IfwithoutElse condition.Refer to the threads below:

http://scn.sap.com/thread/1408680

https://scn.sap.com/thread/480813

nipun_shedhani4
Explorer
0 Kudos

Jeremy,

Use a remove context to remove all the suppressed fields, then as suggested by Amit Srivastava, try to leverage use node function FormatByExample this should solve your purpose.

I had faced a similar problem in one of my interfaces with the use of FormatByExample, I was able to solve my purpose.

Regards,

Nipun

Former Member
0 Kudos

Hello,

Since u have to find Context changes in ur input queue so u have to use "ResultList.CC", but still it won't impact ur output too much. IMO, u have to look out for “FormatbyExample” kind of function( or create a UDF which provide same kind of functionality)…

Check this UDF:

Input will be var1 and var2

Execution type: all values of a context

int count=0;

for(int i=0;i<var1.length;i++)

{

if(!var1[i].equals("0"))

{

for(int j=0+count;j<Integer.parseInt(var1[i])+count;j++)

{

result.addValue(var2[j]);

}

count=Integer.parseInt(var1[i])+count;

result.addContextChange();

}

}

Thanks

Amit Srivastava

ambrish_mishra
Active Contributor
0 Kudos

Hi Jeremy,

Instead of checking for suppress, please try !a[i].equals("") and do resultlist.addValue(a[i])

Hope it helps!

Ambrish

Former Member
0 Kudos

Hi Ambrish,

Thanks for your help, I tried but I got the same behavior as previous UDFs :

http://www.tu-peux-pas-test.com/upload/2013_08/pimappingcontext5.jpg

http://www.tu-peux-pas-test.com/upload/2013_08/pimappingcontext5.jpg

I also tried with this :  ! a[i].equals("__cC_")) for the same result

ambrish_mishra
Active Contributor
0 Kudos

Hi Jeremy,

Pls share the mapping screenshot with your test case. This kind of requirement is common and can be solved by code or standard function.

Ambrish