cancel
Showing results for 
Search instead for 
Did you mean: 

UDF to add context changes by taking reference of other queue

former_member203104
Participant
0 Kudos

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 ?

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

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.

former_member203104
Participant
0 Kudos

Thnx for da idea gavaksh. Wrote an udf and it worked

Answers (2)

Answers (2)

Former Member
0 Kudos

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

gagandeep_batra
Active Contributor
0 Kudos

Hi Challa,

It think you can do this by formatByExample  function 

Regards

Gagan

former_member203104
Participant
0 Kudos

Values in queue are not equal. So cant use

Former Member
0 Kudos

even if the values in both queue are not equal then you can handle it in the UDF. you can check the count of both queue and manage in a way that exception is not raised.