cancel
Showing results for 
Search instead for 
Did you mean: 

How to remove (grey)suppress

archana_g417
Explorer
0 Kudos

Hi,

I have requirement like when input is true corresponding value should be given to output and when it is false corresponding value should be suppressed. after suppressing the values im not able to remove those suppress values. i have used the following udfs to remove suppress:

1. udf

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

{

if (!input[i].equals(ResultList.SUPPRESS))

result.addValue(input[i]);

}

above udf resulted in <null> values in place of suppress. screenshot is attached

2. udf

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(); 
          } 
}

}

by using this udf im able to remove suppress which are in between but when last value is suppress it is again giving <null>

I need to use the output as input to use one as many function which is throwing error because of this suppress values. Can anyone please help me to resolve this issue.

Thanks in Advance.

Accepted Solutions (1)

Accepted Solutions (1)

pvishnuvardan_reddy
Active Contributor
0 Kudos

Hi Archana,

Try the below udf for removing suppress values from the input.

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

if(i>0)

{

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

         result.addValue(input[i]);

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

          result.addValue(input[i]);

    else if(input[i]==ResultList.CC && input[i-1]!=ResultList.CC &&(i+1<input.length))

         result.addValue(input[i]);

}

else  if(input[i]!=ResultList.CC)

        result.addValue(input[i]);

}

Regards

archana_g417
Explorer
0 Kudos

Hi Vishnu,

Thank you. This is working

Answers (2)

Answers (2)

Pranil1
Participant
0 Kudos

Hi Archana,

If I am not wrong, you are using if without else. Instead of that you can use if with else and in else u can pass blank so that context will remain in tact.

Regards,

Pranil

vinaymittal
Contributor
0 Kudos

that is not a solution because the problem is that it will end up populating blank values in display queue

and also there may be a case that in future blank values may come from the source than there is no way to distinguish which blank is required and which blank is inserted by graphical mapping

another solution can be to insert a unique string in the else part like E3#@422423232332 and then elliminating that in a udf or by graphical mapping but it is sort of unacceptable as it is a workaround that isnt fool proof anything can come remember...

archana_g417
Explorer
0 Kudos


i dont want to use remove context and split by because i want the context changes as it is.

sahithi_moparthi
Contributor
0 Kudos

Hi,

Can you please share your logic screenshot.

markangelo_dihiansan
Active Contributor
0 Kudos

Hi Archana,

You can use this code: UDF type is queue


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

  if(i==0){

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

            result.addValue(a[0]);

       }

  }

  else if(i+1<a.length&&i!=0){

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

            result.addContextChange();

       }

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

            result.addValue(a[i]);

       }

  }

}

Testing

Regards,

Mark

vinaymittal
Contributor
0 Kudos

Hi Mark,

Can you explain what is the reason for the first udf not working and giving null in the place of suppress

I am just curious abt the reason

regards

Vinay

markangelo_dihiansan
Active Contributor
0 Kudos

Hi Vinay,

If you add getTrace().addWarning(a[i]); and then display queue, it will say that the grey ones are context changes __cC__ and not suppress That is why UDF 1 did not work.

Regards,

Mark

vinaymittal
Contributor
0 Kudos

Cool thanks mark

vinaymittal
Contributor
0 Kudos

Hi Mark,

//Reducing the problem to removing consecutive _CC

boolean cc = false;

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

  if(i+1 == a.length && !a[i].equals(ResultList.CC))          //we never add the last ResultList.CC to the output queue as it would just create duplicates                                                                                      //as SAP automatically adds a CC in the last after the udf is over

{

  result.addValue(a[i]);

  break;

}

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

{

  result.addValue(a[i]);

  cc = false;

}

else if(cc== false)

{

  result.addValue(a[i]);

  cc = true;

}

}

archana_g417
Explorer
0 Kudos

Hi Mark,

Thank you. its working

archana_g417
Explorer
0 Kudos

Hi Mark,

udf given by you is giving <null> when there is no suppress at last

markangelo_dihiansan
Active Contributor
0 Kudos

Hi Archana,

Can you show me a screenshot?

Regards,

Mark

vinaymittal
Contributor
0 Kudos

I checked marks code it does not give null when last value is SUPPRESS or last two values are SUPPRESS, it works fine... can you share screenshot of display queue

archana_g417
Explorer
0 Kudos

Hi Mark,

Sorry for late reply. here is the screenshot. <null> is given by udf when last values of queue are other than SUPPRESS.

markangelo_dihiansan
Active Contributor
0 Kudos

Hi Archana,

Here is the updated code


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

  if(i==0){

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

      result.addValue(a[0]);

    }

  }

  else if(i+1<a.length&&i!=0){

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

      result.addContextChange();

    }

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

      result.addValue(a[i]);

    }

  }

  else{

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

      result.addValue(a[i]);

    }

  }

}

Here are the results:

Regards,

Mark

archana_g417
Explorer
0 Kudos

Thank you Mark