cancel
Showing results for 
Search instead for 
Did you mean: 

Adding entity objects (cl_crm_bol_entity) to collection (if_bol_bo_col) ?

Former Member
0 Kudos

Hi Experts,

I have an internal table of specific structure. I have to add them to entities with same structure and again i have add the entities to collection of type if_bol_bo_col. Here the code is to be written within badi, which gets empty collection as input. I tried with the ways that i know. But, they result in exception. Anyone can point me to working code that shows how to create entities of specific structure and add them to collection ?

Thanks & Regards,

Gaurav.

Accepted Solutions (0)

Answers (1)

Answers (1)

Former Member
0 Kudos

Hi Gaurav,

You can create an entity by using the below code by using a specific structure.

CREATE DATA v_struct_ref.

CREATE OBJECT v_node

EXPORTING

iv_data_ref = v_struct_ref.

  • Add value node to collection

me->typed_context->BOLENTITYNAME->collection_wrapper->add( v_node ).

After that read that entity from your collection set the values of the entity from table. After that use SET_COLLECTION method for adding it to the collection.

Regards,

Lakshmi.Y

Former Member
0 Kudos

Hi Lakshmi,

Adding value node of type cl_bsp_wd_value_node is fine. I tried to create and add entities of type cl_crm_bol_entity. But, came to know that, it is almost impossible. If i would follow the above mentioned method, then it throws me an exception while we move.

Best Regards,

Gaurav.

Former Member
0 Kudos

Hi Gaurav,

try the following

TYPES: BEGIN OF ltype_attr_struct,

attr1 type string,

"structure

END OF ltype_attr_struct.

DATA: lv_struct_ref TYPE REF TO ltype_attr_struct,

lv_struct TYPE ltype_attr_struct,

lv_value_node TYPE REF TO cl_bsp_wd_value_node,

lv_bo_coll TYPE REF TO if_bol_bo_col.

Former Member
0 Kudos

CREATE DATA lv_struct_ref.

LOOP AT table INTO wa.

lv_struct-attr1 = 'HI'.

lv_value_node->set_properties( is_attributes = lv_struct ).

lv_bo_coll->add( lv_value_node ).

ENDLOOP.

Former Member
0 Kudos

This message was moderated.