In the digital world, customer satisfaction is a goal of an optimized supply chain. We use a business case to demonstrate how a supply chain process can be optimized with the effective consumption of various cloud services in the SAP Cloud Platform. We describe the creation of a purchase order on the fly depending on the health of compressors.
Note: SAP Cloud Platform is a platform-as-a-service (PaaS) offering for digital transformation. It includes application development services and capabilities that enable businesses to collect, manage, analyze, and leverage information of all types; to extend and connect to business systems; and to innovate new scenarios to allow businesses to continuously adapt and advance. It enables users to achieve business agility, create an integrated and optimized enterprise, and accelerate digital transformation – all without maintaining or investing in an on-premises infrastructure.
In our scenario, devices based on the Internet of Things (IoT) read temperature data, forecast future failures, and generates a purchase order without manual intervention. This helps to avoid possible downtime in future. This means that the waiting time for the customer is reduced significantly and no inconvenience is caused. You can find the technical details of the scenario in the “Technical Scenario” section of this document. We walk you through the following steps:
Step 1: Data acquisition using SAP Cloud Platform Internet of Things service
Step 2: Configuration for SAP Cloud Platform Integration to pull data from the back-end system
Step 3: SAP Cloud Platform Workflow
Step 4: SAP Cloud Platform Business Rules
Step 5: The Integration Service for Mail Notification
The end-to-end scenario demonstrates the use of SAP Cloud Platform Integration service, SAP Cloud Platform Workflow, and SAP Cloud Platform Business Rules in routing decisions for triggering business processes in systems based on IoT data. We also explain the high-level features and possible integration of various cloud services.
Note: We assume readers have intermediate knowledge about the supply chain process and about the SAP Cloud Platform catalog of services. In the services section of the SAP Cloud Platform cockpit, you can find the catalog of various services grouped under different categories like Analytics, Business services, Collaboration, Data & Storage, DevOps, Integration, Internet of Things, Machine Learning, Mobile, Security & User Experience. To realize this scenario in the SAP Cloud Platform, you need to subscribe to the SAP Cloud Platform Internet of Things, SAP Cloud Platform Integration, SAP Cloud Platform Workflow, and SAP Cloud Platform Business Rules.
We show how SAP Cloud Platform Integration and SAP Cloud Platform Internet of Things can be used to meet the requirements of the business scenario that we describe.
SAP Cloud Platform Integration Catalog includes offerings such as SAP Cloud Platform API Management service, SAP Cloud Platform Business Rules, SAP Cloud Platform Integration, SAP Cloud Platform Connectivity service, the destination functionality in SAP Cloud Platform cockpit, SAP Enterprise Messaging, SAP Cloud Platform OData Provisioning, RabbitMQ on SAP Cloud Platform, SAP API Business Hub, and SAP Cloud Platform Workflow. The focus of the above services is to build integrated business processes.
Whereas SAP Cloud Platform Connectivity makes it easy for organizations to connect on-premise and cloud-based systems, SAP Cloud Platform API Management helps organizations to monetize their APIs. SAP Cloud Platform API Management is an open extension platform that simplifies integration with SAP and non-SAP solutions. It helps to add policies to the APIs to customize its behavior. The policies range from Traffic Management policies, Mediation policies, Security policies and Custom Policies. SAP Cloud Platform Integration helps to integrate business processes, and SAP Cloud Platform Workflow and SAP Cloud Platform Business Rules help to automate the end-to-end process.
SAP Cloud Platform Internet of Things is a different catalog under the SAP Cloud Platform offering that offers the ease of connecting to devices, acquiring the data, and building the application on it.
In this scenario, we use the following services from the SAP Cloud Platform to realize the current business scenario:
- SAP Cloud Platform Internet of Things enables organizations and partners to develop, customize, and operate IoT business applications in the cloud.
- SAP Cloud Platform Integration supports end-to-end process integration across cloud-based and on-premise applications (cloud-cloud and cloud-on-premise integration). This service facilitates the integration of business processes spanning different companies, organizations, or departments within an organization.
- SAP Cloud Platform Workflow offers the possibility to automate the business processes using workflow technology, build process extensions to SAP cloud applications, or integrate with on-premises systems and call out to back-end services via simple representational state transfer (REST) interfaces.
- SAP Cloud Platform Business Rules enriches SAP Cloud Platform offerings with decisions’ modeling, management, and execution services. Typically, in the past, developers used to hard-code business logic in the programs – for example, tax and discount calculation. However, now with SAP Cloud Platform Business Rules, developers can configure the same logic outside of the application and invoke the programs when necessary. This feature offers flexibility and ease of changing decisions based on different inputs. For example, if Walmart wants to add an additional discount for Christmas, this step can be done without changing the application. This offering enables any cloud-based application developer to easily embed decisions in an application.
The Business Scenario
Intelligent Equipment Inc. manufactures compressors. Recently, the company observed that several compressors were becoming faulty owing to temperature variations. The company faces the following issues that it would like to overcome:
- The company wants to add a preventive mechanism (adding a coolant that controls the temperature) so that compressors do not become faulty and the business runs smoothly.
- The company wants to optimize the supply chain process by generating a purchase order on the fly without manual intervention.
Peter is a customer service manager at Intelligent Equipment Inc. who would like to enhance the user experience of customers. The expectations from Peter along with the current challenges he faces are explained in Figure 1.
Peter’s expectations to enhance the experience of his customers
The details of the business problem that Intelligent Equipment Inc. faces and tries to optimize are shown in the flow chart in Figure 2.
Business problem details
The company would like to read temperature readings in the compressor with the help of sensors installed, analyze the readings, and find out inconsistencies, if any. If an inconsistency is found, Intelligent Equipment Inc. would like to retrieve the warranty information as well as the annual maintenance contract (AMC) of the customer. If either the warranty or the AMC exists, Intelligent Equipment Inc. could create a purchase order for a new coolant. If both the warranty and the AMC do not exist, then Intelligent Equipment Inc. needs the approval from the customer for the coolant purchase, as it involves a cost for the customer. Later Intelligent Equipment Inc. also would like to send a notification about the purchase to the involved parties for documentation purpose.
Now Intelligent Equipment Inc. would like to automate the above process so that the purchase order could be generated automatically on the fly, without manual intervention. This optimized supply chain process would also improve the user experience as the possible future failures could be identified in advance and necessary actions could be taken to ensure the smooth running of the business.
To solve the business problem explained above, Intelligent Equipment Inc. decided to subscribe to various services from the SAP Cloud Platform. The following services helped the company to automate the business processes and generate a purchase order on the fly without any manual intervention:
- Sensor data from the compressors are read with the help of SAP Cloud Platform Internet of Things.
- The cloud-based middleware SAP Cloud Platform Integration reads the sensor data from the platform, analyzes the temperature variations, checks the validity of the warranty and AMC, and invokes a workflow instance for the generation of a purchase order.
- The SAP Cloud Platform Workflow processes the request from SAP Cloud Platform and invokes the SAP Cloud Platform Business Rules, and if required, sends the purchase order request for approval.
- SAP Cloud Platform Business Rules executes a decision table to determine whether an approval is required for the given purchase order request.
The technical scenario that helps Intelligent Equipment Inc. to overcome the business problem is shown in Figure 3.
The technical scenario
The business scenario is automated by integrating various cloud-based services from SAP Cloud Platform. The details of the business solution for Intelligent Equipment Inc. are shown in the flow chart in Figure 4.
The business solution
The Technical Scenario
In this section, we explain the technical scenario and the integration of various cloud-based services to realize the business case.
Note: The scenario assumes that sensor data is being captured with the help of SAP Cloud Platform Internet of Things and is already available. Therefore, this is not in the scope of the scenario.
Step 1. Data Acquisition Using SAP Cloud Platform Internet of Things Service
SAP Cloud Platform Internet of Things service is available in the SAP Cloud Platform cockpit under the category Internet of Things. It helps you connect devices to SAP Cloud Platform to provide scalable ingestion of IoT data and device management. The respective services provide a secure connection to remote devices using a broad variety of IoT protocols and manage the device lifecycle from onboarding to decommissioning.
The SAP Cloud Platform Internet of Things service helps you consume the data from different devices. You can access all the data and details using APIs from the API Hub.
API Hub- https://api.sap.com/ is a platform where you can find API for various services offered by SAP.
To send data to the SAP Cloud Platform Internet of Things service, you need gateway SDK, which can be configured with any protocol. In this scenario, we have dedicated gateway which is pushing the data to SAP Cloud Platform Internet of Things. The gateway provides adapters for network convergence and protocol normalization. It is responsible for collecting data from sensor network and sending commands to the network on behalf of other modules.
In real time, devices will keep pushing the data to the platform using sensors and data can be retrieved using API’s based on user query parameter.
Above web services will pull the data from SAP Cloud Platform Internet of Things, based on our query parameter and will return the data in JSON Format which can be consumed in application.
In the same way, we can take all details of the devices and data can be used for calculation or decision. In this example, we are only taking decision based on temperature.
Step 2. Configuration for SAP Cloud Platform Integration to Pull Data from the Back-End System
SAP Cloud Platform Integration helps to integrate the various business processes spanning across various systems. The scope of SAP Cloud Platform Integration encompasses the following tasks:
- Read temperature data from the SAP Cloud Platform Internet of Things
- Analyze the temperature data and check for inconsistencies
- Read the device warranty and AMC details from the back end
- Trigger a workflow for further processing or the purchase order request
Figure 5 is an overview of the integration flow that includes various steps for implementing the business processes mentioned above.
Overview of integration flow
In the above integration flow, data from SAP Cloud Platform Internet of Things is read through API calls. The incoming data is enhanced and checked for inconsistencies (temperature reading above threshold temperature). If any inconsistency is found, then warranty data along with AMC is read from the back end for further processing. Finally, a call is made to the workflow system for creating a purchase order.
Headers for the Integration Flow
The integration flow consists of the initial headers (implemented with the help of a content modifier) shown in Table 1.
The scenario need to fetch the x-csrf-token, which will be later used to trigger the workflow instance
The threshold value of the temperature (needs to be addressed, if the actual value overshoots the threshold)
The counter value of temperature (needs to be addressed, if there are more temperature records in a row than tempCounter, which overshoots the tempThreshold)
Header values in a content modifier
Figure 6 shows a diagram of the header values for integration flow.
Header values for the integration flow
Fetching an X-CSRF-Token
An X-CSRF-Token needs to be fetched from the SAP Cloud Platform Workflow run time, which is later used for triggering the workflow. The X-CSRF-Token can be accessed at https://<workflow runtime host>/workflow-service/rest/v1/xsrf-token.
After you access the X-CSRF-Token from the SAP Cloud Platform Workflow run time, this token is updated in the header. The integration flow uses an HTTP channel to get the X-CSRF-Token. Figure 7 shows the configurations required for accessing the token.
Accessing the X-XSRF-Token from workflow run time
The address field in Figure 7 holds the HTTPS URL value for fetching the X-CSRF-Token. The X-CSRF-Token value will be used later to perform a POST operation on the HTTPS URL. The proxy type takes two values, i.e., Internet (For making cloud based HTTP calls) and On-Premise (For making calls to on premise systems). In our case, it is a cloud based HTTPS call and hence, the value configured is Internet. The method is a GET operation as we are trying to fetch the X-CSRF-Token here. Other values for method can be POST, PUT, DELETE, etc. The authentication field values can be None, Basic, Client Certificate and Principal Propagation. In this case, it is Basic authentication.
Step 2.1 Read Temperature Data from the SAP Cloud Platform Internet of Things
Sensor data is stored in the SAP Cloud Platform Internet of things service. The SAP Cloud Platform Integration reads the sensor data (temperature) from the SAP Cloud Platform Internet of things service, with the help of an API call. The format of the API url is https://<iot hostname>/iot/core/api/v1/devices/<device_id>/measures.
The integration flow uses an HTTP channel to get the measures from the SAP Cloud Platform Internet of Things service. Figure 8 explains the configurations required for reading the sensor measures.
Reading sensor data from the SAP Cloud Platform cockpit
For extracting data from SAP Cloud Platform Internet of Things, an API call is made via HTTPS protocol. The query parameters are specified as skip=0&tenantId=<tenant_id>&top=3000 which basically means extract the top 3000 records without skipping any record for the tenant Id as <tenant_id>. The other fields are same as shown in Figure 7.
Step 2.2 Analyze Temperature Data
The retrieved temperature data is analyzed with the help of an Apache Groovy script component. If inconsistencies are found, the scenario proceeds with a purchase order request; otherwise, the scenario terminates.
Step 2.3 Read device warranty and AMC details from the Back End
If inconsistencies are found, read the device warranty and AMC details from the back end. Using the web services call, the SAP Cloud Platform integration connects to the back end and retrieves the product information from the product details table. The information being retrieved is device Warranty and existence of AMC (Annual Maintenance Contract).
The sample table structure shown in Figure 9 stores product information.
Database table structure in the back end
Since the scenario identifies inconsistencies with temperature data, you are required to proceed and place the purchase order for a new coolant. Before you place the purchase order, it is also essential to read the warranty and AMC details from the back end on- premise system. If either the warranty or AMC exists, the scenario can continue and place the purchase order without any further approval. If there is neither a valid warranty nor AMC, it is required to have an approval process from the customer as it involves payment from the customer.
Figure 10 explains the configurations required for reading the warranty and AMC details from the back-end system. It is required to route the call via an SAP Cloud Connector as it is a hybrid on-demand to on-premise communication.
Read the warranty and AMC details from the back-end system
The SAP Cloud Connector is used to make a call from SAP Cloud Platform Integration Service to the back end. The configurations in SAP Cloud Connector are described below.
In the SAP Cloud Connector configuration, the internal host that is the real back-end system is mapped to a virtual host and the endpoints are configured in the resources section.
The integration flow uses a Simple Object Access Protocol (SOAP) 1.x channel for reading the warranty and AMC details from the back end (Figure 10).
"definitionId": "<workflow definition id>",
The payload structure for the workflow
Step 2.4. Trigger a Workflow for Further Processing of the Purchase Order Request
In our scenario, you need to trigger a workflow for further processing of the purchase order request. The workflow includes human and automated activities for handling various business processes.
Figure 12 explains the configurations required for triggering the SAP Cloud Platform Workflow instance from SAP Cloud Platform Integration. The format of the API call is https://<workflow runtime hostname>/workflow-service/rest/v1/workflow-instances.
Trigger a workflow instance from SAP Cloud Platform Integration
The integration flow uses an HTTP outbound channel for triggering the SAP Cloud Platform Workflow instance.
Step 3. SAP Cloud Platform Workflow
SAP Cloud Platform Workflow offers the possibility to automate the business processes using workflow technology. SAP Cloud Platform Workflow can be used to orchestrate a sequence of tasks across different people and organizations.
The scope of SAP Cloud Platform Workflow for this scenario encompasses the following tasks:
- Trigger a business rule to determine whether it is necessary to obtain an approval for the purchase order.
- Execute the purchase order approval process with the help of the “My Inbox” application.
- Generate the purchase order in the vendor system with the help of a Service Task.
- Invoke an integration scenario and inform the involved parties via email about the purchase order.
Figure 13 shows the overview of the SAP Cloud Platform Workflow definition that includes several components to automate the business processes mentioned above.
Overview of workflow definition
Step 3.1. Trigger a Business Rule to Determine the Approval Requirement
It is possible to integrate SAP Cloud Platform Business Rules with SAP Cloud Platform Workflow instances and trigger the business rule with the help of a Service Task. SAP Cloud Platform Business Rules executes the decision table associated to it and sends the response back to the SAP Cloud Platform Workflow for further processing.
The above workflow SAP Cloud Platform Workflow uses an Apache Groovy script task to make the payload compatible with SAP Cloud Platform Business Rules. The format of the incoming payload for SAP Cloud Platform Business Rules is shown in Figure 14.
"Warranty_Exists" : "NO"
The format of the incoming payload
Figure 15 explains the configurations required for invoking a SAP Cloud Platform Business Rule from a SAP Cloud Platform Workflow Service Task.
Invoking a Business Rule from Workflow Service Task
The various fields required in the configuration are explained below.
Destination: You need to create a destination in the SAP Cloud Platform for communicating to the SAP Cloud Platform Business Rules. Here RULES_SERVICE is the destination created in the SAP Cloud Platform that internally represents the hostname of the business rule’s run time as shown in Figure 16.
Destination RULES_SERVICE created in SAP Cloud Platform
The configurations required for the destination are mentioned below:
- Name: Any name. The same will be used everywhere else for connecting to the URL specified.
Type: The values can be HTTP, LDAP, MAIL and RFC. In our case, we have configured a HTTP call.
URL: This is the URL to be connected to through this destination.
Proxy Type: Proxy Type can be Internet or On-Premise. In this case, it is Internet.
Authentication: In our case, it is Basic Authentication (using username and password).
Path: The API path required to invoke the Business Rule. The syntax is /rules-service/rest/v1/rule-services/java/<business_Rule project>/<business_Rule service name>
Path to XSRF Token: This path is also required to obtain an XSRF token before triggering the SAP Cloud Platform Business Rule. Here need to maintain the API path for XSRF token. The syntax is /rules-service/v1/rules/xsrf-token
Request variable represents the input to the Business Rule and Response variable is used to store the response from the Business Rule.
The sample format of the Business Rules response is shown in Figure 17.
The format of the Business Rules response
Details of the Business Rule project and the corresponding Decision table are explained in “Step 4: Business Rules.”
Step 3.2. Execute the Purchase Order Approval Process with the Help of the My Inbox Application
The My Inbox application helps you to manage your tasks. You can develop a HTML5 application and link it to My Inbox for managing user-specific tasks.
The Get Approval component in the current workflow scenario is an example of this type of a user task. Get Approval helps the approver to approve or reject the purchase order request.
Figure 18 shows the configurations required for the Get Approval user task.
Configuration for the Get Approval User Task
The configurations are described in the following list:
- Recipients: The user who will have authorization to take an action on the user task (approval).
User Interface: This section is for providing details of the HTML5 application details (deployed in SAP Cloud Platform) to be rendered to the My Inbox application.
HTML5 App Name: The name of the application that is deployed on the SAP Cloud Platform.
Component URL: The name of the HTML5 module in SAPUI5 project.
SAPUI5 Component: The name of the SAPUI5 component in SAPUI5 project.
Figure 19 shows the My Inbox application that allows the approver to accept or reject the purchase order request. The HTML5 application used currently is a simple one with minimum UI controls. But it is also possible to have a rich HTML5 application.
My Inbox for purchase order approval
Step 3.3. Generate the purchase Order using a Service Task
The SAP Cloud Platform Workflow also uses a Service Task for generating a purchase order in the vendor system. The configuration details for the Service Task are shown in Figure 20.
Service Task for generating a purchase order in the vendor system
The various fields in the Service Task configuration are explained in the following list:
- Destination: The destination of the vendor system needs to be deployed in the SAP Cloud Platform cockpit. This involves the URL and user details for accessing the vendor system.
Path: The specific path of the vendor system url where the purchase order could be generated.
HTTP Method: In this case, it is a POST method since we are trying to insert data in the vendor system.
Path to XSRF Token: If x-csrf-token is required for posting data to vendor system, then that needs to be configured in this section
Step 3.4. Inform the Involved Parties via Email
Once the purchase order is generated in the vendor system, the purchase order information needs to be mailed to the involved parties. This task is done with the help of SAP Cloud Platform Integration. The SAP Cloud Platform Workflow uses another Service Task for triggering the Integration flow configured in SAP Cloud Platform Integration. The Integration Flow in SAP Cloud Platform Integration further triggers the email notification with the help of a mail channel. We describe this process in detail in “Step 5. Integration Service for Mail Notification.”
Step 4. SAP Cloud Platform Business Rules
SAP Cloud Platform Business Rules can be used to encapsulate business logic from application logic, enabling business and key users to change the decision logic without re-writing the application.
The SAP Cloud Platform Business Rules in this scenario help you to identify whether an approval process is required for the purchase order. SAP Cloud Platform Business Rules consists of a decision table component that can be used to store and execute complex conditions.
The input and output structures of the SAP Cloud Platform Business Rules are shown in Tables 2 and 3.
Table 2 Input structure for SAP Cloud Platform Business Rules
Table 3 Output structure for SAP Cloud Platform Business Rules
Figure 21 is an overview of the SAP Cloud Platform Business Rules. Here, you need to maintain the data structures for representing the inbound and outbound structures.
Overview of the SAP Cloud Platform Business Rules with inbound and outbound data structures
In the Rule Services tab, it is required to map the Execution Context and Target Runtime. Execution Context represents the input and result structures. The target runtime available currently is JAVA/Cloud. Figure 22 shows the configurations of Rules Service tab of the SAP Cloud Platform Business Rules.
Rule Service of SAP Cloud Platform Business Rules
The configurations are explained in the following list:
- Execution Context: This section describes the inbound and outbound data structure for the Rules Service.
Inbound or input: PurchOrderReq
Outbound or result: ApprovalResponse
The Rules tab of SAP Cloud Platform Business Rules consists of a Decision Table component, which is the core of an SAP Cloud Platform Business Rules project. The Decision Table consists of all the possible conditions which gets executed during run time and provides the required result. The Decision Table of the project can be found in Figure 23.
Decision Table of SAP Cloud Platform Business Rules
Step 5. Integration Service for Mail Notification
The SAP Cloud Platform Workflow instance explained in step 2. generates a purchase order by executing a Service Task on the vendor system. After the successful generation of the purchase order, the purchase order information needs to be informed to the involved parties via mail communication. This process is done by triggering an Integration Flow (iflow) from the SAP Cloud Platform Workflow. The SAP Cloud Platform Workflow instance uses a Service Task for triggering the integration flow in SAP Cloud Platform Integration.
Figure 24 shows the Integration Flow that is triggered by SAP Cloud Platform Workflow. The integration Flow uses the HTTP sender channel to receive the communication from SAP Cloud Platform WorkFlow.
Integration flow for mail notification
The payload sent by the workflow instance is of the type JSON. It is required to convert the JSON payload to XML format. The component JSON to XML Converter converts the incoming payload to XML format.
The Integration Flow uses a Mail channel to send the mail notification (about the purchase order details) to the involved parties.
Figure 25 is the sample e-mail notification received by the recipient.
Email notification received by the recipients
The main objective of the scenario explained above is to introduce the various services in the integration catalog of SAP Cloud Platform and to demonstrate the integration possibilities of various services for realizing business scenarios.
We have taken a customer-like SCM scenario that demonstrates how various cloud-based services could be used effectively for optimizing supply chain processes. The scenario also intends to show technical users about the seamless integration of various services in the SAP Cloud Platform Integration catalog.
The sequential flow of the technical scenario is shown in Figure 26.
Sequential flow of the technical scenario