Skip to Content
Technical Articles
Author's profile photo Piyush Parekh

Challenge Submission : Digital Assistant for Supply Chain Planning enabled by SAP CAI and SAP IBP

This blog post is a part of SAP Conversational AI Tutorial Challenge 2021. This tutorial explains how to build a chatbot which helps to simplify and automate supply chain planning tasks. We will be looking at a specific scenario which deals with rough cut capacity planning.

 

How Digital Assistant makes planner’s job easy?

 

Identifying and removing resource bottlenecks are one of the critical planning tasks. In the process, planners may need to navigate through multiple screens to check utilization, capture, and share reports with other stakeholders, update the numbers and re-generate the plan to assess if bottlenecks are removed.

Using Digital Assistant – powered by SAP Conversational AI, planners can get a summarized view of  constraints in the supply chain network so that they can quickly collaborate with stakeholders to mitigate supply shortage risks without navigating through multiple screens. They can also update the capacity details and re-generate supply plan through chatbot in a seamless manner.

Here’s how it will work –

Behind the scenes

 

There are multiple tools and technologies working in tandem to simplify planner’s task at hand. Let’s have a look :

  1. SAP Conversational AI – Dialogue engine to identify intent, trigger skills and actions.
  2. SAP Integrated Business Planning – OData services to schedule planning algorithm, read and write planning data
  3. SAP Cloud Platform – Python app to convert data to insights

The chatbot can be deployed to any channel for e.g. MS Teams or SAP Jam where a user can swiftly communicate with the bot to perform various planning tasks.

 

Connecting the dots

 

Step 1 : Configure data integration scenarios in SAP IBP

 

We will use following out-of-box communication scenarios in SAP IBP –

  1. Job Scheduling API (SAP_COM_0064) : This API is used to schedule application jobs in SAP IBP through external systems. Using this API, users can run supply planning algorithms without logging into IBP system.
  2. Extract Analytics Data (SAP_COM_0143) : This allows external systems to extract master and transactional data records from IBP.
  3. Planning Data Integration (SAP_COM_0720) : This service allows an external tool to upload data into SAP IBP.

These communication scenarios are used in maintaining communication arrangements like shown below which contains information on inbound services, authentication, and the scenario under use. Create other arrangements as well for rest of the two communication scenarios mentioned above.

 

Step 2 : Build an app to fetch data from SAP IBP and convert it to insights

 

A webhook is created to extract data from SAP IBP and convert raw data to insights. Refer this detailed tutorial on how to build and deploy python webhook on SAP cloud platform.

A similar webhook with additional functionalities is used for this use case. The application is deployed on SAP Cloud Platform. Below code explains how the application extracts available capacity and resource utilization data from SAP IBP basis user input on plant details in SAP Conversational AI.

url = "https://myXXXXXX-api.scmibp.ondemand.com/sap/opu/odata/IBP/EXTRACT_ODATA_SRV/ZXXXXXXX?$select=RESID,LOCID,PERIODID4,ZUTILIZATIONPCT1&$filter=RESID eq '" + resid.upper() + "' and LOCID eq '" + locid + "' and ZUTILIZATIONPCT1 gt 0&$format=json"

url2 = "https://myXXXXXX-api.scmibp.ondemand.com/sap/opu/odata/IBP/EXTRACT_ODATA_SRV/ZXXXXXXX?$select=RESID,LOCID,PERIODID4,ZCAPASUPPLY&$filter=RESID eq '" + resid.upper() + "' and LOCID eq '" + locid + "' and ZCAPASUPPLY gt 0&$format=json"
 
r = requests.get(url,auth=('XXXX', 'XXXXXXXXX'))
planning_data = json.loads(r.content)
cap_uti = list(map(float,pluck("ZUTILIZATIONPCT1",planning_data["d"]["results"])))

r2 = requests.get(url2,auth=('XXXX', 'XXXXXXXXX'))
planning_data2 = json.loads(r2.content)
cap_sup = list(map(float,pluck("ZCAPASUPPLY",planning_data2["d"]["results"])))

 

The next step is to plot the chart using acquired json data from planning system. We have not used any third-party service (for e.g. Quickchart.io) to generate the chart. It is created in the same Python application deployed on SAP Cloud Platform so that business data always reside within client’s own ecosystem.

