Creating Data Mappings

Objective

After completing this lesson, you will be able to create mappings

Data Mapping Definitions

Data mapping defines rules for transforming the source context to a target context. The visual display of mapped data mapping shows how data input and output by activities in the process are converted. Data mapping includes drag and drop, automapping, and quick fix features that make data mapping quick and easy.

Data mapping defines the rules for transforming the source context to the target context. Each context consists of one or more nodes. You specify with drag and drop which nodes are mapped to each other in the mapping editor. You use expressions to specify how the transformation between the nodes is done. Data Mapping is done in the Mapping property section of flow elements and the Expression Editor.

The mapping is performed in the following steps:

  • Define input and output mapping

    Define automappings to show how data used as input and output by the activities and the events in your process is transformed.

  • Define mappings using the Automapping option

    The automapping option creates a set of mapping suggestions based on matching the elements’ names, structure, and data types.

  • Apply quick fixes in data mappings and expressions

    You also have the option of fixing some common errors, which may occur when you define data mappings by applying a quick fix.

Process Context Icons

The Mapping Editor uses a variety of lines, icons, and symbols to help you visualize the data mappings. In this concept, we will discuss:

  • Mapping Editor Lines

  • Process Context Icons

  • Process Context Symbols

Mapping Editor Lines

Mapping Editor Lines are:

  • Solid lines — These lines show actual mappings between source and target nodes. You can change these mappings.
  • Dashed lines — These lines show actual mappings whose source or target nodes or both nodes lie out of the visual area of the screen or is hidden. You can change these mappings.
  • Dotted lines — These lines show implicit mappings that you cannot delete or update.

Implicit mapping can be defined in two ways. First, you can use the deep copy feature to map nodes having the same complex type assigned to them. As all child nodes are mapped to each other implicitly, the mapping lines between them are dotted when the mapping between parent nodes is expanded.

You can also apply a reusable mapping function. All child mappings are done implicitly and the mapping lines between them are dotted when the mapping between the parent nodes is expanded.

Process Context Icons

The figure shows the different process context icons.

Process Context Symbols

Context Node Symbols are:

  • Question Mark — Indicates that mapping to this node is optional (upper right corner).
  • At Sign (@) — Indicates that the node is a simple type attribute (bottom right corner).
  • Stack icon — Indicates that the node contains multiple nodes or values.

A text( ) child node may also be present in the source or target context. When you define data mapping from a text( ) node, the text( ) node uses the text value of its parent node, which is a complex type node with simple content. When you define data mapping to a text( ) node, the text value is assigned to the parent node as a text value. The text value does not have to be of type string, but can also be other types, such as an integer.

Data Mapping Rules

You use expressions and a subset of the XPath grammar to specify how the transformation between the nodes is done. These include the following:

  • Mapping parent and child nodes

    If you define data mappings to a child node, all of its parent nodes are also included in the mapping.

  • Mapping individual child nodes

    If you define mappings between parent nodes of the same type, all their child nodes are also mapped to each other.

  • Using axes in data mappings

    Additional axes can be used for selecting parent and root nodes in the expression editor. Additional axes are useful when you want to define data mappings between lists or between their child nodes.

In data mapping, expressions and a subset of XPath Grammar are used to specify how the transformation between the context nodes is done. Data mapping is done within the flow elements and the Expression Editor.

Input and Output Mapping

Assigning Static Values to Target Context Nodes

You can directly assign a static value to a target context node, which means that no data transformation from the source context is performed. There are many types of values you can enter including: numeral constants, true or false boolean constants, text constants, date, time, date and time. To assign a list with static values, enter the elements of the list between parentheses and separate them by a comma, for example, (ElementOne, ElementTwo, ElementThree).

Defining Data Mappings

You define data mappings to show how data used as input and output by the activities and the events in your process is transformed, according to the following guidelines:

  • Input mapping

    Defines how the data transformation between the process context and the input context of an activity or event is done.

  • Output mapping

    Defines how the data transformation between the output context of an activity or event and the process is done.

  • Input and output mapping

    Shows which nodes are mapped to each other, but does not specify how the transformation is done. You define how the transformation is done with an expression.

  • Mapping assignment options

    Depending on the nodes type and their cardinality, you can define the following mapping assignment options: Set (Source context overrides the target context), Append (Source context objects are appended to the list of existing target context objects), Merge (Source context objects are merged with the target context objects)

You define data mappings to show how input and output data is transformed by the activities and the events in your process. When you define input mapping, you define how the data transformation between the process context and the input context of an activity or event is done. When you define output mapping, you define how the data transformation between the output context of an activity or event and the process context is done.

Input and output mapping shows which nodes are mapped to each other, but it does not specify how the transformation is done. You define how the transformation is done with an expression.

The Assignment Option

Mapping Assignment Options

