Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
139 views

Using The HCP User API in Web Ide

The document discusses how to use the SAP HCP User API in SAP Web IDE to obtain user information and log users out. It provides two examples: 1) Adding user details like name to a view by calling the user API and binding the response to UI elements. 2) Adding a logout button that calls the logout endpoint via AJAX to log the user out.

Uploaded by

Bikash Bhanu Roy
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
139 views

Using The HCP User API in Web Ide

The document discusses how to use the SAP HCP User API in SAP Web IDE to obtain user information and log users out. It provides two examples: 1) Adding user details like name to a view by calling the user API and binding the response to UI elements. 2) Adding a logout button that calls the logout endpoint via AJAX to log the user out.

Uploaded by

Bikash Bhanu Roy
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

SAPUI5 Developer Center: Using the SAP

HCP User API in SAP Web IDE


Posted by Jamie Cawley Apr 16, 2015
SAP HCP provides a service which can be used to obtain user information as well as log off the user. The
details regarding the userapi can be found at
https://help.hana.ondemand.com/help/frameset.htm?1de599bf722446849d2b2e10132df42a.html
Here's two simple examples on how this can be acheived within SAP Web IDE.

Adding the User Details to a View


Add a route into the neo-app.json to reference the userapi
{
"path": "/services/userapi",
"target": {
Create a json model to call the service

"type": "service",

"name": "userapi"

var userModel = new sap.ui.model.json.JSONModel("/services/userapi/currentUser"); sap.ui.getCore().setModel(userModel, "


Now within a view create some fields to display the data returned by the service

<Label text="User Name"></Label> <Text xmlns="sap.m" text="{userapi>/name}"></Text> <Label text="First Name"></Label

Adding a Logout Button to Your Application


In a view add a button to call a function
<Button xmlns="sap.m" text="Log Out" press="logUserOut"></Button>
Within the corresponding controller add the function to process the event.

logUserOut: function(){
$.ajax({
"url":"/services/userapi/logout",
"success": function(){
sap.m.URLHelp
NOTE: When testing this it will log you out of Web IDE and HCP. Also make sure to not test it in the preview
frame, this may cause same origin or https issues. This can be set in the run configuration by unchecking
"open with frame".
Regards,
Jamie Cawley
1050 Views

Generated by Jive on 2015-06-10+02:00


1

SAPUI5 Developer Center: Using the SAP HCP User API in SAP Web IDE

There are no comments on this post

Generated by Jive on 2015-06-10+02:00


2

You might also like