cancel
Showing results for 
Search instead for 
Did you mean: 

Calling a UDF from a Function Library from a different Function LIbrary

Former Member
0 Kudos

I have spent a while this morning trying to find the solution. We have a set of standard UDF stored in a PI function library. This is not an imported archive but a FL in PI. This function library is called:

FL_System (package name: com.server.xi.FUNCTION_LIBRARY)

I am building a new Function Library for this customer process build (the UDFs here would only ever be used by this customer). I need to call back to the FL_System function library but no matter what I try - I keep getting:

error: package com.server.xi.FUNCTION_LIBRARY does not exist.

These are FL objects in PI. They are compiled and active.

Yes - I have added the package.class to the Import Instructions for the new Function Library but that does not help.

How do you call a UDF that exists in FL A from a UDF that exists in FL B?

Accepted Solutions (1)

Accepted Solutions (1)

manoj_khavatkopp
Active Contributor
0 Kudos

Hi Brian,

Just tried this and look like there is no way to call on FL from another FL.

I would suggest you to export the FL_A compile it, import it back as imported Archive and then use this imported archive in your FL_B.

Br,

Manoj

Former Member
0 Kudos

I thought as much.

I was already working on a solution similar to what you suggested. The function library is used by a lot of message maps and java maps. There is no way to change them all to use a IA instead of the Function Library.

So instead, I am making a wrapper class. This class will have all the same functions as the FL, but code will be just a call to the FL. As an example:

public String getSystemEnvironment(Container container) {
FL_System fl = new FL_System(); // name of the function library return fl.getSystemEnvironment (container);
}

I hope this explains my approach and thank you for your help.

former_member207701
Participant
0 Kudos

We had this similar requirement in the past but ended up with the suggestion which is suggested by Manoj, But Brain can you elaborate more we have 2 FL FL_A and FL_B now how do you call the UDF's from FL_A in FL_B where do you write this wrapper class ?

Thanks in Advance,

Kiran Rathor

Former Member

So lets say you have your UDFs in FL_A and you want to call them from FL_B. Let us also assume you have 2 UDFs in FL_A that you want to create a "wrapper" for:

udf_1

udf_2

First, make a compiled version of FL_A in java (this is temporary but necessary).

Second, create a java class that like the following:

package myPackage;
// Any Package name you want can be used here

import FL_A; // The compiled version, this is only for the java compiler and only for this purpose

public class IA_A {
// We use IA for imported Archive, FL for Function Library.  You can use any names you want.

  protected FL_A fl; // create a reference to the function library

  public IA_A {
     // instantiate the "class" for the FL_A so you can call the functions directly.
     fl = new FL_A();
  }

  // wrapper classes
  public <return value> udf_1 (parameters) throws StreamTransformationException {
     return fl.udf_1 (parameters);
  }

  public <return value> udf_2 (parameters) throws StreamTransformationException {
     return fl.udf_2 (parameters);
  }

}

Third, Import this class into PI.

Fourth, on the FL_B - add the Import instructions and Archives used

Last, in the UDF that you want to call udf_1, now you do the following:

IA_A ia = new IA_A();

ia.udf_1 (parameters);

This will call the IA which in turn will just call the original Function Library.

I hope this helps clarify what I meant by wrapper class.

Answers (0)