cancel
Showing results for 
Search instead for 
Did you mean: 

table with a dropdown field with values.....

Former Member
0 Kudos

Friends, I opened this new thread with my good explanation whatim looking for . sorry for this.

I have a table:

col1 col2 col3

row1 r1c1 r1c2 r1c3

row2 r2c1 r2c2 r2c3

row3 r3c1 r3c2 r3c3.

I need col2 to be dropdown. Here when doinit default data is being passed to this table. Now when the WDA loads, i want col2 to be dropdown, but with only one value. whatever i have in backend.Here intially i want to disable col2. User should not hcange it.

But when i hit ADDNEWROW button, it shoudl create row4, with some (i m writing a query to fetch col2 values) values in the dropdown. User should be able to select any value here.

The r1c2 and r2c2, r3c2, should not change on ADDNEWROW. they should remain the same.

Hope this time i explained you correctly, and im expecting ur replies friends...

Kindly respondg back to me. thanks to all in advance,

Niraja

Accepted Solutions (1)

Accepted Solutions (1)

StefanRoesch
Active Participant
0 Kudos

you can bind the "read-only" attribute of your dropdown element to an additional column in your context node (table) which you initially fill with "X". When adding your row 4, just leave that field empty and the user can change the value here...

Stefan

Former Member
0 Kudos

Hi Stefan,

I completely agree and thanks for that,

but how to fill the drop down values? i mean when intially loading the WDA< how to bind the data from backedn,

and when new row is inserted how to append all entries in new coloumns drop down field.

kindly could you pls elaborate on this

Niraja

uday_gubbala2
Active Contributor
0 Kudos

Hi Niraja,

When you create a new value into your dropdown are you reflecting those changes on to the backend database or just filling up your internal table? If you are reflecting these changes on to the database then you can proceed in this way...

Create a supply function to the node under which you have your attribute which you use for binding to your dropdown. Now populate the values to be filled up into this dropdown in this supply function. Now when you create a new value into your drop down, reflect the changes to the database & then call the INVALIDATE method of IF_WD_CONTEXT_NODE. This would result in all the context data getting invalid & execution of the supply function. This would in turn mean that the new set of values would be fetched from the database & populated in your drop down.

Regards,

Uday

pranav_nagpal2
Contributor
0 Kudos

Hi Niraja,

Please refer the code below for filling drop down in table.... this is hard coding i.e. i m filling value directly with out using database table .now wht u have to do is that you have to create an internal table with two column one key and one value. select data from database into internal table. thn just replace hard coding with the value and key column of internal table

Please note SAP doesnt recommend usage of select query in WD abap. use any FM instead.

DATA LR_NODE_INFO TYPE REF TO if_wd_context_node_info.

data ls_value type wdy_key_value.

data lt_value_set type wdy_key_value_table.

ls_value-key = 'a'.

ls_value-value = 'APPLE'.

append ls_value to lt_value_set.

ls_value-key = 'b'.

ls_value-value = 'BANANA'.

append ls_value to lt_value_set.

ls_value-key = 'c'.

ls_value-value = 'GRAPES'.

append ls_value to lt_value_set.

ls_value-key = 'd'.

ls_value-value = 'MANGO'.

append ls_value to lt_value_set.

lr_node_info = wd_context->get_node_info( ).

lr_node_info = lr_node_info->get_child_node( 'CN_UITABLE' ).

lr_node_info->set_attribute_value_set( name = 'CA_COLUMN2' value_set = lt_value_set ).

As suggested by Stefan you can make the read only field by using enable property.

regards Pranav

Edited by: Pranav Nagpal on Nov 21, 2008 5:55 AM

Former Member
0 Kudos

pranav,

the way u showd i tried, but in row1's dropdown field, i m also getting banana, grapes, mango along with apple,

here in first row i need only apple(field should be non editable, and dropdown), row2's dropdown should have banana only,

row3's dropdown should contain grapes only, and row4's dropdown should contain mango, (al now non editable).

this is when my page loads,

when i click add row button, row5's new row should add, and i need new values in the dropdown field( i wan tto select from databse table, now it should be editable, user shud select any value here.)

kindly respnd me, hope this is understandable, sorry but.. this example should give u a clear picture,

:((((((((((((((((((((((((

thanks alot u all again,

niraja

pranav_nagpal2
Contributor
0 Kudos

hii,

you have to initilize the drop down first... thn for the values coming from database see fm below my data is comin in itab_fruit...

call function 'HR_READ_INFOTYPE'

exporting

pernr =

infty =

begda =

endda =

tables

infty_tab = itab_fruit

exceptions

infty_not_found = 1

others = 2.

now just loop at itab fruit and set the values in the internal table u r uing for your table..

say it is itab_context

loop at itab_fruit into wa_fruit.

itab-context-colm1 = wa_fruit-apple.

.

.

.

.

endloop.

now simply bind the the internal table.

lo_nd_cn_family->bind_table( itab_context ).

please note that in the table node you have to create a attribut for enable property and set it for read only while looping.

regards

pranav

Former Member
0 Kudos

I have read the complete table's dropdown values at once.

read elements of table node, looped it and read the child node element(dropdown).. then get_attribute..

solved this issue.

Answers (1)

Answers (1)

Former Member
0 Kudos

Hi,

You can add the new row in your table without changing the prevoius values.

Plz try the following code.

DATA lo_nd_cn_try1 TYPE REF TO if_wd_context_node.

DATA lo_el_cn_try1 TYPE REF TO if_wd_context_element.

DATA ls_cn_try1 TYPE wd_this->element_cn_try1.

  • navigate from <CONTEXT> to <CN_TRY1> via lead selection

lo_nd_cn_try1 = wd_context->get_child_node( name = wd_this->wdctx_cn_try1 ).

lo_el_cn_try1 = lo_nd_cn_try1->create_element( ).

lo_nd_cn_try1->bind_element( NEW_ITEM = lo_el_cn_try1 SET_INITIAL_ELEMENTS = abap_true ).

Here u have to maintain SET_INITIAL_ELEMENTS as false, If u made it True then previous values will

not be visible.

Plz clarify one thing that, if user clilck on the ADDROW button then the previous values you need will be editable or not.

Thanks,

Pankaj Aggarwal.

Former Member
0 Kudos

HI pankaj,

thanks,

but yes, my previous values should be non editable, the WDA loads, at that time i want one value in a drop down, each row i will pass one value, the row1's dropdown value should not be there in

row2's dropdown. when my page loads, all fields are non editable.

now when i click add row, my new row's dropdown values i will fetch again from database, and should populate in new row's drop down, user can select any value now .

But previous rows' are non editable, and every drop down should behave like a input field(non editable, but dropdown, and need one value only).

kindly tell me how to do this..

Niraja