cancel
Showing results for 
Search instead for 
Did you mean: 

How to add database values to dropdownkey values

Former Member
0 Kudos

Hi all,

I have one dropdownkey UI Element in the view.

I want to add the database table field values to the dropdown key ..

how to get this

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi,

Below are the steps to create dropdownbykey.

1. Create a UI element type dropdownbykey in layout

2. create a context NODE1 and add attribute ATTR1 type DATS(what ever can be the type) under it

3. Bind this context attribute ATTR1 to ui element

4. Write below code to WDINIT() method of view or component controller to set possible values for dropdown

data: value type WDR_CONTEXT_ATTR_VALUE,
        value_set type WDR_CONTEXT_ATTR_VALUE_LIST.
 
  data node_info type ref to if_wd_context_node_info.
 
    node_info = wd_context->get_node_info( ).
      "here replace node1 with your node
    node_info = node_info->get_child_node( wd_this->wdctx_node1 ).

* Get the values from DB here
   select * from SPFLI into lt_tab.

   loop at lt_tab into wa_tab.
    value-value = wa_tab-conn_id "what ever the field
    value-text = 'text'.  "text to appear in UI
    insert value into table value_set.
   endloop.
     "this method set the value set to dropdown
    node_info->set_attribute_value_set( name = 'ATTR1' value_set = value_set ).

Note: just to show example i have written a DB query here, but you should use API for that.

Regards,

Manne

Edited by: Raja Sekhar Manne on Jun 25, 2009 1:21 PM

Former Member
0 Kudos

hi raja,

i am not getting the second part of the code could u expalin me clearly..

actually my table name is ZIMAGE and field name is ZFIMAGE..

here lt_tab means it's a structure..is we have to define it before or can we create here itself...

thanks,

viswa

Former Member
0 Kudos

hi,

Declare like this :

Data : lt_tab type standard table of ZIMAGE,

wa_itab type ZIMAGE .

now use the select query like :

select ZFIMAGE from ZIMAGE into corresponding fields of table lt_itab.

Rest proceed as mentioned in previous post.

Thanks.

Former Member
0 Kudos

Hi,

By trying the above code i am getting the error like this

The lead selection has not been set. IMAGEVIEW2

can you tell me what would be the reason....

thanks,

viswa

Former Member
0 Kudos

Set the Lead Selection property for the Context Node under which your Context Attribute is there which is binded to Dropdown by key.

Go to Context -> Context NOde-> properties of Context node(down)

Set the lead selection property for that node.

I hope you have made the attribute which is binded to Drop down by key under a Node.

If you havent, plz declare node. Under that node, a attribute and bind this attritbute to the Dropdown.

Edited by: Saurav Mago on Jun 25, 2009 5:43 PM

Former Member
0 Kudos

Thanks,

My problem is solved...

Answers (0)