Hi guys,
I am facing an issue in HCM ESS portal. The scenario is, when an employee waives a particular benefit plan, some related plans also has to be dropped in back end. We have added the code tho drop the related plans and the BOL was updated for the same. It was working fine. But now we are facing an issue of not dropping the related plans. In debugging, I have found the BOL is updated. I have confirmed this by reading the attribute again and checked the values. But at another point of the program where this data is checked, it hold the old values. And another strange thing is, some times the first record is updated properly(the first plan to be dropped) and it hold the updated value till the end. But some times it wont get updated. This happens for the same scenario and inputs.
The code is as follows.
DATA: lo_bol_core TYPE REF TO cl_crm_bol_core,
lo_hress TYPE REF TO cx_hress,
ls_object_spec TYPE crmt_genil_obj_instance,
lo_iterator TYPE REF TO if_bol_entity_col_iterator,
lo_entity TYPE REF TO cl_crm_bol_entity,
lv_object_id TYPE crmt_genil_object_id,
lt_object_specs TYPE crmt_genil_obj_instance_tab,
lv_tech_exception_text TYPE string,
ls_pernr_struc TYPE hrpernr.
DATA: lv_string TYPE string,
lv_index TYPE syindex,
lv_beg_date TYPE sydatum,
lv_end_date TYPE sydatum,
lv_ben_eff_dt TYPE sy-datum." Insert for SCR4755/XX03907/12.06.2014/HD1K920410
DATA: lo_collection_in TYPE REF TO if_bol_entity_col,
lo_collection_out TYPE REF TO if_bol_entity_col,
lo_bol_filter TYPE REF TO cl_crm_bol_filter,
lo_access TYPE REF TO if_bol_bo_property_access.
lo_bol_filter = cl_crm_bol_relation_filter=>get_instance( iv_bol_relation ).
CALL METHOD lo_bol_filter->if_bol_bo_property_access~set_property
EXPORTING
iv_attr_name = 'EVENT'
iv_value = gv_event.
CALL METHOD lo_bol_filter->if_bol_bo_property_access~set_property
EXPORTING
iv_attr_name = 'PLAN_TYPE'
iv_value = iv_plantype.
CALL METHOD lo_bol_filter->if_bol_bo_property_access~set_property
EXPORTING
iv_attr_name = 'ENDDA'
iv_value = '99991231'.
CALL METHOD lo_bol_filter->if_bol_bo_property_access~set_property
EXPORTING
iv_attr_name = 'BEGDA'
iv_value = lv_beg_date.
lo_bol_core = cl_crm_bol_core=>get_instance( ).
lo_bol_core->start_up(
iv_appl_name = 'EMPTY'
iv_display_mode_support = space ).
lo_bol_core->load_component( 'HRBENF' ).
*----- get object
TRY.
ls_pernr_struc-pernr = cl_hress_employee_services=>get_instance( )->get_pernr( ).
CATCH cx_hress INTO lo_hress.
lv_tech_exception_text = cl_hress_fpm_msg_services=>return_tech_exception( lo_hress ).
cl_fpm_factory=>get_instance( )->display_error_page( cl_fpm_error_factory=>create_from_object(
io_exception_obj = lo_hress iv_technical_exception = lv_tech_exception_text iv_additional_info = 'HRESS_EXCEPTION' ) ).
RETURN.
ENDTRY.
lv_object_id = cl_crm_genil_container_tools=>build_object_id( ls_pernr_struc-pernr ).
CLEAR ls_object_spec.
ls_object_spec-object_name = 'PERNR_BEN'.
ls_object_spec-object_id = lv_object_id.
APPEND ls_object_spec TO lt_object_specs.
lo_collection_in = lo_collection_out = lo_bol_core->get_root_entities( it_instances = lt_object_specs ).
lo_iterator = lo_collection_out->get_iterator( ).
lo_entity = lo_iterator->get_first( ).
IF lo_entity IS BOUND.
lo_entity->lock( ). "Lock the root entity
* Refresh / re-read the contents
lo_entity->reread( ).
* End of Refresh / re-read the contents
IF lo_collection_out IS BOUND.
lo_entity = lo_collection_out->get_first( ).
IF lo_entity IS BOUND.
lo_entity->reread( ). "* "Refresh / re-read the contents
IF lo_bol_filter IS BOUND.
lo_collection_out = lo_entity->get_related_entities_by_filter(
iv_relation_name = iv_bol_relation
iv_filter = lo_bol_filter ).
ENDIF.
ENDIF.
ENDIF.
ENDIF.
lo_iterator = lo_collection_out->get_iterator( ).
lo_entity = lo_iterator->get_first( ).
WHILE lo_entity IS BOUND.
lv_index = sy-index.
CALL METHOD lo_entity->get_property_as_value
EXPORTING
iv_attr_name = 'ENROLLED'
IMPORTING
ev_result = lv_string.
IF lv_string EQ 'X'.
IF lo_entity->alive( ) = abap_true.
lo_access = lo_entity.
TRY.
lo_access->set_property(
iv_attr_name = 'ENROLLED'
iv_value = '' ).
lo_entity->activate_sending( ).
CATCH cx_crm_cic_parameter_error.
ENDTRY.
ENDIF.
ENDIF.
lo_entity ?= lo_iterator->get_next( ).
ENDWHILE.
I have tried LO_CORE->modify( ) after the changes, but the issue still persists. Is there any other way to explicitly update the buffer? Please help me in solving this problem.