cancel
Showing results for 
Search instead for 
Did you mean: 

Save only if data changed...

former_member189058
Active Contributor
0 Kudos

Hi all,

I have a context node with a few attributes. The view has a save button, which saves data to database tables. I need to call the save function only if user has changed any data and not otherwise.

How should I go about for it??

Is using the context change log the only way??? Is there any overhead in using the context change log?? Will it hit the performance of the application??

Regards,

Reema.

Accepted Solutions (0)

Answers (1)

Answers (1)

Former Member
0 Kudos

I just remember that there should be an attribut, is_changed in if_wd_context...

Hope that helps a bit....

former_member189058
Active Contributor
0 Kudos

I have already tried that...


*         Check if changes are made to the node and sub node
          data: lo_node type ref to if_wd_context_node,
                lo_ele TYPE REF TO if_wd_context_element,
                lv_ele_changed TYPE abap_bool,
                lv_node_changed TYPE abap_bool.
*           navigate from <CONTEXT> to <NODE1> via lead selection
            lo_node = wd_context->get_child_node( name = wd_this->wdctx_node1 ).
          lo_ele = lo_node->get_element( ).
          CALL METHOD lo_ele->is_changed_by_client
            receiving
              flag   = lv_ele_changed.
          IF wd_this->g_user_type = c_merchant.
*           navigate from <NODE1> to <NODE1_1> via lead selection
            lo_node = lo_node->get_child_node( name = wd_this->wdctx_NODE1_1 ).
            CALL METHOD lo_node->is_changed_by_client
              receiving
                flag   = lv_node_changed.
          ENDIF.
          IF lv_user_changed = abap_true or lv_dept_changed = abap_true.
          ENDIF.

But this returns an initial flag irrespective of whether data has change or not...

alejandro_bindi
Active Contributor
0 Kudos

That's because method is_changed_by_client is not recursive...i've made that exact same questions myself once, check this thread:

AFAIK, context changelog is the way to go.

Regards