This is how you can close a Portal Window from Web Dynpro. There are however some restrictions on when a portal window can be close which you can read at link Restrictions in CLOSE WINDOW Functions
In my example window W_MAIN is loaded on the page with V_MAIN in it. On the press of button ‘Close’ portal windows needs to be closed.
Step 1: Add exit plug in window
In window W_MAIN define an outbound plug with name EXIT of type ‘Exit’. Mark this as Interface plug. Also add an importing parameter CLOSE_WINDOW of type Boolean.
Step 2: Define usage of window in view
Go to view V_MAIN where close button is. On the Properties tab define usage of window W_MAIN.
Step 3: Add method and make call to window’s exit plug
Now add method CLOSE_WINDOW in view V_MAIN. Use Web Dynpro Code Wizard to call exit plug of window W_MAIN.
Pass value abap_true to close_window parameter. Your code should look like this.
METHOD close_window . DATA lo_w_main TYPE REF TO ig_w_main . lo_w_main = wd_this->get_w_main_ctr( ). lo_w_main->fire_exit_plg( close_window = abap_true ). ENDMETHOD.
Finally, make a call to this method from action handler method of Close button.
Worked like a champ. Thanks
fatabulous… working like king …