Skip to Content

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.


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