Skip to Content

Closing an ABAP WebDynpro application automatically can sometimes be useful if you do not want any further processing to take place after the user has completed a transaction flow.  Note that with EHP6, the browser window closes without notification to the user.  Prior to EHP6, the user received the typical IE popup with information that the browser is going to be closed.  For that reason, you may want to include a popup message prior to calling the exit logic if you wish to warn the user.  Of course, this only applies if you are at EHP6 or later.

For this example, I created a simple WebDynpro as follows:

/wp-content/uploads/2013/03/p_193304.jpg

/wp-content/uploads/2013/03/p_193304.jpg

On the Main Window, Create an Exit Plug as follows:

/wp-content/uploads/2013/03/p_193304.jpg

In the COMPONENTCONTROLLERr, create the following attribute:

/wp-content/uploads/2013/03/p_193304.jpg

In the COMPONENTCONTROLLER, create the following method:

method exit .

  data l_win_cntr type ref to if_wd_window_controller.
 
data l_window type ref to if_wd_window.
 
data l_parameter_list type wdr_event_parameter_list.
 
data l_parameter type wdr_event_parameter.
 
data l_val type ref to data.

  field-symbols <fs> type any.
  l_parameter
name = ‘CLOSE_WINDOW’.
 
create data l_val type c.
 
assign l_val->* to <fs>.
  <fs>
= ‘X’.
  l_parameter
value = l_val.
 
insert l_parameter into table l_parameter_list.
  wd_this
->main_win_controller->if_wd_view_controller~fire_plug( exporting plug_name = ‘EXIT_PLUG’ parameters = l_parameter_list ).

endmethod.

In the Main View, add the following code to the WDDOINIT Method:

method wddoinit .

  data l_view_cntr type ref to if_wd_view_controller.

  l_view_cntr = wd_this->wd_get_api( ).
  wd_comp_controller
->main_win_controller ?= l_view_cntr->get_embedding_window_ctlr( ).

endmethod.

Add a button to this view (or any other view embedded within the main view) that will be where we call the exit command.  Add a method to the OnAction event of the button and insert the following code to call your exit command on the component controller.

method onactionexit .

  data lo_componentcontroller type ref to ig_componentcontroller .
  lo_componentcontroller
=   wd_this->get_componentcontroller_ctr( ).
  lo_componentcontroller
->exit( ).

endmethod.

Activate, Save, and create an application so you can execute and test.  You will see that when you hit the exit button on your view, the browser window closes automatically.  The reason I structured the code such that the actual exit code is on the component controller, is so you can have as many embedded views under your main view and call the exit from anywhere.  Or you might even pass a reference to the controller to another referenced class which handles the exit decisions.

To report this post you need to login first.

Be the first to leave a comment

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

Leave a Reply