cancel
Showing results for 
Search instead for 
Did you mean: 

SAP CPI - read local variable value from Groovy

former_member105769
Participant

Hi

Does anyone know how to access the value of local variables from within a Groovy script?
The problem is, I don't know the name of the variable I need to read, until runtime.

According to SAP Note 3014782, it is no longer possible to dynamically set the value of the variable name using Camel expressions. It seems you now have to hard-code the variable name who's value you want to retieve.

Regards

Steve

Accepted Solutions (0)

Answers (3)

Answers (3)

ab13
Participant
0 Kudos

Hello,

It seems this is already possible. Though the variable content can't seem to get displayed in the Variables section.

Anybody tried this recently ?

Thanks!

Sriprasadsbhat
Active Contributor
0 Kudos

Hello Stephen,

You cant assign dynamic variable name to either header or property in Content Modifier or Groovy Script.Current possible option would be stick on to hardcoded name for Variable and its value can be dynimcally changed ( you have option in write variable step to assign value of header or property ).

Also appreciate if you can raise Customer Influence request for the same so that our developement team will look into it.

https://influence.sap.com/sap/ino/#campaign/2282

Regards,

Sriprasad Shivaram Bhat

former_member105769
Participant

Hi

Thank you, that's unfortunate.

I have changed design to use datastores instead of variables, since these can be created and deleted using dynamic naming.

Regards

Steve

Sriprasadsbhat
Active Contributor
0 Kudos

Hello Stephen,

Its not possible to set the local/global variable value using Groovy Script.You can use Content Modifier to assign the value of variable into Header/Parameter and later use the same headers/properties using write varaible step.

Regards,

Sriprasad Shivaram Bhat

former_member105769
Participant
0 Kudos

Hi

Are you saying it's possible to assign the value of a variable into a Header Parameter, without hard-coding the name of the variable?
The name of the variable is dynamically derived at runtime. However, when I try to specify the name dynamically (i.e. ${header.*}/ ${property.*}), I get the error mentioned in SAP Note 3014782.

Regards

Steve