Using Select-Options in Webdynpro

Even though the use of select-options is not as straight-forward in ABAP Webdynpro as it is in standard ABAP programming you will find bellow that it is easy nonetheless.

The first thing you should do is to create your own Webdynpro Component like the one below, and activate it.
Create your Webdynpro Component


Then go to the Compoment properties and add the WDR_SELECT_OPTIONS reusable component to the used webdynpro components.


add the standard WDR_SELECT_OPTIONS component to our component

Now we add a new ViewContainer to the MAIN_V view so that we can embed the selection-options component. 

ADD the select-options ViewContainer

And embed the WND_SELECTION_SCREEN view of the standard WDR_SELECT_OPTIONS Compoment
Embed the Selection-Options View in the ViewContainer ( 1 )
Embed the Selection-Options View in the ViewContainer ( 2 )

Add the select_options component and controller to the View Used Controllers/Components list.


Add the SELECT_OPTIONS component and controller to the view's used controllers/component list


It is time to start coding. Go to the main view MAIN_V and then enter the WDDOINIT method which is called once to inicialize the view controller.


method WDDOINIT .

  DATA: lr_range_table         TYPE REF TO DATA.

  " Get a pointer to the interface of select options in order to
  " add a new selection field
  IF abap_false EQ wd_this->wd_cpuse_select_options( )->has_active_component( ).
    wd_this->wd_cpuse_select_options( )->create_component(  ).
  ENDIF.

  " Initialize the selection Screen
  wd_this->m_select_options = wd_this->wd_cpifc_select_options( )->init_selection_screen( ).

  " ADD a field of type MATNR to ( Material )
  " - Create a Range table of type MATNR
  lr_range_table = wd_this->m_select_options->create_range_table( 'MATNR' ).

  " --  Add the selection field
  wd_this->m_select_options->add_selection_field( i_id      = 'ID_MATNR'    " ID of Selection Field
                                                  it_result = lr_range_table ).

endmethod.


Now you only have to create the webdynpro application and test.

Create the Web Dynpro Application ( 1 )
Create the Web Dynpro Application ( 2 )


Calling our newly created webdynpro we get the following page with our Material Select-Options, which has a standard F4 just like it would have If you were to create a simple ABAP report.
Webdynpro Select-options
Material Number Search Help
















4 comments: