on 08-12-2015 6:17 AM
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.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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...
i dont want to use remove context and split by because i want the context changes as it is.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
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;
}
}
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
User | Count |
---|---|
87 | |
10 | |
10 | |
10 | |
7 | |
6 | |
6 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.