You can create user-defined functions either from scratch, or from a selection of components that already exist on the mapping.
To create a user-defined function from scratch:
1.On the Function menu, click Create User-Defined Function. Alternatively, click the Create User-Defined Function ( ) toolbar button.
2.Enter information into the required fields (see the reference table below).
Mandatory field. Enter a name for the user-defined function you wish to create. Valid characters:
•Alphanumeric characters (a-z, A-Z, 0-9)
•Underscore ( _ )
•Hyphen/dash ( - )
•Colon ( : )
Mandatory field. Enter a library name where the function should belong. The function will be displayed under this library name in the Libraries window. If you don't specify a library, the function will be placed into a default library called "user".
Optional field. Enter some text that concisely describes the syntax of the function (for example, the expected parameters). This text will be displayed next to the function in the Libraries window, and it does not affect the implementation of the function.
Optional field. Enter the free text description of the function. This text will be displayed when you move the cursor over the function in the Libraries window or in other contexts.
Select this check box if the function should be created as inline. Clear the check box to create a regular function. For more information, see Inline and Regular User-Defined Functions.
3.Click OK. The function becomes immediately visible in the Libraries window under the library name specified above, for example:
Also, the mapping window is now redrawn so as to allow you to create the new function (this is a standalone mapping referred to as the "function's mapping"). Since any function requires an output, the function's mapping includes an output component by default.
The Return to main mapping ( ) button in the top-left corner lets you navigate from the function's mapping back to the main mapping. To open the function's mapping at any time, double-click the function in the Libraries window. For more information, see Calling and Importing User-Defined Functions and Navigating User-Defined Functions.
4.Add to the function's mapping all the components required by the function's definition. You can do this in the same way as for a standard mapping. For example, to add input or output parameters, do one of the following:
•Run the menu command Function | Insert Input, or Function | Insert Output, respectively.
•Right-click the mapping area, and select Insert Input or Insert Output from the context menu.
•Click the Insert Input ( ) or Insert Output ( ) toolbar buttons.
At the minimum, a function requires one output component to which some data is connected. As for input parameters, a function can have zero, one or more inputs. The input or output parameters can be of simple type (such as string or integer) or complex type (a structure). For more information about simple and complex parameters, see Parameters in User-Defined Functions.
So far, you created the user-defined function, but you haven't used it anywhere yet. To use the function in a mapping, drag the function from the Libraries window onto the main mapping area, see also Calling and Importing User-Defined Functions.
To create a user-defined function from existing components:
1.Select multiple components on the mapping by making a rectangular selection with the mouse. You can also select multiple components by clicking each one while holding the Ctrl key pressed.
2.On the Function menu, click Create User-Defined Function from Selection. Alternatively, click the Create User-Defined Function from selection ( ) toolbar button.
3.Follow the steps 2-4 above.