Creating a custom function

To create your own functions, a C or C++ development tool is required, or the Java Native Interface (JNI) if you are working in a Java environment.

  1. In the Type Designer or Map Designer, you can create a new function by selecting Rules > New Function.
    The Custom Function Modules window is displayed.
  2. In the Path field, enter the path of where to create the external library.
    This should always be in the <install_dir>/function_libs directory.
  3. In the Name field, enter a name for the library.
  4. Click Add to add a function to the library.
    The Function Specification window is displayed.
  5. In the Name field, enter a name for the function.
  6. For Return Type, select the function return type from the drop-down list.
    You can select up to four function parameters from the respective drop-down list. Choices include None, Text, Number, Date and Time.
  7. In the space provided, enter a description for your function.
    This information will be displayed in the Functions window of both Designers.
  8. Click OK to validate the selected parameters and close the Function Specifications window.
  9. Click Generate.
    The Designer generates a collection of operating system specific makefiles and definition files that provide the framework for the function you are creating.
  10. Go to the <install_dir>/function_libs directory to view the results.
    As a result of the generation process, framework files are created for each operating system that IBM Sterling Transformation Extender supports. You can find the operating system-specific makefiles and definition files in the <install_dir>/function_libs/your_new_lib directory.
  11. Now you must modify the framework that was generated by the Designer.
    The following functions with the parameter information that you selected were exported to the .c file:
    • GetFunctionCount
    • GetFunctionName
    • GetInputParameter
    • GetReturnType
    • GetParameterCount
    • GetFunctionDesc

    To complete the new function, open the .c file and add your programming code for the applicable function or functions provided.

    Use the .c file to build your dynamic link library (DLL) and then place the DLL in the <install_dir>/function_libs/your_new_lib directory. (All custom designed libraries and functions must be placed in the <install_dir>/function_libs directory.)

    The new library name is listed under Category in the Functions window, and the new function that you created is placed in the list of functions and will remain available for future use from both the Type Designer and Map Designer applications.

At run time, all custom designed libraries and functions that your maps use must be in the <install_dir>/function_libs directory. When you deploy a map that uses a custom function to a remote host, the library is not transferred. Therefore you must manually copy the custom function library to the <install_dir>/function_libs directory on the remote host.

From a component rule in the Type Designer or from a map rule in the Map Designer, right-click and select the Insert Functions option. The new custom functions library appears as a separate category in the Functions window displayed in the Designers. Drag and Drop the new custom function in the component rule in the Type Designer or map rule in the Map Designer.

Custom functions follow the calling convention:

library_name->function_name([argument 1, [argument 2, [argument 3, [argument 4]]]])