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





SAP Cloud Platform Integration (SAP CPI) provides effective message mapping features. One of the center-elements of any integration stage is to interpret and transform message format/schema/rules between various message groups (source and target).





It is the Graphical mapping tool, that does not involve any “significant” coding but does have the 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.


Step 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:





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





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





Provide mapping name and click on create:





Step 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.





Step 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.









Step 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:





Step 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 an array of values:





Limitations:



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:


Step 1: Select XSLT mapping from pallet objects :





Step 2: Place it at required position in iflow and click on + icon:







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





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







Step 5: We can see before mapping and after mapping payload in monitoring for the Iflow:


Before XSLT Mapping:






After XSLT Mapping:






Limitations:


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/javascript 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:


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






Click on + icon after placing:





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





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





Step 4: After deploying, 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:






Limitations:


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

Conclusion:


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 info@abusinesstech.com.


Related Blogs

Learn SAP CPI, using FREE Trial License!

Comparison of testing types applicable to SAP Applications

SAP Cloud Connector - Installation Process

Security/Network Design to enable Connectivity from Cloud to SAP





THANKS FOR VISITING US. FOLLOW US FOR MORE UPDATES.