Skip to Content

UDF requirement to populate the values on target field

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)
Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

2 Answers

  • Nov 26, 2017 at 04:05 PM

    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.

    Add comment
    10|10000 characters needed 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.

  • Nov 26, 2017 at 07:30 PM

    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.

    Add comment
    10|10000 characters needed characters exceeded