on ‎2007 Apr 23 12:28 AM
Hi there,
Not sure if this is currently possible or whether someone can recommend an alternative method. What I want to do is create a context node of 0..n within a higher level context node that is also 0..n. The higher context node has other attributes. I somehow want to bind an internal table to the top context node and have the embedded internal table automagically bind to the lower context node.
For an example, I have an internal table of customers, with names, addresses, etc, and within this internal table there is another internal table of contacts.
Then I want to use a table UI element to display the customers. The contact details are to be displayed as table popins.
So I don't know if this can be dome using existing settings for the context nodes, or I need to use dynamic contexts/binding, or need to use some other method.
Any help is greatly apprciated.
Thanks,
Tim
Request clarification before answering.
Hi Tim,
It is possible to do that. You bind the internal table which holds one more internal table can be binded to the table node which holds the other table node But the structure should be matched otherwise it won't work.
Warm Regards,
Vijay
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Vijaya,
Thanks for your response but I still can't get this to work.
What I have is as follows:
Context
Customer (Node of 0..n)
Name
Address
Contact (Node of 0..n)
Name
Address
I have an internal table of the same deep structure. I have tried binding the customer internal table to the customer node. But when I try to read the contact node, I don't get anything.
The code is as follows:
lr_customer_node = wd_context->get_child_node( name = 'CUSTOMER' ). lr_contact_node = lr_customer_node->get_child_node( name = 'CONTACT' ).
The last statement has a return code 0 but no pointer to the node is assigned.
I have also tried reading the context into the deep internal table structure but this dumps.
Regards,
Tim
Did you try in debugging to see if the node is really assigned and that there is data attached to it? You can use the WD feature of the new ABAP debugger.
Try to use the code access the child node from the WD code generaiton wizard. Then code errors will reduce.
Could you also paste the full code, in case you have not used the wizard?
- Harish.
Hi Tim,
I too had a similar requirement in my project. I could not directly bind the values which i get from my function module into the context node, as the underlying type of my context node was a nested structure(just as in your example). What I did is that I had to fill the inner node(Node Contact in your example) explicitly. Ie. After I get the values from my function module I loop through the values of my inner table (contacts) into a local structure, copy the values in an internal table and then bind these values explicitly to the inner node(contacts node) in the context. You will have to properly set the cardinality of the parent and the child nodes otherwise you will run into dumps.
For your example, 'customer' node is the parent node, Set the cardinality of this node to 1:n and you can bind the customer table values which you get directly to this node. All the attributes will be filled except the contacts which is an internal table.
The 'contact' node is a child node nested in the 'customer' node, so set its cardinality to 0:n and populate it manually by looping through the values (which you would get as an internal table).
Iam not sure if there is a better way of doing this. I would also be glad to know from the experts if there is a better way to do this binding(maybe if it is possible to do the binding directly ?? ).
I hope this information will be helpful to you.
Thanks and Best Regards,
Viqar Ali.
Hi Viqar,
Thanks for your response. Much appreciated.
I'm wondering how you populated the "child" node? Did you bind the internal table of child records to a single parent node? I'm assuming you have to bind the parents one at a time, otherwise how does it know what child node goes with what parent node?
Thanks,
Tim
Hi Tim,
I just missed that point in my earlier reply. Yes you are right. You need to bind the parent records also one at a time. Let me give you a kind of algorithm which I followed and which you can use(Before you bind the values, Make sure to set the cardinality of the parent and child nodes as in my earlier reply):
DATA ls_parent TYPE wd_this->element_parent.
DATA lt_parent TYPE TABLE OF wd_this->element_parent.
DATA lo_node_parent TYPE REF TO if_wd_context_node.
DATA lo_elem_parent TYPE REF TO if_wd_context_element.
DATA ls_child TYPE wd_this->element_child.
DATA lt_child TYPE TABLE OF wd_this->element_child.
Step1:
Loop at parent table into local structure(ls_parent)
Within this loop
Create a new element for the parent node.
lo_elem_parent = lo_node_parent->create_element( ).
Use set_attribute method to populate lo_elem_parent with the values in ls_parent
lo_elem_parent->set_attribute..........
Bind the new element with the populated values, to the parent node.
lo_elem_parent = lo_node_parent->bind_element( new_item = lo_elem_parent
set_initial_elements = abap_false ).
Get a child node for this parent element
lo_node_child = lo_elem_parent->get_child_node( childnode name ).
CALL METHOD LO_NODE_PARENT->BIND_STRUCTURE
EXPORTING
NEW_ITEM = ls_parent
SET_INITIAL_ELEMENTS = ABAP_FALSE.
Step2:
Loop at child table into local structure(inner loop)
prepare 'lt_child' table(declared above) for binding the table values with
the child node
End of child loop.
CALL METHOD lo_node_child->bind_table
EXPORTING
new_items = lt_child
set_initial_elements = abap_true.
Now bind the parent element which we just created with the context node.
lo_node_parent->bind_element( new_item = lo_elem_parent
set_initial_elements = abap_false ).
Endof Parent Loop.
I hope this helps you.
Thanks and Best Regards,
Viqar Ali.
Message was edited by:
Viqar Ali
Hi Tim,
I had the same requirement. I used a supply method to fill the child node where the parent element is provided as an input parameter. So you will always have the right customer on hand and can then populate its contacts. I used the method fill_node of the class cl_wd_dynamic_tool to do this:
node_contacts = cl_wd_dynamic_tool=>fill_node(
parent_element = parent_element
child_name = if_componentcontroller=>wdctx_contacts
values = stru_customer-contacts).
Hope this will help you,
Anika
| User | Count |
|---|---|
| 9 | |
| 6 | |
| 4 | |
| 4 | |
| 3 | |
| 3 | |
| 3 | |
| 2 | |
| 2 | |
| 2 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.