There was a thread in forum asking “Is there a possibility to access XI standard functions in User defined functions?”. This interested me a lot and i started working on the same. The result proved to be fruitful. I found a way to use some of the XI standard functions in UDFs.
The classes required for doing the operations are already present in the server itself. So we don’t need to do anything tough to use them in an UserDefinedFunction. The classes are present in “aii_mt_rt.jar”.
The steps to be done for using XI standard functions in UDFs are
- Import the required class in UDF.
- Instantiate an Object of that class.
- Call the required method with proper parameters.
For example, lets have a look at using an arithmetic function in a UDF.
input: String a, String b, Container container
Arithm ar = new Arithm();
The above UDF gives the functionality of “add” function in Arithmetic category. This is just a sample UDF. The original use might arise when there is a complex UDF and in between that you might require usage of some standard functions of XI.
There are some important points to be noted:
- Some Standard functions cannot be used in simple User Defined Function. The reason is that the those Standard functions work with Queues as input to them.
- Still those Standard functions can be used in “queue” type UDFs.
- One should be careful using a Standard function with some properties like “formatNumber”, “substring” etc. The properties of such functions are picked from container parameters. So one needs to set them before using that function
Here are some classes that i have tried in UDFs.
The methods in “Stat” and “NodeFunctions” classes works only with advanced type UDFs(Queue type UDFs). Things can get clear if one goes through the classes in the jar and looks into the declarations of methods within them.
Note: I have tried this in XI3.0 SP19. I did some R&D and got required output, however i doubt how far this will be helpful in designing complex mappings. Moreover one needs to risk using this in productive environment since even a package structure change(in some other version) might result in an exception.