Enterprise Resource Planning Blogs by SAP
Get insights and updates about cloud ERP and RISE with SAP, SAP S/4HANA and SAP S/4HANA Cloud, and more enterprise management capabilities with SAP blog posts.
cancel
Showing results for 
Search instead for 
Did you mean: 
Eneveux
Product and Topic Expert
Product and Topic Expert
a collaboration between gianluigi.bagnoli, ralph, thiago, mariatrinidad.martinezgea, yatsea.li


The Scenario


If the past year has shown nothing else … it has shown that we all live in interesting times.  Much of the world as we know it has become even more “Digital” in a much shorter time mainly because of the pandemic.  Much of what we do as individuals revolves around living “on-line”.  Think about that for a second.  While working and ordering online is nothing new … with the events of 2020 … we are spending more time “on-line”.

Thinking about that statement, I do not know about you, but one question that comes up day-to-day in my home is the age-old question … “what is for dinner”.  It is a typical workday or weekend and your significant other asks this question.  No one wants to cook on this day or there is nothing in your home to cook.  What do you do?  You grab your mobile device and go on-line and order takeout.  After some back and forth, on what will be ordered, we decide on … pizza!  You use a chatbot for your favorite pizza establishment to start the order.  We order the items we want; we check the order when we are done, we chose that we want our food to be delivered and we check out and then we wait for the all-important message … that our food is on the way!  While this process is probably common place for most and I am sure you don’t really think about what is happening behind the scenes, the nerd and/or geek in me thinks about what happens after I submit the order online.  This blog is where we look under the hood … integrating our front end with the back-end ERP system using SAP Workflow Management.

This focus of this blog will be to discuss using SAP Workflow Management, which is part of the Business Technology Platform, and we will look at the workflow of the order from the placement of our pizza order to the delivery and satisfaction survey using the SMBEats proof-of-concept solution.  We also touch on other components such as SAP Integration Suite, SAP Extensibility Suite and Qualtrics integration with an ERP system such as SAP Business ByDesign, S/4 HANA or SAP Business One.  This blog is one of many that have been published by the SMB Solution Architects that discuss loosely-coupled integration. For more information and samples, please see... https://blogs.sap.com/2018/06/05/loosely-coupled-solutions-for-smbs-topics/.

 

Under the Hood


SAP Workflow Management


While the starting place for our prototype would be to start with our pizza order … as stated … the main goal of this blog is to discuss SAP Workflow Management as this is the engine that will orchestrate every aspect of our scenario.  It is SAP Workflow Management that waits and accepts the order from the front-end chatbot and then directs it through the Agent receiving and accepting the order, sending the order to the kitchen and when complete, notifying the delivery people it is ready to go and finally the conformation it had been delivered which in turn triggers a satisfaction survey from Qualtrics.  As another step, our backend SAP Business ByDesign or S/4 HANA ERP system, is updated via CPI with the Order, Goods Issue and Invoice.  The example we use for this blog is SAP Business ByDesign for the backend but could easily be S/4 HANA or SAP Business One.


 



SAP Workflow Management is part of the Business Technology Platform (BTP).  To start you need a trial or live SAP Business Technology Platform Account to access SAP Workflow Management.  For assistance on setting up an SAP Cloud Platform account you can see this tutorial …https://developers.sap.com/tutorials/cp-trial-quick-onboarding.html and for SAP Workflow Management setup and use, please see this tutorial … https://developers.sap.com/group.cp-workflow-cf.html.

In the image below, you will see the workflow described above of the SMBEats solution as defined in SAP Workflow Management as shown in Fig 1.1.



Fig 1.1

The workflow shows the individual steps once the customer places their pizza order.  In a nutshell the workflow shows Customer Creates Order > Agent Approves order > Kitchen sets the order as ready for pickup > Delivery person starts journey > Delivery person confirms order was delivered > SMBEats sends email to customer asking about satisfaction.

