cancel
Showing results for 
Search instead for 
Did you mean: 

Put action on the default button of the POP-UP Window

former_member213263
Participant
0 Kudos

hi guyz,

I am trying to work on the pop up window but not getting how to fix the bug, actually i want to put action on the default button of the pop up window, i am using the Subscribe_to_button_event for OK and CANCEL button of the popup. I am not getting where to put the code either on the pop up view where i am asking the user to continue further and where to place the code in wddoinit or customized methods.

help me.

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hello Ankit,

In Web Dynpro ABAP, you can call a pop-up in 3 ways -

  1. By simple calling of method "lo_window_manager->create_popup_to_confirm",
  2. Creating a window so as to call the pop-up within it, and
  3. By calling the pop-up in a browser(for opening any external links, this technique is used)

If you are going for the first then you can place the code in an UI elements event property i.e., you can place the code in an button of a view, it would be called automatically.

See the sample code which I have used while trying to delete an entry in a table.

METHOD onactiondelete .

* Data declarations for creating a pop-up to confirm dialog box
   DATA lo_window_manager TYPE REF TO if_wd_window_manager.
   DATA lo_api_component  TYPE REF TO if_wd_component.
   DATA lo_popup          TYPE REF TO if_wd_window.
   DATA l_text            TYPE string_table.
   DATA l_api             TYPE REF TO if_wd_view_controller.

   lo_api_component  = wd_comp_controller->wd_get_api( ).
   lo_window_manager = lo_api_component->get_window_manager( ).

   INSERT `Are you sure to delete the record?` INTO TABLE l_text.

   lo_popup = lo_window_manager->create_popup_to_confirm(
       text                 = l_text
       button_kind          = 4
       message_type         = 5
       close_button         = ABAP_TRUE
       window_position      = if_wd_window=>co_center ).

   l_api = wd_this->wd_get_api( ).

* Assigining action to YES button
   lo_popup->subscribe_to_button_event(
       button            = 7
       action_name       = 'YES'
       action_view       = l_api
       is_default_button = ABAP_TRUE ).

* Assigining action to NO button
   lo_popup->subscribe_to_button_event(
       button            = 8
       action_name       = 'NO'
       action_view       = l_api
       is_default_button = ABAP_FALSE ).

* Opening a popup
   lo_popup->open( ).

ENDMETHOD.

Do find the screen shots for necessary follow-ups. Hope it helps ! Do revert back if any.

Regards,

Varun

former_member213263
Participant
0 Kudos

Varun,

thanks for your help.

I know to put the code on the view on which my popup in been called but where to place methods like

WDDOAFTERACTION,WDDOBEFOREACTION,WDDOEXIT,WDDOINIT,WDDOMODIFYVIEW and

WDDOONCONTEXTMENU.

I mean how to know where to place the code for proper execution otherwise its throwing error.

ankit

Former Member
0 Kudos

Hello Ankit,

Good to know that you have very well understood the facts. Well placing the code depends on your requirement, as to when and how you would like to call it. In my scenario whenever a user does not select a record and presses the DELETE button it throws an error.

You can put your code accordingly as to for example if you want the pop to appear while starting you can place it in WDOINIT, if while modifying a view you want a pop to confirm the changes you can put it it WDOMODIFYVIEW, like wise in all other hook methods.

Even you can create a method of your own and just call in it any one of the hook methods.

Hope this helps. Let me know accordingly if any doubt.

Regards,

Varun

Former Member
0 Kudos

To handle specific button of the popup, you have to create an action with the same name in your view as the action_name in your subscribe method.

An action handler will be created. You should put your code here.

former_member213263
Participant
0 Kudos

thanks Khushboo and varun for your help.

I got the solution, the code for modify my table by entering the values from the user and it has to be placed on the WDDOINIT in the final view. and the code i have implemented is

data:

        lo_api         type ref to if_wd_view_controller,

        lo_window_ctlr type ref to if_wd_window_controller,

        lo_popup       type ref to if_wd_window.

      

        lo_api         = wd_this->wd_get_api( ).

       lo_window_ctlr = lo_api->get_embedding_window_ctlr( ).

           if lo_window_ctlr is bound.

                   lo_popup       = lo_window_ctlr->get_window( ).

           if lo_popup is bound.

                  lo_popup->subscribe_to_button_event(

                           button   = if_wd_window=>co_button_ok

                            action_name = 'SAVE_INP'

                            action_view = lo_api ).

   lo_popup->subscribe_to_button_event(

                           button   = if_wd_window=>co_button_cancel

                           action_name = 'CANCEL'

                            action_view = lo_api ).

   endif.

  endif.

Answers (1)

Answers (1)

Former Member
0 Kudos

You can put the code in the pop up view..