Data mapping defines rules for transforming the source context to the target context. Each context consists of one or more nodes representing the data that is transformed. You use drag and drop to specify which nodes are mapped to each other in the mapping editor. You use expressions based on the XPath grammar to specify how the transformation between the nodes is done. For more information about expressions, see Creating Expressions.
In this section you will find information that you must know to perform data mapping tasks successfully:
How to define mappings between parent and (or) child nodes
How to assign static values to target context nodes
How to refer to parent or root nodes in an expression
What is the meaning of the context nodes decorations
What is the meaning of the different mapping lines
Which are the supported data types
Nodes can be of simple type, which means that the node has no children or of complex type, which means that the node has child nodes. If you define data mapping from the source context to a child node from the target context, all of its parent nodes are also included in the mapping and this mapping is visualized with an asterisk (*) next to the parent node in the target context.
Depending on whether you define mappings between parent nodes or between their child nodes only, you can achieve different mapping results. The results also depend on the cardinality of the parent node. If the cardinality of the parent node is 1 and you map only the child nodes, the mapping engine creates the parent target node (B), even if the source context is empty.
A1 -> B1
A2 -> B2
If you map the parent nodes and the source structure is not initialized, then the target structure is not created.
A -> B
A1 -> B1
A2 -> B2
If the cardinality of the source parent node is greater than 1, which means that the source is a list, you have to map the parent nodes of the source and the target. Thus, for each of the elements of the source, an element is created in the target context and the mapping between child nodes is executed. If no mapping between the source and the target parent nodes exists, the mapping editor shows an error. You need to specify how the elements of the source context are transformed to the target with an expression.
A -> B
A1 -> B1
A2 -> B2
When you define data mappings between parent nodes of the same type, all their child nodes are also mapped to each other. This default behavior is called deep copy and means that the source context is copied to the target context. A plus sign (+) appears on the mapping line between the parent nodes. You can expand the mapping and see the mappings between the child nodes when you click the plus sign.
A -[+]-> B
If you have created deep copy mappings with the mapping editor in enhancement package 1 for SAP NetWeaver CE 7.1, you can migrate these mappings in higher releases of SAP NetWeaver to improve the overall performance. The mapping editor in higher releases reduces the number of persisted data mappings. As a result, you have only one mapping, whereas in CE 7.1.1 the mapping editor created all the child mappings. To do the migration, you proceed as follows:
Open the mapping containing the deep copy mapping you want to migrate, such as the input mapping of a human activity.
Delete the old deep copy mapping and create it again. You can also change other mapping in the same data context to start the migration.
The migration is started automatically.
In case you want to map only individual child nodes and not the whole structure, you can switch the mapping editor to one of the following options:
This option allows you to select individual child nodes from the source context and map them to child nodes from the target context.
This option is available when the parent nodes are lists. It allows you to select several child nodes from the source context and map them to a child node from the target context.
The switch options are available in the context menu of the collapsed mapping line between the parent 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. To do that, you double-click the target context node and specify in the expression editor the value that you want to assign.
You can enter, 5 for numeral constants, true or false for boolean constants, "abc" for text constants, 2009-08-11 for date, 14:05:00 for time, and 2009-08-11Т14:05:00 for date and time.
To assign a list with static values, you enter the elements of the list between parentheses ((...)) and separate them by a comma (,).
(ElementOne, ElementTwo, ElementThree)
When you define data mappings, you can use additional axes for selecting parent and root nodes in the expression editor. Using additional axes is useful when you want to define data mappings between lists or between their child nodes. The following axes are available:
In the expression editor it is presented as “/” and selects the root node of a context node.
In the expression editor it is presented as “../” and selects the direct parent node of a context node.
For example, you have the source and target structures of nodes as described below.
SourceRoot -> TargetRoot
A -----------> B
A1 ------------> B1
A11 -----------> B11
In the source structure, the node A is a list and has two child nodes A1 and A2. The child node A1 also has one child node A11.
You want to map A11 and A2 nodes from the source structure to B11 node in the target structure.
For example, you have the following data in source context:
XML Structure of source context
<SourceRoot> <A> <A1> <A11>a11</A11> </A1> <A2>a2</A2> </A> <A> <A1> <A11>a11'</A11> </A1> <A2>a2'<A2> </A> </SourceRoot>
You can use the string-join function to aggregate the values of the source to the target. Depending on whether you use the parent or root selector, you have different results after the mapping.
string-join( (A11, /SourceRoot/A/A2), "_" )
The result of the mapping to the target node B11 consists of two elements: [a11_a2_a2'] and [a11'_a2_a2'].
string-join( (A11, ../A2), "_" )
The result of the mapping to the target node B11 consists again of two elements: [a11_a2] and [a11'_a2']
If you create a mapping between optional nodes and the source node is missing or it does not contain any content and nested nodes, the target node is removed from the target structure and the structure is still valid.
For example, you have the source and target structures as described below.
SourceRoot -> TargetRoot
r_man_1 ------------> r_man_1
si_man_1 ----------> si_man_1
XML Structure of the source structure:
<input> <r_man_1></r_man_1> <r_man_3> <oi_opt_1></oi_opt_1> </r_man_3> </input>
XML Structure of the target structure:
<result> <r_man_1></r_man_1> <r_man_3></r_man_3> <result>
The mapping is between mandatory child nodes (
<si_man_1>), whose parent is an optional node (
<oi_opt_1>). This optional node is removed from the target structure because its child mandatory node does not receive
data from the source. When mapping is executed, only the mandatory nodes
<r_man_3> are created in the target structure and the structure is valid.
When you define data mappings, you may see the following decorations on the context nodes:
Question mark (?)
The question mark (?) decoration at the upper right corner of a node means that the mapping to this node is optional.
At sign (@)
The at sign (@) decoration at the bottom right corner of a node means that the node is an attribute and is always of simple type.
A node decorated as a stack icon means that this node may contain multiple nodes or values.
A text() child node may be also presented in the source or target context. When you define data mapping from a text() node, the text() node selects the text value of its parent node. The parent node is of complex type 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. Note that the text value is not necessary of type string but can be also of type integer, and so on.
In the mapping editor, the following mapping lines are available, which have different meanings:
They show actual mappings between source and target nodes and you can change these mappings.
They show actual mappings whose source or target node, or both, lies out of the visual area of the screen or is hidden. You can change these mappings.
They show implicit mappings that you cannot delete or update. Implicit mappings are defined in one of the following ways:
You use deep copy 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 mapping between parent nodes is expanded.
You apply a reusable mapping function. All children mappings are done implicitly and the mapping lines between them are dotted when parent mapping is expanded.