Hi,
I am trying to add new row in BPDATA change History result based on another component(component1) data. Both these components are having relation with BuilHeader
Now in the component1 do_prepare_output i have written code to add the record and when i changed the data in component1 view, then i clik enter now in BPDATA changehistory getting new row, but when i click the SAVE button on overview page of BP_Head/overviewpage now the row is missing...
Below code i have written
lv_partner = lr_partner->get_property_as_string( 'BP_NUMBER' ).
lr_coll ?= lr_partner->get_related_entities( iv_relation_name = 'ZComp1' ).
if lr_coll is bound.
if lr_coll->size( ) GT '0'.
lr_ent ?= lr_coll->get_first( ).
endif.
endif.
if lr_ent is bound.
CALL METHOD lr_ent->if_bol_bo_property_access~get_property_as_string
EXPORTING
iv_attr_name = 'CHANGE_REASON'
** iv_use_iso_format = ABAP_FALSE
RECEIVING
rv_result = lv_creason.
endif.
if lv_creason is not initial.
TRY.
lr_coll ?= lr_partner->get_related_entities( iv_relation_name = 'BuilChangeHistoryRel' ).
if lr_coll->size( ) = '0'.
lr_ent1 = lr_partner->create_related_entity( iv_relation_name = 'BuilChangeHistoryRel').
endif.
CATCH cx_crm_genil_duplicate_rel cx_crm_genil_model_error.
ENDTRY.
endif.
if lr_ent1 is bound.
lr_ent1->get_properties( IMPORTING es_attributes = ls_chist ).
endif.
ls_chist-USERNAME = sy-uname.
ls_chist-UDATE = sy-datum.
ls_chist-UTImE = sy-uzeit.
ls_chist-TABNAME = 'ZBUT00'.
ls_chist-FNAME = 'ZCHANGEREASON'.
ls_chist-F_OLD = ls_zbut0000-zchangereason.
ls_chist-F_NEW = lv_creason.
lr_ent1->set_properties( EXPORTING is_attributes = ls_chist ).
* lr_coll->add( lr_ent1 ).
CALL METHOD LR_COLL->INSERT
EXPORTING
IV_BO = lr_ent1
IV_INDEX = '1'.
lr_core->modify( )
lr_transaction = lr_core->get_transaction( ).
if lr_transaction is bound.
lv_success = lr_transaction->check_save_needed( ).
IF lr_transaction->check_save_needed( ) EQ abap_true and lr_transaction->check_save_possible( ) EQ abap_true.
lv_success = lr_transaction->save( ).
IF lv_success IS NOT INITIAL.
lr_transaction->commit( ).
else.
lr_transaction->rollback( ).
endif.
ENDIF.
.
is there anything which need to be done, pls provide some inputs.
Thanks,
RamReddy