Skip to Content

Introduction

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: http://scn.sap.com/thread/3456054 – How to open a popup from OVS and close the OVS if there are no entries found.

Prerequisites

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 : http://scn.sap.com/docs/DOC-32690 by Amy King .

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.

/wp-content/uploads/2013/11/1_331155.jpg

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

ON_OVS

METHOD onovs .

* declare data structures for the fields to be displayed and

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

   TYPES:

     BEGIN OF lty_stru_input,

*   add fields for the display of your search input here

       carrid TYPE string,

     END OF lty_stru_input.

   TYPES:

     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_textname = `CARRID`“must match a field name of search

       ls_textvalue = `Airline`. “wd_assist->get_text( `001` ).

       INSERT ls_text INTO TABLE lt_label_texts.

       ls_textname = `CARRID`“must match a field in list structure

       ls_textvalue = `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` ).

       ovs_callback_object->set_configuration(

                 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.

       ovs_callback_object->context_element->get_static_attributes(

           IMPORTING static_attributes = ls_search_input ).

*     pass the values to the OVS component

       ovs_callback_object->set_input_structure(

           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

       ENDIF.

       ASSIGN ovs_callback_object->query_parameters->*

                               TO <ls_query_params>.

       IF NOT <ls_query_params> IS ASSIGNED.

******** TODO exception handling

       ENDIF.

*     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
         lo_window->subscribe_to_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.
       ENDIF.

     WHEN if_wd_ovs=>co_phase_3.

*   apply result

       IF ovs_callback_object->selection IS NOT BOUND.

******** TODO exception handling

       ENDIF.

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

       IF <ls_selection> IS ASSIGNED.

         ovs_callback_object->context_element->set_attribute(

                                name  = `VAL`   ” Context Attribute Name

                                value = <ls_selection>carrid ).

       ENDIF.

   ENDCASE.

ENDMETHOD.

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

/wp-content/uploads/2013/11/2_331180.jpg

Write the below code in ONACTIONCLOSE_OVS method.

ONACTIONCLOSE_OVS

METHOD onactionclose_ovs .

* Work around to close the OVS search help window

   wd_this->gr_handle->on_cancel( ).

ENDMETHOD.

Save and Activate the Component.


Result

Now Test the Web Dynpro Application.

Select the F4 help in the input field.

/wp-content/uploads/2013/11/3_331186.jpg

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

/wp-content/uploads/2013/11/4_331193.jpg

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

/wp-content/uploads/2013/11/5_331194.jpg

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

/wp-content/uploads/2013/11/6_331195.jpg



Conclusion

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.   



To report this post you need to login first.

5 Comments

You must be Logged on to comment or reply to a post.

Leave a Reply