on 01-20-2009 11:48 AM
Hi!
I have a "node1" with 2 attributes "Attr1" and "Attr2". And a subnode of "node1" named "subnode1_1" with one attribute "sub_attr1".
"Attr1" and "Attr2" of "node1" are string attributes and "node1" has Cardinality 0:n and Selection 0:1
"sub_attr1" is string and "subnode1_1" has Cardinality 0:n and Selection 0:1
I have a table-object, which has 3 cols.
col1 (bound to "attr1") - textfield
col2 (bound to "attr2") - texfield
col3 (bound to "sub_attr1") - dropdown by index
"Node1" is filled by a runtime method via "bind"-> works fine
"subnode1_1" is filled by a supply method -> works fine
So, after loading and filling for example i have 3 rows with values for col1 and col2. Now, i can select a value for col3 for every row in the table.
After select a value for col3 for all rows, i want to click a button and read every row of the table (every row of the "node1").
I can read every col1(node1.attr1) and col2(node1.attr2) but i have no idea, how to read col3(subnode1_1.sub_attr1). I tried the follow:
DATA:
lo_nd_node1 TYPE REF TO if_wd_context_node.
lo_el_node1 TYPE REF TO if_wd_context_element.
ls_node1 TYPE wd_this->element_node1,
node_var2 TYPE REF TO if_wd_context_node,
elem_var2 TYPE REF TO if_wd_context_element,
iCount type i.
iCounter type i.
attr1 type string.
attr2 type string,
attr3 type string.
iCounter = 0.
lo_nd_node1 = wd_context->get_child_node( name = wd_this->wdctx_node1 ).
iCount = lo_nd_node1->GET_ELEMENT_COUNT( ).
do iCount times.
iCounter = iCounter + 1.
lo_el_node1 = lo_nd_node1->get_element( index = iCounter ).
lo_el_node1->get_attribute( EXPORTING name = `attr1` IMPORTING value = attr1 ).
lo_el_node1->get_attribute( EXPORTING name = `attr2` IMPORTING value = attr2 ).
node_var2 = lo_nd_node1->get_child_node( name = 'subnode1_1' ).
elem_var2 = node_var2->get_element( ).
elem_var2->get_attribute( EXPORTING name = `attr3` IMPORTING value = attr3 ).
enddo.
i get the right value for attr1 and attr2, but for attr3 there is everytime only the first value of subnode, not the selected one.
Thanks.
Chris
Hallo,
try instead of:
elem_var2 = node_var2->get_element( ).
elem_var2 = node_var2->get_lead_selection( ).
for one selected element
or
lt_elements = node_var2->get_selected_elements().
for a multiple selection
grtz,
Koen
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thanks Thomas, your information was very useful to me.
I understand your point.
I was doing the same that Christopher did: Subnode using value_set to define the same values of list box selection for all rows, in different columns. Yes, dropdown by key is easier solution.
Now I solve my problem!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
What did you choose for the singleton option on the subnode? It sounds like you may have singleton set incorrectly.
http://help.sap.com/saphelp_nw70ehp1/helpdata/en/47/45641880f81962e10000000a114a6b/frameset.htm
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I'm having a difficult time figuring out why you even have a subnode of 0:n if you are filling this attirbute with the table bound to your parent node. It doesn't sound like you can input more than one value in the subnode per parent node. Why have a child node? And with singleton false - you will have a new instance of the node collection for each row of the parent.
Hi!
I dont't fill the child node with table data from parent node.
The parent node is filled with data of "table1" and col3, in fact the dropdownboxes, are filled row for row with data from "table2". And only after selecting a value from the dropdownbox, i want to read out the whole row.
You know, what i plan to do?
I think my whole workaround isn't the right way to do this.
Regards
Chris.
If you are just using the subnode as the value set for the drop down by index then yes you have done this wrong. In that case do you really need a different value set for each row in the parent table? You would need to read via the selectedElement. Consider if you only need the same value set to use a Drop down by Key and load the value set directly into the attribute of the parent node and eliminate the need for the child node all together. This is a much simplier approach.
Hi!
When i put the subnode out of the node1, i have no chance to select different values to each row.
What i tried to do:
data-table1: (for col1 and col2)
Car | white
House | red
dog | blue
data-table2: (for col3)
1
2
3
4
6
webdynpro table:
col1 | col2 | col3
Car | white | dropdownbox with 1-6 : selected value for example 2
House | red | dropdownbox with 1-6 : selected value for example 3
dog | blue | dropdownbox with 1-6 : selected value for example 2
I load data for col1 and col2 , by binding the table1 to node1. And for col3 with a supply method using data from table 2. Now i can choose different values for col3 for each row. But, when i read out context, i don't get the right value for col3.
Regards.
Chris
Hello Mr Jung,
last night i've tried to solve my problem by using a DropDownByKey-Box and look at books and articles. So i found something interesting in a german webdynpro book.
i try to translate it for you:
When using drop down lists in columns the use of DropDownBylndex is inevitable, if for different lines selection lists with different values are to be indicated. The DropDownByKey View element cannot be used in these cases, because the value_set is valid always for all elements of a Context Nodes. In case of a table this characteristic applies to each line and to the announcement of same contents in each line would therefore lead.
So, i'm at my start point.
Best Regards
Diederich
>
> Hello Mr Jung,
>
> last night i've tried to solve my problem by using a DropDownByKey-Box and look at books and articles. So i found something interesting in a german webdynpro book.
>
> i try to translate it for you:
>
> When using drop down lists in columns the use of DropDownBylndex is inevitable, if for different lines selection lists with different values are to be indicated. The DropDownByKey View element cannot be used in these cases, because the value_set is valid always for all elements of a Context Nodes. In case of a table this characteristic applies to each line and to the announcement of same contents in each line would therefore lead.
>
> So, i'm at my start point.
>
> Best Regards
> Diederich
This is exactly what I said the following in my message: "If the value set of the ddlb is the same for all rows, this will be much simplier. You don't need the sub-node in the context at all."
Do you in fact need different DDLB value sets for each row? If not then the DropDownByKey will still work just fine. This is the reason why I asked this question.
Me again,
I solved the problem with one, not really elegant, way.
Enclosed the code, which functions.
DATA:
lo_nd_node1 TYPE REF TO if_wd_context_node.
lo_el_node1 TYPE REF TO if_wd_context_element.
ls_node1 TYPE wd_this->element_node1,
node_var2 TYPE REF TO if_wd_context_node,
elem_var2 TYPE REF TO if_wd_context_element,
iCount type i.
iCounter type i.
attr1 type string.
attr2 type string,
attr3 type string.
iCounter = 0.
lo_nd_node1 = wd_context->get_child_node( name = wd_this->wdctx_node1 ).
iCount = lo_nd_node1->GET_ELEMENT_COUNT( ).
do iCount times.
iCounter = iCounter + 1.
lo_el_node1 = lo_nd_node1->get_element( index = iCounter ).
lo_nd_node1->SET_LEAD_SELECTION_INDEX( iCounter ).
lo_el_node1->get_attribute( EXPORTING name = `attr1` IMPORTING value = attr1 ).
lo_el_node1->get_attribute( EXPORTING name = `attr2` IMPORTING value = attr2 ).
node_var2 = lo_nd_node1->get_child_node( name = 'subnode1_1' ).
elem_var2 = node_var2->get_element( ).
elem_var2->get_attribute( EXPORTING name = `attr3` IMPORTING value = attr3 ).
enddo.
>
> Hello,
>
> Sorry, i misunderstood you.
>
> The user must have the possibility of selecting for each line a different value.
>
> Regards
> Diederich
Still think there is a misunderstanding. Of course the user can select a different value on each line That works fine with byKey. The root of the question is, does the valueSet change from line to line. In other words do the possible values in the DropDown itself need to change from line to line.
User | Count |
---|---|
82 | |
10 | |
10 | |
9 | |
6 | |
6 | |
5 | |
5 | |
4 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.