Skip to Content
Technical Articles
Author's profile photo Andreas Forster

Installing the Automated Predictive Library (APL) on SAP HANA Express 2.0

The Automated Mode of SAP Predictive Analytics allows the efficient creation of powerful predictive models. Installing the Automated Predictive Library (APL) on SAP HANA makes it possible to train these models directly in SAP HANA. The data does not have to be extracted into an external system, the architecture is simplified and agility is increased.

In the official documentation you will find the overall steps of the installation process of the APL. This blog shows how to apply these steps, from downloading the APL to using it in SAP Predictive Analytics.

This blog was initially written in January 2018 for SAP Predictive Analytics 3.3, APL3 and SAP HANA Express 2.0 SPS02. In 2019 a new Python interface was released for the APL. This “SAP HANA Python Client API for Machine Learning Algorithms” (also known as hana_ml) requires APL4, for which the installation steps are slightly different. These differences are mentioned in the APL4 section at the bottom of this blog.

Prerequisites

It is assumed that you have a SAP HANA Express 2.0 up and running. You have also been able to establish a connection from the SAP HANA studio. (Please note that the APL is also available for SAP HANA 1, but this article is focussing on SAP HANA 2.0)

In case you do not have such a system available yet, you can follow the SAP HANA Express documentation. To follow the steps in this blog it is sufficient to download the “Server only virtual machine”. Some of the steps listed below are flagged for “Server + Applications VM Only”, these are not required to be able to install the APL:

You should be seeing something similar to this screen. Notice that the only installed plug-in is the Application Function Library (AFL). If the APL was installed, we should see it there.

 

Download the APL

The APL can be downloaded from the Software center. You find it by following this path:

  • INSTALLATIONS & UPGRADES
  • By Alphabetical Index
  • P
  • SAP Predictive Analytics
  • SAP PREDICTIVE ANALYTICS 3
  • COMPRISED SOFTWARE COMPONENT VERSIONS
  • PRED ANALYTICS APL 3 FOR HANA2

Before downloading, make sure to set the drop down on that page to the correct operating system. The APL has different downloads for x86 and PowerPC.

Then download the latest version, currently: “APL 3.3. PRED ANALYTICS APL 3.3 FOR HANA2”. The file itself is called SAPPAAPL3003_0-80002689.TGZ.

Copy the APL onto SAP HANA

The file you have just downloaded needs to be copied onto the SAP HANA system. I am using a program called WinSCP, but plenty of other options are available.

Connect from WinSCP to the SAP HANA operating system, logging on with the ‘hxeadm’ user and the password you had specified during the setup of SAP HANA Express.

Copy the APL you had downloaded into the /tmp folder on the SAP HANA system.

 

Once the file is copied, it needs to be extracted. Still in WinSCP, select the file on the right hand side, on the SAP HANA system. Right-click the file, select “File Custom Commands”, then “UnTar/GZip…”. Confirm all prompts and the file is extracted into a newly created folder.

Install APL

The actual installation of the APL can be started from within the SAP HANA Administration Console. Right-click on your System connection, choose “Lifecycle Management”, then “Platform Lifecycle Management” and finally “SAP HANA Platform Lifecycle Management”.

 

You will be prompted for a password. Logon with the hxeadm user of the Linux operating system. This logon is NOT for your SAP HANA user.

 

Click into “Install or Update Additional Components”. Go into “Add Software Locations…” and choose the “installer” folder of the extracted APL file.

 

Confirm the selection with “Add”. You should see a screen that the “Automated Predictive Library” has been detected in that folder. Continue with “Next”. Confirm that you want to install this library.

 

On the next screen enter the passwords for both the Linux operating system user as well as for your SAP HANA user. Continue and the install will start and complete in a few minutes.

 

The APL is now installed! It will show as new plugin on the Administration panel of the SAP HANA Administration Console. If this screen was open during the install, you need to close and reopen it to see the new component.

 

 

Configure APL

The APL is installed, but not quite ready yet for use. It still needs to be configured. We will configure the system so that we can use the APL on the HXE tenant database, which comes with SAP HANA Express 2.0.

To run the APL the script server needs to be activated for the database. Open an SQL Console for the SYSTEMDB under the SYSTEM user and execute this statement:

ALTER DATABASE HXE ADD 'scriptserver';

 

Now make sure you have a connection to HXE in the SAP HANA Administration Console. Just specify the tenant database “HXE” when adding the system.

 

