Blog Post

SAP CPI Message Mapping Examples (Groovy, XSLT, Graphical)

August 4, 2023

SAP Cloud Platform Integration (SAP CPI) provides message mapping feature. One of the center-elements of any integration stage, is to interpret between message format/schema/rules between various message groups.

It is the Graphical mapping tool, that does not involve any “significant” coding but does have flexibility to use custom code functions.

  • It is incorporated appropriately with the SAP CPI web application.
  • You can develop a message mapping by interfacing source structure fields to target structure fields through intuitive select, click, connect features.
  • It can only be used to perform the XML to XML transformations.

Some of the other mapping options provided by SAP Cloud Platform Integration:

  • XSLT
  • JavaScript & Groovy scripting

Mapping is an important step between source and target messages, it will be great if message mapping is tried before the iFlow is deployed. We can use DOST Add-on™ to test mapping features in each environment as per best practices and using good data in your functional end to end testing. 

Simulation is the functionality for testing the message mapping while at the same time structuring the Integration Flow data in SAP CPI. Let’s take a quick review of SAP CPI systems hands-On considering IDOC to File scenario for GL Posting.

Stage 1: Create an iFlow in a package as below.

Click on edit as below:

Click Add and from the dropdown menu select Integration Flow: 

On popup provide Integration Flow name:

Stage 2: Configure the IDOC sender channel as below. Give the endpoint name which is one of a kind.

Stage 3: Now include the message mapping in the iFlow and snap on the pointed symbol as below.

Provide mapping name and click on create:

Stage 4: Now import the XSD from the local folder as input and output schema as below.

Map source and target structures with conditions or coordinated.

Stage 5: To simulate or test, click on the Simulate option in the mapping as below and after that another window pops up. Presently click-on browse button and select the input file for testing.


Stage 6: Now click on the test option and check the output structure is creating. Once the file uploaded, we can change the edit the field data and test on various occasions if fundamental. 

Confirm the mapping conditions are filling in as characterized as below

“COS” is concatenated to Cost_Center field:

Stage 7: We can also perform the Display Queue option in mapping for analyzing node by node as below.

Click on highlighted button:

Popup window will appear now, which will show array of values:


1. Simulation is not possible, without uploading the sample XML.

2. Can’t copy similar or same mapping for one target element to another.

3. GUI is a little problem as you have to scroll to the right for complex mappings.

4. As compared to SAP PO, display queue option take more time to load.

XSLT Mappings:

We can also use XSLT mappings for achieving the XML based mapping requirements in SAP CPI. We need to follow below steps to use XSLT mapping:

  1. Select XSLT mapping from pallet objects :

  1. Place it at required position in iflow and click on + icon:


  1. New screen containing basic XSL template will appear, write your required XSLT transformations as below to concatenate cost center and GL account fields:


  1. After saving and deploying above transformation, we are ready to test the mapping end to end. 

  1. We can see before mapping and after mapping payload in monitoring for the Iflow:

Before XSLT Mapping:


          After XSLT Mapping: 


1. We can test XSLT mapping by deploying iflow or by external tools. Without deploying testing is not possible, you can use tools like DOST Add-on to speed up the iflow transport, testing and error handling tasks.

2. It can be used only for input messages of type XML.

3. Editor has very limited functionality and not provides much recommendations.

4. Writing of XSLT mapping required knowledge of XSL syntax and not easy to use.

Groovy Script Mappings:

Third method of transformation available in CPI is groovy/java script mappings. We can use groovy mappings by following the steps below, it gives you superman powers to transform and include custom logic in your Interfaces:

  1. Select groovy script from pallet object and place it at appropriate location in iflow where mapping transformation is required:


Click on + icon after placing:

  1. After New screen appears, you can write your required groovy script transformation on the provided screen:



  1. After saving and deploying above transformation, we are ready to test the mapping end to end. 



  1. We can see before mapping and after mapping payload in monitoring by enabling log level as trace for the Iflow:

Before Groovy Script:


        After Groovy Script:



1. We can test groovy script mapping by deploying iFlow or by external tools. Without deploying testing is not possible.


The message mapping (graphical) tool is exceedingly simple to get and begin with; you can learn the basics in a very short amount of time. It excels at solving mapping problems of low to medium complexity. Graphical, Groovy, XSLT individually or a combination of one or many types of message mapping “together” can solve different categories of problems. We can use Groovy or XSLT mappings If detailed custom logic/transformation is required between source and target messages. 

By utilizing the Simulate choice, you can try to test the mapping changes but you must have the XML before hand. Same applies for Groovy or XSLT mappings, where SAP CPI gives very limited options to test the mappings individually. DOST Add-on™ solves this problem beautifully where you can test your iFlows at Component or System level by Fast & Easy transport of iflows, test your Groovy,XSLT,Graphical mappings with the next level of Simplicity in each environment as per the change management best practices. Contact us to learn more about our Innovative, problem solving approach to supercharge your SAP CPI productivity and User Experience.

ABUSINESS is active in the field of Systems Integration focusing on SAP, SAP Cloud Platform, S/4HANA, C/4HANA technologies with subject matter expertise in SAP Cloud Platform, CPI, PI, PO, Dell Boomi, MuleSoft etc. platforms. A core part of our services consists of providing help with a strategic analysis of your integration strategy and reviewing your current development roadmap. Contact us today for consultations at

Related articles:
- The Role of an SAP Consultant in Modern Business

- The Hidden Gems of SAP Architect

- SAP DevOps: Empowering Modern Business with Abusiness Tech

- What is an SAP Developer?

Forbes Technology Council, Official Member (2022)
Forbes Technology Council, Official Member (2022)

About the Author

Jaspreet is an Executive Consultant with expertise in SAP, SaaS/Cloud Integrations, Cyber Security and Data Science. Jaspreet is hands-On Architect who does Pre-Sales, Solution Architecture, Development, Lead Delivery of Complex Integration programs, Manage disperse teams and Ensure successful Project Go-Live/Goals. He has made a lasting impact on global businesses IT projects including Aflac, Advanced Energy, Donnelley Financial Solutions(DFIN), Dell EMC and many more.

Do you want to
learn more about integration?

We are dedicated to make our knowledge accessible. You can either figure it out by yourself or you can let us give you a hand.

Let us take care of your integration.

We are SAP Certified and we can make your project happen. Explore our services and contact us. We will be happy to take on your project.

View Our Services