By clicking on each of the individual Task Properties, we can see the detail of each task.  We start after the order is placed.  The pizza order is placed using a chatbot.


Fig 1.3

Once the order is placed and confirmed via the chatbot, we move to the next task in the workflow of the pizza agent accepting the order which then moves it to the kitchen to be prepared.


Fig 1.4

The order was confirmed via the chatbot and we can see that now there is one item in the Inbox for the pizza agent to Approve.

When we click on the Task, we can see the detail from the chatbot such as Customer Name, Customer E-Mail, Address and the pizza that was ordered as the Product ID.  This information is now waiting for the pizza agent to Approve the order which will then move the order to the kitchen staff. Back in the Application Studio interface by clicking on the Approve Meal Order Task we can also view Details and other information.


Fig 1.5

You will notice that in this task that in the User Task Properties > General > Details and then under Recipients > Users that we have the value ${context.recipient}.  This is using the email that was supplied from the chatbot when it asked for your email.  This is used to open a task in the Inbox for approval of the order.


Fig 1.6

Also under User Task Properties > User Interface > Form Details the approvalform.form link.  When you open this link you see the makeup of the Fields on the Approval Meal Order from in Fig. 1.5 …


Fig 1.7

… and then the Decisions, which in this case is just Approval.


Fig 1.8

Once we Approve the Order by clicking the Approve button as shown in Fig 1.5, the next Task in succession is the Task is to create the Sales Order in SAP Business ByDesign or S/4 HANA.  We also see the pizza order in the Kitchen interface that the staff in the Kitchen use to understand what is being ordered

If we look at the task in the workflow for “Ready for Pickup” by clicking on it and view the “User Task Properties” > Details … we see the Recipients > Users as “Kitchen”.  There is no user called “Kitchen”, but it is used by the Kitchen API as shown in Fig 2.0 and reads all the pending tasks for this user.  These API’s are separate code from the workflow definitions we see in our example.


Fig 1.9

When the pizza order is complete, click on the “Ready For Delivery Button”


Fig 2.0

At this point we can also see the workflow progression by opening the Monitoring Tools > Monitor Workflows/ Workflow Instances.  We can see in the Execution Log the progression i.e. the start of the workflow > Approve Meal Request > the creation of the Sales Order, start and finish and then the Ready for Pick-up.  The tasks show from the bottom up in the Execution Log.


Fig 2.1

It is also at this point that the Sales Order has been created in our SAP Business ByDesign and/or S/4 HANA backend.  This was possible by the workflow task "Check core ERP".  This uses the script file "checkERP.js" to see if either "byd" or "s4" is passed to know then which system and CPI integrations to use to create the Sales Order and other documents in the appropriate system.  In this sample, "byd" is defaulted, but can be changed in the script file.  The next task is to “Create SO in Core ERP” in our workflow.  If we look at the details for the task, we can see that the “Path”, is derived from the /${context.erp}/CreateSalesOrder.  Again ... based on the $.context.erp from the previous task we are sending all of the order data to the appropriate CPI integration flow, again from the chatbot, such as the user, the product, the quantity and other data that makes up the order


Fig 2.2
// check if ERP backend is set
if (!$.context.erp) {
$.context.erp = "byd";
}

and that data is passed to the SAP Business ByDesign backend as OData using the SAP Integration Suite flow shown here using the endpoint /byd/CreateSalesOrder.


Fig 2.3

There are also integration flows for the “Post of the Goods Issue” and “Creating the Customer Invoice. For more information on SAP Integration Suite and using and building integration flows you can see this blog … https://blogs.sap.com/2020/09/30/sap-cloud-platform-integration-for-sap-business-bydesign-webinar/

