In SAP Cloud Integration (CPI), Message Mapping allows you to visually transform data from
one structure to another (typically XML-to-XML). Within the Message Mapping tool, Node
Functions are some of the most frequently used functions, especially when working with
repeating structures, conditional mappings, and hierarchy changes.
Here’s a detailed overview of the frequently used Node Functions in SAP CPI Message
Mapping:
What Are Node Functions?
Node Functions operate on node-level structures — such as repeating elements or groups
— in the source and target messages. They help:
• Control occurrence mapping (1:n, n:1, or 1:1)
• Implement conditional mapping logic
• Handle hierarchical transformations
• Manage empty or null nodes
Most Frequently Used Node Functions
Node Function Purpose Example Use Case
Checks if a source node exists (is Only map if Customer/Address
exists()
present) node exists
Conditionally map target node Map Discount only if TotalAmount
ifWithoutElse()
based on source > 1000
Flattens hierarchical structures Combine multiple line items into a
removeContexts()
(removes node contexts) flat list
Repeats a single value for multiple Assign the same OrderID to
useOneAsMany()
target occurrences multiple Item lines
Create separate groups in the
splitByValue() Splits source node by unique values
target per OrderID
Removes empty contexts, useful for Remove null or empty values in
collapseContexts()
flattening nested nodes
Node Function Purpose Example Use Case
Copies the current value, often Used with splitByValue or
copyValue()
used in loops conditional structures
Counts the number of occurrences Map total number of Items into a
count()
of a node summary field
equals() / Route mapping based on status
Compares node values
notEqual() being Open
Reorder Items by Price or
sort() Sorts repeating nodes by value
ItemNumber
How These Are Typically Used in Mapping
1. exists()
TargetField → exists(SourceField)
Only maps if SourceField exists. Useful in optional structures.
2. ifWithoutElse()
TargetField → ifWithoutElse(condition, sourceValue)
Maps only if a condition is true — without default fallback.
3. removeContexts() + collapseContexts()
Used together to flatten and clean nested/repeating structures.
collapseContexts(removeContexts(SourceNode))
4. useOneAsMany()
Repeats a constant or single value multiple times.
useOneAsMany(Constant("Order123"), SourceItemList)
5. splitByValue()
Splits based on unique values, useful in 1:n transformations.
splitByValue(Source.OrderID)
Example: Common Use Case
Scenario: You want to send multiple Item lines under a single Order, and assign a constant
order number to each item.
You would use:
• useOneAsMany() → Repeat OrderID
• removeContexts() → Flatten nested items
• collapseContexts() → Remove null items
Best Practices
• Use collapseContexts() with caution – it can remove meaningful structure if
overused.
• Always simulate mapping using the "Test" tab to validate node behavior.
• Chain functions logically — e.g., collapseContexts(removeContexts(...)).
• Use Message Mapping logs and traces to debug mapping results.
Quick Reference: When to Use What
Requirement Node Function
Conditional Mapping ifWithoutElse(), equals(), notEqual()
Flatten Structure removeContexts(), collapseContexts()
Group or Loop Mapping useOneAsMany(), splitByValue()
Count Elements count()
Check Existence exists()
Copy/Re-map Values copyValue()