Open Connectors: Formula with Manual Trigger – FaaS
Open Connectors provide services that connects to third party apps directly from SAP eco system. These services can be used efficiently to trigger a sub-process, calling another service or collate data from two or more services on an event.
Open connectors offers these flexibility through the use of Formulas. Formulas are work flow templates through which one or more process can be automated across multiple applications.
This blog deals with the use of manual triggers in Formulas. The further section of this blog provides an overview of the issue related to HTTP 503 and how Formulas helped to design a workaround to handle 503 code.
Google Analytics is a service that is deployed to extract the metrics and dimensions data. This service is vital for the data team to build reports and analytics in SAP. I have used CPI as the integration platform which extracts these details through the use of connectors designed specifically for Open Connectors, called OpenConnector adapter.
The Google Analytics service had to be called in a loop until all relevant dataset is read. This is achieved through the use of Page Tokens – provided by Google Analytics. While most of the calls to the service result is HTTP 200 code, there had been instances of HTTP 503 received.
There was no definite explanation for HTTP 503, but upon resubmission the service is synchronised and successful with the API calls.
OpenConnector Adapter does not provide any re-try mechanism and the resubmission has to be modelled into the CPI integration flow. I wanted to have a pragmatic approach on this issue by using the functions provided by Open Connectors – the resubmission through CPI flow was still on the cards when the former fails.
The solution to implement re-try mechanism on HTTP 503 error is through the use of Formulas.
Formulas are workflow templates that are independent of the API provider. Formulas are designed to achieve specific purpose and support different use cases. Keeping the systems in sync, data migration, automation of business process are some of the use cases. You can find few of the examples detailed here
In my use case, I have to consider the option of manual triggers in formulas. As only the manual trigger supports synchronous API calls and in rest of the triggers (Event, Connector Request, Scheduled) only asynchronous communication is possible.
- Create a new formula template and select manual trigger
provide a name for the formula and Save the template
- The creation of manual trigger alone doesn’t complement the formulas. Hence each formula with trigger is followed with formula steps. In this case I’m selecting the “Connector API Request” to set up the connector to the specified API instance.
Click on “Add step” to reveal the different formula steps
Complete the configuration as desired. In my case, I had filled the API instance variable (a connector variable which is mapped with the API instance while creating an instance for the formula), the API method and API resource.
- Save the step
A comprehensive overview of the formula that suits my requirement:
Formula as a Resource
Now with the formula ready, we need to expose this formula as a resource. Exposing Formula as a Resource [FaaR] enables us to use the formula as a synchronous API. In my case, I can call the endpoint in CPI flow. To enable the formula as FaaR, the very first step is the creation of the formula instance.
From the formula page, hover over the formula tile and click on create instance >
Name the instance and select the Open Connector instance of the actual API >
Open Connector Instances listed here and selected >
Now with the instance created, the last step to complete is to assign the API URI name and the API method.
Go to the formula in edit mode and click on “Advance”. Complete the API method and URI name as this reference is used to call the API service.
Testing from Postman:
Successful execution step:
With this, we will be able to call the formula synchronously and resubmit the API resource for the given HTTP error codes.