cancel
Showing results for 
Search instead for 
Did you mean: 

Getting the index of an unbounded item

Former Member
0 Kudos

Hi there,

How can i get the index of an unbounded item in an incoming record set message?

For example, suppose my message looks like this:

<Root>

<Record>item_1</Record>

<Record>item_2</Record>

...

<Record>Item_X</Record>

...

</Root>

And i want to know the index of "Item_X" while mapping

Thanks,

Yigal.

Accepted Solutions (1)

Accepted Solutions (1)

MichalKrawczyk
Active Contributor
0 Kudos

Hi,

define your user defined fuction as type queue

this way you will get all values </Record>

as a table and this way you can get index easily

Regards,

michal

Former Member
0 Kudos

Yes but what is the function to gat the specific index of a record in that udf ?

Former Member
0 Kudos

Yigal,

I dont think there is a std function for that. You can write a for loop in the UDF and get the index. I guess Michal meant this.

Regards,

Jai Shankar

henrique_pinto
Active Contributor
0 Kudos

yeah, just instantiate the for loop with a counter variable, running it until a.length (where a is your input queue). then you will handle all instances of that particular node, and your counter variable will have its index value.

Regards,

Henrique.

Former Member
0 Kudos

Ok, i'll figure out how can i do this.

Thanks & Reagards,

Yigal.

henrique_pinto
Active Contributor
0 Kudos

Just create a UDF of type queue. The input of UDF is the node you want to access (in your example, Record).

In the code, use somehing like:

...
for (int i=0; i< a.length; i++) {
  <insert logic here>
}
...

And inside the for loop, you can implement the desired logic, and the variable i will have the index of your node (actually it will have index - 1, since its from 0 until a.length-1 ).

Regards,

Henrique.

Answers (0)