Technology Blogs by SAP
Learn how to extend and personalize SAP applications. Follow the SAP technology blog for insights into SAP BTP, ABAP, SAP Analytics Cloud, SAP HANA, and more.
cancel
Showing results for 
Search instead for 
Did you mean: 
Former Member
SAP's Predictive Analysis allows users to leverage the HANA PAL (Predictive Analysis Library) while connected to HANA in an online mode. This results in a user friendly interface which still allows you to push the processing to the HANA server. The PAL is not installed on HANA by default so I'll show below one way in which it can be installed. I've used Rev 60 of HANA for this guide.
Check if the AFL is installed:
You should first check if AFL (Application Function Library which includes PAL) is installed on your HANA server. To do this, log in to your HANA server in HANA Studio. Then open a SQL console and run the following commands:
SELECT * FROM
"SYS"."AFL_AREAS" WHERE SCHEMA_NAME = '_SYS_AFL' AND
AREA_NAME = 'AFLPAL';
SELECT * FROM
"SYS"."AFL_PACKAGES" WHERE SCHEMA_NAME = '_SYS_AFL' AND
AREA_NAME = 'AFLPAL';
SELECT * FROM
"SYS"."AFL_FUNCTIONS" WHERE SCHEMA_NAME = '_SYS_AFL' AND
AREA_NAME = 'AFLPAL';
If results get returned then you already have AFL installed (image below shows a HANA server with the AFL successfully installed).
Install AFL:
If you don't have the AFL installed, follow the steps below to install (you can download the AFL from http://service.sap.com/swdc)
  1. Log in as root.
  2. Extract the files using SAPCAR - SAPCAR -xvf IMDB_AFL100_60_1-10012328.SAR.
  3. Navigate into the SAP_HANA_AFL directory which was created in step 2 and execute hdbinst:
~/tmp/SAP_HANA_AFL #./hdbinst
SAP Application
Function Libraries installation kit detected.
SAP HANA Database
Installation Manager - SAP AFL Installation 1.00.60.379371
****************************************************************************
Enter SAP HANA
system ID: HVN
Enter System
Administrator Password:
Checking
installation...
Preparing package
"AFL"...
Installing SAP
Application Function Libraries to
/sapmnt/HVN/exe/linuxx86_64/plugins/afl_1.00.60.379371_1147257...
Installing package
'AFL' ...
Stopping system...
Activating plugin...
Starting system...
Installation done
Log file written to
'/var/tmp/hdb_afl_2013-07-29_16.12.49/hdbinst_afl.log'.
Check if AFL__SYS_AFL_AFLPAL_EXECUTE has been granted to the user who will be running the predictive models:
Grant AFL__SYS_AFL_AFLPAL_EXECUTE if the user doesn't have it:
NOTE: there are two underscores _ between AFL and SYS.
You can grant the option through the GUI or run a SQL statement similar to the following where MyHANAUser is the username you wish to give access to:
grant AFL__SYS_AFL_AFLPAL_EXECUTE to MyHANAUser;
Check if you already have the afl_wrapper_generator and afl_wrapper_eraser procedures and access to run them:
Below we can see the procedures do indeed exist:
Here we can see that user I817307 has access to the procedures:
Add the afl_wrapper_generator and afl_wrapper_eraser procedures if they don't exist:
  1. On the HANA server, navigate to the /hanamnt//<SID>/HDB <instance_number>/exe/plugins/afl/ directory and execute the afl_wrapper_generator.sql and afl_wrapper_eraser.sql scripts as HANA user SYSTEM. (An easy way to do this is to open the files in a text editor on the Linux server and copy the code back to HANA studio for execution as the SYSTEM user in a SQL console).
  2. You now have two procedures - AFL_WRAPPER_GENERATOR and AFL_WRAPPER_ERASER which are owned by SYSTEM.
  3. Grant the EXECUTE privilege on system.afl_wrapper_generator and system.afl_wrapper_eraser to your predictive analysts.
  4. For example, if the user name is MyHANAUser, run the commands: GRANT EXECUTE ON system.afl_wrapper_generator to MyHANAUser; GRANT EXECUTE ON system.afl_wrapper_eraser to MyHANAUser;.
Check if you've enabled the Script Server.
Next you'll need to check if you have enabled the Script Server. To do this, go to the administration view of your SAP HANA system in Studio.  Under Configuration | daemon.ini |scriptserver, you'll need to check if the value is 0 or 1. 0 indicates you have not enabled the server.
Below we can see the server is indeed enabled.
Enable the Script Server if it wasn't already in the step above:
I personally used method B in the above note.

Please note, it's important to TAKE A COMPLETE BACKUP as mentioned in the note.
You may need to restart your HANA instance after going through the steps.
That's it - you have configured PAL for use by SAP Predictive Analysis! To begin using it, perform the following steps:
  1. Connect in online mode:

   2. Select an appropriate algorithm from the Predict tab (HANA Apriori for example):

  3. Follow the usual steps you would to run a predictive analysis.

21 Comments