Skip to Content
0

UDF requirement to populate the values on target field

Nov 26, 2017 at 01:51 PM

60

avatar image

Hi Experts,

I have requirement as below, say the input queue looks like below:

The output should be produced on logic

1. If both 1st input and 2nd input are true then output should occur two times of occurence of 3rd input.In above example in case of 1st context for 1st and 2nd input both are true so output should contain should occur two times with same values as of that 1st context of 3rd input.

2. If either first or second input is true then output should occur same times as that of 3rd input, say in above example in 2nd context first input is "false" and 2nd input is "true" so output should occur one time with same values as that of 2nd context of 3rd input.

If you can observe first 2 contexts are two times the occurrence of first context of 3rd input because the first two inputs of 1st context of input queue are "true" .

3rd context is one time occurrence of 3rd input of 2nd context since either of first two inputs are "true" in second context of input queue.

4th and 5th contexts are two times occurrence of 3rd context of 3rd input since both first and second inputs of 3rd context of input queue are true.

6th context is one time occurrence of 4th context of 3rd input since anyone of the first two inputs value is true of 4th context of input queue.

Thanks,

Ramu.

capture.jpg (31.3 kB)
output.jpg (19.7 kB)
output.jpg (51.8 kB)
output.jpg (51.8 kB)
10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

2 Answers

Justin Santhanam Nov 26, 2017 at 04:05 PM
0

Question:

- Is there a possibility that both 1 & 2 inputs are false? If yes, how you need to handle it?

- Can we assume that all the three inputs will have the same number of queue length (in the context change perspective)? In your example all the 3 inputs has the Queue Length of "4".

Thanks,

Justin.

Show 1 Share
10 |10000 characters needed characters left characters exceeded

Hi Justin,

1. Yes, both 1&2 inputs willbe false. In that case need to suppress the output.

2. Yes all three inputs will have same queue length ( same number of context changes).

Kindly help me with udf code to achieve the requirement.

Also the number of occurrences of 3rd input will dynamic on each context.

Thanks,

Ramu.

0
Justin Santhanam Nov 26, 2017 at 07:30 PM
0

Please see the below code. Hope I understood your requirement correctly. Let me know if it doesn't meet what you need.

if(inp1[0].equals("true") && inp2[0].equals("true"))
{
                for(int i=0;i<inp3.length;i++)
                                {
                                                result.addValue(inp3[i]);
                                }
                result.addContextChange();
 
                for(int i=0;i<inp3.length;i++)
                {
                                                result.addValue(inp3[i]);
                }
}
else if(inp1[0].equals("false") && inp2[0].equals("false"))
{
               result.addSuppress();
}
else
{
                for(int i=0;i<inp3.length;i++)
                {
                                                result.addValue(inp3[i]);
                }
 
}

Thanks,

Justin.

Show 2 Share
10 |10000 characters needed characters left characters exceeded

Hi,

Is it inp1[0] or inp1[i] , are we not checking whole input array?

Thanks,

Ramu.

0

Did you see the UDF Execution Type? It's All value of the Context. So it will be always one input coming into the UDF for inp1 & inp2( can't check inp3 coz it's dynamic) . So it's okay to check inp[0].

Thx.

0