A Great Combination: Python and SAP Predictive Analytics

Introduction

Recently, SAP released SAP Predictive Analytics version 3.3.  Details on what is in this release can be found on the blog Announcing the release of SAP Predictive Analytics.  This release touts new support for Python.  Python is one of the most used languages for machine learning and is well equipped in numeric calculation.  Embedding predictive analytics libraries into a Python application is a natural progression for SAP Predictive Analytics.  In this article, we will take you through setting up the SAP Predictive Analytics Automated Analytics library with a Python environment on Windows.

Details on Python’s use with data science and in general can be found in the links below:

https://towardsdatascience.com/what-is-the-best-programming-language-for-machine-learning-a745c156d6b7

https://fossbytes.com/popular-top-programming-languages-machine-learning-data-science/

https://www.python.org/about/apps/

Note: You can also embed the SAP Predictive Analytics library into C++ and Java applications.

Business Benefits of Python

There are many web sites identifying the business benefits of Python. Here are some of my favorites which those of you working in data science may also appreciate.

* Ease of use and readability
* Large community support with many examples to draw upon
* Large list of standard libraries, with many numeric and scientific libraries
* No need for compilation
* Internet of Things (IOT) applications are adopting Python
* Python’s support for procedural, functional and object oriented approaches
* Ability to integrate with Enterprise Applications
* Extensibility

I encourage you to do an internet search on “business benefits of using Python” you may find other reasons that resonate better for your situation.

Additionally, for those who are leveraging the segmenting feature for forecasting in SAP Predictive Factory, using Python could be used to accomplish the same functionality with other types of predictive models.

What type of use-cases could include predictive analytics into an application?

Below are some examples where an application can include predictive analytics as a differentiating feature:

* Recommending products to customers based on prior buying patterns in on line web stores
* Scoring customers for the customer service team based a customer’s likelihood to churn in CRM applications
* Forecasting profit, sales growth rates in financial applications
* Alerting maintenance teams when a bearing has an 80% chance of failing to keep operations at running 100% of the time
* Alerting insurance agents on cases that have 90% chance of fraud.

Many SAP Partners embed SAP Predictive Analytics into their application to differentiate their own solution.  This article discusses embedding advanced analytics into applications:

https://blogs.sap.com/2016/08/29/predictive-analytics-changing-the-game-for-sap-oem-partners/

Additionally, there are perks for SAP Partners described in the article on Becoming an OEM partner has its benefits.

Prerequisites:

SAP Predictive Analytics 3.3 Desktop

Steps to Follow

* First you will need to get Python. The Anaconda distribution is very popular for Python and you can download it from https://www.anaconda.com/download/ . The default Anaconda install currently installs Python version 3.6.  SAP Predictive Analytics requires Python version 3.5.  To download this version with Anaconda, download Anaconda version 4.2 which uses Python version 3.5.  Anaconda 4.2 can be found on this URL.  If you download this version, then you will not need to manage versioning with environments as the instructions below state.
* I will continue using Anaconda3 5.0.1.  Install Anaconda using the graphical installer using the default options.

* Open the environment settings for your computer. Press the Windows start button and type “explorer”, click on the “File Explorer” icon the appears as shown below.

* Right click on the computer icon circled in red below and select the “Properties” option in the pop-up menu.

* Click on the “Advanced system settings” option circled below.

* Click on the Environment Variables button highlighted below.

* Add Python environment to your Windows computer. Press the ‘New’ button boxed in red below.

* Type ‘PYTHONPATH’ for the variable name and ‘C:Program FilesSAP Predictive AnalyticsDesktopAutomatedEXEClientsPython35’ for the variable value.  Then press the OK button.

* Again, press the ‘New’ button boxed in red below.

* Type ‘AALIBPATH’ for the variable name and ‘C:Program FilesSAP Predictive AnalyticsDesktopAutomatedEXEClientsPython35’ for the variable value.  Then press the OK button.

* Select the ‘PATH’ system variable by clicking on the PATH entry in the lower dialog which is highlighted in blue (you may need to scroll down).  Click on the lower Edit button circled below.

* Click on the New button boxed in red below. This action will add a row to the bottom of the PATH editor.

* Enter ‘C:Program FilesSAP Predictive AnalyticsDesktopAutomatedEXEClientsCPP’ for this new row and press the OK button circled below.

* Press the OK button circle below.

* To launch the Anaconda command line, press the Windows start button  and type “anaconda”, then click on the “Anaconda Prompt” icon the appears as shown below.

* SAP Predictive Analytics requires Python version 3.5. To setup Anaconda with that version, you will need to add this environment as discussed in this article https://conda.io/docs/user-guide/tasks/manage-environments.html  Type the following commands:

conda create -n py35 python=3.5 activate py35

* The first command above installs Python version 3.5.  The second command changes the environment to use Python version 3.5.  Your command prompt should now start with (py35) c:…  Lets run a SAP Predictive Analytics clustering sample. Type the following commands at the prompt:

cd %PYTHONPATH%..SAMPLESpython python clustering.py

You will see the following output:

