cancel
Showing results for 
Search instead for 
Did you mean: 

REMOVE_ATTRIBUTE removes all of the attributes

ged_hurst
Participant
0 Kudos

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!

Accepted Solutions (1)

Accepted Solutions (1)

ged_hurst
Participant
0 Kudos

I was expecting an alternative to this weird functionality...

thomas_jung
Developer Advocate
Developer Advocate
0 Kudos

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.

ged_hurst
Participant
0 Kudos

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

Answers (1)

Answers (1)

Former Member
0 Kudos

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

ged_hurst
Participant
0 Kudos

I figured that out as well

But the semantics is pretty weird and to me it's more a bug than a feature!

Cheers