Hi Priya,
use below code before this statement gr_bol_col = lr_result->if_bol_entity_col~get_copy( ).
and also make sure to refer your code with standard query lr_queryres_col = lr_query_service->get_query_result( ). for sort result list by date & time for the last interactions.
IF lr_result IS BOUND.
lr_entity ?= lr_result->if_bol_bo_col~get_first( ).
WHILE lr_entity IS BOUND.
TRY.
lr_entity->get_property_as_value(
EXPORTING iv_attr_name = 'STAT_TXT'
IMPORTING ev_result = lv_object_type ).
IF lv_object_type EQ 'Open'.
lr_result->if_bol_bo_col~remove( iv_bo = lr_entity ).
ENDIF.
CATCH cx_bol_exception cx_root.
ENDTRY.
lr_entity ?= lr_result->if_bol_bo_col~get_next( ).
ENDWHILE.
ENDIF.
Regards,
Sumeet