Congratulations you are ready to work Python with SAP Predictive Analytics Automated library!

* This example uses the mathlibplot library. Add this library to your environment if you wish using the following command:

python -mpip install -U matplotlib

* When you rerun the clustering sample again with the following command:

python clustering.py

You should see the following graph plotted (It may take a few seconds to render).

Some Python lovers prefer command line, while others like Python graphical tools.  If you are a command line person, you are ready to work with SAP Predictive Analytics and Python.  If not, your next step would be to setup a Jupyter Notebook for a more interactive experience. I have an article on this topic as well.

Related Resources

For more information on the Automated Analytics API, see the SAP documentation at https://help.sap.com/http.svc/download?deliverable_id=20569176

You may also want to connect with your HANA database from your Python code.  The article “Connect to SAP HANA, express edition using Python” will help you get this setup as well.  Additionally, there is a blog on connecting Python to SAP HANA on the Cloud. http://bit.ly/2mMyyHt #SAP #SAPCloud #AI

Enable & troubleshoot Create Purchase Requisition and Manage Purchase Requisition apps in S/4 HANA 1610

This blog will help in enabling the “Create Purchase Requisition” and “Manage Purchase Requisition” apps in S/4 HANA 1610 FPS01 and also help in troubleshooting any issues with the app.

Create Purchase Requisition

Steps to enable

* Ensure the software component UIS4HOP1 200 – SP 0001 is installed.
* Ensure the backend component S4CORE 101 – SP 0001 is installed.

* Enable the below SICF services

* MM_REQ_MAINTS1
* MM_REUSE_ACCS1 *

* Enable the below ODATA services

* MMPUR_REQ_SSP_MAINTAIN_SRV 0001

* Assign the business role SAP_BR_EMPLOYEE_PROCUREMENT to

* the business catalog SAP_PRC_BC_EMPLOYEE
* the business group SAP_PRC_BCG_ESS

* Assign the respective users to the business role SAP_BR_EMPLOYEE_PROCUREMENT

Trouble Shooting

After enabling the app, you may come across below issues.

Issue 1:

* Go to Create Purchase Requisition app by clicking on to the tile that you have just enabled
* Click on to Create Own Item link which is below the search box and load the Create Own Item screen
* Click on to the Material input box F4 help in the Create own item screen.
* Enter a material number in the popup screen which will return some results.
* Click on / Select one of the rows in the search results displayed

Now the parent screen will display the details of the material and short description will be non editable.

But, if you enter the material number directly in the Create own item screen without using the F4 help and get the search results and then chose one of the materials from that search result, the details of that material doesn’t get displayed in the parent screen and the short description box remains editable.

This issue can be resolved by applying the note 2414881.

Issue 2:

* Go to Create Purchase Requisition app by clicking on to the tile that you have just enabled
* Click on to Create Own Item link which is below the search box and load the Create Own Item screen
* Enter the material number and all the details in the Create Own Item screen.
* Click on add to cart

If the material number is given, then the data will not be added to the cart and cart on the top right corner will not reflect the count. However, if the material number is not entered, add to cart will work. Please note that the material number is not a mandatory field.

This issue can be resolved by applying the note 2511441

Manage Purchase Requisition – Professional

Steps to enable

* Ensure the software component UIS4HOP1 200 – SP 0001 is installed.
* Ensure the backend component S4CORE 101 – SP 0001 is installed.

* Enable the below SICF services

* MM_PPR_MAINTS1

* Enable the below ODATA services

* MM_PUR_PR_PROFNL_MAINTAIN_SRV 0001

* Assign the business role SAP_BR_PURCHASER to

* the business catalog SAP_PRC_BC_PURCHASER_PR
* the business group SAP_PRC_BCG_PURCHASER_PR

* Assign the respective users to the business role SAP_BR_PURCHASER

Trouble Shooting

After enabling the app, you may come across below issue

* Go to Manage Purchase Requisition – Professional app
* Enter a PR no and click on to Go button
* The search results will be displayed below.
* Click on the settings icon and include the column “Is Advanced PR?” and refresh
* In the search results, choose one of the PRs which is marked as Advanced PR.

This will open both UI5 app and Web GUI app. This is the expected behavior as per the product. The link will open the UI5 app and check if it is a advanced PR. If it is an advanced PR, the UI5 app will close and return back to the parent screen and the Web GUI screen will be opened.

Hope this helps. http://bit.ly/2mNtsL1 #SAP #SAPCloud #AI

Development Lifecycle of a RESTful API Service

Software API Development Lifecycle

Every software company or startup has a unique software development lifecycle that they are using. It is often necessary to synchronize and align RESTful API deployment with the same processes that you use today for developing, testing, and deploying other applications.

Some services provide tools and sometimes even RESTful APIs that enable you to integrate their tools into your own development lifecycle. A common usage of the RESTful API is to write scripts or code that programmatically deploy REST API web services, or that migrate REST API services from one environment to another, as part of a larger automated process that also deploys or migrates other applications. https://goo.gl/CTwzmw #DataIntegration #ML