Skip to Content
0

UDF to produce output queue without false

Dec 09, 2017 at 02:08 PM

89

avatar image

Hi Experts,

Output queue should be produced after removing "false" values and it should not contain either "SUPPRESS" or "<null>" values in the place of false.

I can achieve requirement by using "ifWithoutelse" but it will produce SUPPRESS values wherever the false value appears, I do not require that.

Also if I write below UDF it will return <null> values in queue.

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

{

if(!(Input[i].equals("false))) { result.addValue(Input[i]);

} }

Input Queue:

Output Queue should look exactly like below:

Is it possible to achieve the requirement?

Thanks,

Ramu.

inputq.jpg (23.0 kB)
outputq.jpg (19.6 kB)
10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

3 Answers

avatar image
Former Member Dec 09, 2017 at 06:29 PM
1

Because you are not handling context changes once we have false values its not resulting into expected output queue.

Assumption : all values in a context can either all be true or all be false and NOT mix of both. (base on your input queue screenshot)

Use below code:

import all values form source field in var1[] (all values of queue)

//pull all values in the queue and loop all over the values
for(int i =0; i<var1.length; i++)
{
	//compare each value to "true"
	if ((var1[i].equals("true"))){
		//add values to result queue only if value is true
		result.addValue(var1[i]);
		}
	//else check if it context change, if yes
	else if(var1[i].equals(ResultList.CC)){
		//check if previous value before context change is true, if yes
		if(var1[i-1].equals("true")){
			//add context change to result queue
			result.addContextChange();
			}
			//else do nothing
			
		}
	
}
Share
10 |10000 characters needed characters left characters exceeded
Govindaraj Thangavel Dec 13, 2017 at 04:53 AM
0

Hi Ramu,

Hope this works even when we have mix of values.

String lastone="";
for(int i=0;i<Input.length;i++)
{
if(Input[i].equalsIgnoreCase("True"))
	{ 
	lastone=Input[i];
	result.addValue(Input[i]);
	}
else if((Input[i].equals(ResultList.CC)))
	{
	if(lastone.equalsIgnoreCase("True"))
	{
	lastone="";
	result.addContextChange();
	}
}
}
Share
10 |10000 characters needed characters left characters exceeded
Evgeniy Kolmakov Dec 12, 2017 at 11:45 AM
0

Hi Ramu!

IfWithoutElse function has a parameter named "Keep SUPPRESS values". If you turn it off, you won't get that values in output queue.

Regards, Evgeniy.

Share
10 |10000 characters needed characters left characters exceeded