on 10-13-2008 10:31 AM
hi,
i have a node called CUSTOMER,under i have a child node called CONTACTS in which i have several attributes.
now i want to pass a value to the attributes of child node.how i can acheive this.
Pls help me
Siva
Hi Siva,
You need to first get the reference to the deeper noce i.e, CONTACTS. Then you can set the value for these attributes normally using their reference. You can get access to the deeper context nodes in 2 ways:
1) You can repeat the normal process for accessing a context node step by step until you 'reach' the required node.
method EXAMPLE .
data: l_node type ref to IF_WD_CONTEXT_NODE,
l_snode_11 type ref to IF_WD_CONTEXT_NODE.
l_node = wd_context->get_child_node( name = 'CUSTOMER' ).
l_snode_11 = l_node->get_child_node( name = 'CONTACTS' ).
2) You can use the PATH_GET_NODE method to reference the required subnode.
data: l_snode_21 type ref to IF_WD_CONTEXT_NODE.
l_snode_21 = wd_context->path_get_node( name = 'CUSTOMER.CONTACTS' ).
Try going through this [document|https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/60730016-dbba-2a10-8f96-9754a865b814] for more explanation and examples.
Once you have the reference of the desired child node then you can make use of the SET_ATTRIBUTE / SET_STATIC_ATTRIBUTES methods of IF_WD_CONTEXT_NODE.
Regards,
Uday
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Siva,
Thats simple. You would first have to get the reference of the CONTACTS node as how I had explained earlier. You can then set the attribute by coding as:
lr_node->set_attribute( exporting name = 'EMAIL_ID'
value = lv_email ).
lv_email would be a local variable containing the value which you want to set to the attribute.
Regards,
Uday
this is my code in supply function method
method SUPPLY_CONTENT .
General Notes
=============
A common scenario for a supply method is to aquire key
informations from the parameter <parent_element> and then
to invoke a data provider.
A free navigation thru the context, especially to nodes on
the same or deeper hierachical level is strongly discouraged,
because such a strategy may easily lead to unresolvable
situations!!
*
data declaration
data:
Stru_Customer type IF_COMPONENTCONTROLLER=>Element_Customer,
lr_node_customer TYPE REF TO if_wd_context_node,
lr_node_contacts TYPE REF TO if_wd_context_node,
lr_element_contacts TYPE REF TO if_wd_context_element.
Stru_Contacts type IF_COMPONENTCONTROLLER=>Element_contacts.
@TODO compute values
e.g. call a data providing FuBa
Stru_Customer-COMPANY = 1. " sample only !
Stru_Customer-CITY = 1. " sample only !
Stru_Customer-FIRST_NAME = 1. " sample only !
lr_node_customer = wd_context->get_child_node( NAME = 'CUSTOMER' ).
lr_node_contacts = wd_context->get_child_node( NAME = 'CONTACTS' ).
*lr_element_contacts = lr_node_contacts->get_lead_selection( ).
lr_node_contacts->set_attribute( exporting name = 'EMAIL_ID'
value = 'siva.palaniswamy' ).
bind a single element
node->Bind_table( new_items = lr_node_contacts ).
*
endmethod.
********************************************************************
In my layout ,i have two tables.
the table 1 has to display customer information,so whenever i select a particular customer ,all his contact information has to be displayed in another table (table2).
How i can do this..
Regards,
Siva
Hi Siva,
The problem arises coz you are trying to get the reference of the nested node CONTACTS. I guess you didnt pay attention to my first thread in which I explained as to how you can get access to nested context nodes. Since the node CONTACTS is a child of CUSTOMER you can't directly code as:
lr_node_contacts = wd_context->get_child_node( NAME = 'CONTACTS' ).
You can try obtain its reference by using the reference of its parent node (CUSTOMER) that you had obtained earlier.
lr_node_customer = wd_context->get_child_node( NAME = 'CUSTOMER' ).
*lr_node_contacts = lr_node_customer->get_child_node( name = 'CONTACTS' ).*
I hope that you will realise where & why things are going wrong now. You can even use the alternative way of obtaining the reference by saying as:
lr_node_contacts = wd_context->path_get_node( name = 'CUSTOMER.CONTACTS' ).
Go through the [link|https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/60730016-dbba-2a10-8f96-9754a865b814] which I had even sent you in my first thread to understand about the working with the context nodes & attributes.
Regards,
Uday
Try the following too
DATA ls_customer TYPE if_main=>Element_customer.
DATA customerNode TYPE REF TO IF_WD_CONTEXT_NODE.
DATA contactNode TYPE REF TO IF_WD_CONTEXT_NODE.
DATA contactElement TYPE REF TO IF_WD_CONTEXT_ELEMENT.
customerNode = wd_context->get_child_node( 'CUSTOMER' ).
ls_customer-name = 'Anil.
customerNode->bind_structure( new_item = ls_customer ).
contactNode = customerNode->get_child_node( 'CONTACTS' ).
DATA ls_contacts TYPE if_main=>Element_contacts.
ls_contacts-email = 'aaaa'.
contactNode->bind_structure( new_item = ls_contacts ).
Regards, Anil
User | Count |
---|---|
85 | |
10 | |
10 | |
9 | |
6 | |
6 | |
6 | |
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.