cancel
Showing results for 
Search instead for 
Did you mean: 

Calling builtin functions from user defined functions

Former Member
0 Kudos

Hello

Can we call mapping builtin methods from our simple or advance java functions? e.g. can we have like

if(a<i>.equals(ResultList.CC))

removeContexts();

I tried using this but was giving error of undefined method. I hope our GUI mappings ultimately creates one Java class and these methods are the part of it. so can we call them inside our custom functions?

Thanks in advance.

Regards

Rajeev

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

>>Can we call mapping builtin methods from our simple or advance java functions?

This is not possible. But you can chain them to get the desired result. For example the output of the UDF can be mapped as the input of "removeContext" node function and the output of the "removeContext" can be mapped to the target.

Regards,

Jai Shankar

Answers (2)

Answers (2)

Former Member
0 Kudos

Can we call mapping builtin methods from our simple or advance java functions? e.g. can we have like

It is not possible,But you can use both UDF and builtin functions in your mapping.

ex: source structure->udf>builtinfunciton-->target strucutre.

This can be possible.Please let me know if you have any quieries.

Thanks and Regards,

Sekhar

bhavesh_kantilal
Active Contributor
0 Kudos

Rajeev,

Any special reason for this?

In an User Defined Function, you can write any Java Code and so it provides more independence to manipulate and write your logic as per requirements which the standard functions do not allow.

If you are writing a user defined function, you can always write you won java codde to handle any requirement that you want and so , I dont see any value in calling built in functions from user Defined Functions. I woudl rather write the custom code and have more flexibilty for the same.

Regards

Bhavesh

Former Member
0 Kudos

Bhavesh,

Its just to reduce our efforts of coding -:).

e.g. in our user-defined function if we want to concat some values instead of writing our code we could reuse the existing functions of concat.

but is there any reason why we can't use these methods? also if we have used some java functions e.g. deleteLeadingZeros etc. how we can resue into different mapping programs. Currently we are just recreating the same into another message mappings and copy-pasting the code.

Thanks and Regards

Rajeev

Former Member
0 Kudos

Rajeev,

UDFs can be used only in the mapping program in which it is created. As you said the easiest way is to copy and use it in another program.

But, if you need to reuse the code, you need to create a jar file for the java function you create and import the jar as an external defenition into your SWCV. Now this will be available across all mappings in your SWCV.

Regards,

Jai Shankar

Former Member
0 Kudos

Hi,

That is the way to be used because UDF belongs to a single mapping.

But one alternative is to create the function in a class. Make it as a jar and impoet it in 'imported archives'.

Then u can use the function in any mapping.

All u need to do is give an import statement in the UDF.

Regards,

P.Venkat

bhavesh_kantilal
Active Contributor
0 Kudos

Rajeev,

if you want to make a UDF generic across your Software components , one option which we have used successfully.

1. Create a Generic Software Component.

2. All other software components you create for your projecrt should have a Usage Dependency on this Software Component created in the SLD.

3. Now, write a class with the code for the UDF and create a JAR file for this and import it under imported archive of the Generic Software Component.

4. You can now, use this Class in any UDF across any Software Compoenent by creating an Object of this class and calling the corresponding methods this class.

Regards

Bhavesh