SAP Integration

SAP CPI Message Mapping Basics: Build, Test, and Troubleshoot Graphical Mappings

Learn how SAP CPI message mapping works, how to connect source and target fields, when to use mapping functions, and how to troubleshoot common runtime errors.

SAP CPI Message Mapping WorkflowShow the main path from an incoming payload through schema mapping to receiver output.SAP CPI Message Mapping WorkflowShow the main path from an incoming payload through schema mapping to receiver output.loads structuredefines fieldsproduces outputdeploy after validationIncomingmessagePayloadreceived…Source andtarget…Definitionsthat describ…Graphicalmessage…Fieldconnections,…Validationand testTestcomplete,…ReceiverpayloadTransformedmessage…CertPas original visual explanation
Process diagram showing an incoming SAP CPI message moving through source and target schemas, graphical mapping, testing, and the receiver payload.
On this page
  1. Understand message mapping in SAP CPI
  2. Prepare source and target schemas
  3. Create graphical field mappings
  4. Use SAP CPI mapping functions
  5. Test a message mapping
  6. Troubleshoot mapping failures
  7. Maintain mappings safely
  8. Choose the right mapping approach

SAP CPI message mapping transforms an incoming XML structure into the format required by a receiver. In SAP Integration Suite, Cloud Integration, a mapping is commonly placed inside an iFlow between sender processing and receiver conversion or adapter steps.

A reliable mapping starts with a clear source message, a matching target definition, and test data that represents real business cases. The graphical editor then lets you connect fields, apply functions, and validate the output before deployment.

Understand message mapping in SAP CPI

Message mapping works on a source schema and a target schema. The source describes the payload received by the iFlow, while the target describes the structure expected by the receiver. The mapping runtime evaluates the source values and produces a target message.

A typical flow is:

  1. The sender adapter receives the message.
  2. The iFlow identifies or creates the source structure.
  3. The message mapping transforms source nodes into target nodes.
  4. Subsequent steps enrich, convert, route, or deliver the result.

Mapping is different from simple content modification. A content modifier can set or replace selected values, while graphical mapping expresses relationships between hierarchical message structures. Review the broader flow design in SAP CPI iFlow Basics before changing a mapping inside an existing integration process.

SAP CPI Mapping Troubleshooting FlowGuide operators from a mapping symptom to the most relevant diagnostic area.SAP CPI Mapping Troubleshooting FlowGuide operators from a mapping symptom to the most relevant diagnostic area.empty or missing valueduplicates or missing repeatsconversion or receiver errortrace executiontrace executiontrace executionMappingsymptomEmpty,duplicated,…Checksource dataConfirm thesource node…CheckcontextReviewrepeating-n…CheckformatReview types,dates,…Reviewmessage logCorrelatethe failure…CertPas original visual explanation
Troubleshooting flow for SAP CPI message mapping symptoms, checking source data, context, output format, and the message processing log.

Prepare source and target schemas

Open the message mapping artifact and load the source and target definitions used by the integration scenario. XML schemas, WSDL-derived structures, and imported message definitions are common inputs.

Before connecting fields, check these details:

  • The source root and target root represent the intended message types.
  • Repeating nodes are modeled as repeating nodes on the correct side.
  • Required target fields have a source value or a defined constant.
  • Namespace information is consistent with the actual payload.
  • Field names and data types match the business meaning, not only the visual position.

A mapping can be technically valid while still producing incorrect business data. For example, connecting a source partner identifier to a target material identifier may pass structural validation but fail downstream processing.

Create graphical field mappings

Drag a connection from a source field to its corresponding target field. Direct one-to-one connections are the simplest mapping pattern and should be established first.

For a practical sequence:

  1. Connect the root or main business object.
  2. Map mandatory identifiers and control fields.
  3. Map repeating item or position structures.
  4. Add constants, defaults, and conditional logic.
  5. Validate the mapping with representative payloads.
  6. Save and deploy only after the output matches the receiver contract.

