cancel
Showing results for 
Search instead for 
Did you mean: 

how to populate the dropdown key values as shown in the below screen shot

Former Member
0 Kudos

Hi

i am trying to populate the drop down by key value for trader , for Trader we  have few values i need to populate the Those values in values columns . as shown in the below screen shot .

Accepted Solutions (1)

Accepted Solutions (1)

rajeshkothamasu
Active Participant
0 Kudos

Hi,


Follow below steps


Step 1 - Create basic wdp table

Step 2 - Create context to store dropdown values Within your web dynpro application table
Now you need to create a context node to store the dropdown values, but this needs to be within the context node of your table.

For this example I will use fields CARRID and CARRNAME from structure SCARR to create the dropdown list within the table context.

Choose the attributes to represent the id and the text values

The finished context should now look like this

Step 3 - Update context mapping within VIEW
Within the Context tab of your view update the context node you have just modified (CARRIERS) right click and select 'Update Mapping'. Alternatively if this is a new context drag it from the right hand window and drop it onto the context node in the left window,

Step 4 - Update table field
Within the layout tab of the view, field the table field you want to replace with with a dropdown and remove the UI element associated with it

Now insert new dropdownbyindex UI cell element

Step 5 - Assign Dropdown Ui element to Context
Click on your UI element within the Layout tab, you will now see all the properties for this element which can be changed. You now need to assign the field within the context which you want to be displayed in the drop down i.e. it will be the CARRNAME field within context element DROPDOWN_CARR. To do this simply click on the button at the end of the 'texts' property (the one with a yellow square and circle on it) and select the correct context field.

Step 6 - ABAP code to populate dropdown list and set correct initial value
Insert the following ABAP code into the appropriate place. For this example it will go within the WDDOMODIFYVIEW method of the view.

  Data: it_scarr type standard table of scarr, wa_scarr like line of it_scarr, context_node type ref to if_wd_context_node.  Data: it_ddcarr type STANDARD TABLE OF if_main=>element_DROPDOWN_CARR, wa_ddcarr like line of it_ddcarr, lr_element TYPE REF TO if_wd_context_element, ld_tabix type sy-tabix, ld_index type sy-index, it_carriers type STANDARD TABLE OF if_main=>element_CARRIERS, wa_carriers like line of it_ddcarr.  select * from scarr into table it_scarr. sort it_scarr by carrid.  * select * from scarr into table it_scarr. context_node = wd_context->get_child_node( name = 'CARRIERS' ).  * Get all rows of table and values stored in each cell currently displayed to user context_node->get_static_attributes_table( importing table = it_carriers ).  if sy-subrc eq 0. loop at it_carriers into wa_carriers. free lr_element. ld_tabix = ld_tabix + 1.  *     assign context_node to table context context_node = wd_context->get_child_node( name = 'CARRIERS').  *     assign lr_element to row of table lr_element = context_node->get_element( ld_tabix ).  *     assign data to dropdown of the row  context_node = lr_element->get_child_node( name = 'DROPDOWN_CARR'). context_node->BIND_TABLE( it_scarr ).  *     Set correct initial value read table it_scarr into wa_scarr with key carrid = wa_carriers-carrid. ld_index = sy-tabix. context_node->set_lead_selection_index( index = ld_index ).  endloop. endif. 



Step 6 - 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:


former_member197475
Active Contributor
0 Kudos

Well Said Rajesh.

BR,

RAM.

Former Member
0 Kudos

Thanks Rajesh my issue is solved .

Thanks and Regards

Kaggal Sreedhara

Answers (1)

Answers (1)

former_member184578
Active Contributor
0 Kudos

Hi,

You need to change the cell editor of column to drop down and then bind the drop down to the context node: check this wiki for reference: http://wiki.scn.sap.com/wiki/display/WDABAP/Using+DropDownByIndex+in+Table+UI+Element

hope this helps,

Regards,

Kiran