cancel
Showing results for 
Search instead for 
Did you mean: 

Fiori App - Need to Create a Fiori App that calls an HTML link with the user's SAP User Id embedded

0 Kudos

We have a requirement where we want to add a Fiori Tile that links to an HTML link, but we need to add the Fiori users ID as part of the HTML link.

Is this possible? Does Fiori provide for global abap global variables and if so how can I capture the user ID and add it to the link as a variable?

gregorw
Active Contributor
0 Kudos

Doesn't the target application authenticate the user? Do you want to trust something that the user can influence?

Accepted Solutions (0)

Answers (1)

Answers (1)

pramod_nagargoje
Explorer

Hi Paul,

It's not possible with simple link configuration inside Fiori launchpad using admin page.

You need to develop a SAPUi5 app or HTML5 app which takes username from browser session or javascript variable and redirects to your desired HTML link.

Regards,

Ravi Soni

0 Kudos

Hi Ravi,

So if I do an SAPUi5 or HTML5 development does that mean that I can somehow capture the SAP user ID via a global variable?

Is it easier to developer the SAPUi5 app? Is that done in SE80 and it is similar to ABAP? I have experience in ABAP but not HTML5. If you can point me in the right directly I can problably figure it out. Thanks!

Paul

pramod_nagargoje
Explorer

Hi Paul,

Yes, you can capture SAP user id using oData services which gives you your username, email, contact etc details. Or you can take it using SAP User ID.

You can develop SAPUI5 app and deploy it on SAP server using SE38 or using Eclipse HANA tools.

Please refer below link.

https://blogs.sap.com/2015/09/15/how-to-deploy-a-simple-sapui5-application-into-abap-server-using-ec...

Regards,

Ravi Soni

0 Kudos

Thanks Ravi that is very helpful! So the link above explains how to create a JavaScript program and add it to SAP's repository, but how do I call an ABAP SAP function module from the JavaScript to get the username?

Finally how do I call the JavaScript program from the Fiori tile?

I have those two pieces then I can do what I need to do. Thank you so much for your help!

Paul

pramod_nagargoje
Explorer
0 Kudos

HI Paul,

This should help.

$.response.contentType = "application/json";
var output = "";
var userName = $.session.getUsername();
output = '{"username":"'+userName+'"}';
$.response.setBody(output);

or this

var oUser = sap.ui2.shell.getUser();
oUser.load({}, function() {
var userID = oUser.getId();
}

and you need to do this inside your index.html:

<script src="/sap/public/bc/ui2/services/sap/ui2/srvc/error.js"></script>
<script src="/sap/public/bc/ui2/services/sap/ui2/srvc/utils.js"></script>
<script src="/sap/public/bc/ui2/shell-api/sap/ui2/shell/startup.js"></script>

0 Kudos

Hi Ravi,

I was able to install Eclipse Luna. I created a new project and I tried the code that you gave me with no luck. I am able to create code to generate a link, but am having issues getting the odata. Can you please look at my code below and tell me what the syntax is to get the username from the fiori sap session? I need the data for var str2.

Here is the code:

<!DOCTYPEhtml>

<html>

<head>

</head>

<body>

<script>

var str1= '?name=' ;

var str2="Testuser";

var str3="$loginstatus=0"

var url="https://demo.com/default.aspx?params=user=";

var newurl=url+str1+str2+str3;

window.location.href(newurl);

</script>

</body>

</html>