cancel
Showing results for 
Search instead for 
Did you mean: 

How to handle popups?

alejiandro_sensejl
Active Participant
0 Kudos

Hello Gurus,

I have a problem with the handling of a popup in WD4A!

The outcommented block Further coding... depends on the answer of the user. When I use the following coding he processes the Further coding BEFORE the popup is opened and all my checks are done too early.

How can i let my method wait for the answer from the popup?

METHOD send_mails.

  DATA: lt_texts           TYPE string_table,
        lo_component_api   TYPE REF TO if_wd_component,
        lo_view_controller TYPE REF TO if_wd_view_controller,
        lo_answer          TYPE REF TO if_wd_popup_to_confirm.

  lo_component_api = wd_comp_controller->wd_get_api( ).

  APPEND 'Yes / No?' TO lt_texts.

  cl_wd_popup_factory=>popup_to_confirm(
    EXPORTING
      component     = lo_component_api
      text          = lt_texts
      window_title  = 'Confirm'
    RECEIVING
      popup_to_confirm = lo_answer ).
  
  
* Further coding...  
  
ENDMETHOD.  

Thanks in advance,

Alej

Accepted Solutions (1)

Accepted Solutions (1)

UweFetzer_se38
Active Contributor
0 Kudos

Hi Alej,

the "RECEIVING popup_to_confirm" is not the answer of the popup, its the reference of the newly created window.

You have to declare "actions" for the popup, depending on the answer, on wich you can react.

In help.sap.com there is a good sample for popups.

Regards, Uwe

alejiandro_sensejl
Active Participant
0 Kudos

Hello Uwe,

as far as I can remember there is a instance attribute answer or something like in IF_WD_POPUP_TO_CONFIRM. I can't confirm that, because I' currently at home. This attribute is what is checked later on.

Where can I declare this actions? In the popup object or in the coding of the method? I want to have the business logic (= flag for a BAPI) in the method because I'm trying to seperate it from the UI as far as possible!

Can you give me the help-link? I searched for about 30 minutes now and couldn't find a good link...

Some more information are appreciated.

Best regards,

Alej.

UweFetzer_se38
Active Contributor
0 Kudos

Hi Alej,

"Can you give me the help-link?" -> sure

SAP NetWeaver Library -> SAP NetWeaver by Key Capability -> Application Platform by Key Capability -> ABAP Technology -> UI Technology -> Web UI Technology -> Web Dynpro ABAP

Web Dynpro ABAP: Development in Detail -> Advanced Concepts -> Working with Dialog Boxes -> Calling a Confirmation Dialog Box

On this site you can find the example.

Easy, isn't it ?

The actions you define on the "Action"-Tabstrip of your view.

Regards, Uwe

Former Member
0 Kudos

Hi Alej.

For this type of thing, where you want to take a user input, and based on that you want to do some action, you can use the following code:

DATA: l_cmp_api TYPE REF TO if_wd_component,

l_window_manager TYPE REF TO if_wd_window_manager,

l_popup 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( ).

l_popup = l_window_manager->create_popup_to_confirm(

text = <text_ques>

button_kind = <popup_type>

message_type = <mess_type>

"if_wd_window=>co_msg_type_question

window_title = <win_title>

window_position = if_wd_window=>co_center )."#EC *

      • Then register the events which you want to react on

l_api = wd_this->wd_get_api( ).

l_popup->subscribe_to_button_event(

button = if_wd_window=>co_button_yes

action_name = 'YES'

action_view = l_api

is_default_button = abap_false ).

l_popup->subscribe_to_button_event(

button = if_wd_window=>co_button_no

action_name = 'NO'

action_view = l_api

is_default_button = abap_true ).

l_popup->open( ).

After that, you need to register the actions on the ACTIONS tabstrip of your view. In the above case, you will register 2 actions - YES and NO.

Then react according on the ONACTIONYES and ONACTIONNO methods.

Hope it helps....

alejiandro_sensejl
Active Participant
0 Kudos

Points rewarded,

thanks Uwe!

Answers (0)