cancel
Showing results for 
Search instead for 
Did you mean: 

fetching values in a dropdown from data base table

Former Member
0 Kudos

hi all,

i m using dropdown in a table.i want , when i click on dropdown ,values should come from the database table.and then i should b able to select vale from those values which came from database table.can any one suggest in step by step procedure.

thanx in advance

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi Govind,

There are lots of solution to this requirement.As u said the data is there in database table and u need to show it in drop down list.

then use DROPDOWN BY KEY element.

Bind the propety selected key with an attribute.

Now as data is there in database table and u need to display it.Use following code it will work

Here instead of fetching from database table i am inserting details in table from code only.So u can change that logic.

If u have any doubt feel free to ask.

Also write this code in WDDOINIT method.

data:

lr_node_info type ref to if_wd_context_node_info,

lt_value_set TYPE wdy_key_value_table,

value_set_item TYPE wdy_key_value.

  • get object referent of root node metadata

lr_node_info = wd_context->get_node_info( ).

  • fill values into table of type wdy_key_value_table

value_set_item-key = 'X'.

value_set_item-value = 'Charter'.

insert value_set_item into table lt_value_set.

value_set_item-key = 'P'.

value_set_item-value = 'Private'.

insert value_set_item into table lt_value_set.

  • set values (table) to context attribute

lr_node_info->set_attribute_value_set( NAME = 'FLIGHT_TYPE_DYN'

VALUE_SET = lt_value_set ).

regards

PG

Edited by: PG on Aug 19, 2008 12:25 PM

Former Member
0 Kudos

hi PG ,

this one i knew ,but can u guide me through coding that how to assign values to that context atribute from that field (say ZPIN )of database table (say Z123) . this ll b very helpful.

Former Member
0 Kudos

Hi govind,

Refer following code it will solve ur problem.

Create a node of name ZPIN and an attribute inside tht with name PIN .And bind ur selected value property to this attribute

and use follwoing code in init method.

data: node_info type ref to if_wd_context_node_info.

data: pin type table of ZPIN.

field-symbols: <PIN_F> type ZPIN.

data: value type wdy_key_value,

value_set type wdy_key_value_table.

*METHOD FOR DEFAULT VALUES OF ZPIN IN DROP DOWN by key LIST START HERE

clear value_set.

node_info = wd_context->get_node_info( ).

node_info = node_info->get_child_node( `ZPIN` ).

call method cl_wd_dynamic_tool=>get_table_data

exporting

tab_name = 'ZPIN'

row_count = 0

importing

data = pin.

loop at pin assigning <PIN_F> .

value-key = <PIN_F>-Z123.

value-value = <CITY_F>-Z123. "yOUR field name of table(whos value u want to show in drop down)

insert value into table value_set.

endloop.

node_info->set_attribute_value_set( name = `PIN` value_set = value_set ).

If any doubt ask .

regards

PG

Former Member
0 Kudos

THANX A lot. Its done after sm changes.

Answers (0)