cancel
Showing results for 
Search instead for 
Did you mean: 

Close Window on Button Click

former_member189058
Active Contributor
0 Kudos

I have created a Webdynpro Application that works fine. On the View, I have created a Cancel Button. On click of this button, I need to close the application.

I tried the following:



  data:
    lr_api type ref to if_wd_view_controller,
    lr_window_ctlr type ref to if_wd_window_controller,
    lr_window TYPE REF TO if_wd_window.

  lr_api = wd_this->wd_get_api( ).
  lr_window_ctlr = lr_api->get_embedding_window_ctlr( ).
  if lr_window_ctlr is bound.
    lr_window = lr_window_ctlr->get_window( ).
    IF lr_window is BOUND.
      lr_window->close( ).
    ENDIF.
  ENDIF.

However, this doesnt work because get_window( ) method of if_wd_window_controller returns reference of a popup window.

But in my case, there is no popup window, instead I need to close the main Window of the application.

Pl suggest a solution.

Regards,

Reema.

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi Reema,

Check this,

/people/mohammed.anzys/blog/2007/06/05/how-to-close-parent-window-in-webdynpro-applications

http://help.sap.com/saphelp_nw70/helpdata/en/45/1bc575ba064574e10000000a114a6b/frameset.htm

Thanks.

Answers (1)

Answers (1)

former_member515618
Active Participant
0 Kudos

Hi Reema,

If iam not wrong this is what i understand.You want to close the application upon clicking cancle. i.e. close the Browser.

To achieve this, do the following.

1. In the view which has this exit button, create an outbound plug. say 'OUT_EXIT_VIEW'

2. Create an inbound plug in your Main window say 'IN_EXIT_WINDOW'.

3. Create an outbound plug say 'OUT_EXIT_WINDOW', set Interface as 'X', and lug type as 'Exit'.

4. Go to the event handler method of IN_EXIT_WINDOW plug and fire the outbound plug

'OUT_EXIT_WINDOW'. say wd_this->fire_OUT_EXIT_WINDOW_plg( ).

5. Go to the window and create a navigation plug between plugs OUT_EXIT_VIEW (View) to

IN_EXIT_WINDOW' (Window).

6. Creat a new html page in your notepad and name it a exit.html

Inside the exit.html write the code to close a window. I cannot attach the code here as it is not letting us to do so.

Now save this file on your local machine, and then upload this to the MIME repository of your SAP System. Go to SE80 --> MIME Repository and upload it into sap --> bc --> bsp --> sap --> public folder

Go back to step 4 and do the following

wd_this->fire_OUT_EXIT_WINDOW_plg( URL = '/SAP/BC/BSP/SAP/PUBLIC/exit.html' ).

So on the view, when you click on the exit button, an inbound plug to the window is called subsequently calling outbound plug of the window, and executes the script and closed the window.

Hope this helps.

Regards,

Sravan Varagani