You can extend the standard BPM modeling and mapping functionality with custom Java code. This way you will be able to introduce new functionality which is not provided by the standard BPM modeling environment.
In order to do that, you need three development components (DC):
An EJB DC
An EAR DC
The existing process composer DC
When creating such a function, you can perform the following steps:
Create an EJB DC
Create an EAR DC
Define component dependencies
Create a stateless EJB session bean
Implement the mapping function in the EJB
Build the EJB DC and the EAR DC
Deploy the EAR DC
Use the defined EJB function as a mapping function
Create an EJB DC and an EAR DC
In the SAP NetWeaver Developer Studio, open the Development Infrastructure perspective.
Select a software component (SC). Within this SC, create a new DC with type JavaEE EJB Module . Keep the default settings.
Select the same SC and create a new DC with type JavaEE Enterprise Application . Keep the default settings.
For more information about creating and naming a DC, see Creating Development Components .
Create Dependencies for the New DCs
You have to create dependencies between the newly created DCs. For more information about how to accomplish this, see Defining Development Component Dependencies .
Follow the wizard and set the following types of dependencies:
For the new EAR DC:
For the EJB DC you created.
Select only the Build Time reference to ejbjar.
For the DC tc/bpem/mapping/facade in the SC SERVICE-COMP:
tc/bpem/mapping/facade: Deploy Time
tc/bpem/mapping/facade: Runtime
tc/bpem/mapping/facade api: Build Time
For the DC tc/je/sdo21/api in the SC ENGFACADE:
tc/je/sdo21/api: Deploy Time
tc/je/sdo21/api: Runtime
tc/je/sdo21/api: Build Time
For the new EJB DC:
For the DC tc/bpem/mapping/facade in the SC SERVICE-COMP:
tc/bpem/mapping/facade: Deploy Time
tc/bpem/mapping/facade: Runtime
tc/bpem/mapping/facade: Build Time
For the DC tc/je/sdo21/api in the SC ENGFACADE:
tc/je/sdo21/api: Deploy Time
tc/je/sdo21/api: Runtime
tc/je/sdo21/api: Build Time
Create the EJB project
Open the Java EE perspective and open the EJB project you created.
Open the context menu for ejbModule .
Choose
.Create a stateless container managed session bean and include a local business interface.
Implement the Mapping Function in the EJB
In the newly created EJB 3.0 session bean, let the local interface of your EJB extends the following two interfaces:
com.sap.glx.mapping.execution.api.function.Function com.sap.glx.mapping.execution.api.invoker.SdoInvoker
You can use the mapping function method invokeSdo in the bean implementation. The data is passed as a service data object (SDO) into this method and the result is also returned in this format.
You can import com.sap.glx.sdo.api.SdoRenamingHelper and use the provided helper functions for accessing the individual data elements within the SDO:
SdoRenamingHelper.renameXsdElementToSdoProperty SdoRenamingHelper.renameXsdAttributeToSdoProperty
Build the EJB DC and the EAR DC
Open the Development Infrastructure perspective.
Open the context menu for the EJB DC you created.
Choose Build .
Do the same for the EAR DC you created.
Deploy the EAR DC
Before you are able to deploy a DC, SAP AS Java, which runs the BPM Process Server, must be configured in the Developer Studio. To configure the SAP AS Java, choose . For more information, see Configuring the Application Server in the Developer Studio .
Open the Development Infrastructure perspective.
Open the context menu for the EAR DC you created.
Choose Deploy .
You can find out the JNDI lookup name for the EJB via opening SAP NetWeaver Administrator in a Web browser pointing to http://<host>:<port>/nwa/jndi .
Using the Defined EJB Function as a Mapping Function
Open the Process Development perspective
Create a new EJB function to be used by your business process from the context menu of the Functions folder, choose New EJB Function... .
Specify the names and the types of the function parameters. They have to match the ones you defined in the Java implementation of your EJB.
Open the newly created EJB function and enter the JNDI lookup name found above in the Object Name field. You can see the JNDI name field when you open the EJB function in the function editor.
From now on you can use this function within a mapping. For more information about data mappings, see Defining Data Mappings .
You can create different external functions and use them in your business processes. For example, you can create functions that work over strings, lists, or create complex types.
For more information about creating a function that concatenates two strings, see Example of an EJB Function Exposed as Mapping Function .