Skip to Content

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

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?

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

1 Answer

  • Best Answer
    Aug 15, 2017 at 03:56 PM

    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

    Add comment
    10|10000 characters needed characters exceeded

    • 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.