Skip to Content

UDF to add context changes by taking reference of other queue

Hi,

I require help in writing a interesting UDF. We need to insert context changes in a queue at specific position taking into reference of contexts in other queue.

We have a queue with X no.of fields.
We have another field in source which has its own contexts. Based on the position of its contexts. We need to add context changes in the above queue.

Ex:
We have 2 fields <Field1> <Field2>
<Field1> Queue needs to be modified will be like
1
2
3
.
.
,
100

field2 queue.

A
B
<ContextChange>
C
<ContextChange>
D
<ContextChange>
etc

The expected output should be like
1
2
<ContextChange>
3
<ContextChange>
4
<ContextChange>
etc

How can we take another queues context changes as reference and add the same ?

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

3 Answers

  • Best Answer
    author's profile photo Former Member
    Former Member
    Posted on Sep 02, 2013 at 12:12 PM

    Hi,

    you can create a udf with two input parameters. first will contain field one queue. second one will contain field queue. get the values as "Queue " and not context.

    You can use many approches from here. One of them could be to calculate the index where we have a context change and store them in another array(getIndex array). after that, you can create a new array(finalArray) , copy fields from fieldOne to the new array and insert context change at index stored in getIndex array.

    One thing to note here is that the number of values in both input queues should be equal or you may get indexOutOfBound exception.

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Sep 02, 2013 at 12:10 PM

    Hi Challa,

    It think you can do this by formatByExample function

    Regards

    Gagan

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Sep 02, 2013 at 01:16 PM

    Hi Challa,

    Going through your requirement tried to make a suggestion.Please check if this is of your help. I think you will get an idea how can this be handled. E1EDP19 is the segment under which Feild2 is present.

    UDF for context Handling:

    int c = 0;

    int l = 0;

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

    c = c + Integer.parseInt(var1[i]);

    for(int j = l;j < c; j++){

    result.addValue(var2[j]);

    }

    l = c;

    result.addContextChange();

    }

    Regards

    Arpan


    pastedImage_2.png (10.2 kB)
    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.