Global Variable: Write Variable in CPI
There are scenarios where you might want to use a variable stored in one iFlow and call it from another process in CPI or to query OData based on the last successful run from another IFlow. Write Variables is one such functionality provided by SAP in CPI/HCI.
Scenario: Save the last Successful run date of my IFLOW1 and check the last successful run in my next IFLOW2
I’ve used a very simple iFlow to explain the procedure. The same can be used when you need to query other systems based on the variable stored in another iFlow.
In IFlow1: add step Write Variables:
I have added additional steps to check whether my variable has any value or not.
Below are the details in the properties tab, in case I wanted to save the currentDate:
Note: Tick the GobalScope option in properties.
In Flow2: Add Step ContentModifier with below properties:
Note: Save it as Global Variable, else this property would not have any value assigned to it.
In the second Content Modifier, I’ve used the property in my output file:
Deploy iFlow1 first and then iFlow2.
Output for iFlow1:
Output of iFlow2 with the last run date of iFlow1:
Write Variable can also be used in the same iFlow as local variable- save it as a property or header and use it anywhere in your iFlow.