Technology Blogs by Members
Explore a vibrant mix of technical expertise, industry insights, and tech buzz in member blogs covering SAP products, technology, and events. Get in the mix!
cancel
Showing results for 
Search instead for 
Did you mean: 
fabianl
Product and Topic Expert
Product and Topic Expert

Introducing


In my previous blog i´ve shown you how easily we can build up an simple Workflow with new SAP Cloud Platform Workflow service. In this blog i will start this WF periodically to get every day an overview of my current alerts.

The setup is also aquite simple process how described also in this blog.

 

Let´s start....


Enter your SAP CP Integration Web UI and switch to "Monitor" view:



In this view we must define/deploy our "User Credential" for the user which is allowed to start the WF:



Now enter the "Security Material" tile and add the credential:



Define the following Information:

  • Name

  • Description

  • User

  • Password


An click Deploy



Yo should now see the new credential on top of the of your security materials:



 

No we can switch to the "Design" view of SAP CP Integration to define our new artifact (Integration Flow).

Design the Integration Flow


Select an existing package or create an new one:



Create a new Integration Flow by providing a name, for me i call the Flow "timer_based_wf_instance_start":



If we click Ok we switch over to the desing perspective, were we can see an empty iflow:



My First task is now to delete the "Start" event and the "Sender".

The final Integration flow should look like this:


Integration Flow objects in detail


The following objects are added/changed:

  • Timer: The Start Event is now a "Time based Event", because of the fact that i want to shedule my Integration Flow once a day at 9:00, from Monday to Friday.




  • Content Modifier #1: This "Message Header" is requierd to fetch the XSRF token from SAP Cloud Platform Workflow API.




  • Request-Reply: This object is used to calling the SAP CP WF API  to get the XSRF Token.



The HTTP(S) connection between our Request-Reply connection and the Receiver, contains the following details:


Address: The Endpoint form the API documentation "https://<WFRUNTIME_HOST>hana.ondemand.com/workflow-service/rest/v1/xsrf-token"


Method: GET


Authetication: Basic


Credential Name: Our credential Name which we created earlier "WFAAS_USER"




  • Content Modifier #2: This contains in the "Message Body" section our "definitionid" for the SAP CP WF, this is required for the API call to start our WF instance.




  • Groovy Script: This script is used to store the cookie in our message header. You can find the script also in this blog, but there are two little errors, the script which work's for me is this one:


import com.sap.gateway.ip.core.customdev.util.Message;
import java.util.HashMap
import java.util.ArrayList
import java.util.Map
import org.slf4j.Logger
import org.slf4j.LoggerFactory
import groovy.xml.*
import java.io.*;

def Message processData(Message message){

def headers = message.getHeaders();
def cookie = headers.get("set-cookie");
StringBuffer bufferedCookie = new StringBuffer();

for(Object item : cookie){
bufferedCookie.append(item + ";");
}

message.setHeader("cookie", bufferedCookie.toString());
Logger log = LoggerFactory.getLogger(this.getClass());
log.error("cookie"+ bufferedCookie);

return message;
}


  • Finally we need the Connection between the Message End and the Receiver, which contains the API call to start the WF:



The HTTP(S) connection has the following


Address: The Endpoint form the API documentaion


"https://<WFRUNTIME_HOST>hana.ondemand.com/workflow-service/rest/v1/workflow-instances"


Method: POST


Authetication: Basic


Credential Name: Our credential Name which we created earlier "WFAAS_USER"


Test the Integartion Flow

To test our newly created Integration Flow we just change the "Timer Start Event" to the option "Run Once".

Finally click on deploy an check the "Monitor" view of SAP CP Integration



 

An yes no error, also we should now have a new SAP CP WF Instance running?......

Enter the FLP and open the "Workflow Instances" tile:



.....and whoot, there it is... ;o)



 

Conclusion


I hope you can see how easily you can start an SAP Cloud Platform Workflow by SAP Cloud Platform Integration.

For me, this is a (the) perfect combination. And shows once more (hopefully) how simple you can combine different SAP Cloud Platform services together.

 

Finally check my next blog how we go ahead with the combination.

cheers,

fabian
4 Comments
Labels in this area