sapdev logo background
sapdev logo sapdev logo
Comments

ABAP web dynpro Dropdown default value, allow you to set current value of dropdown UI element




Below are the simple steps required to set an abap web dynpro dropdown field (UI element) to be a value other than the first value in the drop down table.


Step 1 - Create a drop down UI element Within your ABAP web dynpro application
Insert the following ABAP code into the appropriate place such as just after you have built your drop down. If you have used the code from this website it could go into the WDDOINIT method of the view:


**************************BEGIN*
*EXISTING CODE TO BUILD DROPDOWN
********************************
* create local data variable to access context information
  Data: context_node type ref to if_wd_context_node.

* create table based on context structure
  Data: it_carriers type STANDARD TABLE OF if_view1=>element_DROPDOWN_CARRIERS,
        wa_carriers like line of it_carriers.

  select *
    from scarr
    into table it_carriers.
  context_node = wd_context->get_child_node( name = 'DROPDOWN_CARRIERS').
  context_node->BIND_TABLE( it_carriers ).
****************************END*

  DATA: index type i.

* Set displayed value of dropdown by index UI element.
  index = 3. "sets dropdown value to the third entry in the drop down table
  context_node->set_lead_selection_index( index = index ).

Step 2 - Save, Activate and Run
Save and activate your abap web dynpro, now when you execute it you should see a drop down object similar to the following:


Next step would be to add code to Retrieve value selected by user in a dropdownbyindex field




comments powered by Disqus