There are many libraries available in Python for data visualization. Out of which, Matplotlib is used here to create combination chart for available supply and utilization over the period. It is very flexible to use and one can format charts as needed.

pd1 = pd.DataFrame({
    'cap_sup' : cap_sup,
    'cap_uti' : cap_uti})

a1 = pd1[['cap_sup']].plot(kind='bar',color='springgreen', width = 0.8)
a2 = pd1['cap_uti'].plot(color='black',secondary_y=True,linewidth = 2)

 

To send above chart to SAP Conversational AI, below lines of code convert the chart to base64 format and sends it as a json response to SAP Conversational AI. In step 3, we will see how to consume this data.

s1 = io.BytesIO()
plt.savefig(s1, format='png', bbox_inches="tight")
s1 = base64.b64encode(s1.getvalue()).decode("utf-8").replace("\n", "")
s1_final = "data:image/png;base64," + s1

 

Once application is built and deployed on SAP Cloud Platform, make sure the instance has started successfully.

 

Step 3 : Build a chatbot in SAP Conversational AI platform

 

Here we will create intents and entities, build skills, and assign actions for following tasks.

Task 1 : Schedule a job

 

Create an intent which identifies user wants to schedule an application job. This should trigger job intent skill shown below. In this skill, list of jobs is maintained.

 

Once job scheduling intent is detected, system triggers a sequence of skills to trigger a job. User can select the job to be executed from the list as shown below.

 

 

 

 

 

 

 

 

 

Follow-up skill and action triggers an API service to schedule the job selected by user.

 

Task 2 : Generate a report

 

Create an intent which identifies user wants to generate a report. For this use case, we are modeling only one report – resource utilization. Here, a webhook is configured which connects to the app built in step 2. As an input, user sends plant location for which resource utilization summary to be generated.

 

In the response, python app first extracts data from SAP IBP, converts it to the chart and base64 format which is consumed in SAP Conversational AI. Planner can save the chart image offline or send it via email/MS Teams to plant manager.

 

Task 3 : Update planning data

 

Once plant manager finds a way to increase resource capacity (for e.g. adding another shift), the planner now wants to update the capacity details in SAP IBP. Here, we are using Planning Data Integration API in SAP IBP to update the resource capacity.

 

It is required to send details like resource, plant, new capacity, and date with the POST request. These details are added in Body of the request.

 

Once new resource capacities are updated in SAP IBP, user can take a re-run of planning algorithm to check if constraints are vanished.

 

And there you go!!

 

Here is a quick demo of how the chatbot works.

 

Thanks for reading. Hope you find this blogpost helpful!! Share your thoughts on what aspects of supply chain planning processes can be improved using SAP Conversational AI.

