Technology Blogs by Members
Explore a vibrant mix of technical expertise, industry insights, and tech buzz in member blogs covering SAP products, technology, and events. Get in the mix!
Showing results for 
Search instead for 
Did you mean: 
Active Contributor


This document helps how to close OVS Popup window in Web Dynpro ABAP programatically.

Here I would like to address the requirement in this thread: - How to open a popup from OVS and close the OVS if there are no entries found.


Knowledge on creating  OVS Value Help .

Here, I am not going to explain creating OVS search help in Web Dynpro ABAP again as there are already lot of documents available in SCN for the same. For reference you could check this detailed document : by amy.king2 .

Step by Step Process

After creating the OVS, follow the below steps to open a popup in OVS event handler and close the OVS search help window automatically if no values found.

Note: Here I am just demonstrating a work around to achieve the above requirement.

Go to Attributes tab of view and create an attribute GR_HANDLE of TYPE REF TO IF_WDR_OVS_LISTENER.

Now write the below code in ON_OVS ( Event handler method of OVS).


METHOD onovs .

* declare data structures for the fields to be displayed and

* for the table columns of the selection list, if necessary


     BEGIN OF lty_stru_input,

*   add fields for the display of your search input here

       carrid TYPE string,

     END OF lty_stru_input.


     BEGIN OF lty_stru_list,

*   add fields for the selection list here

       carrid TYPE string,

     END OF lty_stru_list.

   DATA: ls_search_input  TYPE lty_stru_input,

         lt_select_list   TYPE STANDARD TABLE OF lty_stru_list,

         ls_text          TYPE wdr_name_value,

         lt_label_texts   TYPE wdr_name_value_list,

         lt_column_texts  TYPE wdr_name_value_list,

         lv_window_title  TYPE string,

         lv_group_header  TYPE string,

         lv_table_header  TYPE string.

   DATA: lo_window_manager TYPE REF TO if_wd_window_manager,

         lr_view_controller TYPE REF TO if_wd_view_controller,

         lo_api_component  TYPE REF TO if_wd_component,

         lo_window         TYPE REF TO if_wd_window,

         l_text            TYPE string_table.

   FIELD-SYMBOLS: <ls_query_params> TYPE lty_stru_input,

                  <ls_selection>    TYPE lty_stru_list.

   CASE ovs_callback_object->phase_indicator.

     WHEN if_wd_ovs=>co_phase_0"configuration phase, may be omitted

*   in this phase you have the possibility to define the texts,

*   if you do not want to use the defaults (DDIC-texts)

       ls_text-name = `CARRID`"must match a field name of search

       ls_text-value = `Airline`. "wd_assist->get_text( `001` ).

       INSERT ls_text INTO TABLE lt_label_texts.

       ls_text-name = `CARRID`"must match a field in list structure

       ls_text-value = `Airline`. "wd_assist->get_text( `002` ).

       INSERT ls_text INTO TABLE lt_column_texts.

*      lv_window_title = wd_assist->get_text( `003` ).

*      lv_group_header = wd_assist->get_text( `004` ).

*      lv_table_header = wd_assist->get_text( `005` ).


                 label_texts  = lt_label_texts

                 column_texts = lt_column_texts

                 group_header = lv_group_header

                 window_title = lv_window_title

                 table_header = lv_table_header

                 col_count    = 2

                 row_count    = 20 ).

     WHEN if_wd_ovs=>co_phase_1"set search structure and defaults

*   In this phase you can set the structure and default values

*   of the search structure. If this phase is omitted, the search

*   fields will not be displayed, but the selection table is

*   displayed directly.

*   Read values of the original context (not necessary, but you

*   may set these as the defaults). A reference to the context

*   element is available in the callback object.


           IMPORTING static_attributes = ls_search_input ).

*     pass the values to the OVS component


           input = ls_search_input ).

     WHEN if_wd_ovs=>co_phase_2.

*   If phase 1 is implemented, use the field input for the

*   selection of the table.

*   If phase 1 is omitted, use values from your own context.

       IF ovs_callback_object->query_parameters IS NOT BOUND.

******** TODO exception handling


       ASSIGN ovs_callback_object->query_parameters->*

                               TO <ls_query_params>.

       IF NOT <ls_query_params> IS ASSIGNED.

******** TODO exception handling


*     call business logic for a table of possible values

       SELECT carrid FROM sflight INTO TABLE lt_select_list.
       ovs_callback_object->set_output_table( output = lt_select_list ).
       IF lt_select_list IS INITIAL.     
*     Open a popup if no entries found 
         lo_api_component  = wd_comp_controller->wd_get_api( ).
         lo_window_manager = lo_api_component->get_window_manager( ).
         INSERT `No Entries Found! Do you want to create new entries?` INTO TABLE l_text.
         lo_window   = lo_window_manager->create_popup_to_confirm(
                           text = l_text
                           button_kind = if_wd_window=>co_buttons_yesno
                           message_type = if_wd_window=>co_msg_type_question
                           window_position = if_wd_window=>co_center
*     Get View Controller Reference
         lr_view_controller = wd_this->wd_get_api( ).
*     Subscribe to No button Event
               button = if_wd_window=>co_button_no
               action_name = 'CLOSE_OVS'           " Create this Action
               action_view = lr_view_controller
               is_default_button = abap_false ).
         lo_window->open( ).
*     Store OVS Listener instance globally
         wd_this->gr_handle ?= ovs_callback_object.

     WHEN if_wd_ovs=>co_phase_3.

*   apply result

       IF ovs_callback_object->selection IS NOT BOUND.

******** TODO exception handling


       ASSIGN ovs_callback_object->selection->* TO <ls_selection>.

       IF <ls_selection> IS ASSIGNED.


                                name  = `VAL`   " Context Attribute Name

                                value = <ls_selection>-carrid ).




Now go to Actions tab of View and create an action CLOSE_OVS.

Write the below code in ONACTIONCLOSE_OVS method.


METHOD onactionclose_ovs .

* Work around to close the OVS search help window

   wd_this->gr_handle->on_cancel( ).


Save and Activate the Component.


Now Test the Web Dynpro Application.

Select the F4 help in the input field.

Click on start search ( If co_phase_1 is not omitted ).

Now, If there are no entries in output table we can see the popup opened!

( I cleared entries in output table via debugging to show popup ).

Here I just handled for 'No' button to close the OVS search help window. When clicked on 'No' we can see the OVS will be closed automatically.


Here I just handled for button 'No' to close the OVS search help window. Similarly we can handle for yes to create new entries. Hope this helps to others who has similar requirements.   

Labels in this area