Select Options - SAP ABAP Web Dynpro

We create a WD component that offers complex possibilities to search for a candidate.To be able to use these complex search possibilities,we have used the WDR_SELECT_OPTIONS component.

Figure shows the WD component structure and the usage definition.

The WD component structure

We create,in Context view,the node PERSON with the samestructure (Cardinality 0...n, dictionary structure YPERSON, Singleton, without supply function).
In View Layout,we have to insert a View Container UIElement required to integrate the interface view WND_SELECTION_SCREEN of the Select Option component.Besides this UI element, we need a Button and a Table UI element.

Context view and view layout

How to define the usage

We create two attributes: M_HANDLER type ref to IF_WD_SELECT_ OPTIONS and M_WD_SELECT_OPTIONS type ref to IWCI_WDR_SELECT_ OPTIONS.


We use the wdDoInit Hook method to instantiate the used component WDR_SELECT_OPTIONS,in order to dynamically create a range table and to add a selection screen Field.

The wdDoInit Hook method

METHOD wddoinit .
rt_range_table TYPE REF TO data,
lv_tooltip TYPE string VALUE'Search for id',
lv_abap_bool TYPE boolean VALUE abap_true,
lr_componentcontroller TYPE REF TO ig_componentcontroller,
lr_cmp_usage TYPE REF TO if_wd_component_usage.
lr_cmp_usage = wd_this->wd_cpuse_select_options( ).
IF lr_cmp_usage->has_active_component( ) IS INITIAL.
lr_cmp_usage->create_component( ).
wd_this->m_wd_select_options =
wd_this->wd_cpifc_select_options( ).
wd_this->m_handler =
wd_this->m_wd_select_options->init_selection_screen( ).
rt_range_table =
i_typename = 'YIDI').
i_id = 'ID_PERSON'
i_obligatory = lv_abap_bool
it_result = rt_range_table
i_tooltip = lv_tooltip
i_value_help_type = if_wd_value_help_handler=>co_prefix_searchhelp
i_value_help_id ='YSH_ID_PERSON'

By using the method INIT_SELECTION_SCREEN of the IWCI_WDR_SELECT_OPTIONS interface,we initialize the selection screen.After this,we use the method CREATE_RANGE_TABLE of the IF_WD_SELECT_OPTIONS

interface to dynamically create a Range Table.This method has three importingparameters: I_TYPENAME type STRING,I_LENGTH type I,I_DECIMALStype I and a returning parameter RT_RANGE_TABLE type ref to data.The I_TYPENAME is not optional;we use it to specify the data element for the LOW and HIGH component. The ID_PERSON has the data type YIDI.

Database table YPERSON

A Range Table has four components: SIGN,OPTION,LOW and SCREEN. It can be also created in the ABAP Dictionary,as special type of table types.

The method ADD_SELECTION_FIELD of the IF_WD_SELECT_OPTIONSinterface adds an additional Field to the Selection Screen. This method has many parameters, but only one is mandatory – I_ID.We have used the:

  • i_id parameter,of STRING type,to define the ID of the Selection Field
  • i_obligatory parameter,of ABAP_BOOL type,to set the mandatory field
  • it_result parameter,type ref to data, for reference to the Range table
  • i_tooltip,of STRING type, to create a quick info in a tooltip form
  • i_value_help_type, of type:IF_WD_VALUE_HELP_HANDLER)CO_PREFIX_NONE
  • to specify the type of the search help that we want to use
  • i_value_help_id of WDY_VALUE_HELP_ID type,to specify the name of the search help that we use, or the name of the OVS (Object Value Selector) field ID_PERSON has associated the search helpwith the name YSH_ID_PERSON

When the user presses the Search button,the Framework triggers the event handler method onactionsearch.

The onactionsearch event handler method

METHOD onactionsearch .
DATA: l_node TYPE REF TO if_wd_context_node.
DATA: rt_range_table TYPE REF TO data.
DATA: it_yperson TYPE TABLE OF yperson.
rt_range_table = wd_this->m_handler->get_range_table_of_sel_field
i_id = 'ID_PERSON' ).
ASSIGN rt_range_table->* TO <fs_id_person>.
CLEAR it_yperson.
REFRESH it_yperson.
FROM yperson
WHERE id_person IN <fs_id_person>.
l_node = wd_context->get_child_node(name =`PERSON`).

The method GET_RANGE_TABLE_OF_SEL_FIELD of the IF_WD_ SELECT_OPTIONS interface has an importing parameter I_ID,of STRING type,and returns the range table for the Selection Field – rt_range_table generic type data.We define a field symbol typified as ANY TABLE and we generically dereference the data reference variable typed with data into our field symbol,through the dereferencing operator“->*”.

After this, we select all the records that correspond to our search and pass these values in the corresponding attributes of the context node PERSON.We have to embed the interface view WND_SELECTION_SCREEN into the ViewContainerUIElement.Now we are ready to run our application.

Embedding the view interface WND_SELECTION_SCREEN


In default mode,Select Option is the interval between two values,but we can also use other Select options.

Selecting options

As we have seen,the component WND_SELECTION_SCREEN offers four buttons to provide four functions:

  • Cancel
  • Check
  • Reset
  • Execute

We can hide one of these buttons by using the method SET_GLOBAL_OPTIONS of the IF_WD_SELECT_OPTIONS interface.

This method has four mandatory parameters of ABAP_BOOL type.


We want to extend our example,by hiding the buttons CANCEL, RESET,COPY and using the CHECK button to trigger the event handler method on_check.In this case,we don’t use our Search button.We implement the code in the on_check event handler method.

First, we must use,in the wdDoInit Hook method,the SET_GLOBAL_OPTIONS.

The wdDoInit Hook method

METHOD wddoinit .
wd_this->m_handler =
wd_this->m_wd_select_options->init_selection_screen( ).
i_display_btn_cancel = abap_false
i_display_btn_check = abap_true
i_display_btn_reset = abap_false
i_display_btn_execute = abap_false).

After this,we create an event handler method named on_check and we register to the ON_CHECK event in the WDR_SELECT_OPTIONcomponent.This event is triggered when the user clicks the CHECK button.

Registering to the ON_CHECK event

We copy the entire coding from the onactionsearch event handler method in the on_check event handler method, and then we can run our application.


To create more than one selection screens Field,we have to create,into the wdDoInit Hook Method,as many range tables as many screen Fields we need,and then we have to extend the event handler method to be able to select the desired data.

All rights reserved © 2018 Wisdom IT Services India Pvt. Ltd Protection Status

SAP ABAP Web Dynpro Topics