Skip to Content

REMOVE_ATTRIBUTE removes all of the attributes

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!

Add comment
10|10000 characters needed characters exceeded

  • Follow
  • Get RSS Feed

2 Answers

  • Best Answer
    Posted on Apr 21, 2011 at 09:01 AM

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

    Add comment
    10|10000 characters needed characters exceeded

    • 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

  • author's profile photo
    Former Member
    Posted on Apr 18, 2011 at 04:36 PM

    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

    Add comment
    10|10000 characters needed characters exceeded