Skip to Content

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

  1. Import the required class in UDF.
  2. Instantiate an Object of that class.
  3. 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
import: com.sap.aii.mappingtool.flib3.Arithm;

Code:

Arithm ar = new Arithm();
return ar.add(a,b,container);

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.

  • Arithm
  • Stat
  • TextFunctions
  • Bool
  • NodeFunctions

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.

To report this post you need to login first.

4 Comments

You must be Logged on to comment or reply to a post.

  1. Deviprasad Pothireddy
    Hi venkat,
       Generally we go for UDF if there is no suitable function avialable in standard functions. and my opinion is, try to implement most of the logic using standard functions.
    keep R&D on XI.

    (0) 
  2. Stefan Grube
    Hi Venkat,

    It is true that you can use a lot of standard functions inside the UDF, but unfortunately this is not possible for those functions: If, ifWithoutElse, Exists, SplitByValue, CollapseContexts and Counter.

    Regards
    Stefan

    (0) 

Leave a Reply