Quantcast
Channel: SCN : Blog List - Web Dynpro ABAP
Viewing all articles
Browse latest Browse all 107

Custom timeout page for Web Dynpro applications

$
0
0

     Sometimes, users tend to open a lot of WD applications in multiple tabs. After some time (depending on SAP Basis configuration) the session is automatically closed by the application server (Web AS), which will result in a timeout. From a user's perspective this is confusing.


Requirement:

     Create a timeout page for system idles. The standard SAP response is:


     Instead, the system should return a custom (company-specific) page with both F5 (Refresh) functionality and a big "Refresh" button. For example:

timeout.png

     In transaction SICF both short dumps and session timeouts are treated as application errors:

sicf.png

     If you choose to implement an explicit response page, this will be shown for all kinds of application errors. But we don't want that, we only want to see a custom page for timeouts.

     The explicit page can be written in HTML+CSS, but a major issue is that it completely ignores JavaScript. This means, you cannot test the error type and switch between different responses.

  

Solutions:

     After trying multiple alternative, like redirecting to another URL and test the system tag <%=MESSAGE%>, I've found a working solution which is actually quite simple (Occam's razor states: "The simplest answer is usually the right one"):

     1. Create the .html page in any suitable program (Notepad++, or even a BSP application if you want to have the code available inside the system).

BSP.png

     2. You need to copy-paste the code inside an OTR long text using transaction SOTR_EDIT. (This is how the explicit pages are created in SICF)

 

     3. You'll have to create a modification in the core WD class CL_WDR_CLIENT_ABSTRACT_HTTP for method PREPROCESS_REQUEST. (This cannot be enhanced as you need access to instance attributes which is not possible inside pre-/post exits, so you'll need an access key)

wdr.png

     Here, instead of writing the code directly, I chose to call a static method in a customer class. Also, I do this because I don't want to use this timeout page in all applications. I've created a customizing table where I store the WD application name and a flag for 'Active', for all applications that should use this functionality.

 

method handle.

 
data:
    lr_server   
type ref to cl_http_server,
    lt_path      
type string_table,
    ls_appl      
type ytpf_t_appl_list,                       "#EC NEEDED
    ls_page     
type icf_response_page,
    lv_index    
type i,
    lv_service 
type string.

lr_server ?= ir_server
.
 
if lr_server is bound.

     "cl_wdr_task=>application->name can NOT be used here, as the instance is already destroyed...
   
split lr_server->m_runtime_memory_id at `/` into table lt_path[].

   
if not lt_path[] is initial.
     
describe table lt_path[] lines lv_index.
     
read table lt_path[] into lv_service index lv_index. refresh lt_path[].

     
if sy-subrc is initial.
       
translate lv_service to upper case.

 

        select single service_name active
                            
from ytpf_t_appl_list
                            
into corresponding fields of ls_appl
                            
where service_name eq lv_service
                                
and active       eq abap_true.

       
if sy-subrc is initial.
          ls_page
-body = `2C768A4E40741EE3A7A55C5708059340` "SOTR automatically generated GUID

          ir_server->set_page(
           
exporting
              response_page_type   
= ir_server->co_page_error_type
              response_option_page
= ls_page
           
exceptions
              invalid_parameter       
= 1
              document_not_found  
= 2
             
others                           = 3 ).

       
endif.
     
endif.
   
endif.
 
endif.

endmethod.

 

At runtime, if the application error type is a session timeout the explicit page is replaced with the custom page stored in the OTR long text.

This works both in IE and NWBC.

 

I've also started a discussion some time ago: Custom timeout page in SICF

 

Give it a shot and provide some feedback!

 

Tudor


Viewing all articles
Browse latest Browse all 107

Trending Articles