The next step in our workflow is the “Acknowledge and Start Delivery” task now that the Kitchen has completed the pizza order and the interface indicates that the pizza is ready for Delivery, the persons responsible for the delivery take the order from the Kitchen open the Delivery interface, find the correct order and click the “Go!” Button.  The Delivery API uses the “Rider” user to read the Orders for Delivery and the information associated with the delivery such as the address entered when the pizza was ordered and showing the location on a map as presented in Fig 2.5.


Fig 2.4

While the above step in Fig 2.4 is the interface that the delivery person sees and interacts with, the step in the workflow of “Post Goods Issue in the core ERP” happens behind the scenes.  It is a task in the workflow that occurs based on the what occurs in the Delivery interface above.

Just like the creation of the Sales Order task, information is passed to SAP Integration Suite to be able to reduce items that make up the pizza and  create the Goods Issue as collected in the Service Task Properties > Details.  The SAP Business ByDesign endpoint is defined as /byd/PostGoodsIssue and the SAP Integration Suite passes information to that endpoint.

The delivery person will then be presented with the following interface which is a map to the address that was entered in the chatbot when we started.


Fig 2.5

Once they arrive at the specified address and drop the pizza off, they will click on “Confirm Delivery” at the bottom of the screen. This “Delivered” task is the using the “Rider” user as defined to write back the Confirmation of the Delivery to the API.


Fig 2.6

Now that the delivery has been confirmed the next task is the “MailTask2” which is under the Task Property > Details, takes the customer email as was entered when ordering as noted in the “To” value ${context.orderData.CustomerEmail}, contains a subject definition for the email and configures the email sent as HTML.


Fig 2.7

The HTML sent is defined as Qualtrics_sample_sbeats.html.  When clicking on that link you will see the code for the definition as shown


Fig 2.8

An email will be sent to the email provided


Fig 2.9

When we click on the “Rate SMB Eats” button we are the presented with Qualtrics Survey


Fig 3.0

The final task is “Create Customer Invoice in the core ERP”.  This is information that gets passed to the SAP Integration Suite and then to the backend SAP Business ByDesign ERP to create the customer invoice for the pizza Order


Fig 3.1

If we now look back at the Workflow Monitor for the instance of our order we can see, again, the progression of our order from where we looked last, now the workflow has progressed to the creation of the Sales Order in SAP Business ByDesign and now we can see that the order progressed to “Ready for Pickup” to the “Start Delivery” task


Fig 3.2

Then through creating the “Goods Issue” in SAP Business ByDesign using SAP Integration Suite


Fig 3.3

To the order being delivered and the satisfaction email sent from Qualtrics and the final Invoice created in the SAP Business ByDesign ERP and completion or the order and the workflow


Fig 3.4

From the Monitor Workflow > Workflow Instances as part of the Workflow Context we can also see the Sales Order ID that has been created in SAP Business ByDesign


Fig 3.5

We can also see Sales Order ID 4439 in the SAP Business ByDesign interface


Fig 3.6

And then the Sales Order Document Flow showing the Sales Order, Outbound Delivery and Invoice for SAP Business ByDesign


Fig 3.7

Here is the list of Sales Order documents from S/4 HANA and order 447


Fig 3.8

And the document flow for S/4 HANA showing the Order, Outbound Delivery, Invoice and Journal Entries


Fig 3.9

Conclusion


In this blog we have shown how using SAP Workflow Management in a loosely-coupled scenario allowed us to orchestrate using different interfaces such as SAP Conversational AI, SAP Integration Suite, and the Extensibility Suite, all part of the Business Technology Platform, to create a solution like SMBEats.  This same scenario however, could easily be applied to any industry such as retail, manufacturing, etc.

You can find the SMBEats proof-of-concept code here:

https://cai.tools.sap/yatseali/smb-eats-assistant

https://github.com/SAP-samples/smb-eats-backend

http://github.com/SAP-samples/smb-eats-integration

You can also find code samples for all SAP Business One and SAP Business ByDesign proof-of-concepts on the SMB Solution Architects page … https://b1sa.github.io/
2 Comments