Skip to Content
author's profile photo Former Member
Former Member

How to close the window on click of a button

Hi,

I have an application which consists of two windows.

I am able to open one window from another window using

lo_window = lo_window_manager->create_window(

window_name = 'ZDUPLICATE'

title = 'DUPLICATE CANDIDATES LISTS'

close_in_any_case = abap_true

message_display_mode = if_wd_window=>co_msg_display_mode_selected

close_button = abap_true

message_type = if_wd_window=>co_msg_type_none

).

But the problem is on the click of a button i want to close the opened window.

Please let me know the solutions

Thanks

Bala Duvvuri

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

5 Answers

  • Best Answer
    author's profile photo Former Member
    Former Member
    Posted on May 16, 2008 at 11:48 AM

    Hi,

    If u r opening the pop up from view then call the component controller method from view

    and in component controller method write the coding related to pop up

    wd_this->mo_popup = lo_win_manager->create_window(

    title = lv_title

    window_name = lv_window_name

    button_kind = lv_btn_kind

    message_type = lv_message_type ).

    wd_this->mo_popup->open( ).

    where mo_popup is an attribute in component controller of type ref to if_wd_window.

    when you click on the button to close the window then call in action method

    component controller method wd_comp_controller->close().

    in component controller close method write the following coding

    wd_this->mo_popup->close().

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on May 16, 2008 at 02:46 AM

    Hi,

    After creating the window, lo_window, you will be invoking:

    lo_window->open( ).

    Similarly, whenever you want to close the window, just invoke:

    lo_window->close( ).

    Regards,

    Wenonah

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on May 16, 2008 at 02:05 AM

    Not a problem. Just add a little extra code after the create window to register your own action for the close button:

     l_api = wd_this->wd_get_api( ).
      l_window->subscribe_to_button_event(
                   button            = if_wd_window=>co_button_cancel
                   action_name       = ACTION_CANCEL'
                   action_view       = l_api
                   is_default_button = abap_true ).
    
      l_window->open( ).
    

    Add a comment
    10|10000 characters needed characters exceeded

    • dont understand what is l_api.

      Sorry about that. l_api is type ref to if_wd_view_controller.

      data: l_window_manager type ref to if_wd_window_manager,
              l_cmp_api        type ref to if_wd_component,
              l_window         type ref to if_wd_window,
              l_api            type ref to if_wd_view_controller.
      
      
        l_cmp_api        = wd_comp_controller->wd_get_api( ).
        l_window_manager = l_cmp_api->get_window_manager( ).
      
      

      I'm hooking the standard cancel or ok button. You can do this if you want to fire your own logic on these standard events. You can also do as others have suggested and save a reference to the window and close it manually as well.

  • author's profile photo Former Member
    Former Member
    Posted on May 16, 2008 at 03:30 AM

    Hi Bala

    You need to write it in the event handler of the button you are using to close the window from. However, for this method you also have to define lo_window (the reference to the object) as a global attribute (either in the view, or the component controller)

    Regards,

    Wenonah

    Add a comment
    10|10000 characters needed characters exceeded

    • Former Member

      I wrote the following code

      method ONACTIONCANCEL .

      try.

      data:

      lv_url_string type string,

      lt_parameters type tihttpnvp,

      lo_api_componentcontroller type ref to if_wd_component,

      lo_window_mgr type ref to if_wd_window_manager,

      lo_window type ref to if_wd_window,

      lv_title type string,

      lv_application type string.

      DATA:

      LO_MESSAGE_MANAGER TYPE REF TO IF_WD_MESSAGE_MANAGER,

      LO_EX TYPE REF TO CX_ROOT.

      • Get a reference to the window manager.

      lo_api_componentcontroller = wd_comp_controller->wd_get_api( ).

      lo_window_mgr = lo_api_componentcontroller->get_window_manager( ).

      data lo_window_manager type ref to if_wd_window_manager.

      data lo_api_component type ref to if_wd_component.

      *data lo_window type ref to if_wd_window.

      lo_api_component = wd_comp_controller->wd_get_api( ).

      lo_window_manager = lo_api_component->get_window_manager( ).

      lo_window = lo_window_manager->create_window(

      window_name = 'ZDUPLICATE'

      title = 'DUPLICATE CANDIDATES LISTS'

      close_in_any_case = abap_true

      message_display_mode = if_wd_window=>co_msg_display_mode_selected

      close_button = abap_true

      message_type = if_wd_window=>co_msg_type_none

      ).

      • close the new window.

      lo_window->close( ).

      CATCH CX_HRRCF.

      CATCH CX_ROOT INTO LO_EX.

      CALL METHOD CL_HRRCF_EXCEPTION_HANDLER=>WRITE_EXCEPTION_LOG

      EXPORTING

      EX = LO_EX.

      CALL METHOD LO_MESSAGE_MANAGER->REPORT_T100_MESSAGE

      EXPORTING

      MSGID = 'HRRCF0002'

      MSGNO = '800'

      MSGTY = 'A'.

      ENDTRY.

      endmethod.

      it is not working.

      any other solutions

  • author's profile photo Former Member
    Former Member
    Posted on May 16, 2008 at 04:32 AM

    Hi,

    You should not re-create the lo_window attribute again.

    Do the following:

    1. In the component controller OR view controller, define an attribute lo_window of type IF_WD_WINDOW

    2. Create and open the window wherever required.

    lo_window = lo_window_manager->create_window(
    window_name = 'ZDUPLICATE'
    title = 'DUPLICATE CANDIDATES LISTS'
    close_in_any_case = abap_true
    message_display_mode = if_wd_window=>co_msg_display_mode_selected
    close_button = abap_true
    message_type = if_wd_window=>co_msg_type_none
    ).
    lo_window->open( ).
    

    3. In the event handler method write only the following statement for closing the window

     lo_window->close( ). 

    Regards

    Wenonah

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.