Technical Articles
Faster Groovy Development for SAP CPI without Installing an IDE
The Need for Speed
Groovy scripting is an integral part of the CPI. It is a perfect glue script in Java environments and it has integration history.
There are a few annoyances to using it:
- The only way to check for syntax errors is to deploy the integration.
- The only way to check logic and functionality is to deploy the integration and ensure the message processing in the flow by triggering it via an adapter like HTTP or SFTP
It takes a lot of time to validate your script even for small changes.
I tried Eclipse and the experience was not perfect. Intellij IDEA seemed to be the way to go. I prepared myself to install another IDE to my computer on top of different versions of Eclipse that I had to maintain. I was going to learn every button and best practice to tell my consultant colleagues.
Then one night, I couldn’t sleep. Whether I turn to left or right in the bed I was seeing some Groovy script telling me to “run”. Why don’t I build a solution that will make my life and the lives of my fellow SAP integration consultants in the world easier? I had to try even that made me skip sleep a few nights more.
The Quick & Easy Solution
Just use your browser, paste your input, paste your Groovy script, and run. That is all.
You can bookmark the “CPI Test Mode” page.
https://groovyide.com/cpi
Conclusion
For the power user and complicated projects with library dependencies, IntelliJ IDEA may be a better solution now. But even for them, there comes a time to write a one-off script on a different computer and test it fast.
It is free and It will be free, so it can become a useful everyday app in your toolbelt like Postman or SoapUI for SAP CPI development.
Regards
Hello Hasan,
Can you run this script as a response?
Love it. Glad you could not sleep. I hope you can sleep better now.
It enables you to try out some code easy.
One idea would be to add the option to upload a trace and parse the input and fill it in. That way it will be easier to run.
Ps. If you get to install an IDE then we provide a git repository and Gradle plugins to deploy the ilfow from the IDE.
Hi Daniel, thanks for the feedback! Yes, I can sleep in peace now.
Automatically filling in input can be an interesting use case. I try to keep this as simple as possible, so I will think about that.
Also, storing code in Git is never a bad move. I will check that.
Regards,
Fatih
Hi Fatih,
Thats really a wonderful tool :).
thanks for sharing.
regards,
Praveen T
Hi Praveen,
Thanks for the comment. I'm glad you find this useful.
Regards,
Fatih
Hi Fatih,
what do you think about integrate it to the cpi helper plugin?
I was thinking for a link that sends the trace data and a general link in the editor that also sends the groovy script to your side.
I do not think that’s too much work on both sides.
I can do the cpi helper part.
For you it would be:
What do you think?
But first I should check if it is possible to send data to foreign pages from chrome plugin. Maybe there is some security mechanism that prevents this.
Best regards
Dominic
Edit: connection to your page would work if you set the correct CORS Header.
Hello Dominic,
Thank you for your comment. I agree that a page clarifies data protection is a very good idea even without any integration. Right now server doesn't persist anything, so I should state that.
Regarding integration with CPI helper plugin. Changing CORS headers can cause everyone to send requests to the server. It can cause more security problems in the long run.
I also want to control the user experience. So a better option can be preparing a URL in the plugin and opening the URL in a new tab.
When I implement this feature, I will share here.
Regards,
Fatih
Hi Dominic Beckbauer ,
I would really love to see this feature in your plugin. From my understanding Fatih's current implementation (see here) doesn't need CORS headers. You could just scrape the ressources together, encode them as base64, build the url and then render a regular link in your plugin with target="_blank". That should be sufficient to let users jump from your plugin to the Fatih's pre-filled IDE. Or did I oversee anything?
Best regards,
Raffael
I am already working on it 🙂
The problem is to get the current version of the script. So probably there will be a version but it will not send the script. You still have to copy and paste it.
Hi Dominic Beckbauer ,
I don't know which point exactly is holding you back from getting the script content, but maybe I can help by describing how I would do it. 🙂
Then extract the field "reg_id" from the object where the field "TechnicalName" equals the {package-id} from the response and save it as variable "package-tech-id". (We need it later.)
Then extract the field "reg_id" from the object where the field "Name" equals the {iflow-id} from the response and save it as variable "iflow-tech-id". (We need it later.)
The get the scriptname (without path) from the response (e.g. "script1.groovy") and store it in a variable like "script-name". (We need it for the last step.)
(Attention the double slash in front of the script name is a must!)
Let me know if I can help you any further.
I already hate the day when SAP changes the internal APIs 🙂
Seems like this is a way to go. Do you know if it is always the last version of the script? So when I change sth in the iflow, press safe (or maybe do not press safe), do I get this version or the last version that was safed with a version number?
Thanks for the hint. That saved a lot of time 🙂
Should be always the latest version, because it is the API which is called when you open the script in the IFlow editor. ?
And yes, when internal APIs change your plugin may break, but until then it makes life easier. By the way I guess this is true for the complete plugin. If anything in the HTML/CSS structure changes, I guess it would even break the plugin…
But since you are not selling the tool, I guess nobody will blame you if it breaks. And we have to keep in mind: the tool makes life easier, but life is possible without the tool. So let’s use the tool to be more efficient as long as it is working. If it breaks one day, it’s not mission critical because it’s a helper and not an integral part of the interface’s infrastructure. ?
I agree with Raffael, it is a free tool we share provided as-is. We can try our best to be stable but no commitments and no deadlines, only fun 🙂 I encourage everyone to publish free tools if they want to change the experience for good.
In the end, SAP can also pick and implement good ideas from these tools and I want that to happen. That will be a good outcome for CPI developers. In the meantime, people can enjoy increased effectiveness with these tools. It is a win-win.
Hi Fatih,
what a great tool! If I had one wish free, I would wish, that you would add a "share"-functionality, so that we could generate a shortlink for the current IDE state and share it with our colleagues. Maybe, if you plan to further develop this tool, you could add this feature on your todo list. 🙂
Best regards and thanks for contributing this tool to the community!
Hi Raffael,
Thank you for your support and for providing good ideas!
Short-link is a feature I thought as well. It has some interesting use cases like:
Storing the state in DB is a solution to this problem. However, it can complicate the infrastructure. Even for a free product, I want to provide stable service and have peace of mind. Being able to say "nothing is stored in the server" is also nice.
Another option I'm thinking about implementing is using URL to store data. One drawback is it won't be a short-link! It will be a long link... But it will be a practical one. 🙂
What are your other two wishes? 😉
Best regards,
Fatih
This will save a lot of working hours! Thanks a lot Fatih Pense !
Hi Cagri,
Thanks for your feedback! Every hour a developer saves makes me happier!
Regards,
Fatih
when I'm trying to reach https://groovyide.com/cpi, my company's proxy has detected a potential security risk with this website...
Hello Aurélien,
Thanks for your comment and for letting me know.
As far as I know, firewall proxies work based on categories. This site is very new so it can cause problems. Unfortunately, I can't think of any workaround.
It seems to be a problem only the network team can solve. I believe the people in the network team are the best friends of an integration consultant.
Regards,
Fatih
Hello Aurélien,
Now there is an offline version for Windows 10: https://blogs.sap.com/2020/07/20/groovy-ide-fixes-feedback-form-and-desktop-beta/
You can download from the store page: https://www.microsoft.com/en-us/p/groovy-ide/9n7z5k1vrhb3
Regards,
Fatih
Hello Faith,
This is fantastic tool.Kudos to you.!!
Regards,
Sriprasad Shivaram Bhat
Hello Sriprasad!
Thank you for your kind words. It is really motivating when developers find this useful.
Regards,
Fatih
Hi,
it is wonderful and will save time for us.
Thanks for sharing.
Thanks for the feedback Metin. I'm glad it will save time.
Regards,
Fatih
Hi Fatih,
Great work! Thanks a lot for making our lives a bit easier.
Iddo
Hi Iddo,
We always work hard to find good solutions for customers. Sometimes we can solve our own problems? 🙂
Thanks for your feedback.
Fatih
Great Job!!
Thank you for your feedback Rajendra!
Regards,
Fatih
Great Job Fatih! Thanks for making life easier.
Hello Bekir!
Thank you for your support.
It has been a long time since we drank soda water to relieve stress after a long day's work.
Best regards,
Fatih
Many thanks Fatih!
Thank you for your feedback Rakesh!
Thank you, Faith, for taking the time to build it. Great work.
Thank you for your feedback Ajit. I'm glad it is helpful.
Hi Fatih,
Great work. Thanks for sharing.
Thank you for your support, Hasan.
Regards,
Fatih
Thanks Fatih,
This tool is a great help in testing the scripts and will save lot of development time 🙂
Regards,
Jitender
Thanks for the feedback Jitender! I'm glad it is helpful.
Regards,
Fatih
A great tool, thanks!
Thank you for the feedback Blazenko! The image made my colleagues' day 🙂
Regards,
Fatih
This is pretty awesome!
Thank you!
Thanks for the feedback Gabriel!
Great, now all CPI Developers are enabled to easily "Walk like an Egyptian" <- dance
Best regards, mitch
Thanks for the feedback, Michael!
Best regards,
Fatih
Great tool..Thanks for Sharing!
Thanks,
Syam
Thanks for the feedback Syambabu!
Regards,
Fatih
Good work
Thanks Mustafa!
Awesome, great job, thanks for making our job even more funier!
Thank you for the feedback Youssef!
Regards,
Fatih
One of the best tools ever. Made my life easy.
Thanks for the comment Ashutosh. I'm glad it is useful!
Regards,
Fatih
That's awesome, thank you so much!
One little thing that I noticed, sometimes the CPI groovy script acts a little different than your tool. Is there an explanation for it (different version etc.)?
Hello Christopher,
I'm glad it is useful!
Yes, the differences can be caused by many reasons, including library&runtime versions. It is a completely different runtime built from scratch to emulate the CPI environment. I'm interested to know the differences. Ideally, it should be bug-for-bug compatible with CPI runtime!
You can always use the "send feedback" form, or send me the script which runs differently as a message. Then, I will try to analyze and get back with an explanation, or hopefully with a fix.
Best regards,
Fatih
Amazing, You just saved my sleepless night too. 🙂
Thanks Senz! Great to hear that! When it is useful for a lot of people, it motivates me to keep going and sharing 🙂
There will be a v2 version that can work with local files. It is in development & it will be free.
Regards,
Fatih
Very nice and helpful!