Additional Blogs by SAP
cancel
Showing results for 
Search instead for 
Did you mean: 
Former Member
In PI 7.0 and XI 3.0, one of the most often requested features (or complaints) is the capability (or lack of) to share user-defined functions (UDFs) across multiple message mappings. As a result, we often had to duplicate the code of frequently used UDFs to multiple message mappings.

This feature is now available with PI 7.1. The only restriction is that the library containing the UDFs has to be in the same Software Component Version (SWCV) as the message mapping. Therefore, if we wish to share the library in more than 1 SWCV, then we will need to create dependencies in the System Landscape Directory (SLD).

In this blog, I will discuss how to created and use UDFs that can be shared with multiple message mappings.

For demostration purposes, I will create a UDF to calculate the factorial of a number in a function library. Then, use this function library's UDF in a message mapping.

Below is the simple procedure:

  1. Create a Library and an User-Define Function to be shared.

    A Function Library can be create in any namespace under a SWCV. The Function Library, then, can be referenced from any namespace under the SWCV.

    I am going to create a function library in the namespace, http://test.com/shared, called "myUdfLibrary".

    Right-click on the namespace and select "New":

    Select "Function Library", enter the name "myUdfLibrary", and click on "Create":

    The following screen will appear. Then, follow the procedure below:

    1. Click on the "+" in "Functions and Java Area".
    2. Enter the function name, "ComputeFactorial".
    3. Enter "ComputeFactorial" as the Title.
    4. Enter the java code.
    5. Save and Activate.
  2. Use the User-Defined Function in the Function Library.

    Here, we are just going to do a simple one-to-one mapping, and use the UDF to compute the factorial. But, first, we will have to reference the function library.

    Click on the new icon "Show Used Function Libraries", as below:

    With the following screen.

    1. Click on the "+" in "Used Function Libraries".
    2. Click on the "down arrow" to select the function library from the value list.

    Select the function library and click "Apply":

    Now, we can select the function library, "myUdfLibrary", from the Message Mapping:

    Now, we can use the UDF, "ComputeFactorial", just as though we had developed it in the message mapping locally.

    When testing it, we get the following:

9 Comments