Multiple Select Options in WebDynpro ABAP
Below are the steps for creating multiple select options in WebDynpro ABAP.
Step 1: Open transaction SE80 and from the drop down list select WebDynpro Component.
Step 2: Create a Web Dynpro Component called Z_MULTIPLE_SELECT_OPTIONS.
Step 3: The usage of WDR_SELECT_OPTIONS component is defined in the Used Components tab as SELECT_OPTIONS.
Step 4: Create a Context node called N_SELECT_OPTIONS
Step 5: Click the button Add Attributes from Structure/Table, select the required fields and then click ok.
Step 6: Now Create a View Container UI Element as VIEW_CONTAINER
Step 7: In the Properties tab of the view controller, under the Used Controllers/Components, click on create button to add the used controllers/components.
Step 8: In the view controller, we need an attribute that holds the reference to the instance of the Select Options component. This is necessary because at
runtime we access this reference to the search criteria that have been entered in the event-handler method.
Step 9: Now in the WDDOINT method of the view controller write the below code.
* create the used component
DATA lo_cmp_usage TYPE REF TO if_wd_component_usage.
DATA: lit_range_table TYPE REF TO data.
DATA: lr_componentcontroller TYPE REF TO ig_componentcontroller,
l_ref_cmp_usage TYPE REF TO if_wd_component_usage.
DATA: lit_sel_item TYPE if_wd_select_options=>tt_selection_screen_item,
lwa_sel_item LIKE LINE OF lit_sel_item.
CONSTANTS: lc_id TYPE string VALUE ‘BL01’,
lc_claim_number TYPE string VALUE ‘QMNUM’,
lc_creation_date TYPE string VALUE ‘ERDAT’,
lc_material TYPE string VALUE‘MATNR’,
lc_dealer_refno TYPE string VALUE ‘BSTNK’,
lc_salesorder TYPE string VALUE ‘KDAUF’.
* create the used component
lo_cmp_usage = wd_this->wd_cpuse_select_option( ).
IF lo_cmp_usage->has_active_component( ) IS INITIAL.
lo_cmp_usage->create_component( ).
ENDIF.
wd_this->m_wd_select_options = wd_this->wd_cpifc_select_option( ).
* init the select screen
wd_this->m_handler = wd_this->m_wd_select_options->init_selection_screen( ).
wd_this->m_handler->set_global_options(
i_display_btn_cancel = abap_false
i_display_btn_check = abap_false
i_display_btn_reset = abap_false
i_display_btn_execute = abap_false ).
* Block for select-options.
CALL METHOD wd_this->m_handler->add_block
EXPORTING
i_id = lc_id
i_block_type = if_wd_select_options=>mc_block_type_transp_container
i_hide_if_empty = abap_false
i_stretched_horizontally = abap_true.
* Creating range table for each field and appending to the internal table.
REFRESH lit_sel_item.
CLEAR lwa_sel_item.
lit_range_table = wd_this->m_handler->create_range_table( i_typename = lc_claim_number i_length = 500 ).
lwa_sel_item–m_id = lc_claim_number.
lwa_sel_item–mt_range_table = lit_range_table.
lwa_sel_item–m_description = ‘Notification No’.
lwa_sel_item–m_within_block = lc_id.
APPEND lwa_sel_item TO lit_sel_item.
CLEAR lwa_sel_item.
lit_range_table = wd_this->m_handler->create_range_table( i_typename = lc_creation_date ).
lwa_sel_item–m_id = lc_creation_date.
lwa_sel_item–mt_range_table = lit_range_table.
lwa_sel_item–m_description = ‘Creation Date’.
lwa_sel_item–m_within_block = lc_id.
APPEND lwa_sel_item TO lit_sel_item.
CLEAR lwa_sel_item.
lit_range_table = wd_this->m_handler->create_range_table( i_typename = lc_material ).
lwa_sel_item–m_id = lc_material.
lwa_sel_item–mt_range_table = lit_range_table.
lwa_sel_item–m_description = ‘Material’.
lwa_sel_item–m_within_block = lc_id.
APPEND lwa_sel_item TO lit_sel_item.
CLEAR lwa_sel_item.
lit_range_table = wd_this->m_handler->create_range_table( i_typename = lc_dealer_refno ).
lwa_sel_item–m_id = lc_dealer_refno.
lwa_sel_item–mt_range_table = lit_range_table.
lwa_sel_item–m_description = ‘Dealer Referance No’.
lwa_sel_item–m_within_block = lc_id.
lwa_sel_item–m_width =200.
APPEND lwa_sel_item TO lit_sel_item.
CLEAR lwa_sel_item.
lit_range_table = wd_this->m_handler->create_range_table( i_typename = lc_salesorder ).
lwa_sel_item–m_id = lc_salesorder.
lwa_sel_item–mt_range_table = lit_range_table.
lwa_sel_item–m_description = ‘Sales Order’.
lwa_sel_item–m_within_block = lc_id.
APPEND lwa_sel_item TO lit_sel_item.
* Using the method ‘ADD_SELECTION_FIELDS’ we can add the fields in select option.
CALL METHOD wd_this->m_handler->add_selection_fields
EXPORTING
it_fields = lit_sel_item.
Step 10: Create an Embed View in the VIEW_CONTAINER of the window level.
Step 11: Now your window should look like this.
Step 12: Now Create a Web Dynpro Application and save and activate all.
Output:
Thank you 🙂