Applying Data Transformations by Using Functions

Objective

After completing this lesson, you will be able to apply data transformations by using functions

Generic Functions

The figure illustrates the way to access the generic functions.

Guidelines for Generic Functions:

  • Allow for general data mappings and data transformation abilities.
  • Supply out of the box functions for general common used cases.
  • Include basic Text, Data, Boolean, Numeric, and several generic functions.

Generic functions are out-of-the-box functions that provide general data mapping and data transformation capabilities for commonly used cases. These functions include text, date, boolean, and numeric.

Some examples of built-in generic functions are listed below:

  • Concatenate, If then Else
  • Sub String, Equals
  • Greater, Less Than
  • Sort, Filter, Add/Subtract Date

Custom Functions

Custom functions are reusable functions that you create that allow for advanced data mapping and data transformation capabilities. You can create your own custom functions that can be reused. To create a custom function, right-click on Functions.

The figure illustrates the ways either to define custom functions, or to assign custom functions.

There are three function types:

  • Expression functions
  • Mapping functions
  • Enterprise Java Beans (EJB) functions

Expression Functions

Expression functions define both input and return parameters.

To create a custom expression function, use the following high level procedure:

  1. Create a new expression function and define both the input and return parameters.
  2. Add the expression logic by dragging the input parameter(s) from the context including the desired function.
  3. To use the function go to the Mapping view and double-click on the desired field.
  4. Drag your new function into the work area and add the particular input field(s) from the context.

To create a custom mapping function, use the following procedure:

  1. Create a new mapping function and define both the input and return parameters.
  2. Perform the necessary mapping, or use additional built-in expression functions.
  3. To use the function, go to the Mapping view and double-click the desired field.
  4. Drag your new function into the work area and add the particular input field(s) from the context.

Custom EJB Function

To create a custom EJB function, use the following procedure:

  1. Create a new EJB function and define both the input and return parameters.
  2. Select any existing EJB project to add the EJB, or select the existing service composer project.
  3. Add the necessary Java code to the EJB.
  4. Drag your new function into the work area and add the particular input fields from the context.

Custom and Generic Function Results

The mapping functions deliver various outputs, as shown in the figure, Final Result--Custom and Generic Functions. In the first example shown, a mapping function concatenates values. In the second example, a built-in function cuts away the information about data and year. In the third example, a EJB function adds information to a delivered field value. In the fourth example, the built-in functions select the largest order of the orders section.

Operation Mappings Import

It is possible to import graphical, XSLT, and Java operation mappings defined in the Enterprise Service Repository (ESR) of SAP Process Integration (PI) and assign them to automated activities in a Business Process Management (BPM) process. Values and parameterized mappings are not supported during import. After a successful import, the mapping can be used in an automated activity. Operation mappings cannot be assigned to message start events or intermediate message events.

Following is the procedure for import:

  1. In SAP NetWeaver Developer Studio (NWDS), go to the Process Development perspective.
  2. Choose a product, then choose Process Modeling, then expand Operation Mappings (PI).

  3. In the context menu, choose Import Operation Mapping.

  4. In the ESR Login dialog box, enter the user name and password for the system on which ESR is installed.

    SAP NWDS connects to the ESR. The Enterprise Service browser is populated with content available in the ESR.

  5. Expand a software component, namespace, and operation mappings, then choose an operation mapping to import and choose Finish.

    The operation mapping appears in the Operation Mappings (PI) folder, while the WSDL file appears in the WSDL folder. It is now possible to assign the operation mapping to an automated activity in a process.

To Import Operation Mappings from Enterprise Services Repository (ESR)

Steps

  1. Create the operation mapping in ESR.

  2. Import the WSDL of Operation Mapping by using the Process Development perspective.

  3. Switch back to the Composite Designer perspective

  4. Create an Automated Activity in BPM to reference the imported WSDL.

  5. Under PropertiesInterface assign the imported mapping as Service interface PropertiesInterface.

  6. Create a new Service Reference using the type "WS" and "localhost" and the local Provider System field flagged.

  7. Create the Input and Output Mappings. This is to do the following:

    • Map the BPM local variable to the outbound interface of the Operation Mapping.

    • Map the result of the mapping in the inbound interface to a local variable.

Log in to track your progress & complete quizzes