SAP Content Modifier Step
The Content Modifier is one of the most frequently used steps in CPI. It lets you set, change, or delete values in three places: the message header, the message body, and exchange properties. You use the Content Modifier to prepare a message before it reaches the next step — adding metadata, injecting fixed values, or storing intermediate results for later use.
Think of the Content Modifier like a clerk who reviews a package before sending it out. The clerk checks the label (headers), writes additional notes on the form (properties), and sometimes repackages the contents (body). The Content Modifier does the same to every message that passes through it.
The Three Tabs in Content Modifier
When you open a Content Modifier step, you see three tabs:
Tab 1: Message Header
Message headers are key-value pairs that carry metadata about the message. They travel alongside the payload but are not part of the business data itself. Common uses:
- Set an HTTP header (Content-Type, Authorization) before calling an external API
- Set a custom header that downstream steps can read to make routing decisions
- Copy a value from the payload into a header for easy access in later steps
Tab 2: Exchange Properties
Exchange properties are variables scoped to the current iFlow execution. They hold intermediate values — results from a lookup, a counter, a flag — that you need to reference in later steps of the same iFlow. Properties are internal; they are never sent to the receiver.
Tab 3: Message Body
The body tab lets you replace the entire message body with a new value. Use this when you need to construct a completely new payload — for example, creating a fixed XML wrapper, or assembling a body from a combination of header values, properties, and literal text.
Value Types Available in Content Modifier
For each header or property you create, you choose how the value is determined:
- Constant – A literal value you type directly: "OUTBOUND", "001", "EN"
- Header – Copy the value from another existing header
- Property – Copy the value from an existing exchange property
- XPath – Extract a value from the XML body using an XPath expression
- Expression – Use a Groovy/Camel expression for dynamic values like timestamps
Practical Example: Setting Headers Before an API Call
SCENARIO: CPI calls an external REST API that requires specific headers
Content Modifier configuration (Message Header tab):
┌──────────────────┬────────────┬──────────────────────────────────┐
│ Name │ Type │ Value │
├──────────────────┼────────────┼──────────────────────────────────┤
│ Content-Type │ Constant │ application/json │
│ Accept │ Constant │ application/json │
│ X-Correlation-ID │ Expression │ ${property.CorrelationID} │
│ X-Source-System │ Constant │ SAP-CPI │
└──────────────────┴────────────┴──────────────────────────────────┘
Result: Every API call carries these headers, identifying the request
format and its origin.
Practical Example: Extracting a Value from Payload into Property
SCENARIO: Message contains a SalesOrder number you need in a later step
Incoming XML:
<SalesOrder>
<OrderID>SO-98765</OrderID>
<Customer>CUST-001</Customer>
...
</SalesOrder>
Content Modifier configuration (Exchange Properties tab):
┌────────────────┬───────┬──────────────────────────────────────┐
│ Name │ Type │ Value │
├────────────────┼───────┼──────────────────────────────────────┤
│ SalesOrderID │ XPath │ /SalesOrder/OrderID │
│ CustomerID │ XPath │ /SalesOrder/Customer │
└────────────────┴───────┴──────────────────────────────────────┘
Later in the iFlow, a Content Modifier can use:
${property.SalesOrderID} → "SO-98765"
${property.CustomerID} → "CUST-001"
Practical Example: Constructing a New Message Body
SCENARIO: Build a simple JSON acknowledgment response after processing
Content Modifier configuration (Message Body tab):
Type: Expression
Value:
{
"status": "success",
"message": "Order ${property.SalesOrderID} processed",
"timestamp": "${date:now:yyyy-MM-dd HH:mm:ss}",
"processedBy": "CPI-PROD"
}
Result at runtime:
{
"status": "success",
"message": "Order SO-98765 processed",
"timestamp": "2024-05-01 14:32:10",
"processedBy": "CPI-PROD"
}
Dynamic Values Using Expressions
The expression language in CPI follows the Apache Camel Simple language syntax. Commonly used expressions in Content Modifier:
- ${header.HeaderName} – Value of a specific header
- ${property.PropertyName} – Value of a specific property
- ${date:now:yyyy-MM-dd} – Current date in specified format
- ${date:now:yyyyMMddHHmmss} – Current date and time
- ${exchangeId} – Unique ID for the current message processing run
- ${camelId} – ID of the CPI tenant
Multiple Content Modifiers in One iFlow
You can use as many Content Modifier steps as needed in a single iFlow. A typical pattern:
[Start] → Content Modifier 1: Extract key fields from payload into properties → Message Mapping: Transform payload to target format → Content Modifier 2: Set required receiver headers using stored properties → Receiver Adapter: Send transformed message [End]
Using multiple small Content Modifiers, each doing one clear job, is easier to read and debug than cramming all modifications into one step.
Removing Headers
By default, CPI may pass some incoming headers to the receiver, which can cause unexpected behavior — especially security headers that should not leave CPI. You can delete headers in the Content Modifier by setting the Action to "Delete" for a specific header name, or by using a dedicated Header Remover step (available in newer CPI versions) to strip all headers before delivery.
