Show TOC

Performing Complex Data Transformation with FunctionsLocate this document in the navigation structure

Prerequisites

You have opened the Process Development or Service Composer perspective in the SAP NetWeaver Developer Studio and have expanded your project in Project Explorer view.

Context

You create a function to perform a complex data transformation. A function relates all of its inputs to exactly one output. In the function's signature, you define the names and types of the input parameters and the value type, which the function returns. Then you create your own implementation to define how the function does the data transformation.

Once you define a new function, you can reuse it in other projects in SAP NetWeaver Developer Studio.

When you create functions, you do the following:

  1. Define the function type.

    You define one of the following function types:

    • Expression function

      You define how the function does the data transformation with an expression.

    • Mapping function

      You define how the function does the data transformation with a mapping.

    • EJB function

      You define how the function performs the data transformation with an Enterprise Java Beans (EJB) implementation. You specify the Java Naming Directory Interface (JNDI) name of the existing EJB. The EJB has a special method that executes the EJB function.

  2. Define the function name.

  3. Define the function return type.

    The return type is the type of value that is produced after the data transformation.

  4. Define the function input parameters.

Using AnyType in Functions

You can define functions for which the input and output parameters are of unknown type at design time. To do that, you use xsd:anyType (xsd is the prefix for namespace http://www.w3.org/2001/XMLSchema).

Using xsd:anyType when you create the function, means that you can provide every custom or base type as an actual parameter to the function. Using xsd:anyType is particularly useful when you define mapping functions, because it allows flexible behavior at runtime when the mapping is executed.

Procedure

  1. Expand Process Modeling if you are working in the Process Development perspective.

    If you are working with a Service Composer project, then in the Project Explorer view navigate to Start of the navigation path Service Composer Next navigation step Functions End of the navigation path.

  2. In the context menu of the Functions node, choose one of the following function types depending on your needs:
    • New Expression Function... type

    • New Mapping Function... type

    • New EJB Function... type

  3. In the dialog that appears, specify a function name in the Name field.
    Note

    The function namespace is predefined and it is the namespace of the development component (DC) that contains your project and where you create your function. You can also use functions created in different DCs in your current project. To do that, you proceed as follows:

    1. You configure dependencies to the DC containing the function you want to use. For more information about dependencies, see Defining Development Component Dependencies .

    2. You define the namespace prefix of the DC containing the function you want to use, before using the function.

  4. Select a function return type from the Return Type dropdown menu.
  5. (Optional) Select the Returns a collection checkbox if the function return type is a list of elements.
  6. Choose the Add pushbutton to add function parameters.
  7. Click Browse... in the Type field to activate the dropdown menu and select a type.
    Note

    You can click the parameter's name in the Name filed if you want to rename the parameter.

  8. (Optional) Select the checkbox in the Collection field if the parameter type is a list of elements.
  9. Choose the Finish pushbutton.

Results

You have created a function and have defined its signature. You can change the function name and signature and you can define the function implementation of expression and mapping functions when you edit the function. For more information about editing functions, see Editing Functions .