Skip to Content

How to get login info in XSODATA Service consumed by SCP Mobile Services

Dec 22, 2017 at 04:54 PM


avatar image

Hi everybody,

we've implemented a solution in which a SAPUI5 application calls an oData service, exposed by a HANA system (XS Advanced), through SCP Mobile Services destination and Cloud Connector.

Now we're trying to filter data based on user logged in the application, without passing a parameter in URL calls, but using some sort of session variable inside our Calculation View exposed with .xsodata files.

We are able to retrieve the caller's username only inside .xsjs file.

Is there a way to use that information inside Calculation View?

10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

1 Answer

Best Answer
Ivan Mirisola
Dec 26, 2017 at 03:17 PM

Hi Edoardo,

Like you said, using parameters is not a good idea.

Instead, you need to rely on the DB itself to produce the correct output. Not only it is safer, but the result set will be better optimized.

XSA has DCL to produce DB Roles in HANA (CDS Roles) so your view will automatically filter out data based on user roles. DCL will rely on SESSION_CONTEXT, so you can retrieve attribute data dynamically on your CDS View and it will perform filters based on it. With DCL you could also define the data restriction based on static values, external attributes, etc. Please review this document.

XSC will rely on Analytical Privileges to restrict the outputted data. Check this examples for detailed information on how to create and use them for your Calculation Views. Check this blog for dynamic analytic privileges using procedures and how this privileges interact with Calculation Views on this blog. Another good blog points tho the step-by-steps required to create such privileges.

If you are still using Classic database objects on top of XSA I would highly recommend migrating such artifacts to CDS DDL.


10 |10000 characters needed characters left characters exceeded