Analytic Privilege is used to restrict accessing of entire data present in information models (modeling objects) in SAP HANA. Also we can define a simple restriction to a set of complex restrictions with the help of Analytic Privileges and assign them to individual users or roles to restrict the data when they execute those objects.
After we create analytic privileges, we assign them to users. This restricts the users to access only the data of certain combinations of dimension attributes for which they are authorized.
From SAP HANA SP10, we can create two types of Analytic Privileges in SAP HANA. They are
- Classical Analytic Privileges (XML Analytical Privileges)
- SQL Analytic Privileges
The privileges needed to control access to row-level data in SAP HANA are called analytic privileges. These allow some users to see data X and others to see only data Y when accessing the same information view.
Now We are implementing SQL Analytic Privilege.
here is the following steps to Implement SQL Analytic Privilege.
Step 1: First Create a Table in your schema
your schema->Table->new Table
create table with following structure
Insert Following DATA into your Table
Run it and check the output
Step 2: Create Calculation View in your Package
Your Package->new->Calculation view
Create Calculation view with the name “EMPLOYEE_LOCATION_RESTRICTION_DATA”
Select ‘+’ symbol for select table
select your table
Select the following columns from your table
Select Apply Privilege as “SQL Analytic Privilege”
Save and Activate the view
and See the Output
In above output we can see the All the three countries INDIA ,US,UK but I want to see “INDIA”. I want to restrict “US” and “UK” so now I am creating “SQL Analytic Privilege”.
STEP 3:Create Analytic Privilege
Analytic Privilege -> New
Create new Analytic Privilege name as “ZEMPLOYEE_LOCATION_RESTRICTION”
Select your Package
Select your Calculation View “EMPLOYEE_LOCATION_RESTRICTION_DATA”
Click on Finish Button and You will get below screen
Below Screen you will add Time validity
Below Screen you can select the Restriction column
our Target is we can see only Employee_Working_Location as INDIA
Step 4: Apply the Privileges to User’s To Restrict Data
Go To security -> Users->your user
Go to Analytic Privileges Select the ‘+’ Symbol
Select your Analytic Privilege click on “OK” Run it.
Then your Analytic Privilege is Added.
Chick the Output.
We can sell the Following Output
Here We can see “EMPLOYEE_CURRENT_LOCATION” as “INDIA”