cancel
Showing results for 
Search instead for 
Did you mean: 

How to add a new Entity to Empty BOL colletion

eyal_alsheikh
Active Participant
0 Kudos

Hello Experts,

I have created a View in my own Component with a context to simple object that I have created.

I need to add a new empty entity to my view's collection in method DO_INIT_CONTEXT

What is the elegant/correct way to do it?

Thank You,

Eyal

View Entire Topic
eyal_alsheikh
Active Participant
0 Kudos

Hi,

I found this way:

DATA: lv_query TYPE REF TO if_bol_bo_property_access,

lr_coll_wrapper TYPE REF TO cl_bsp_wd_collection_wrapper,

lr_cucoaui TYPE REF TO cl_iccmp_in_bspwdcomponen_impl,

lv_col TYPE REF TO if_bol_bo_col,

lr_col TYPE REF TO cl_bsp_wd_collection_wrapper,

lr_entity TYPE REF TO if_bol_bo_property_access.

CALL METHOD super->do_init_context.

lr_coll_wrapper = typed_context->zbpactstatissearch->get_collection_wrapper( ).

  • create query instance

CREATE OBJECT lv_col TYPE cl_crm_bol_bo_col.

lv_query ?= cl_crm_bol_query_service=>get_instance( iv_query_name = 'ZBPActStatisSearch' ). "#EC NOTEXT

lv_col->add( iv_entity = lv_query ).

typed_context->zbpactstatissearch->set_collection( collection = lv_col ).

  • set default 'My Groups' for 'Assigned To'

lr_col = typed_context->zbpactstatissearch->get_collection_wrapper( ).

IF lr_col IS BOUND.

lr_entity = lr_col->get_current( ).

IF lr_entity IS BOUND.

TRY.

CALL METHOD lr_entity->set_property_as_string

EXPORTING

iv_attr_name = 'BP'

iv_value = '150'.

CATCH cx_sy_conversion_error .

ENDTRY.

ENDIF.

ENDIF.

Is this the Best Way?

Thanks,

Eyal

Former Member
0 Kudos

Hi,

As per my knowledge this is the only way...

The collection should be of type IF_BOL_BO_COL and you can add an entity by casting it to type

lr_entity TYPE REF TO if_bol_bo_property_access.

Regards,

Masood Imrani S.