cancel
Showing results for 
Search instead for 
Did you mean: 

check_save_needed does not work correctly

former_member188843
Participant
0 Kudos

Hi All Expert,

I created an own model. it works fine when i create a new entity from UI. But when i edit a exist entity, when i try save my changes i call

lr_tx ?= lr_entity->get_transaction( ).

lr_tx->check_save_needed( ) eq abap_true.

lr_tx->check_save_needed do not return true even there is real change to entity.

I debugged it and found it try to get result from following code. in create mode, it return true. but in change mode it is not true.

rv_result = me->my_manager_entry->data_changed.

any hints will be highly appreicated.

Accepted Solutions (0)

Answers (4)

Answers (4)

former_member211707
Active Participant
0 Kudos

Hello Joshua,

firstly check entity is locked or not.

check lr_entity->lock()= abap_true.

then after making change and setting some value, call

lr_core->modify().

then write below code:--

data: lr_tx type ref to if_bol_transaction_context.

lr_tx = lr_entity->get_transaction( ).

check lr_tx->check_save_needed( ) eq abap_true.

check lr_tx->check_save_possible( ) eq abap_true.

if lr_tx->save( ) = abap_true.

   lr_tx->commit( ).

else.

  lr_tx->rollback( ).

endif.

Thanks and Regards,

Amit

Former Member
0 Kudos

Hi Joshua,

You need to lock entity,

if entity is locked successfully,

make changes then use lr_core->modify( )

also check in genil modify( ) CT_CHANGED_OBJECTS Parameter shouldn't be blank

former_member188098
Active Contributor
0 Kudos

Hi Joshua,

Try with this

data: lo_core           TYPE REF TO cl_crm_bol_core,

  lo_tx             TYPE REF TO if_bol_transaction_context.

*a Save changes

  lo_tx = lo_order_entity->get_transaction( ).
    lo_core = cl_crm_bol_core=>get_instance( ).
    IF lo_core IS BOUND.
      lo_core->modify( ).
    ENDIF.

    IF lo_tx->check_save_needed( ) EQ abap_true .
      IF lo_tx->check_save_possible( ) EQ abap_true .
        IF lo_tx->save( ) EQ abap_true.
          lo_tx->commit( ).

EINDIF.

ENDIF.

ENDIF.

Regards,

jorge_ocamposbenito
Contributor
0 Kudos

Hi Joshua,

Have you add   lr_core->modify( ). before check if save is needed?.

Best regards.