on 02-28-2007 11:34 AM
Hello Experts,
my Problem is to fill a non Singlton Subnode.
I have a Node called Subject with some Attribute plus a Subnode called Details
Details is a non Singleton node (Singletonbox is unselected).
The node Subject is filled with n Elements.
Then i try to fill the Subnode Details:
I get the number of Elements from Node Subject:
nodelength = node_subject->get_element_count( ).
then a move to the very first element:
node_subject->move_first( ).
then i do a loop
DO nodelength TIMES.
then i get the id of the selected element
node_subject->get_attribute ( EXPORTING name = 'ID' IMPORTING value = subjectid ).
then i search for the elements in a table
select * from detailstab into table tmpdetailstab where ID = subjectid.
the next step is, to bind the result table (possible n elements) to the node details
node_details->bind_table( NEW_ITEMS = tmpdetailstab SET_INITIAL_ELEMENTS = abap_false).
then i make a step to the next elements in subject
node_subject->move_next( ).
and the loop is at the end
ENDDO.
The code runs, butt the result is not equals to my forecast.
There is only a filled subnode Details in the first element of Subject. If i set the lead_selection for Subnode Details in the second element of Subject, i get the error "Invalid Index 1 when Setting the Lead Selection."
Have somebody an idea what's going wrong?
Stephan Borchert
Hi Stephan,
Your code doesn't work, because you have to get a reference to the subnode inside the loop.
There are some disadvantages in this coding:
- The lead selection is changed each time you run through the loop. This may be bad for performance, because the framework changes a lot for each lead selection change.
- The coding is not very short.
You can change it in different ways:
- Just define a supply function for the subnode. There you get the parent element, where you can read the 'ID', and have the reference to the node you want to fill. Anothere advantage is that the subnode is only filled for those nodes, which are really used. It does not matter whether this is a singleton node or not.
- Another possibility is to fetch a list of elements from the node (IF_WD_CONTEXT_NODE=>GET_ELEMENTS( )), then run through these elements, read the attribute, get a reference to the subnode and fill it.
Ciao, Regina
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Stephan.
You can loop over all elements of your subject node and retreive the child node
details of each elemnt to bind your selection result like this:
DATA:
lr_node_subject TYPE REF TO if_wd_context_node,
lr_subject_element TYPE REF TO if_wd_context_element,
lr_node_details TYPE REF TO if_wd_context_node.
DATA:
lt_elements TYPE wdr_context_element_set.
lt_elements = lr_node_subject->get_elements( ).
loop at lt_elements into lr_subject_element.
lr_node_details = lr_subject_element->get_child_node( 'DETAILS' ).
lr_node_details->bind_table( <your_selection_result> ).
endloop.
Hope this helps a bit.
PS: Maybe you just forgot to get the reference to the details node of current subject node in your loop.
Cheers,
Sascha
Message was edited by:
Sascha Dingeldey
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 | |
10 | |
10 | |
9 | |
7 | |
7 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.