Let’s create a user, under which we call the APL. I name the user SAPPA. Grant this user the role APL_EXECUTE.

 

The role can also be assigned to an existing user, ie with this SQL statement:

call _SYS_REPO.GRANT_ACTIVATED_ROLE ('sap.pa.apl.base.roles::APL_EXECUTE','SAPPA');

 

Test APL

The APL is installed and configured. As final step we should verify everything is working well. The second line in the following SQL syntax has to be called by the user that wants to call the APL The first line switched the code execution to that user. Stating the obvious, you need to replace the Xs with the user’s real password.

CONNECT SAPPA PASSWORD XXXXXXXXX;
call "SAP_PA_APL"."sap.pa.apl.base::PING"(?)

Only if the above statement executes successfully, the APL is ready!

 

Bonus Material

If you just wanted to install the APL, then you are all set. Should you want to see how SAP Predictive Analytics leverages that APL, then read on. With SAP Predictive Analytics you get a graphical interface to train predictive models, without the need of using SQL.

This final part of the blog is kept rather short, it is assuming you are already fairly familiar with SAP HANA and SAP Predictive Analytics. Since the user is interacting with SAP HANA, ie to upload data, the user has been granted additional rights. To help you test this quickly, you could assign all roles visible in the SAP HANA Administration Console to the user.

On the machine you have SAP Predictive Analytics installed, you have to create a 64 bit ODBC source to SAP HANA Express. This uses the HANA ODBC driver that is installed by the SAP HANA Client, which is part of the SAP HANA Express download. In the ODBC Administrator, the driver is called HDBODBC.

The Server:Port setting for you is probably something like: hxehost:39015

 

To connect directly to HXE, you can go into “Settings” and add a property called DATABASENAME, pointing to the HXE database.

 

We also need some data in SAP HANA Express to train a model. You can use your own data or test with sample data of SAP Predictive Analytics. There are many ways to upload data. For such a quick test I prefer to use SAP Predictive Analytics itself. Make sour your installation of SAP Predictive Analytics has the same version as the APL you installed. Open the tool and in the menu select “Toolkit”, followed by “Perform a Data Transfer”.

This options allows to easily move data. You can transfer all columns from that file through ODBC into SAP HANA:
C:\Program Files\SAP Predictive Analytics\Desktop\Automated\Samples\Census\Census01.csv

Stay in SAP Predictive Analytics to train a model. Go into “Create a Classification/Regression Model”. Select the ODBC source and choose the table that holds the data from the Census file.
Set the “class” column as target variable. Exclude the columns KxIndex and fnlwgt.

Start the model training and the status messages should show the term “APL”. The model is being trained directly within SAP HANA, without extracting the data!

 

APL4

This blog was initially written in January 2018 for SAP Predictive Analytics 3.3, APL3 and SAP HANA Express 2.0 SPS02. In 2019 a new Python interface was released for the APL. This “SAP HANA Python Client API for Machine Learning Algorithms” (also known as hana_ml) requires APL4, for which the installation steps are slightly different.

The APL4 can be downloaded from the Software center. You find it by following this path:

  • SUPPORT PACKAGES & PATCHES
  • By Alphabetical Index
  • H
  • SAP HANA PLATFORM EDITION
  • SAP HANA PLATFORM EDITION 2.0
  • APL 4 FOR HANA 2 SP03+
  • SUPPORT PACKAGE PATCHES
  • [Select your operating system, ie LINUX ON X86_64 64BIT]

The current version of the file as of November 2019 is SAPPAAPL4_1910_0-80004547.ZIP (Predi. Analy. APL 1910 for SAP HANA 2.0 SPS03 and beyond).

When downloading SAP HANA Express 2.0 SPS04 you have the option to also download an older version of APL4. This file is currently (November 2019) not on the version required by hana_ml. Hence you still need to download the most recent version from the Software center as described above.

