Skip to Content


This document helps how to close web dynpro application browser window automatically after specified event/time.

Here I will explain a simple Scenario: After displaying success message the browser has to close automatically in 5 seconds.

Step by Step Process

Step 1: Create a Web Dynpro Component.

   Go to the SE80 transaction and create a Web Dynpro Component.


Enter Description and click on ok.


Save and Activate the component.


Step 2: Create EXIT plug

Go to the Outbound Plugs tab of the window and create an EXIT plug with the parameter CLOSE_WINDOW of type WDY_BOOLEAN.


Step 3: Data Binding

Go to the Context tab of Main View and create and create attributes : EMPID of type STRING and ENABLE of type WDY_BOOLEAN.

Right click on the Context and click on create attribute.


Create attribute EMPID of type STRING.


Similarly create an attribute ENABLE of type WDY_BOOLEAN.


Step 4: Layout Design.

   Now Go to Layout tab:

  1. Create label UI with text ‘Enter employee ID’.

     Right click on ROOTUIELEMENTCONTAINER and click on Insert Element


   Enter ID and select UI ‘Label’.


Similarly create Input filed EMPID and bind the value to EMPID attribute.


Now create a button UI element.


Enter button Text and click on create button to create an Action for button.


Enter Action name, description and click on OK.


Now create a message area UI element to display messages.


Create a Timed Trigger UI element.


Bind the enable property of the timed trigger UI to the attribute ENABLE.


Set the delay time of timed trigger UI element.


Create an Action for timed trigger UI.


Step 5: Create Component Usage

Now go to Properties tab and click on create button to create controller usage.


Select the controller by double clicking on it. We have to add the controller to make EXIT plug method of window in View Controller.


Now go to Methods tab of MAIN view and write the below code ONACTIONREGISTER method.

METHOD onactionregister .

   DATA lo_el_context             TYPE REF TO if_wd_context_element.
   DATA ls_context                 TYPE wd_this->element_context.
   DATA lv_empid                    TYPE wd_this->element_contextempid.
   DATA lo_api_controller         TYPE REF TO if_wd_controller.
   DATA lo_message_manager TYPE REF TO if_wd_message_manager.

*  get element via lead selection
   lo_el_context = wd_context->get_element( ).

*  get single attribute
       name `EMPID`
       value = lv_empid ).

* Register the employee for event
*      emp_id = lv_empid.

   IF sysubrc = 0.
*  get message manager
      lo_api_controller ?= wd_this->wd_get_api( ).

      CALL METHOD lo_api_controller->get_message_manager
          message_manager = lo_message_manager.

*  report message
      CALL METHOD lo_message_manager->report_success
          message_text = ‘Employee Registered Successfully!’.

*   Enable Self destruction
         name `ENABLE`
         value abap_true ).



And Enter the below code in ONACTIONCLOSE_BROWSER method

METHOD onactionclose_browser .

   DATA lo_zwd_auto_close_demo TYPE REF TO ig_zwd_auto_close_demo .

    lo_zwd_auto_close_demo =   wd_this->get_zwd_auto_close_demo_ctr( ).

*  Exit Application and Close Browser
      close_window = abap_true


Step 6: Create Application.

Save and Activate the Web Dynpro Component.  Create the Web Dynpro Application and Save it.


Enter description and save it.


Test Application

Now Right click on Web Dynpro Application and click on Test.


The application will open in the browser. Enter the employee ID and click on Register button.


Now we will get success message upon successful registration of the employee.


After displaying the message the browser will close automatically after 5 seconds (delay time of timed trigger).

In chrome and IE7 the browser window will close automatically. In higher versions of IE the browser will prompt to confirm closing of the browser.



Here I demonstrated a simple Web Dynpro Application. We can use this according to our Requirements.

To report this post you need to login first.


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

  1. Prathamesh Gandhi

    Hi Kiran,


    It is really helpful document, but when it POPUP for asking confirmation about closing window, gives two options Yes & No.


    on Yes it working perfectly fine, but on No your browse page turned into white.

    Can we somehow handle this ? like by only giving option of Yes or on close action instead of this POPUP can we directly close ?


    Thanks In Advance,


    1. Kiran Kumar Valluru Post author



      As mentioned already in the document


      In chrome and IE7 the browser window will close automatically. In higher versions of IE the browser will prompt to confirm closing of the browser.


      If you run your WDA application in Chrome or IE7 the browser window will close automatically. In higher versions of IE say IE 8 or IE9, you will get a popup to confirm the closing of browser.


      You cannot handle it in WDA as it is purely browser dependent. May be you have to change some settings in your browser. I have checked in IE9 and there is no provision to disable the prompt to close the browser.






    after displaying popup message as  YES NO  … can we handle yes action through webdynrpo abap ?

  requriement in popup  is yes action is clicked by default.  how can i do that ?


    I need to close  the browser without user interaction. without user interaction yes action is triggered ? ,.. can we do it through webdynpro coding ?

  3. Jim Hawthorne

    Hi there

    While not wishing to decry your efforts – this seems a lot of unnecessary work  just to get a message “Browser is trying to close Window” (or similar).


    With the later versions of IE just set to tabbed / caret  browsing (in Windows) – any new application will throw up a new browser page. Just close the tab(s) you don’t need.


    If your solution needs you to click an OK button to close the window – there’s NO advantage over just closing the tab in Windows explorer. Since each web application (or web dynpro or whatever) opens a new browser window there’s no advantage in your method.


    So have I missed something here



    1. Kiran Kumar Valluru Post author

      Hi Jim,


      Thanks for the feedback. The popup is browser dependent. Please read the previous comments aswell. It has nothing to do from WDA side.


      If you run this application in other browsers/ on lower versions of IE it closes the browser.





        Hi Kiran,

                         as you said ,

        In IE9 it not closing directly . It giving same  popup to close option in IE9.

  4. S K

    It doesn’t like the WDY_BOOLEAN. I get an error that EXIT plugs do not have the right type for the parameter. If I try to correct it to STRING, it expects a URL string.


    500 SAP Internal Server Error

    ERROR: Parameters of exit plugs and suspend plugs must be of type STRING or TIHTTPNV (termination: RABAX_STATE)


Comments are closed.