Monday, June 27, 2016

SAP Hana Analytical Privilege for Team Logic



You have a context calculation view and want to implement a manager user who can see content of his team .

For this purpose you opened an Authorization table with 2 columns (KEY_NAME KEY_VALUE)


Table AUTH_OPINT

KEY_NAME KEY_VALUE
U1 U4,U5
   



According to this table U1 has a team consisting of U2 and U3 .

Your view has a column as approverid, which is the column for storing approverid.
By definition a manager user can see items he approved or items approved by his team.

We have entries at this table for defining our teams , so a query like below :
select KEY_VALUE from YOURSCHEMA.AUTH_OPINT where KEY_NAME = SESSION_USER

will bring "U4,U5"

instr is a function searching second argument in 1st, so
instr( "U4,U5","approverid" ) will return bigger than 1 if approverid is either U4 or U5



TOTAL SCRIPT

("approverid" = SESSION_USER ) or
(
instr( (select KEY_VALUE from YOURSCHEMA.AUTH_OPINT where KEY_NAME = SESSION_USER) ,"approverid" ) >= 1
)

No comments:

Post a Comment