cancel
Showing results for 
Search instead for 
Did you mean: 

Access to the datastore from Groovy

DG
Active Contributor
2,357

Hi

Is it possible to access the datastore from a groovy script or is it a requirement to use the datastore tool?

axelalbrecht
Product and Topic Expert
Product and Topic Expert

Hi Daniel,

may I ask for your use case why you asked for the Datastore access in scripts?

thx,
Axel

DG
Active Contributor

Hi Alex,

My case at that point in time was to create scripts that could store relavnt information about a message so I could use it for regression testing. Now we fixed it wtih the Trace mode where we should not need it.

So logging make sense, if you are extracting payloads that you normally would save as MPL attachement, it could make sense to save them to this flow instead. Then you dont need to write some payload to message and then revert back to the original message.

Accepted Solutions (1)

Accepted Solutions (1)

MortenWittrock
Active Contributor

Hi Daniel

You mean from within an iflow, right? There are no facilities in the Java APIs for accessing a data store, so you do need to use the data store steps.

Regards,

Morten

Answers (2)

Answers (2)

r_herrmann
Active Contributor

Hi Daniel,

the answer may come a little bit late, but there's a solution to access the Datastore from Groovy script. I wrote a small tutorial in this blog post: https://blogs.sap.com/2020/01/04/how-to-read-write-sap-cpi-datastore-from-groovy/

Let me know, if this solves/had solved your question.

Regards,
Raffael

DG
Active Contributor
0 Kudos

Thanks. So it is possible just not well documented.

r_herrmann
Active Contributor
0 Kudos

Not well documented or SAP just don't want us to use it. Since it's not officially documented, use it wisely/carefully. I just wanted to let you know, that indeed a solution exists.

MortenWittrock
Active Contributor

I actually phrased that answer carefully 🙂 I didn't say it was impossible; just that there aren't facilities in the API for it.

DG
Active Contributor
0 Kudos

thanks.

I guess we will need an other way around it.