Show TOC

Creating an External Function, Exposing It as an EJB, and Using It as a Mapping FunctionLocate this document in the navigation structure

Use

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:

  1. Create an EJB DC

  2. Create an EAR DC

  3. Define component dependencies

  4. Create a stateless EJB session bean

  5. Implement the mapping function in the EJB

  6. Build the EJB DC and the EAR DC

  7. Deploy the EAR DC

  8. Use the defined EJB function as a mapping function

Procedure

Create an EJB DC and an EAR DC

In the SAP NetWeaver Developer Studio, open the Development Infrastructure perspective.

  1. Select a software component (SC). Within this SC, create a new DC with type JavaEE EJB Module . Keep the default settings.

  2. 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:

  1. For the new EAR DC:

    1. For the EJB DC you created.

      Select only the Build Time reference to ejbjar.

    2. 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

    3. 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

  2. For the new EJB DC:

    1. 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

    2. 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

  1. Open the Java EE perspective and open the EJB project you created.

  2. Open the context menu for ejbModule .

  3. Choose Start of the navigation path NEW Next navigation step Session Bean End of the navigation path.

    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

  1. Open the Development Infrastructure perspective.

  2. Open the context menu for the EJB DC you created.

  3. 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 Start of the navigation path Window Next navigation step Preferences Next navigation step SAP AS Java End of the navigation path. For more information, see Configuring the Application Server in the Developer Studio .

  1. Open the Development Infrastructure perspective.

  2. Open the context menu for the EAR DC you created.

  3. 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

  1. Open the Process Development perspective

  2. Create a new EJB function to be used by your business process from the context menu of the Functions folder, choose New EJB Function... .

  3. 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.

  4. 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 .

Example

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 .