When a target node occurs multiple times, confirm that the source context produces the intended number of target instances. Context behavior is a frequent cause of duplicated, missing, or unexpectedly grouped records.

Use SAP CPI Adapter Types Compared when the mapping output depends on the payload format expected by a specific sender or receiver adapter.

Use SAP CPI mapping functions

Mapping functions handle transformations that cannot be represented by a direct field connection. Common categories include string manipulation, mathematical operations, date conversion, constants, existence checks, and conditional logic.

Useful patterns include:

  • Concatenation: combine several source values into one target field.
  • Substring and replacement: normalize identifiers or remove unwanted characters.
  • If-then-else logic: select a target value based on a condition.
  • Context functions: control how repeating source nodes create target instances.
  • Default handling: provide a fallback when an optional source value is empty.
  • Date and format conversion: transform values into the receiver’s required representation.

Keep function chains readable. A long chain that combines formatting, conditions, and context changes is difficult to test and maintain. Split complex logic into clear stages where the mapping design allows it, or move business logic to a dedicated processing step when that produces a more supportable iFlow.

Test a message mapping

Test with more than one payload. A successful test with a complete sample does not prove that the mapping handles missing optional fields, multiple items, empty collections, special characters, or alternate code values.

A useful test set includes:

  • One valid message with a single business object.
  • A message containing several repeating items.
  • A message with optional fields omitted.
  • Empty and null-like values where the source system permits them.
  • Boundary values such as long identifiers and unusual characters.
  • A negative case that should be rejected or routed for error handling.

Compare the generated output with the receiver schema and the receiving application’s business rules. Check both structure and value content. A target field may be present but still fail because of an incorrect namespace, format, code, or context.

Troubleshoot mapping failures

Mapping failures generally fall into three groups: design-time validation errors, runtime transformation errors, and downstream business validation errors.

For design-time errors, inspect missing schemas, invalid connections, incomplete mandatory targets, and incompatible node contexts. For runtime errors, capture the failed message and identify the source node or function associated with the failure. For downstream errors, compare the mapped output with the receiver’s required format and code lists.

Use SAP CPI Monitoring and Error Handling Basics to correlate the mapping failure with the message processing log and the exact iFlow execution.

Common symptoms and checks include:

SymptomChecks
Target field is emptyConfirm the source value exists and the function handles empty input.
Repeating items are duplicatedReview source and target contexts and the placement of context functions.
Expected target node is missingCheck mandatory conditions, filters, and node creation logic.
Runtime conversion errorVerify data type, date format, numeric format, and special characters.
Receiver rejects the messageValidate namespaces, required fields, code values, and target structure.

Maintain mappings safely

Treat a message mapping as part of the interface contract. Record the source and target message definitions, assumptions about optional fields, function behavior, and test payloads alongside the integration documentation.

When a source or target structure changes, test the complete iFlow rather than only the mapping artifact. A field addition may affect routing, content modifiers, receiver conversion, or adapter configuration. Deploy changes through the normal transport and approval process, then monitor the first production messages closely.

Keep mapping logic focused on transformation. Place credentials and endpoint settings in the appropriate security and configuration artifacts, and keep environment-specific values outside hard-coded mapping expressions.

Choose the right mapping approach

Graphical message mapping is a good fit for structured XML transformations with clear field relationships and moderate transformation logic. Other approaches may be better when the payload is simple, when the transformation is highly procedural, or when the message format is not represented well by a schema.

Use the following decision guide:

  • Choose graphical mapping for visual source-to-target relationships and reusable mapping functions.
  • Choose a content modifier for a small number of fixed headers, properties, or values.
  • Choose a script when procedural logic, custom parsing, or complex state handling is required.
  • Choose format conversion steps when the main task is XML, JSON, CSV, or fixed-length representation conversion.

The selected approach should make the integration easier to test, operate, and change. Keep the mapping artifact aligned with the iFlow’s overall design and monitoring strategy.

Back to all articles