cancel
Showing results for 
Search instead for 
Did you mean: 

Not able to remove entity from a collection of type CL_CRM_IU_IC_BOL_TREE_NODE_COL.

sapRSH
Explorer
0 Kudos

Hello all, I am new to CRM programming.

My requirement is to remove an entity present inside a collection wrapper having collection of type CL_CRM_IU_IC_BOL_TREE_NODE_COL.

I got hold of this collection and am able to access the entities inside it using get_first( ), get_next( ) etc. methods .


Now my problem is when I use iv_bo = iv_obj->get_first( ), iv_bo = iv_obj->get_next( ) etc methods (where iv_obj is the reference to collection wrapper), it returns me an entity of type cl_crm_bol_entity, because the method IF_BOL_BO_COL~GET_FIRST (CL_CRM_BOL_BO_COL) , IF_BOL_BO_COL~GET_NEXT(CL_CRM_BOL_BO_COL)etc. get called eventually.


But on calling iv_obj->remove(iv_bo), it is calling the method IF_BOL_BO_COL~REMOVE (CL_CRM_IU_IC_BOL_TREE_NODE_COL). Now inside this it is casting this entity using the code     bo_node ?= iv_bo.

where iv_bo is of type cl_crm_bol_entity and bo_node is of type cl_crm_iu_ic_bol_tree_node.

and thus we get a casting exception cx_sy_move_cast_error.

Hence I am unable to remove the entity from collection .

One way is to add the needed (not to be removed) entities from this collection wrapper into another collection, then clear this collection wrapper and finally set the new collection. But I am having certain side effects from that approach, so can't use that.

Could anyone please tell how I can remove an entity from this collection.

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

HI,

Try using iv_bo->delete( ) and after core->modify( ).

Regards,

Tejaswini P.

sapRSH
Explorer
0 Kudos

Hi Tejaswini,

Thanks for replying.

Actually I can't delete the entity to remove it from the collection. These entities are being used at some other views too, specifically in the bol-trees at some locations. Deleting them like this will affect the functionality of other views too, and might even result in dumps.

Can I try any other way? May be converting the bol-entity of type cl_crm_bol_entity into entity of type cl_crm_iu_ic_bol_tree_node somehow. Obviously simply type-casting the two doesn't work.

Any help would be highly appreciated.

Thanks.

Former Member
0 Kudos

Hi Ravi,

As you are using CL_CRM_IU_IC_BOL_TREE_NODE_COL which is for tree context node collection. In collection you will get the data as Nodes to the tree view collection.

So try to read the data using GET_FIRST_NODE( ), GET_NEXT_NODE( ), GET_LAST_NODE( )  methods then you will get the data in ref to the class" cl_crm_iu_ic_bol_tree_node ".

Then you can use the Remove method as tejaswini Suggested.

Thanks & Regards,

Rajya lakshmi CH


Answers (3)

Answers (3)

Former Member
0 Kudos

HI,

i have the same requirement. but i want to get the entity collection of Context node ITEMS of View ICCMP_INBOX/InboxItems.

i am writing the code in Do_prepare_output method.

please tel me the code , how to get the entity collection of ITEMS context node which is a Tree contect node. It would be thankful if anybody can post the code.

Waititng For Reply.

Thanks in Advance.

nicolas_busson
Active Contributor
0 Kudos

Hi,

I'm going to chime in here because AFAIK the collection you're referring to is used to display parent/child relationships in a tree view. In a Utility scenario we use it for the technical object workbench for example. So why don't you simply adjust your customizing (or custom development), to read the right relationships in the first place?

Example: imagine you are displaying a tree view with the following structure:

BuilHeader

>> BuilHeaderAllRelationshipsRel

>>>> Is contactPerson

>>>> Is payer

>>>> Is Ship to

>>>> ...

Now if below the root business partner node you want to display the contact persons only, do not try to remove the entities for Payer, Ship to, etc. but change the relationship that is read and turn it into something like BuilHeaderContactPersonRel.

Regards,

Nicolas.

sapRSH
Explorer
0 Kudos


HI Nicolas,

Sorry I wasn't clear enough. Actually I had to remove certain nodes corresponding to "Installation" and "Premise" based on certain conditions only (i.e. it should be marked deleted in ECC). So, I could not simply remove these nodes permanent using costomizing settings.

Anyway, my issue stands resolved. Thanks everyone for replying!

Regards,

Ravi

Former Member
0 Kudos

Hi Ravi,

Use get_first_node() and get_next_node() instead of get_first() and get_next(). The get_first_node() and get_next_node() will return an instance of type CL_CRM_IU_IC_BOL_TREE_NODE. You can pass this reference to the delete() method.

Hope this helps.

Regards,

Prathap