Depending on the type of nodes and their cardinality, you can define the following mapping assignment options: set, append, and merge.

The figure shows a screenshot, which illustrates the procedure to create an assignment. The assignment has three options:

  • Append

  • Merge

  • Set

Set

Set is the default assignment for both node types. When you use the set option, the source context overrides the target context. For example, in the source context object you have one element, and the target object contains five elements. When you use the set option, you have one element after mapping.

Append

The append option is available for both node types if the maximum occurrence is greater than 1. When you use the append option, the source context objects are appended to the list of existing target context objects. For example, in the source context object, you have one element and the target context object is a list containing five elements. When you use the append option, you have six elements after mapping.

Merge

The merge option is intended for structured target data. When you use the merge option, the source context objects are merged with the target context objects. New objects are created in the target object if the number of objects in the source object is greater than the number of objects in the target object. For example, in the source context object, you have a list containing five nodes A, B, C, D, and E. In the target object you have a list containing two nodes M and N. When you use the merge option, after mapping you have a list with the following nodes: M, N, C, D, and E.

Automapping

The automapping option creates a set of mapping suggestions by matching the elements' names, structure, and data types. You can also manually specify any necessary assignments.

Automapping Options are:

  • You can select between simple and advanced automapping.
  • Mapping suggestions are created using different algorithms based on your selection.

Simple Name-Based Automapping

The simple name-base automapping option creates mapping suggestions by matching the elements' names from the source and target structures.

Advanced Automapping

The advanced automapping creates the mapping suggestions by matching the source and the target elements using the following algorithms:

  • Name Matcher — compares only the names of elements.
  • NamePath Matcher — compares the entire paths from element to root.
  • Leaf Matcher — compares the leaves that lie underneath the given elements.
  • Parent Matcher — compares the siblings of the given elements.

When using the advanced automapping option, you can select the method for similarity aggregation. You can select either average, which calculates the average over all selected algorithms, or maximum, which accepts only the highest result over all algorithms and rejects the rest.

Matching Precision

You can adjust the level of matching precision when you switch between the high,medium, and low options. The high precision option means that only matches with a good quality are accepted, so you can be reasonably confident that the matches make sense. However, you must always check all the results. The low precision offers more matches but these may not be of a very high quality.

Dictionary Import

You can import a dictionary file to improve matching using synonyms and abbreviations. The dictionary supports text files and OLIF V2 file formats.

In a text file, you define synonyms following a header named Synonyms and abbreviations under the keyword Abbreviations. With abbreviations, you must write the short form first separating pairs of entries by a comma. A sample text file is shown in the following example:

Synonyms ship, deliver bill, invoice state, county Abbreviations No, Number tel, telephone VAT, value added tax

OLIF File V2 Specification

For information about the OLIF V2 format, see http://www.olif.net.

Errors in Mappings

You can solve several types of errors in data mappings and expressions by applying a quick fix. You can apply a quick fix to errors resulting from a difference between data types to define mapping between source and target nodes with different data types. The quick fix enables the source node data type to be processed as the target node data type with the "cast as" function.

Built-in Mapping Functions

A number of predefined built-in functions (Rules and Functions) are provided to assist with mapping. These built-in functions are Java methods. You can find these predefined rules and functions in the mapping and expression editor.

You can create your own user defined functions (UDFs) using the the Composer Project Type (Developer Component) service. UDFs created in the service are then placed in the project and are available in the mapping editor.

The figure shows the built-in mapping functions.

Mappings: Triggers, Conditions, and Correlations

Event triggers are used in the following flow objects:

  • Start events

  • Intermediate events

  • End events

From a technical standpoint, event triggers are treated as service interface endpoints, a classical Web service provider. The trigger is defined separately and assigned to the corresponding event.

The start trigger can be assigned a start condition. The values of the incoming messages can be checked against a start condition. For this, the Expression Editor is used. Built-in functions and UDFs can also be used here for mapping. The result of the test must provide the value boolean TRUE. Therefore, at least one value of TRUE must be configured.

In a process, checks (also known as conditions), ‘is the weight of a package below 5 KG’ are frequently processed.

An intermediate message event (details of which are shown in the figure, Expression Editor) can examine the values of the incoming message in a correlation condition. These are the same conditions as those of the start condition. A trigger may be associated with an intermediate message event only once.

Mappings: Conditional Start

The feature conditional start was introduced in version 7.31 SP06. Conditional start works in the following way: If the same trigger is used twice in a process, first at a start event and secondly at an intermediate message event, the BPM runtime decides to which receiver the message is sent. The message is received in an ongoing BPMN process by the intermediate message event, or a new process instance is created by the start event.

Additional Information can be found in the Developer Network at: https://blogs.sap.com/2013/03/25/conditional-start-introduction-17/

Log in to track your progress & complete quizzes