
You edit functions when you want to define or change the function's implementation, its name or signature. When defining the function's implementation, you define how the function does a complex data transformation to produce (a new value) a result. The function's implementation depends on the type you defined when you created the function. You cannot change the function's type once you created the function.
You define the function's signature when you create it. You can change the function's return type, the names and types of its input parameters.
You can also rename the function and provide a description.
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 .
To open the function's editor, expand the Functions node in your project. In the context menu of a function, choose Open .
Defining the Implementation of a Function
You define the function's implementation depending on the function's type:
Expression function
Open the Expression tab page of the function's editor.
Specify an expression that produces the return value when the function is evaluated. For more information about expressions, see Creating Expressions .
Mapping function
Open the Mapping tab page of the function's editor.
Drag the function's arguments on the left to the function's result data on the right to define the mappings.
If you change the type of a node from the target data structure, you would still be able to see the mapping lines of previously valid mappings in the mapping editor. In the target tree, you would see the nodes that are undefined in angle brackets. The lines for these mappings would be displayed in a different color than the color for correct mappings. For more information about how you can change the color of mapping lines, see Configuring the Appearance of the Mapping and Expression Editors .
(Optional) Change already defined or erroneous mappings.
You can drag the mapping line of already created mappings to another target node. You can modify the defined expressions for the different mappings.
To correct a mapping with an undefined target, select it and drag the line to a new node from the target structure that would result in a valid mapping. Alternatively, you can change the type of the node that caused the erroneous mapping in such a way that a target node for this mapping would exist. This way, the mapping would be recovered to its previous state.
To correct a mapping with undefined source data, change the type of the source node that caused the interruption of the mapping line. This way, the mapping would be recovered to its previous state.
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.
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.
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
Expand the Functions node in your project.
In the context menu of a function, choose Open .
The function editor opens.
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.
You can select the Deprecated checkbox if you want to make the function deprecated, that is, you should avoid using it anymore.
Choose the Add pushbutton to add function parameters.
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.
Click the parameter's name in the Name field to rename the parameter.
If you change a parameter's name in a mapping function, all the mappings you had created would still exist and the change in the name would be applied.
If you change a parameter's name in an expression function, this name will be changed in all the valid expressions where it is used.
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.
Expand the Functions node in your project.
In the context menu of a function, choose Open .
The function editor opens.
Choose the Rename... pushbutton under General Information on the Overview tab page.
In the dialog that appears, specify a new name of the function in the New Name field and choose the OK pushbutton.
Specify a description of the function in the Documentation field.