cancel
Showing results for 
Search instead for 
Did you mean: 

CATW Internet Service - SE80

Former Member
0 Kudos

Dear Experts,

I have a requirement in which I need to do some changes to the CATW Internet Service in SE80 such that when the user clicks on the X (Close) button in the Internet Explorer browser window, I should be able to trap the event and kill the user's session.

After trapping the event, I need to place the same functionality in a JAVA SCRIPT that is there when a user clicks on the "QUIT" hyperlink on the Timesheet Window when this service runs.

Basicaly the idea is to "Kill the user's session when a user clicks on X (Close) button in the Internet Explorer browser window.

Since this service is running in ITS, i need help on the following.

1. Which is the "HTML Template" in the CATW Internet Service in SE80 in which the "QUIT" hyperlink functionality is written that kills the user's session.

2. Which is the "HTML Template" in the CATW Internet Service in SE80 in which i place the code for trapping the event raised when a user clicks on the on X (Close) button in the Internet Explorer browser window.

Please help.

Regards

Saurabh

Accepted Solutions (1)

Accepted Solutions (1)

thorsten_domsalla
Active Participant
0 Kudos

Hello Saurabh,

simply spoken, you just need to send an /nex to the ITS. If you use the Javascript function setOkCode("/nex") it should do the logoff.

But, if you want to implement more fail-safe there are many other things to be taken into consideration: Do you want to delete cookies? Do you want to let the user navigate in that transaction?

Actually, there is another command you need to execute if you want do delete the cookies (e. g. the SSO cookie): webguiSendCommand('LogOff'). But, I am not sure if it is available in IAC services.

Then, the only event handler that can be used (in any browser) to catch the click on the Close button 'X' is the unload event handler. You need to put an onunload="dosomething_onunload();" somewhere (primarily into the <body> tag). It will catch the event when the user navigates to another site or closes the browser window. BUT - if you put it in the <body> of your dynpro page it will execute the event everytime when the user loads another page. You need to implement a frameset with that handler. The dynpro must be loaded into a frame of this frameset.

On the other side, the SAP GUI for HTML could do everything for you automatically. If you use ~webgui_simple_toolbar and ~singletransaction with ~webgui in your service you kind of emulate the IAC service.

With best regards,

T. J. Domsalla

Former Member
0 Kudos

Hi Thorsten,

Thanks so much for your reply.

I have implemented this in my HTML Template - 1000TOPCORE

This is the code.



<body `SAP_BodyAttributes()` onload="`SAP_OnloadJavaScript()`" >

`SAP_TemplateHeader( applicationTitle=~windowtitle, type="SAP_WEBGUI",logoffOnclick="" )`

`	SAP_BodyContentBegin();`

<form id=webguiform name="webguiform" action="`wgateURL()`" method="post" target="_parent" onSubmit="return false;" onclick="webguiDoClick(event)" onfocus="webguiDoFocus(event)">
`form_parameters();`
<div id="webguiContainer"><div id="webguiUserArea">

<b><table>
<tr> 
<td>
<input type="button" value="saurabh" onclick="javascript:setOkCode('/nex')"> 
</td>
</tr>
</table></b>


Now this code works fine and when I click on the button "saurabh" or the "EXIT" link I am redirected to a new page with message

"Logged Off Successfully

You have been logged off from SAP Web Application Server."

This is the same functionality when I click on the STANDARD "EXIT" hyperlink.

So far so good.

Now Im going to trap the X- (Close) Button on the browser.

This is the code:



<body `SAP_BodyAttributes()` onload="`SAP_OnloadJavaScript()`"  <b>onbeforeunload=" chk()"></b>

and the function chk() is like this 

function chk()
            {
            alert('inside function');
                setOkCode('/nex');
               alert('success');
                }

Now when I implement this : <b>onbeforeunload=" chk()"></b>

The "EXIT" and the new button (Saurabh) that I have created as below:

<input type="button" value="saurabh" onclick="javascript:setOkCode('/nex')">

do not redirect me to the following message :

"Logged Off Successfully

You have been logged off from SAP Web Application Server."

Instead I get this message.

"

400 Session timed out - please log in again

-


Error: -11

Version: 7000

Component: ICM

Date/Time: Wed Jul 25 11:14:57 2007

Module: icxxthr_mt.c

Line: 1705

Server: er3asu72_S02_21

Error Tag: {-}

Detail: Session does not exist

"

