Webdynpro Select Options
Webdynpro Select Options
Link to this Page Link Tiny Link OK Known Location You must make a Web Dynpro ABA Page Ordering Editing restricted Back Cancel Reorder Close Wiki Markup Cancel The specified pag Failed to retrieve Close Click to select the Browse There were no pa Move Page We Search Error reading the Showing <b>{0}< Snippets Move Save
Set Page Location Move Recently Viewed You could try relo Move failed. Ther Code Gallery Unknown user or There were no re HTTP Status You cannot move You cannot move Page Restrictions
Page restrictions apply Attachments:9 Added by David Pietroniro, last edited by Guest on Aug 19, 2010 (view change)
view
User Interface Development with Web Dynpro for ABAP Working with select-options in Web dynpro for ABAP Using select-options in a Web Dynpro ABAP Application Web dynpro for ABAP - Get Started
Description
In this I will explain how to use complex select-options components like groups, parameters and select-options with default values and more. This assumes that you have a basic acknowledge of the Web Dynpro ABAP and have created a web dynpro component via Object Navigator (transaction SE80).
View VI_MAIN
Create a view by right clicking on the web dynpro component and choose Create->View. Define the view name as VI_MAIN.
Used Components
Now in tab Properties add the Used Components like follows:
Context
Now in the Context tab create a new node with name T_SBOOK, cardinality 0..n and defines the Dictionary Structure SBOOK. Click on the button Add Attribute from Structure and add the fields like follows, the structure of the node must be the following:
Layout
Go to the Layout tab and insert a View Container UI Element with id VC_SEL_OPT. Finally add a table to the view layout, name it as TBL_SBOOK, right click the table and select the Create Binding option and bind the table to the T_SBOOK context. Defines the Cell Editor as TextView and bound the attributes to the property text:
Attributes
In the Attributes tab add the attributes like follows:
Methods
Method BUILD_SELECT_OPTIONS
This method is responsible to create the select-options, add the group, fields and set its default values.
METHOD build_select_options . TYPES: ty_r_date TYPE RANGE OF s_date, ty_s_date TYPE LINE OF ty_r_date. * Reference variable used instantiate the select-options component DATA lr_cmp_usage TYPE REF TO if_wd_component_usage. * Variables used to create the select-options fields and * define its initial values DATA: lr_field TYPE REF TO data, ls_date TYPE ty_s_date.
* Instantiate the select-options component lr_cmp_usage = wd_this->wd_cpuse_cmp_sel_opt( ). IF lr_cmp_usage->has_active_component( ) IS INITIAL. lr_cmp_usage->create_component( ). ENDIF.
* Hide the standard select-options components. wd_this->m_helper->set_global_options( i_display_btn_cancel = abap_false i_display_btn_check i_display_btn_reset = abap_false = abap_false ).
* Adding a parameter field to the created block * Create a reference to the type of airline code CREATE DATA lr_field TYPE s_carr_id. * Sets the airline code initial value ASSIGN lr_field->* TO <fs_field>. <fs_field> = 'AA '. * Add the parameter to the group wd_this->m_helper->add_parameter_field( i_id = `CARRID`
* Adding a select-options field to the created block * Create a reference to the connection number range table lr_field = wd_this->m_helper->create_range_table( `S_CONN_ID` ). * Add the select-option to the group wd_this->m_helper->add_selection_field( i_id = `CONNID`
* Adding a select-options field to the created block * Create a reference to the flight date range table lr_field = wd_this->m_helper->create_range_table( `S_DATE` ). ASSIGN lr_field->* TO <fs_range>.
ls_date-sign
= 'I'.
APPEND ls_date TO <fs_range>. * Add the select-option to the group wd_this->m_helper->add_selection_field( i_id = `FLDATE`
= lr_field ).
METHOD execute_search . TYPES: lty_r_connid TYPE RANGE OF s_conn_id, lty_r_fldate TYPE RANGE OF s_date. DATA lr_sbook TYPE REF TO if_wd_context_node.
* Variables used to retrieve the values of select-options fields DATA lt_sel_item TYPE if_wd_select_options=>tt_selection_screen_item. FIELD-SYMBOLS: <fs_sel_item> LIKE LINE OF lt_sel_item, <fs_carrid> <fs_connid> <fs_fldate> TYPE s_carr_id, TYPE lty_r_connid, TYPE lty_r_fldate.
LOOP AT lt_sel_item ASSIGNING <fs_sel_item>. CASE <fs_sel_item>-m_id. WHEN `CARRID`. ASSIGN <fs_sel_item>-m_value->* TO <fs_carrid>. WHEN `CONNID`. ASSIGN <fs_sel_item>-mt_range_table->* TO <fs_connid>. WHEN `FLDATE`. ASSIGN <fs_sel_item>-mt_range_table->* TO <fs_fldate>. ENDCASE. ENDLOOP.
* Retrieve the data from the database, for simplicity, the * SELECT statement has been implemented here. SELECT * FROM sbook INTO TABLE wd_this->t_sbook WHERE carrid = <fs_carrid> AND connid IN <fs_connid> AND fldate IN <fs_fldate>.
* Bind the data to the context lr_sbook = wd_context->get_child_node( name = `T_SBOOK`). lr_sbook->bind_table( wd_this->t_sbook ). ENDMETHOD. Method WDDOINIT
Include a call to the method responsible by create the select-options.
Window
Now in the window right click on the VC_SEL_OPT view and embed a view like follows:
Application
Now create a web dynpro application and test it, the result must be like follows:
If you would like more information about select-options see the web dynpro component WDR_TEST_SELECT_OPTIONS in your SAP system.