Skip to Content
Author's profile photo Chandra Shekhar Agarwal

Solution : Session Time out Error in Web Dynpro Application.

Error: While working on Web Dynpro Application, when the application is not accessed (left inactive) for a longer duration, when we come back to or Screen, it shows an error, Session Time out. To resolve this kind of error we can use following process.

Here we need to make some node and UI element for the same.

Let’s start with:

Component Controller:

Create a node with the name Time_out and one attribute init named as Time with Type INT4 with Cardinality 1:1 and Selection 0:1.

Methods:

Create a method in the component controller itself.

METHOD calculate_server_timeout


DATA:  

  lv_name              TYPE pfeparname,
  lv_value             
TYPE pfepvalue,
  lv_icf_timeout       
TYPE icftime,
  lv_timeout           
TYPE int4,
  lv_tmp_timeout       
TYPE int4,
  lv_time_deduct_sec   
TYPE int4.


DATA: minutes TYPE i.


*Reading of Timeout node..
DATA lo_nd_time_out TYPE REF TO if_wd_context_node.
DATA lo_el_time_out TYPE REF TO if_wd_context_element.
DATA ls_time_out TYPE wd_this->element_time_out.
DATA lv_time TYPE wd_this->element_time_out-TIME.


lo_nd_time_out
= wd_context->get_child_node( name = wd_this->wdctx_time_out ).
lo_el_time_out
= lo_nd_time_out->get_element( ).

****Get the App Server Timeout
lv_name
= ‘rdisp/plugin_auto_logout’.
CALL ‘C_SAPGPARAM’ ID ‘NAME’  FIELD lv_name
ID ‘VALUE’ FIELD lv_value.

****Is there a specific Timeout set
IF wdr_task=>server IS BOUND.
IF wdr_task=>server->session_timeout IS INITIAL.
lv_timeout
= lv_value.
ELSE.
****We got a specific timeout – now convert it to a number of seconds.
lv_icf_timeout
wdr_task=>server->session_timeout.
minutes
= lv_icf_timeout+0(2) * 60.
minutes
= minutes + lv_icf_timeout+2(2).
lv_timeout
= ( minutes * 60 ) + lv_icf_timeout+4(2).


****If a specified timeout is larger than the default, it is ignored.
****Use the default instead.
IF lv_timeout > lv_value.
lv_timeout
= lv_value.
ENDIF.
ENDIF.
ELSE.
lv_timeout
= lv_value.
ENDIF.

* Default the timeout deduction to 2 min
lv_time_deduct_sec 
= 120.

lv_tmp_timeout  = lv_timeout  lv_time_deduct_sec.


* Here we are setting value in the time_out Attribute
lo_el_time_out
->set_attribute(
name
=  `TIME`
value = lv_tmp_timeout ).
ENDMETHOD.

METHOD wddoinit . (Component controller)
* Calling method created by us, because it will triggered when the application gets load.
wd_this-> calculate_server_timeout ( ). 

View…

Open the view where you want to save session time out. IF you want to do in your whole application follow below step in all views.


1.Create a New UI Element (TimedTrigger)Timer.

2.USE component controller node by using context mapping form Component controller to view and bind delay with the attribute TIME

3. Create a new method in the view.


method ONACTIONTIME_ACTION .

***Simply Reading a Context Node to Activate this Action

DATA lo_nd_time_out TYPE REF TO if_wd_context_node.
DATA lo_el_time_out TYPE REF TO if_wd_context_element.
DATA ls_time_out TYPE wd_this->element_time_out.
DATA lv_time TYPE wd_this->element_time_out-TIME.


lo_nd_time_out
= wd_context->get_child_node( name = wd_this->wdctx_time_out ).
lo_el_time_out
= lo_nd_time_out->get_element( ).


lo_el_time_out
->get_attribute(
EXPORTING
name
=  `TIME`
IMPORTING
VALUE = lv_time ).

endmethod.


Assigned tags

      34 Comments
      You must be Logged on to comment or reply to a post.
      Author's profile photo Aravindan Aravi
      Aravindan Aravi

      Nice Document...

      Author's profile photo Aravindan Aravi
      Aravindan Aravi

      No.. Yet to try..

      Author's profile photo Chandra Shekhar Agarwal
      Chandra Shekhar Agarwal
      Blog Post Author

      Okay, Try it. let me know if you got any issue 🙂 ..

      Author's profile photo Aravindan Aravi
      Aravindan Aravi

      Sure 🙂 ..

      Author's profile photo Former Member
      Former Member

      Hi Chandra Sekhar,

      Can we not increase the time out session without doing this like doing some settings in SICF transaction.

      By default the system is having certain amount of time for time out, so my question is can we not increase the default time set by SAP for the web dynpro Applications

      Author's profile photo Chandra Shekhar Agarwal
      Chandra Shekhar Agarwal
      Blog Post Author

      Hello VR V,

      Yeah, we can increase the time out for the web dynpro application. There will be two limitation will come in picture.

      1. Extended timeout will be applicable for all the application, and there can be a case that we don't want all the application alive all the time, so i will increase load on system.

      2. It is important one, we can extend session time till a certain limit, lets say 20 mins. but after that our application will move to suspended mode, so we can't keep it alive all the time. As you can check in the code also first we are calculating system alive time and then we are doing our operations.

      here..

      lv_name = 'rdisp/plugin_auto_logout'.
      CALL 'C_SAPGPARAM' ID 'NAME'  FIELD lv_name
      ID 'VALUE' FIELD lv_value.

      Author's profile photo Former Member
      Former Member

      So we need to implement this ontime_action in every view of the WD Application.

      Is there way can we do it once instead of doing in all views

      Author's profile photo Chandra Shekhar Agarwal
      Chandra Shekhar Agarwal
      Blog Post Author

      Basically in this we are triggering a event to keep our application alive with the help of time. I don't think we can do this exactly you are looking for.  

      Author's profile photo Former Member
      Former Member

      Hi Chandra,

      Good One!

      Regards,

      Hari Suseelan

      Author's profile photo Chandra Shekhar Agarwal
      Chandra Shekhar Agarwal
      Blog Post Author

      Thanks Hari 😛

      Author's profile photo Former Member
      Former Member

      You are welcome. Keep blogging and rocking!

      Author's profile photo Former Member
      Former Member

      No order! Only request!

      Regards,

      Hari Suseelan

      Author's profile photo Arjun Pawar
      Arjun Pawar

      Very good and helpful document Chandra Shekhar Agarwal , Thanks a lot for sharing 🙂

      Author's profile photo Chandra Shekhar Agarwal
      Chandra Shekhar Agarwal
      Blog Post Author

      Thanks Arjun. Try this and if you got any kind of problem please let us know 🙂

      Author's profile photo Srinu S
      Srinu S

      Very helpful document shared Chandra.Thanks for sharing 🙂

      Author's profile photo Chandra Shekhar Agarwal
      Chandra Shekhar Agarwal
      Blog Post Author

      Thanks Srinu..:)

      Author's profile photo Former Member
      Former Member

      Chandra,

      do you have a similar solution for an FPM application with no Web Dynpro components?

      Thanks,

      Gabriela

      Author's profile photo Chandra Shekhar Agarwal
      Chandra Shekhar Agarwal
      Blog Post Author

      Gabriela de Pompignan

      i will try to find/implement some code, and i got something useful i will share with you.

      Author's profile photo Former Member
      Former Member

      Thanks! 🙂

      Author's profile photo Former Member
      Former Member

      nice document..... 🙂

      Author's profile photo Chandra Shekhar Agarwal
      Chandra Shekhar Agarwal
      Blog Post Author

      Thanks Sunita..

      Author's profile photo Former Member
      Former Member

      Nice Blog, though I have a question.

      What's the use of maintaining this at the application when we modify the default timeout parameter in the instance profile? Also, this seems to be at a application level.

      -Balajii

      P.S: Just wanted to understand the use case, I appreciate your efforts.

      Author's profile photo Chandra Shekhar Agarwal
      Chandra Shekhar Agarwal
      Blog Post Author

      I think by configuration level we can set maximum time out till 30 minutes.. Here we are reading the system's time out and reducing it by 2 minutes and calling a method, with the help of timer, after "actual timeout -  2 min "  to keep alive our application.

      Author's profile photo Nageswara Katta
      Nageswara Katta

      Chandra,

      In my webdynpro application i'm using suspend/resume plugs to navigate to Payment Gateway(PG), if PG does not return to SAP application before set time I'm having session timeout. Is there any way to avoid timeout in my scenario. Any help is much appreciated. Thanks

      Author's profile photo Chandra Shekhar Agarwal
      Chandra Shekhar Agarwal
      Blog Post Author

      I think same logic should work in your case also.

      Author's profile photo Former Member
      Former Member

      Maybe you meant to write TimedTrigger instead of Timer since there is no UI element called Timer in WDA. Maybe it is also worth noticing that TimedTrigger works only if the view having the UI element is visible.

      Author's profile photo Chandra Shekhar Agarwal
      Chandra Shekhar Agarwal
      Blog Post Author

      Thanks for information, I have updated the name accordingly.

      Author's profile photo Former Member
      Former Member

      very nice blog thanks...... 🙂

      Author's profile photo Former Member
      Former Member

      Really helpful document.

      Thanks

      KH

      Author's profile photo Former Member
      Former Member

      Helpful document !

      Author's profile photo Valeriy Zauzolkov
      Valeriy Zauzolkov

      One smalle note - you don't need to clear local variables in the begining of method ...

      Author's profile photo Chandra Shekhar Agarwal
      Chandra Shekhar Agarwal
      Blog Post Author

      Yeah Thanks. Updated 🙂

      Author's profile photo Mohammed sajid
      Mohammed sajid

      Hi Chandra Shekhar Agarwal,

       

      Im calling a FM which takes to much time to get the data from DB during this process I'm getting 500 connection timed out. in this case can I use this UI element.

      Author's profile photo Chandra Shekhar Agarwal
      Chandra Shekhar Agarwal
      Blog Post Author

      first try to increase timeout session of your system ...