Show TOC

Editing FunctionsLocate this document in the navigation structure

Use

You edit functions to define the function implementation and if you want to change the function name and signature. When defining the function implementation, you define how the function does a complex data transformation to produce a new value. The function implementation depends on the function type which you defined when you created the function. You cannot change the function type once you created the function.

You define the function signature when you create the function. When changing the function signature, you specify the new return type and input parameters of the function.

You can also rename the function and provide a function description.

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

  • You have created a function. For more information about creating functions, see Performing Complex Data Transformation with Functions .

Procedure

Defining Function Implementation

  1. Expand the Functions node in your project.

  2. In the context menu of a function, choose Open .

    The function editor opens.

  3. Define the function implementation.

    You define the function implementation depending on one of the following function types:

    • Expression function

      1. Open the Expression tab page of the function editor.

      2. Specify an expression that produces the return value when the function is evaluated. For more information about expressions, see Creating Expressions .

    • Mapping function

      1. Open the Mapping tab page of the function editor.

      2. Drag the function arguments on the left to the function return type on the right to define the mappings.

        In process modeling, you can use the mapping function you defined if a similar mapping is required to show how data is used in the process model. For more information about data mappings, see Defining Data Mappings

        In process modeling, you can also use mapping functions to create an instance of a complex type.

        Example

        In process modeling, you want to provide a list of principals as an argument to a custom function processPrincipals . To do that, first you create a mapping function createPrincipal createPrincipal("principalId","type") . CreatePrincipal function gets as arguments principalId (xsd:string) and type (xsd:int) and returns Principal as a result. Then, you use the mapping function to provide the list of principals to processPrincipals function.

                                         processPrincipals(
        (
        createPrincipal("principalId_1", 1),
        createPrincipal("principalId_2", 1)
        )
        )
                                      
    • EJB function

      On the Overview tab page of the function editor, specify a Java Naming Directory Interface (JNDI) name of the EJB under EJB .

      The EJB has a special method that executes the EJB function. An EJB function can be included in every expression. When the mapping is done also the EJB function is executed.

      Caution
      • The EJB must be stateless

      • The EJB must not have side effects. It must not be transactional and must not write or change anything because it cannot be guaranteed that the transaction is done only once.

      For more information about how to implement an EJB function and use it in a mapping, see Creating an External Function, Exposing It as an EJB and Using It as a Mapping Function .

(Optional) Editing the Function Signature

  1. Expand the Functions node in your project.

  2. In the context menu of a function, choose Open .

    The function editor opens.

  3. Select a new return type from the dropdown menu in the Return Type field under Signature on the Overview tab page.

    You can select the Returns a collection checkbox if the parameter type is a list of elements.

  4. Choose the Add pushbutton to add function parameters.

  5. Click the parameter's type in the Type field to activate the dropdown menu and select a type.

    You can select the checkbox in the Collection field if the parameter type is a list of elements.

  6. Click the parameter's name in the Name field to rename the parameter.

    Caution

    If you change parameter's name, all the mappings you have created in the mapping function so far are lost. For more information, see SAP Note 1465410 Information published on SAP site.

  7. Click a parameter and choose the Up or Down pushbutton to change the parameters' order.

(Optional) Editing Function Name and Description

You specify a name of the function when you create the function. In the function editor you have the option to rename the function.

  1. Expand the Functions node in your project.

  2. In the context menu of a function, choose Open .

    The function editor opens.

  3. Choose the Rename... pushbutton under General Information on the Overview tab page.

  4. In the dialog that appears, specify a new name of the function in the New Name field and choose the OK pushbutton.

  5. Specify a description of the function in the Documentation field.