cancel
Showing results for 
Search instead for 
Did you mean: 

Populate Select options with values

Former Member
0 Kudos

Hi Experts,

I have an urgent requirement.

I am selectiong some values from the drop down list . BAsed on the value selected from drop down I am rading a a DB table. I am usiong SELECT SINGLE * FROM DBTABLE.

These values I would like to populate into Select Options. How can I do this?

I have designed select option using following code in WDINIT of main view.

lt_range_table = wd_this->m_handler->create_range_table( i_typename = 'ERDAT' ).

  • add a new field to the selection

wd_this->m_handler->add_selection_field(

i_id = 'ERDAT'

it_result = lt_range_table

i_read_only = read_only ).

  • create a range table that consists of this new data element

lt_range_table = wd_this->m_handler->create_range_table( i_typename = 'IWERK' ).

  • add a new field to the selection

wd_this->m_handler->add_selection_field(

i_id = 'IWERK'

it_result = lt_range_table

i_read_only = read_only ).

How cum can I get the referance to these two select options created above, So that i can populate them.

THIS IS VERY URGENT. plz respond ASAP.

Regards,

Vishal.

Accepted Solutions (0)

Answers (3)

Answers (3)

Former Member
0 Kudos

Hi,

refer to these examples

WDR_SELECT_OPTIONS,WDR_TEST_SELECT_OPTIONS

Former Member
0 Kudos

Hi Vishal,

1. Declare these table and work area.

lt_valueset TYPE wdy_key_value_table,

ls_valueset TYPE wdr_context_attr_value,

lt_temp LIKE TABLE OF ls_valueset.

lr_node TYPE REF TO if_wd_context_node,

lr_info TYPE REF TO if_wd_context_node_info,

l_info TYPE wdr_context_attribute_info,

2. Format the help this way.

FREE lt_valueset.

CLEAR: l_info, lr_node, lr_info, lt_valueset.

lr_node = wd_context->get_child_node( 'NODE' ).

lr_info = lr_node->get_node_info( ).

l_info = lr_info->get_attribute( 'ATTRIBUTE from node' ).

lt_temp[] = l_info-value_set.

  • DELETE ADJACENT DUPLICATES FROM lt_temp COMPARING value.

lt_valueset[] = lt_temp[].

3. Create select options like this.

lt_range_table =

wd_this->m_handler->create_range_table(

i_typename = 'DATAELEMENT' ).

  • Add a new field to the selection

wd_this->m_handler->add_selection_field(

i_id = 'DATAELEMENT'

i_within_block = 'B01'

i_no_intervals = abap_true

it_result = lt_range_table

i_read_only = read_only

it_value_set = boldlt_valuesetbold ).

Former Member
0 Kudos

Hi Sameer,

Already selet option have been created.

And I would like to populate the select option field values with values that I fetch from table, ON CLICK OF BUTTON. just want to refresh the select option and do not want to create new options.

the code you have given would create new select option.

Is there any method that can refresh the select options?

Regards,

Vishal.

Former Member
0 Kudos

Hi Vishal,,

If you need to populate the drop down values from the table you can do it bu creating a table in se11 with Id and value and insert values in the table (thru se11).

In the webdynpro side, create a node with DDIC of that table ref and bind it to a drop down by key to the value of the context in the layout.

and when you run the application the table values will be populating when the page is loaded.

Cheers

Mary

Former Member
0 Kudos

MARY : I want to populate SELECT-OPTION with the value selected from DROP DOWN not vice versa.

already i have values in DROP down. based on drop doen i an reading some table and that table value i want to dsplay in SELECT-OPTION on the screen.

Sridevi: These examples does not solve my purpose. Do you have any other example?

Regards,

Vishal.

Edited by: VISHAL GUPTA on Apr 25, 2008 10:17 AM

0 Kudos

Hi,

You have select-option field based on 'IWERK'

First, create range type

types: type_iwerk type range of iwerk.

Add data variables like these:

data: it_sel_iwerk type type_iwerk,

wa_sel_iwerk line of it_sel_iwerk,

rt_sel_iwerk type ref to data.

Add field symbol <fs_iwerk> type any table.

Then, add your data to select-option field, like this:

wa_sel_iwerk-sign = 'I'.

wa_sel_iwerk-option = 'EQ'.

wa_sel_iwerk-low = <from your dropdown list>

append wa_sel_iwerk to it_sel_iwerk.

CREATE DATA rt_sel_iwerk like it_sel_iwerk.

ASSIGN rt_lel_iwerk->* to <fs_iwerk>

USE SET_RANGE_TABLE_OF_SEL_FIELD method

with parameters i_id - <your sel.option name>

and it_range_table = rt_sel_iwerk

Hope it helps.

Ihar

Former Member
0 Kudos

Hi Ihar,

I am using the below code.

types: type_erdat type range of erdat.

data: it_sel_erdat type type_erdat,

wa_sel_erdat like line of it_sel_erdat,

rt_sel_erdat type ref to data.

field-symbols: <fs_erdat1> type any table.

wa_sel_erdat-sign = 'I'.

wa_sel_erdat-option = 'EQ'.

wa_sel_erdat-low = '20080101'. " <from your dropdown list>

append wa_sel_erdat to it_sel_erdat.

CREATE DATA rt_sel_erdat like it_sel_erdat.

ASSIGN rt_sel_erdat->* to <fs_erdat1>.

CALL METHOD WD_THIS->M_HANDLER->SET_RANGE_TABLE_OF_SEL_FIELD

EXPORTING

I_ID = 'ERDAT'

IT_RANGE_TABLE = rt_sel_erdat .

But here u told me to write.....

append wa_sel_erdat to it_sel_erdat

but I am passing rt_sel_erdat to SET_RANGE_TABLE_OF_SEL_FIELD.

and there is no value in rt_sel_erdat at run time.

how can i transfer the data from "it_sel_erdat" to "rt_sel_erdat "

Regards,

Vishal.

Former Member
0 Kudos

Hi Ihar,

I have changed the code as below........its working now.

types: type_erdat type range of erdat.

data: it_sel_erdat type type_erdat,

wa_sel_erdat like line of it_sel_erdat,

rt_sel_erdat type ref to data.

field-symbols: <fs_erdat1> type any table.

wa_sel_erdat-sign = 'I'.

wa_sel_erdat-option = 'EQ'.

wa_sel_erdat-low = '20080101'. " <from your dropdown list>

append wa_sel_erdat to it_sel_erdat.

CREATE DATA rt_sel_erdat like it_sel_erdat.

ASSIGN rt_sel_erdat->* to <fs_erdat1>.

get REFERENCE OF it_sel_erdat INTO rt_sel_erdat.

rt_sel_erdat->-low = wa_sel_erdat-low.

CALL METHOD WD_THIS->M_HANDLER->SET_RANGE_TABLE_OF_SEL_FIELD

EXPORTING

I_ID = 'ERDAT'

IT_RANGE_TABLE = rt_sel_erdat .

Thanks. Points rewarded.

Regards,

Vishal.

0 Kudos

Sorry,

I missed one line

<ft_iwerk> = it_sel_iwerk,

before calling method.

Anyway, glad you found workaround

Former Member
0 Kudos

HI,

Does anyone has any idea, How to use following methods.

GET_RANGE_TABLE_OF_SEL_FIELD

SET_RANGE_TABLE_OF_SEL_FIELD

RESET_SELECTION_FIELD

RESET_ALL_SELECTION_FIELDS

GET_SELECTION_FIELD

Regards,

Vishal.