Assigned Tags

      46 Comments
      You must be Logged on to comment or reply to a post.
      Author's profile photo Girish Kumar Jain
      Girish Kumar Jain

      Good Information

      Author's profile photo Piyush Parekh
      Piyush Parekh
      Blog Post Author

      Thank you Girish.

      Author's profile photo Ayush Somani
      Ayush Somani

      Very informative blog Piyush. Its going to be a big help in projects. Kudos

      Author's profile photo Piyush Parekh
      Piyush Parekh
      Blog Post Author

      Thanks for encouraging words, Ayush.

      Author's profile photo Venkadesh Seetharaman
      Venkadesh Seetharaman

      Good one Piyush!

      Author's profile photo Piyush Parekh
      Piyush Parekh
      Blog Post Author

      Thanks Venkadesh.

      Author's profile photo Amit Tewari
      Amit Tewari

      Very good explanation.

      Author's profile photo Piyush Parekh
      Piyush Parekh
      Blog Post Author

      Thanks Amit

      Author's profile photo Savio Anthony Moraes
      Savio Anthony Moraes

      Very Informative

      Author's profile photo Piyush Parekh
      Piyush Parekh
      Blog Post Author

      Thank you Savio. Glad you liked it.

      Author's profile photo GOWRISHANKAR SUBRAMANIAM
      GOWRISHANKAR SUBRAMANIAM

      Very good insights Piyush!

      Author's profile photo Piyush Parekh
      Piyush Parekh
      Blog Post Author

      Thank you Gowri.

      Author's profile photo shrutarth arora
      shrutarth arora

      Very detailed and informative. Great read!

      Author's profile photo Piyush Parekh
      Piyush Parekh
      Blog Post Author

      Thank you Shrutarth.

      Author's profile photo sushant pradhan
      sushant pradhan

      Good articulation of the approach.

      Author's profile photo Piyush Parekh
      Piyush Parekh
      Blog Post Author

      Thanks Sushant.

      Author's profile photo krishna ayathu
      krishna ayathu

      Excellent Blog Piyush. Thanks for sharing this. This for sure is a eye catcher.

      Author's profile photo Piyush Parekh
      Piyush Parekh
      Blog Post Author

      Thank you for your kind words!!

      Author's profile photo Sunil Mannur
      Sunil Mannur

      Very Informative . Thanks for sharing Piyush !

      Author's profile photo Piyush Parekh
      Piyush Parekh
      Blog Post Author

      Thank you Sunil.

      Author's profile photo Samir Mistry
      Samir Mistry

      Very Informative Piyush - Well Done

      Author's profile photo Piyush Parekh
      Piyush Parekh
      Blog Post Author

      Thank you Samir.

      Author's profile photo srikant kumar kuanar
      srikant kumar kuanar

      Great Idea and well detailed. Good job!

      Author's profile photo Piyush Parekh
      Piyush Parekh
      Blog Post Author

      Thanks Srikant.

      Author's profile photo Shankar Sundaramurthy
      Shankar Sundaramurthy

      Good one Piyush..very informative.

      Author's profile photo Piyush Parekh
      Piyush Parekh
      Blog Post Author

      Thanks Shankar.

      Author's profile photo prashanth kalluri
      prashanth kalluri

      Good one Piyush! This approach will definitely improve the user experience and the way they interact with planning tool

      Author's profile photo Piyush Parekh
      Piyush Parekh
      Blog Post Author

      Indeed!! Thank you Prashanth for your feedback.

      Author's profile photo Lokesh Reddy
      Lokesh Reddy

      Very Informative!! Adopting this approach will definitely improve the business performance in realtime!! Thanks for sharing!!

      Author's profile photo Piyush Parekh
      Piyush Parekh
      Blog Post Author

      Thank you Lokesh!!

      Author's profile photo Kumar Shanmugam Prem
      Kumar Shanmugam Prem

      Good work Piyush !

      Author's profile photo Piyush Parekh
      Piyush Parekh
      Blog Post Author

      Thanks Prem.

      Author's profile photo Mohamed Azarudeen
      Mohamed Azarudeen

      Great Work Piyush !!

      Author's profile photo Piyush Parekh
      Piyush Parekh
      Blog Post Author

      Thanks Azar

      Author's profile photo Shikha Shivhare
      Shikha Shivhare

      Very informative Piyush.

      Author's profile photo Piyush Parekh
      Piyush Parekh
      Blog Post Author

      Thank you Shikha.

      Author's profile photo Akil Shaikh
      Akil Shaikh

      good informative use case Idea with example, shared on Digital Business Planning !!

      Author's profile photo Piyush Parekh
      Piyush Parekh
      Blog Post Author

      Thanks Akil

      Author's profile photo Disha Jain
      Disha Jain

      Very Informative!!

      Author's profile photo Piyush Parekh
      Piyush Parekh
      Blog Post Author

      Thanks Disha

      Author's profile photo Jose Anthony Mannala
      Jose Anthony Mannala

      This is really cool Piyush!

      Author's profile photo Piyush Parekh
      Piyush Parekh
      Blog Post Author

      Thanks Jose

      Author's profile photo sarthak chadha
      sarthak chadha

      Very Informative, Thank You Piyush!!

      Author's profile photo Piyush Parekh
      Piyush Parekh
      Blog Post Author

      Thanks Sarthak

      Author's profile photo Sujit Mandal
      Sujit Mandal

      Excellent article Piyush! Very detailed and informative.Thanks for sharing!

      Author's profile photo Piyush Parekh
      Piyush Parekh
      Blog Post Author

      Thanks Sujit