In both the cases the session is killed, but the message is different. I would like to have the SAP standard message ("Logged Off Successfully

You have been logged off from SAP Web Application Server.") displayed when I click on "EXIT" link after implementing the following :

<b>onbeforeunload=" chk()"></b>

I hope u understand my concen.

Plz help

saurabh

thorsten_domsalla
Active Participant
0 Kudos

Hello Saurabh,

first, please note that the onbeforeunload handler does not work in other browsers as in the Internet Explorer.

Then, when you execute the onbeforeunload handler chk() you send the ~okcode=/nex everytime before the page unloads due to the response of the click on the button that already ended the session. What you see is the response of the second logoff request.

With best regards,

TJ

Former Member
0 Kudos

Hello Thorsten,

Thanks for all your help, I have user onunload instead of onbeforeunload. This has solved the problem.

I have given points for that

Thanks again

Saurabh

thorsten_domsalla
Active Participant
0 Kudos

Hello Saurabh,

thank you.

However, I want to note that the unload event handler is called any time the current page is released, refreshed or whatever. So, if there are screen elements or controls that are used for taking the next step in the program and that cause a server request, loading the following page will unload the current page and thus trigger the logoff.

With best regards,

TJ

Former Member
0 Kudos

Hi TJ,

Absolutely correct, that is what is happening.

Whenever I click on any button on the screen, it logs off.

Is there any solution for this??

PLs suggest.

Regards

Saurabh

thorsten_domsalla
Active Participant
0 Kudos

Hello Saurabh,

as I wrote earlier in this thread there exists a solution with using a frameset.

With Javascript we are not able to distinguish between the different causes of an unload event. Wether the user types in a new URL in the location bar or a new page belonging to the current application or even the click on the browser window's close button is all the same from the perspective of Javascript. Thus, we are not able to simply catch the event on our current page and do something regarding the session of the application.

But, there is another way to overcome this restriction: We need an additional page that does not trigger the unload event when the user navigates inside the application but everytime he leaves the current service. That is where the frameset comes into play. The principle is easy: Load a frameset with the unload event handler. Load the dynpro into a frame of this frameset. All application dependend actions of the user are "encapsulated" in that frame. Each server response returns into this frame. But, when the user enters a new URL in the location bar or, if he closes the browser window, not only the frame but also the frameset will be unloaded. In that case the event handler can do its job and release the session.

This is how the SAP GUI for HTML works.

What do you think about using the SAP GUI for HTML instead of an EWT service?

Regards,

TJ

Former Member
0 Kudos

HI TJ,

Im trying it the other way round. but the setOkCode('/nex'); doesnt seem to work.



<body `SAP_BodyAttributes()` onload="`SAP_OnloadJavaScript()`;browser()" onunload="chk(event)">


<SCRIPT LANGUAGE=JavaScript>
var versionindex ;
var version=0;

	
function chk(evt){
   alert('in function');
   alert('versionindex'+versionindex);
   alert('version'+version);
   
   
   if(version !=0) 
     {
       alert('inside if');
       alert('type '+ evt.type);
       if (evt.type == 'undefined' || evt.type == 'unload') 
	{
         alert('IE closed!');
         setOkCode('/nex');
         exit;
	}
       }
	
	if(version==0 && versionindex != 'undefined')
	{	
	alert('mozilla ....');
        alert('type '+ evt.target);
            

         if (evt.target==null)
		{
            
                closeSession();
		alert('closing ....');
            
        	exit;
      		}
	}
	alert('refreshing');	

}





function browser(){


if(navigator.userAgent.indexOf("Firefox")!=-1){
versionindex=navigator.userAgent.indexOf("Firefox")+8
if (parseInt(navigator.userAgent.charAt(versionindex))>=1)
alert("You are using Firefox 1.x or above")
}



if (navigator.appVersion.indexOf("MSIE")!=-1){
temp=navigator.appVersion.split("MSIE")
version=parseFloat(temp[1])
}

if (version>=5.5) //NON IE browser will return 0
alert("You're using IE5.5+")


} 
 

function closeSession(){

alert('closing session');
setOkCode('/nex');
alert('session closed');

}        

</SCRIPT>

The function browser() in java script captures the browsertype .

Now in the onUnLoad event, I am checking this browsertype, and accordingly The X-button is captured.

In Mozilla Firefox, the click of X-button fires the event and we capture it thru evt.target.This returns 'null' when we click the X-button.This is in case of mozilla. The page refresh, etc, return some other values, which can now be handled easily.

In case if IE, the X-button click returns 'unload' as the event type.

Now the problem here is:

In mozilla everything goes fine, all the lines of code specific to mozilla are executed without any failure.But the setOkCode('/nex'), seems to be called, but not doing its job, i.e. the user remains locked in the backend. All lines of code are executed, which are written after setOkCode('/nex').

Plz suggest why is this setOkCode('/nex') not working fine inside javascript?

If you have any other solution please suggest.

thorsten_domsalla
Active Participant
0 Kudos

Hello Saurabh,

did you check the HTTP trace? Was the request with ~okcode=/nex sent? If yes, is there a 200 response? I suspect the request has been aborted by the browser before it could be executed by the server.

At the moment, while the lines with setOkCode() are processed, the DOM is unloaded. Some browsers, especially the IE, will send an HTTP ABORT right after the request was sent in order to cancel it. However, I did not see that behaviour in Firefox.

In such a case it helps to let the /nex request use another window.

Is the Javascript function setOkCode() available? Did you debug it with Venkman?

Did you consider the SAP GUI for HTML solution?

Regards,

TJ

Former Member
0 Kudos

HI TJ,

Thanks for your reply,

Im trying to use setokcode(/nex) in nother window basically a new window which opens when the user closes a tab in mozilla. I have added a new HTML template under CATW->TOPIC99->HTML TEMPLATES, which i call "loggoff"

Now I need to use "window.open" to open this new HTML file "loggoff" that I created above and use the setokcode(/nex) on the onload event of this new window.

This is the code that im using, but it doesnt seem to open my file.

window.open ("Z_LOGOFF_MOZILLA.html","mywindow");

TJ, we will not be able to use SAP GUI for HTML solution as we are not using dynpro's for this service.

Pls suggest.

Regards

Saurabh

Former Member
0 Kudos

Ok now I can call the new HTML template that I created but the new page that opens up does not execute setokcode('/nex').

this is the HTML TEMPLATE -> loggoff

`include (~service="catw", ~theme="99", ~name="functions_1000.html");`

<html>

<head>

<!-- <title>`#windowtitle`</title> -->

`SAP_TemplateStylesheet()`

`SAP_TemplateJavaScript()`

<SCRIPT LANGUAGE=JavaScript>

function closeSession(){

alert('inside new');

setOkCode('/nex');

alert('killed session');

}

</script>

</head>

<body `SAP_TemplateBodyAttributes( )`

onload="`SAP_TemplateOnLoadJavaScript()`;closeSession()" >

<!-- add content here -->

im in body

</body>

`SAP_TemplatePostProcess();`

</html>

Once the method close session is called, it executes alert('inside new'); but after that it does notthing.

Please suggest if I need to add anything more to get setOkCode('/nex'); executed in this new HTML TEMPLATE..

Regards

Saurabh

thorsten_domsalla
Active Participant
0 Kudos

Hello Saurabh,

> window.open ("Z_LOGOFF_MOZILLA.html","mywindow");

You will need to specify the mimesURL() path to refer to a static HTML file.

> we will not be able to use SAP GUI for HTML solution as we are not

> using dynpro's for this service.

I do not understand. What else if not a dynpro do you process in the ITS?

Regards,

TJ

thorsten_domsalla
Active Participant
0 Kudos

Hello Saurabh,

> <body `SAP_TemplateBodyAttributes( )`

> onload="`SAP_TemplateOnLoadJavaScript()`;closeSession()" >

Oh, you are using a template instead of a static HTML file. Ok.

Could you please delete the line

alert(`'inside new');

and do the test again?

Thanks,

TJ

Former Member
0 Kudos

HI TJ,

I did the following but still the user is getting locked in the backend.



`include (~service="catw", ~theme="99", ~name="functions_1000.html");`

<html>
  <head>
    <!-- <title>`#windowtitle`</title> -->
    
	`SAP_Stylesheet();`
	`SAP_JavaScript()`
`SAP_WebFrameworkJavaScript();`

<SCRIPT LANGUAGE=JavaScript>

function closeSession(){

setOkCode('/nex');
alert('killed session');
}

</script>



  </head>
  <body `SAP_TemplateBodyAttributes( )` onload="closeSession()" >
        im in body

  </body>
  

</html>

Regarding the dynpro's there is no usage of dynpro in 1000TOPCORE the HTML template that is getting the timesheet. Is this dynpro the same as webdynpro, please excuse if its stupid question ) I am an EP guy and do not have ITS dev exp.

Regards

Saurabh

Former Member
0 Kudos

HI TJ,

please send me your contact no to my mail id bhardwajsaurabh@hotmail.com, may be I can call you and discuss this over the phone if its ok with you.

Let me know when you send it )

Regards

Saurabh

Former Member
0 Kudos

Hi TJ

ok I created the new template like i mentioned before, but any serverside code is giving a shortdump.

Pla suggest.

Regards

Saurabh

thorsten_domsalla
Active Participant
0 Kudos

Hello Saurabh,

sorry for the delay. The last days I have been busy.

Regarding the shortdump - did you check the traces, especially the webgui traces (use SM50, set trace component to DIA and webgui)? In many cases a simple syntax error crashes the session.

I highly recommend to watch the HTTP communication. Use a tool like Ethereal or an IE plugin like HTTPwatch to evaluate the HTTP messages. Is the /nex request sent? How do you check for the sessions to be still running?

Best regards,

TJ

Answers (0)