Skip to Content

As you have probably found out already, the log off procedure explained onhttp://help.sap.com/saphelp_nw04/helpdata/en/6b/9d91d062cc52419f23926ff1bf2ad3/content.htm implies that you close the browser window.

Now, this becomes almost impossible when dealing with handheld devices like barcode scanners.

The scenario I’m going to refer to in this page is intended to SAP BSP developments for handheld devices running Windows Mobile and IE 6+.

So all you need to do is:

– close the current SAP session

– clear authentication cache.

1) Closing the current SAP Session

Logging off is extremly easy. Let’s say your bsp app has a page called logoff.htm. Just create a link to this page like

http://<hostname.domain>:<port>/bc/bsp/sap/bc/<your_app>/logoff.htm?sap-sessioncmd=logoff

Sending the parameter ?sap-sessioncmd=logoff  will start actually close the current connection, and if you check in SM04 TCODE you should no longer see any Plugin Http connections  (or at least you’ll notice that one of them closes ).

Great so far, but there is another problem. If you hit refresh or do anything to make the BSP App pages reload, you’ll notice that the connection you just close, reopened because of the IE cache.

2) Clearing the authentification cache of IE

Clearing the authentification cache of IE is done by simply putin the following JS command in the URL Bar of the IE browser:

javascript: document.execCommand(‘ClearAuthenticationCache’);

Note: This command is not compatible with all browsers (like chrome) and probably not all versions of IE. To test it, just put the above mentioned command in the address bar and run it. It should return “true”.

Also if this command is succesful, your BSP App should popup the logon dialog box again. Keep in mind that this won’t mean that the previous session was closed. It only means that IE no longer knows that you have an open connection.

Puting it all togheter:

Another problem that might come up is the order in which the two commands run (log of and clear cache).

-If you clear cache before logoff you’ll have the logon dialog box again, and thus create multiple connections.

-If you call the logoff parameter via url like:

     http://<hostname.domain>:<port>/bc/bsp/sap/bc/<your_app>/logoff.htm?sap-sessioncmd=logoff

your browser might not run the JS function.

So you have to run them kinda at the same time, and in the following order:

– Log Off

– Clear Authentification Cache

Following is the code of the logoff page.

Note that the link to my page is simply

     http://<hostname.domain>:<port>/bc/bsp/sap/bc/<your_app>/logoff.htm

witout sending the logoff command.

<%@page language="abap" %>
<%@extension name="htmlb" prefix="htmlb" %>
<htmlb:content design="design2003" >
 <htmlb:page>
 <head>
<script type="text/javascript">
function clearCache()
{
   window.setTimeout('document.execCommand("ClearAuthenticationCache", "false")',1500); 
}
</script>
</head>
  <body onload="clearCache()">
  <img src="?sap-sessioncmd=logoff" width="1" height="1">
  <h1 align="center">You have been logged off</h1>
  <div align="center">
      <input type="image" src="./Images/home.jpg" style="width:100px; height:100px;" onclick="window.location.href='start.htm';"/>
  </div>
  </body>
  </htmlb:page>
  </htmlb:content>

In the page you have the clearCache() JS function that runs delayed for 1.5 seconds and it clears the authentication cache, and the

<img src="?sap-sessioncmd=logoff" width="1" height="1">

will run the logoff command for your app.

So this is it…

Links:

     Logging onto BSP Applications

     Logging off BSP Applications

To report this post you need to login first.

1 Comment

You must be Logged on to comment or reply to a post.

Leave a Reply