Skip to Content

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.

8 Comments
You must be Logged on to comment or reply to a post.
  • Hi Merina,

    Nice Blog!

    I have one question ,that is it good practise to use Write Variables at the beginning of i flow, as we have to store LastSuccessFull run but if in case due to some reasons i flow fails, then what?

    As per my understanding it should come before the end message event.

    Make sense?

     

    Regards,

    Pravesh Shukla

    • HI Pravesh,

       

      Yeah you are right, but ive used it here only as an example to show how this functionality works.

       

      Regards,

      Merina

      • HI Merina,

         

        I have a scenario like above but what if SFTP connection fails intermittently. Then write variable is working though scenario failed to push files through SFTP.

         

        Please reply, how can we handle such scenarios.

         

        Many Thanks,

        Anurag

  • Hi Merina ,

    What is the persistence period  for these Local/Global variables ? As i don’t see any parameter defining the time-frame unlike Data Store.

    Thanks,

    Manoj