Do not unzip the APL4 file on Windows. Transfer the file onto the SAP HANA operating system (ie using WinSCP as described above. Then extract the file directly on the Linux system, ie with the command unzip SAPPAAPL4_1910_0-80004547.zip.

With these few adjustments you should be able to follow this blog to install APL4 for use with the hana_ml wrapper.

Assigned Tags

      8 Comments
      You must be Logged on to comment or reply to a post.
      Author's profile photo RAJIV SRIVASTAVA
      RAJIV SRIVASTAVA

      Thanks . Followed the process and successful ran APL Regression and Key Influencers

      Has anybody run APL Timeseries Forecast on HANA 2.0 SPS02 Express  . I get the following error

      Could not execute 'CALL "SAP_PA_APL"."sap.pa.apl.base::FORECAST" ( "TUTORIAL_PREDICTIVE"."APL_FUNCTION_HEADER" , ...' in 5.920 seconds .
      SAP DBTech JDBC: [423]: AFL error: "SAP_PA_APL"."sap.pa.apl.base::FORECAST": line 38 col 4 (at pos 2071): AFL error: search table error: _SYS_AFL.APL_AREA:FORECAST: [423] (range 3) AFL error exception: [APL error] Automated Analytics error (-2147467257): phase 'KxCPPInterf::IKxenModel::sendMode()' [[:Unexpected internal error
      Please contact SAP support.
      Error detail: thread creation failed(11)]]

      Author's profile photo RAJIV SRIVASTAVA
      RAJIV SRIVASTAVA

      Hey Andreas,

      Just an update , have resolved the issue mentioned earlier in my comment. Increased the number of CPUs and memory for my VM machine on the Google Cloud Platform (to 4 CPUs and 26 GB RAM a highmem configuration available on GCP)…feels good.

      The Timeseries forecast also worked well.

      Thanks for the blog above

      cheers

      Rajiv

      Sydney,Australia

      Author's profile photo Andreas Forster
      Andreas Forster
      Blog Post Author

      Hello Rajiv,
      Good to hear that you could use the APL for time series forecasting.
      APL delegation for time series is working also on my little HANA Express VM, which has only 8 GB and 2 processors assigned.
      I just tested this on a daily time series, with a history of about 5 years.
      Many Greetings
      Andreas

      Author's profile photo Marc DANIAU
      Marc DANIAU

      The good news is that the APL component is now included in SAP HANA Express with version: 2.0 SPS 03 Revision 30

      sap-hana-express.release-notes

       

      Author's profile photo Mathias Kemeter
      Mathias Kemeter

      Thanks for this blog - and especially the appendix on the HANA ML Python client. This saved me a lot of time!

      Author's profile photo Georg Schukat
      Georg Schukat

      APL 4 for HANA Express?

      just installed a APL 4 patch 2004 similar to your recommendations.

      executing to verify:

      call SAP_PA_APL."sap.pa.apl.base::PING"(?)

      gives

      name,value
      "HDB.Version","2.00.040.00.1553674765"
      "APL.Version.Major","4"
      "APL.Version.Minor","203"
      "APL.Version.ServicePack","2004"
      "APL.Version.Patch","0"
      "APL.Info","Automated Predictive Library"
      "AFLSDK.Version.Major","2"
      "AFLSDK.Version.Minor","16"
      "AFLSDK.Version.Patch","0"
      "AFLSDK.Info","2.16.0"
      "AFLSDK.Build.Version.Major","2"
      "AFLSDK.Build.Version.Minor","13"
      "AFLSDK.Build.Version.Patch","0"
      "AutomatedAnalytics.Version.Major","10"
      "AutomatedAnalytics.Version.Minor","2004"
      "AutomatedAnalytics.Version.ServicePack","0"
      "AutomatedAnalytics.Version.Patch","0"
      "AutomatedAnalytics.Info","Automated Analytics - Unlicensed Version"
      

       

      so this needed current APL 4 can not really be used with HXE?

       

      Will a new HANA Express resolve that issue?

       

      Author's profile photo Andreas Forster
      Andreas Forster
      Blog Post Author

      Hello Georg, The APL version that comes with the HANA Express download was recently updated. So it might not be needed anymore to download the very latest APL separately. I understand that shipped APL version is sufficient to work with hana_ml 1.0.7. It might also work with version 1.0.8 that is currently on pip.

      Author's profile photo Georg Schukat
      Georg Schukat

      Hi Andreas,

       

      yes, verified with new HXE 2 SP04 045  Version. It comes with the 1911 APL.

      When upgrading my HANA Express 040 Version install, the upgrader did not touch my APL install because it is a newer version. Good.

       

      Python hana_ml lib which comes with the official full 2.4.045 HANA client is already the 1.0.8 version. So it would be great if APL 1911 which comes with HXE, had no problems with that hana_ml. Will see. I can not test that scenario because I would have to downgrade the HXE APL version.