cancel
Showing results for 
Search instead for 
Did you mean: 

reg:dropdownbykey

Former Member
0 Kudos

hi all

Here i am using two drop down by key ui elements in the layout.In the first Drop down i am having two values in it.in the second drop down 4 values ,two are related to first value of first drop down other two are related to secnd value in the first drop down.here my requirement is when i select the value in first drop down the vlaues which are related to the first vlaue should be displayed in the second drop down automatically.

How to work on with this,can any one please share there ideas on this.

Thanks in advance

Deepika

Edited by: deepika_indian on Feb 15, 2011 6:02 AM

Accepted Solutions (1)

Accepted Solutions (1)

abhimanyu_lagishetti7
Active Contributor
0 Kudos

for dropdowns you have to code it in web dynpro.

In onSelect event handler of first dropdown read its value and fill the second dropdown.

To fill dropdown values programatically use

SET_ATTRIBUTE_VALUE_SET method of IF_WD_CONTEXT_NODE_INFO interface.

Former Member
0 Kudos

hi

but when i try to append values it is giving an error,bcoz the cardinality of dropdown by key is 1.1 cardinality property as well as selection cardinality is 0.n.

bcoz of this i cant append 4 values at a time to node.how can this be resloved and how to change the cardinality ,if change the cardinality it is giving the error.

Thanks & Regards

Deepika

abhimanyu_lagishetti7
Active Contributor
0 Kudos

follow the code to set value help to the context attribute, value help is set of values that you expect that user choose at runtime.

Note we are not appending values to the context node.

data: lr_node type ref to if_wd_context_node,

lr_info type ref to if_wd_context_node_info,

lt_valueset type table of wdr_context_attr_value,

ls_valueset type wdr_context_attr_value.

ls_valueset-value = '01'.

ls_valueset-text = 'First option'.

append ls_valueset to lt_valueset.

ls_valueset-value = '02'.

ls_valueset-text = 'Second option'.

append ls_valueset to lt_valueset.

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

lr_info->set_attribute_value_set( name = 'ATTRIBUTE2' value_set = lt_valueset ).

gill367
Active Contributor
0 Kudos

Hi Deepika,

If you are using dropdown by key then atleast one element whould be there in the node whose attribute you have bound to

selected key.

either the cardinality should be 1..1 or 1..n and if this is not possible manually create the element.

after that will the value set of the first dropdown and then fill the other dropdown's attribute's valuset in the onselect event of first one.

Take an example you need two dropdown with two values A1 and A2 in the first dropdown and

if you select A1 then second dropdown will be filled with B1 and B2.

and if you select A2 then second dropdown will be filled with B3 and B4.

then in the wddoinit method write the code to fill two values in the first dropdown.

here is the sample code for that . my first dropdown is bound to attribute A of node VAL.

"filling the dropdown one

data vl type table of  wdr_context_attr_value.
data wl type wdr_context_attr_value.
data nd type ref to if_wd_context_node.
data nodeinf type ref to if_wd_context_node_info.
nd = wd_context->get_child_node( 'VAL' ).
nodeinf = nd->get_node_info( ).

wl-text = 'A1'.
wl-value = 'A1'.
append wl to vl.
wl-text = 'A2'.
wl-value = 'A2'.
append wl to vl.

nodeinf->set_attRibute_value_Set(
name = 'A'
value_Set = vl
).

then in the onselect of this first dropdown write the below code.

second dropdown's selectedkey property is bound to attribute B of node VAL.

"filling the dropdown second

data vl type table of  wdr_context_attr_value.
data wl type wdr_context_attr_value.
data nd type ref to if_wd_context_node.
data nodeinf type ref to if_wd_context_node_info.
nd = wd_context->get_child_node( 'VAL' ).
nodeinf = nd->get_node_info( ).
DATA FS_VAL TYPE STRING.
ND->GET_ATTRIBUTE(
EXPORTING
NAME = 'A'
IMPORTING
VALUE = FS_VAL
).

IF FS_VAL EQ 'A1'.
wl-text = 'B1'.
wl-value = 'B1'.
append wl to vl.
wl-text = 'B2'.
wl-value = 'B2'.
append wl to vl.
ELSEIF FS_VAL EQ 'A2'.
  wl-text = 'B3'.
wl-value = 'B3'.
append wl to vl.
wl-text = 'B4'.
wl-value = 'B4'.
append wl to vl.


ENDIF.

nodeinf->set_attRibute_value_Set(
name = 'B'
value_Set = vl

).

thanks

sarbjeet singh

Former Member
0 Kudos

hi

Thanks very much for the answ it sloved my problem ,but when i select particular field in the first drop down it need to display one input field along with label and if i select second value in the drop down it need to display two more fields below it.

can u please share your exp on this

thanks in advance

Deepika

Answers (2)

Answers (2)

sahai
Contributor
0 Kudos

hello deepika,

just focus on creating an event handleer fr "onSelect" event of the drop down(you will find this in the property section in layout tab of the dropdown created). code accordingly to put the logic.

in case of further issues inform.

regards,

sahai.s

Former Member
0 Kudos

Hi deepika,

I am explaining your scenario with some details:-

1.In the WDDOMODIFYVIEW or WDDOINIT :-

Bind some values in the first drop down:-

DATA: LT_SECTIONS TYPE STANDARD TABLE OF WDR_CONTEXT_ATTR_VALUE, " you

LS_SECTIONS TYPE WDR_CONTEXT_ATTR_VALUE.

you need the above two attributes to set values in dropdown.

fill values:-

LOOP AT IT_TABLE_NAME INTO WA_TABLE_NAME.

LS_SECTIONS-VALUE = WA_TABLE_NAME-VALUE.

LS_SECTIONS-TEXT = ' Text to display '.

ENDLOOP.

LR_NODE_INFO->SET_ATTRIBUTE_VALUE_SET(

EXPORTING

NAME = ' ATTRIBUTE_NAME ' "attribute name

VALUE_SET = LT_SECTIONS ).

2. Now in the action of the first dropdownby key:-

Get the selected value of the attribute :-

read attribute value from code wizard.

Now as in your scenario

if VALUE 1.

then like same way take some values ( two values ) and bind to second attribute.

endif.

if VALUE 2.

then like same way take some values ( two values ) and bind to second attribute.

ENDIF.

Reply in case of any issue.

Regards,

Monishankar C