on 04-18-2011 2:44 PM
Hello everyone,
I've coded a WDA which builds a UI dynamically. I'm adding attributes to a context node and removing them whenever the user clicks on a button.
I've realized that in this case all of the attributes assigned to the node are removed. In fact the standard method:
IF_WD_CONTEXT_NODE_INFO~REMOVE_ATTRIBUTE
contains the statement:
me->invalidate_nodes( )
which appears to invalidate all of the nodes and this is clearly not what I was expecting.
I just wanted to remove the selected attribute through the coding:
node_info->remove_attribute( name = lv_param3 ).
I honestly don't understand why the REMOVE_ATTRIBUTE has got this semantics, it doesn't make much sense to me.
How can I delete a certain attribute without invalidating all the other siblings?
Thank you!
I was expecting an alternative to this weird functionality...
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Maybe instead of a dynamic attribute you can build your context structure dynamically but using all static attributes. You can build a static context node using an RTTI object:
dyn_node_info = rootnode_info->add_new_child_node(
name = 'MDM_DATA'
is_mandatory = abap_false
is_mandatory_selection = abap_false
static_element_rtti = struct_type
is_multiple = abap_true ).
You can then use a GET_STATIC_ATTRIBUTES_TABLE call to get the current data, then rebuild the RTTI structure with the new attributes, rebuild the context node, and re-fill the data with the internal table retrieved from the GET_STATIC_ATTRIBUTES_TABLE method call using a BIND_TABLE. A lot more manual work, but it gets you around some of the limitations of using dynamic attributes.
Thank you very much Thomas,
I wasn't aware of this option.
However I found an alternative solution. Instead of creating child attributes of a parent node, I've created child nodes (and attributes to them) of the parent node.
This means that my context contains:
CONTRACT.COMPANY_CONTACTS.COMPANY_CONTACT_1.COMPANY_CONTACT_1
CONTRACT.COMPANY_CONTACTS.COMPANY_CONTACT_2.COMPANY_CONTACT_3
CONTRACT.COMPANY_CONTACTS.COMPANY_CONTACT_3.COMPANY_CONTACT_3
and I then invalidate
CONTRACT.COMPANY_CONTACTS.COMPANY_CONTACT_X.COMPANY_CONTACT_X
It works okay.
Anyway, yours is a more elegant solution. Going to go for it next time. However I still can't figure out why SAP implemented the REMOVE_ATTRIBUTE that way.....?
Cheers
Hello,
I hadnt used this before.
This seems to be standard behavior. I had a look at the documentation at https://cw.sdn.sap.com/cw/docs/DOC-30536.
REMOVE_ATTRIBUTE
A dynamic attribute can be deleted again using this method. All nodes (runtime instances are invalidated) that reference to this node info.
The reason for invalidating the nodes corresponding to the node info could be that all the existing instances would have the reference to the attribute which is getting deleted. That will be invalid information after the attribute is removed. So by invalidating the nodes, all the elements for those nodes will be removed. And we need to create the elements again.
Hope this helps!
Best Regards,
Srilatha
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
86 | |
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.