cancel
Showing results for 
Search instead for 
Did you mean: 

How to implement exists and index functions inside UDF.

Former Member
0 Kudos

Hi All,

I have a complex mapping. In this i need to check wether a segment exits and if true and need to chk the element existence and if true then return the value at index = 1.

But i am not able to read the function exists inside the UDF. Can anyone help me with the syntax please...

or else how can i implement the fuctionality of mapWithDefault inside an UDF?

-Anu

Edited by: C. Anuradha on Feb 12, 2010 8:12 AM

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi All,

Thanks a lot for ur valuable suggestions.. I am able to implement this successfully...

Similarly, can anyone explain me how formatByExample works out internally?..

- Anu

jose_augastine3
Active Participant
0 Kudos

Hi Anu,

For formatByExample : /people/sundararamaprasad.subbaraman/blog/2006/02/21/real-example-for-formatbyexample

Hope this helps !!!

Regards,

J Augastine

Former Member
0 Kudos

This message was moderated.

stefan_grube
Active Contributor
0 Kudos

> Similarly, can anyone explain me how formatByExample works out internally?..

Here you find a UDF which works like formatByExample:

/people/stefan.grube/blog/2005/12/30/test-user-defined-functions-for-the-xi-graphical-mapping-tool-in-developer-studio

Answers (3)

Answers (3)

Former Member
0 Kudos

I thank you all for ur valuble help!!!

Former Member
0 Kudos

Hi Anuradha,

But i am not able to read the function exists inside the UDF. Can anyone help me with the syntax please..

You can't use exist function inside the UDF but simila functionality can be achieved.

make your UDF as Context level .Then all your input will be treated as arry. Now suppose you have a segment y and inside it field x . just take the segment as input to UDF and then in UDF ches if a. length >0 then it means the segemnt exist and by a<i> you can access all the field value of that segment.

If you can write the exact req we can give you the exact UDF also.

Regards,

Saurabh

Former Member
0 Kudos

Hi,

I even tried chkin with the length of the array.. but its not coming...

Former Member
0 Kudos

Hi Anuradha,

I have a complex mapping. In this i need to check wether a segment exits and if true and need to chk the element existence and if true then return the value at index = 1.

Why cannot u use the Node Function exists.. in mapping.

Use the Exists function to check the existence of the node and it will return true or false based on existence of node....

now pass this output to the UDF and assing the value 1 to index if u want or what ever the transformation u want...

Also u can use the if condition along with Exists function and if it is true assign the constant 1 to the target.

If i am nt clear, discribe the doubt clearly..

Babu

Former Member
0 Kudos

Hi Babu,

For both the fuctionalities I can use Standard functions. But this i need to do it for almost all the elements. So thought of doing it.

and one more thing is that, if I handle the exitstance using the stnd function can u please sugesst me how can I implement the logic like return only the 1st index value... again this can be handled using index function.. but i wanted to handle it in UDF.. so how to read index of a segment?

Former Member
0 Kudos

Hi Anuradha,

Yes u r correct if the same mapping is required for many elements... then we can write a single UDF and then reuse the same for all.

For ur requirement can u please try this one out..

write a UDF.

All values of queue.

-


input: element,result,container.

output:void

code:

result.addValue(element[0]); //only one line of code.....

-


try this logic....

Lemme know if i am wrong...

Babu.