Skip to Content

check_save_needed does not work correctly

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.

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

4 Answers

  • Posted on Dec 31, 2013 at 10:32 AM

    Hi Joshua,

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

    Best regards.

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Dec 31, 2013 at 10:45 AM

    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,

    @Harish Kumar

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Dec 31, 2013 at 10:45 AM

    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

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Jan 03, 2014 at 05:15 AM

    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

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.