Technology Blogs by Members
Explore a vibrant mix of technical expertise, industry insights, and tech buzz in member blogs covering SAP products, technology, and events. Get in the mix!
Showing results for 
Search instead for 
Did you mean: 

Introduction :

In this blog post I’m going to brief about, How effectively we can use Groovy script to tackle Agile developments in your SAP CI/CPI projects.

The requirement that we had is, need of change in IDoc basic type to the latest basic type used in ABAP code which sends the data to SAP CI. In CI/CPI we need to update the IDoc basic type to its latest where we have already completed the IDoc mappings. Keeping the effort estimation & amount of rework in consideration, we've handled this change through a simple Groovy script where it will replace the IDoc basic type to its latest in runtime instead of replacing the entire IDoc XSD which will remove the entire message mappings & would require to do complete remap.

The scenario is an outbound asynchronous iFlow, where source is SAP S/4 HANA and target is 3rd party P2P application. Also knowing about  replaceALL function in prior will help to understand the objective of this blog post.


Below is where we've add the Groovy script in our iFlow specific to the requirement. One can add the script just 1 step before the message mapping or so as per the requirement.



And the Groovy script goes by as follows,
import java.util.HashMap;
def Message processData(Message message) {
def body = message.getBody(String) as String;
return message;

with this code in place there is no need to do any further changes in your iFlow to convert the basic type. The above code will replace all the instance of "INVCON02" to "INVCON03" in the iFlow. For example in IDoc XSD, parameter in Content Modifier's Header/Property type as X-Path etc.


To conclude, you've learnt How effectively one can use "replaceALL" in Groovy, which eventually adds up an agility to meet your deliverables on time ( a Change request basically) without much effort or rework been put. Also do note that this is definitely not a SAP's best practice to have in live tenant instead use it when you need a quicker solution during your development/ testing.

Happy Learning folks 🚀



Balamurugan Jaipraakaash

Integration Consultant.
1 Comment
Labels in this area