on 12-04-2018 11:42 PM
I am building a simple BSP that builds a link. The link requires the global user Id of the person running thee BSP...(sy-uname). I need to include their user name in the link. Below is my code and I want to replace the code that says "var str='TNSUSER01" with the actual sy-uname value. How do I retrieve an ABAP global variable from this BSP (HTML) code?
<!DOCTYPE html>
<html>
<head>
</head>
<body>
<script>
var str1= '?name=' ;
var str2="TNSUSER01";
var str3="$loginstatus=0"
var url="https://eba.quinteldemo.com/eba.net/default.aspx?params=user=";
var newurl=url+str1+str2+str3;
window.location.href(newurl);
</script>
</body>
</html>
Hi Sandra,
Thanks for your response. I checked and "without script" in the BSP properties is not checked. The page type is set to "Page with Flow Logic".
Do you happen to know if the line of code below is correct when referencing a Page Attribute value? that part of the code is in the
<script> section of the HTML:
var str2 = "<%= username %>";
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thanks for the reply. So I tried the statement :
var str2 = "<%= sy-uname %>"
The result was the value of var being the literal value <%= sy-uname %>
I also tried the statement
var str2 = "<%= username %>"
Username is a global variable that I setup under "page attributes" and flagged it as "auto". In the Event Handler tab under the event "on create" I added the following code:
USERNAME = SY-UNAME.
When I use this statement in the HTML code
var str2 = "<%= username %>"
the value that is put in var is the literal <%= username %>
I am at a complete loss at this point. I feel like I tried everything. I assume if you write logic in ABAP on the Event Handler page you should be able to pass any Page Attribute variable values to the HTML page??? Here is my new code:
<!DOCTYPE html>
<html>
<head>
</head>
<body>
<script>
var str1= "?name=" ;
var str3= "zzzz";
var str2 = "<%= username %>";
var url="http://google.com/";
var newurl=url+str1+str2+str3;
window.location.href(newurl);
</script>
<!-- <p>The value you entered on the previous screen is: <%= username%>
</p> -->
</body>
</html>
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
.. further on from your code, if the HTML is within the BSP, you should be able to call
var str2 = "<%= sy-uname %>" and then continue as usual.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Within a BSP, you can call ABAP code within the <%= and %> brackets. Thus you can try calling the sy-uname value either as
<%= sy-uname %> or by first moving it to a JS variable.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
82 | |
10 | |
10 | |
9 | |
6 | |
6 | |
5 | |
5 | |
4 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.