cancel
Showing results for 
Search instead for 
Did you mean: 

Gettin Exception in EH_ONSEARCH

Former Member
0 Kudos

Hi,

I have created new component with Search & Result and created EH_ONSEARCH event in search view to fill the result collection, but problem is that I am getting exception while converting if_bol_bo_property_access  to CL_CRM_BOL_ENTITY.

1. please suggest what is wrong with this code and also suggest which method is best to fill Result collection?

2. Does sort functionality in result will work ?

code:

DATA :    lr_ent TYPE REF TO if_bol_bo_property_access,
           lr_ent1 TYPE REF TO if_bol_bo_property_access,
           lr_res   TYPE REF TO cl_crm_bol_entity.
DATA: lr_cuco TYPE REF TO ZL_ZNEHA_ZCUCO_IMPL.



data : IT_TEMP type table of Znitin,
        wa_temp like LINE OF it_temp,


lr_cuco ?= me->get_custom_controller( 'GLOBAL.ZNEHA/ZCuCo ' ).


lr_ent ?= me->typed_context->SEARCH->collection_wrapper->get_current( ).

   lr_ent1 ?= lr_cuco->typed_context->result->collection_wrapper->get_current( ).



lr_res ?= lr_ent1. "Getting Exception Here



SELECT * from znitin into table it_temp .


loop at it_temp INTO wa_temp.

    lr_res->set_property( iv_attr_name = 'ZID'
                              iv_value     = wa_temp-zid ).
   lr_res->set_property( iv_attr_name = 'NAME'
                              iv_value     = wa_temp-name ).
   lr_res->set_property( iv_attr_name = 'ZADD'
                              iv_value     = wa_temp-zadd ).
          lr_cuco->typed_context->result->collection_wrapper->add( lr_res ).

ENDLOOP.


Please suggest if my approach is wrong.



Regards

Nittu

Accepted Solutions (1)

Accepted Solutions (1)

kumar5
Active Contributor
0 Kudos

Hi,

If I understood your requirement correctly then , you can make lr_ent1 of type cl_crm_bol_entity so that there will be no need to move it later.

Second you can use the set_property method of interface as well without converting it first to type cl_crm_bol_entity i.e. do not use line lr_res ?= lr_ent1 and use lr_ent1 to set the property.


Thanks

Kumar.

Answers (0)