Skip to Content

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.

Images 1.jpg

Step 2: Create a Web Dynpro Component called Z_MULTIPLE_SELECT_OPTIONS.

Images 2.jpg

Step 3: The usage of WDR_SELECT_OPTIONS component is defined in the Used Components tab as SELECT_OPTIONS.

Images 3.jpg

Step 4: Create a Context node called N_SELECT_OPTIONS

Images 4.jpg

Images 5.jpg

Step 5: Click the button Add Attributes from Structure/Table, select the required fields and then click ok.

Images 6.jpg

Step 6: Now Create a View Container UI Element as VIEW_CONTAINER

Images 7.jpg

Images 8.jpg

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.

Images 9.jpg

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.

Images 10.jpg

  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_itemm_id = lc_claim_number.
  lwa_sel_itemmt_range_table = lit_range_table.
  lwa_sel_itemm_description  = ‘Notification No’.
  lwa_sel_itemm_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_itemm_id = lc_creation_date.
  lwa_sel_itemmt_range_table = lit_range_table.
  lwa_sel_itemm_description  = ‘Creation Date’.
  lwa_sel_itemm_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_itemm_id = lc_material.
  lwa_sel_itemmt_range_table = lit_range_table.
  lwa_sel_itemm_description  = ‘Material’.
  lwa_sel_itemm_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_itemm_id = lc_dealer_refno.
  lwa_sel_itemmt_range_table = lit_range_table.
  lwa_sel_itemm_description  = ‘Dealer Referance No’.
  lwa_sel_itemm_within_block = lc_id.
  lwa_sel_itemm_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_itemm_id = lc_salesorder.
  lwa_sel_itemmt_range_table = lit_range_table.
  lwa_sel_itemm_description  = ‘Sales Order’.
  lwa_sel_itemm_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.

Images 11.jpg

Step 11: Now your window should look like this.

Images 12.jpg

Images 13.jpg

Step 12: Now Create a Web Dynpro Application and save and activate all.

Images 14.jpg

Output:

Images 15.jpg

To report this post you need to login first.

1 Comment

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

Leave a Reply