on 08-07-2007 4:55 PM
Hello,
I am quite new webdynpro abap. I would like to display a dropdown box, input field on an iView. The selected value from dropdownbox and entered input value together has to be displayed during runtime. I was looking around for a step by step by guide which i couldn't find. Please provide me a solution for which points are rewarded
best regards,
k.c.
Hi,
There are 2 dropdown UI elements present in WD abap.
1. For DropDownListByKey:
Create a dropdownby key element in your view, and bind the selectedKey property to whichever node attribute you wish to bind. When you select a value in the dropdown, it is this value you have to bind and init method write code to popuate the values to the dropdown.
The wddoinit method: write the following code:
data: lt_valueset type standard table of wdr_context_attr_value,
ls_valueset type wdr_context_attr_value,
lr_node_info type ref to if_wd_context_node_info,
lr_node type ref to if_wd_context_node,
wa_kna1 type <your kna1 table type>.
lr_node = wd_context->get_chilod_node( 'NODE_KNA1MOD' ).
lr_node_info = lr_node->get_node_info( ).
loop at kna1 into wa_kna1.
ls_valueset-value = wa_kna1-kunnr. "this will be the selected value
ls_valueset-text = wa_kna1-kunnr. "this will be the displayed value in the UI
append ls_valueset to lt_valueset.
endloop.
lr_node_info->set_attribute_value_set(
exporting
name = 'KUNNR'
value_set = lt_valueset ).
you can find more info at:<a href="http://help.sap.com/saphelp_nw2004s/helpdata/en/c5/e4884180951809e10000000a155106/frameset.htm">http://help.sap.com/saphelp_nw2004s/helpdata/en/c5/e4884180951809e10000000a155106/frameset.htm</a>
2. Dropdown by Index:
<a href="http://help.sap.com/saphelp_nw2004s/helpdata/en/dd/b0884118aa1709e10000000a155106/content.htm">http://help.sap.com/saphelp_nw2004s/helpdata/en/dd/b0884118aa1709e10000000a155106/content.htm</a>
Define a node (for eq. 'TEXT') with cardinality '0..n' with attribute (for eq. 'TEXT').
In the view create a UI element DropDownIndx
Bind the text property of DropDownbyIndex UI element to attribute Text of context node Text.
For populating the values to the node text;
In the WDDOINIT method you can prepare an internal table with the values and bind it to the node and the lead selection defines the selected element.
The below code sample may help.
method WDDOINIT .
for populating the values in drop down
data:
node_text type ref to if_wd_context_node,
stru_text type if_componentcontroller=>element_text,
tab_text type if_componentcontroller=>elements_text .
node_text = wd_context->get_child_node( name = if_componentcontroller=>wdctx_text ).
Set/fill your values
stru_text-text = 'Value1'.
append stru_text to tab_text.
stru_text-text = 'Value2'.
append stru_text to tab_text.
set values to the node
call method node_ddi_also_text->bind_table
exporting
new_items = tab_text.
endmethod.
for reading the values which user has selected in dropdown; for reading the selected index you can write the logic/method for the Onselect event of dropdownbyindex ui element. in the method read the attribute of the node text. the lead selection of the node gives the selected element (you can use the code wizard to read the context).
Hope this helps.
Regards,
Suresh
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
The code to display the three letters using drop down by key would be like this:
data: lt_valueset type standard table of wdr_context_attr_value,
ls_valueset type wdr_context_attr_value,
lr_node_info type ref to if_wd_context_node_info,
lr_node type ref to if_wd_context_node.
lr_node = wd_context->get_chilod_node( <node name> ).
lr_node_info = lr_node->get_node_info( ).
ls_valueset-value = 'A'.
ls_valueset-text = 'A'.
append ls_valueset to lt_valueset.
ls_valueset-value = 'B'.
ls_valueset-text = 'B'.
append ls_valueset to lt_valueset.
ls_valueset-value = 'C'.
ls_valueset-text = 'C'.
append ls_valueset to lt_valueset.
lr_node_info->set_attribute_value_set(
exporting
name = <attribute name>
value_set = lt_valueset ).
Have this code in the doinit method. <node name> will be the name of your context node and <attr name> is the context attribute which you want as a drop down. Bind the selectedKey property of the drop down by key UI element to the context attribute.
Regards,
Nithya
Hi,
1.Create a node (e.g: portal node),and create a attribute under that(e.g value1)
2.Bind the value1 attribute in the texts property of dropdown.
Add the following code in the on select event of dropdown,
<b> String[] letters = new String []{"A", "B", "C", "D"};
List nodeElements = new ArrayList();
for (int i = 0; i <letters.length; ++i)
{
IPrivateportal_comp.IportalElement PortalnodeElement = wdContext.createportalElement();
PortalnodeElement.setValue1(letters<i>);
nodeElements.add(PortalnodeElement);
}
wdContext.nodePortalnode().bind(nodeElements);
wdContext.nodePortalnode().setLeadSelection(1);</b>
Regards
Nandha
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
88 | |
23 | |
11 | |
9 | |
8 | |
5 | |
5 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.