cancel
Showing results for 
Search instead for 
Did you mean: 

Dropdown in WD.

Former Member
0 Kudos

Hi Everyone ,

How to populate values into the dropdown in webdynpro..

Please help me.

Thanks and regards,

Vijay

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi Vijay

Create a node called dropdowngroup, bind this to your dropdown UI element and write the below code to populate the dropdown. (You can change the code as per the node name you choose, here the view name is considered to be MAIN, change that according to the view name you have)

Data : v_Element type ref to If_Wd_Context_Element,
       Items_node type ref to If_Wd_Context_node,
       itemList type STANDARD TABLE OF IF_MAINVIEW=>ELEMENT_dropdowngroup,
       w_list LIKE LINE OF itemList.
* Appending elements to "itemList"
w_list-ebeln = 'Blue'.
     append w_list to itemList.
w_list-ebeln = 'Yellow'.
     append w_list to itemList.
w_list-ebeln = 'Red'.
     append w_list to itemList.
w_list-ebeln = 'Magenta'.
     append w_list to itemList.
w_list-ebeln = 'White'.
     append w_list to itemList.
w_list-ebeln = 'Black'.
     append w_list to itemList.
Items_node = wd_Context->get_Child_Node( Name = `DROPDOWNGROUP` ).
Items_node->bind_table( itemList ).

Revert in case of any doubts.

Thanks & Regards,

Gayathri Shanbhag

Answers (2)

Answers (2)

sahai
Contributor
0 Kudos

Hi Vijay,

You can use drop down by key element to have a drop down on screen.

now to populate it you will have to write the code below.

create an attribute in the context of the type you require.

bind the drop down by key element with this attribute.

now write the following code to get the attribute to be populated.

DATA: LT_VALUE TYPE STANDARD TABLE OF WDR_CONTEXT_ATTR_VALUE,
         LS_VALUE TYPE WDR_CONTEXT_ATTR_VALUE,
         LR_NODE_INFO TYPE REF TO IF_WD_CONTEXT_NODE_INFO,
         LR_NODE TYPE REF TO IF_WD_CONTEXT_NODE.

   LR_NODE = WD_CONTEXT->GET_CHILD_NODE( 'CTX_VN_SELECTION_DET' ). "CTX_VN_SELECTION_DET is the nameof      "the node in which i created the attribute
   LR_NODE_INFO  = LR_NODE->GET_NODE_INFO( ).

"fill internal table any selection query of from some work area as per your scenario once you get this table populated just fill "Lt_VALUE like below

LOOP ATinternal_table  INTO work_area.
   LS_VALUE-VALUE = work_area-variable.
   LS_VALUE-TEXT = work_area-variable.
   APPEND LS_VALUE TO LT_VALUE.
ENDLOOP.

LR_NODE_INFO->SET_ATTRIBUTE_VALUE_SET(
     EXPORTING
      NAME = 'BILLABLE_LOT_NO'   "attribute name
      VALUE_SET = LT_VALUE ).

if you need to populate dropdown in alv you can check the following article also.

http://www.sdn.sap.com/irj/scn/index?rid=/library/uuid/50d4f5b6-fd1b-2e10-3190-823bcaff92d7

Regards,

Sahai. S

Former Member
0 Kudos

Hi Vijay

Create a node called dropdowngroup, bind this to your dropdown UI element and write the below code to populate the dropdown. (You can change the code as per the node name you choose, here the view name is considered to be MAIN, change that according to the view name you have)

Data : v_Element type ref to If_Wd_Context_Element,
       Items_node type ref to If_Wd_Context_node,
       itemList type STANDARD TABLE OF IF_MAINVIEW=>ELEMENT_dropdowngroup,
       w_list LIKE LINE OF itemList.
* Appending elements to "itemList"
w_list-ebeln = 'Blue'.
     append w_list to itemList.
w_list-ebeln = 'Yellow'.
     append w_list to itemList.
w_list-ebeln = 'Red'.
     append w_list to itemList.
w_list-ebeln = 'Magenta'.
     append w_list to itemList.
w_list-ebeln = 'White'.
     append w_list to itemList.
w_list-ebeln = 'Black'.
     append w_list to itemList.
Items_node = wd_Context->get_Child_Node( Name = `DROPDOWNGROUP` ).
Items_node->bind_table( itemList ).

Revert in case of any doubts.

Thanks & Regards,

Gayathri Shanbhag