Skip to Content

Sometimes one may get a requirement such as to produce a pop-up message on UI 5 minutes from timeout, so as to intimate the user to perform some activity to avoid session timeout.

Now the challenge here is that in order to trigger a pop-up there has to be an event. In the absence of any event trigger, this becomes a challenge to perform this using only ABAP.

It can be done using the combination of Javascript and ABAP code. One can enhance the component ‘CRM_UI_FRAME’ and the view ‘WorkareaViewset’. In the HTML page of the view, one can write the following code.

<script type=“text/javascript”>
var c=4200;                             <%–   session time out pop up time    –%>
var t;
var timer_is_on=0;

thtmlbRegisterOnLoad(doTimer);

function timedCount()
{
<%–document.getElementById(‘txt’).value=c;–%>
c=c-1;
if (c ==
‘0’)
{
alert(
“Your session will time out in 5 minutes”) ;
}

t=setTimeout(“timedCount()”,1000);

}

function doTimer()
{
c = 4200;                   <%–   session time out pop up time      –%>
if (!timer_is_on)
{
timer_is_on=
1;
timedCount();
}
}

</script>

Here, the variable ‘c’ contains the value of the session timeout popup in seconds. Now, this value can be caught from the system constant for session time out time. The code above is quite simple but the point to be noted here is the call to ‘thtmlbRegisterOnLoad’. This resets the counter on any user action. Since, all of the UI content is placed in Iframes so resetting the counter on ‘bodyonload’ works only the first time the page is loaded.

How I found out the ‘thtmlbRegisterOnLoad’ event : View->source of the page and then searched for any ‘load’ keyword.

This was my first blog. I hope consultants will find it helpful. In my next blog I’ll describe how to launch a GUI transaction on UI , on a custom button click.

To report this post you need to login first.

11 Comments

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

  1. Glenn Michaels

    Thumbs up, is testing fine in our dev system.  Will make the users happy.  They will be typing in notes & taking phones calls and get lost on time, lots of complaints when the system times out as typing in notes doesn’t re-set the clock.

    (0) 
  2. Mukesh Lakshmanan

    Great post thanks Nitin!!

    When I tested in sandbox,the popup appeared for the first timeout only.To make it appear again i need to log off and log in again.

    Is that something I am missing in your code or any additional logic have to be implemented for that feature?

    Your response is much appreciated!!!

    (0) 
      1. Jean-Yves Guyomarc'h

        Hi Sara,

        There is now a standard feature that covers this topic. See Note 2092893, it adds an optional timeout countdown in the CRM header and also a popup that will warn the user a few minutes before his session times out.

        Regards,

        Jean-Yves Guyomarc’h

        (0) 
        1. Sar CRM

          Hi Jean-Yves Guyomarc’h,

          Unfortunately..I cannot implement this oss note as it’s related to higer versions of CRM..ours is 7.0 EHP1..

          Thanks,

          Sara.

          (0) 
          1. Sigrid Wieshofer

            Hi Sara,

            If you use a CRM Interaction Center business role, SAP Note 1877120 CRM-IC: session timeout issue with CRM 7 EHP1 and higher might be interesting for you.

            Best Regards,

            Sigrid

            (0) 
            1. Sar CRM

              Sigrid,

              I already explored OSS note 1877120..this works only for IC with multi session..but we need user time out popup for all the roles..we are going with custom coding approach to achieve this.

              (0) 

Leave a Reply