cancel
Showing results for 
Search instead for 
Did you mean: 

Message before save?

Former Member
0 Kudos

Hi All

In one requirement, i have save button, if user done any changes in table data will be saved, but without doing any changes if user click on save, i need to display message like "NO Chnages ", how to track if user done changes or not... Pelase help

Thanks,

Venkat

Accepted Solutions (0)

Answers (2)

Answers (2)

Former Member
0 Kudos

hi,Venkat..

Do you use ALV as your table??

If it does, i suggest you make use of the ALV self-bringing Event named "On_data_check", in this event handler, you can check whether the user has input any data..For example:


*3. setting
  LOOP AT r_param->t_modified_cells INTO ls_modified_cells.
    "changed or not?
    IF ls_modified_cells-r_value <> ls_modified_cells-r_old_value.
        
    endif.
    "no input
    IF ls_modified_cells-r_value is initial.
        
    endif.

Endloop.

If you do not use ALV, instead just "TABLE" UI element, you can make use of the Context Node bound to the table.For example:

 
data: lo_Node      type ref to If_Wd_Context_Node,
      lt_elems     type WDR_CONTEXT_ELEMENT_SET,
      lo_Elem      type ref to If_Wd_Context_Element,
      lw_varint      type string.

* navigate from <CONTEXT> to <FLIGHTS> via lead selection
  lo_Node = wd_Context->get_Child_Node( Name = 'NODE' ).

  lt_elems = lo_node->GET_ELEMENTS( ).
    loop at lt_elems into lo_Elem.
* get single attribute
      lo_Elem->get_Attribute(
        exporting
          Name =  '  '  "you want to check whether this column has been inputed or not
        importing
          Value = lw_varint ).

* check input or not?
        if   lw_varint  is initial.

        endif.
    endloop.

Hope it can help you a little.

Best wishes.

Former Member
0 Kudos

In addition,

If you just want to track the Change-log, you can refer the the link which chinnaiya P provided..

It is also simple.

But you should active the "Change-log" function first..


****get the change log of context
  wd_this->go_context = wd_context->get_context( ).
  wd_this->go_context->enable_context_change_log( ).

Then you can get the Change Log as you want...

Best wishes.

Former Member
0 Kudos

Hi Venkat ,

you can track changes happening in the context using contex changes log

pls look at the below link

[http://help.sap.com/saphelp_sm40/helpdata/en/ae/f95e42ff93c153e10000000a1550b0/content.htm|http://help.sap.com/saphelp_sm40/helpdata/en/ae/f95e42ff93c153e10000000a1550b0/content.htm]

also look at the component : DEMO_CONTEXT_CHANGES

Regards

chinnaiya P

Former Member
0 Kudos

Hi chinniya,

I am not getting, can u help me please

Thanks,

venkat.

Former Member
0 Kudos

Hi venkat ,

You will have to code somthing like below shown in the handler of your save button.

DATA lo_node TYPE REF TO if_wd_context_node.
DATA lo_node1 TYPE REF TO if_wd_context.
DATA lt_change TYPE WDR_CONTEXT_CHANGE_LIST."table type


lo_node = wd_Context->get_Child_Node( Name = 'NODE' ). "getting the reference of the node bound to the table.
lo_node1 = lo_node->get_context( ).

lo_node1->ENABLE_CONTEXT_CHANGE_LOG( )."enabling the context change log.
lt_change = lo_node1->GET_CONTEXT_CHANGE_LOG( )."Obtain the changes done on the node.

Then you can check if the table lt_change is initial.If initial , then no changes are done on the context node and you can raise a message saying "nothing to save".

else, if there are changes ..then save the changes.

Thanks,

aditya.

Former Member
0 Kudos

Ya...

You does want "Change Log"??

Share you one EXAMPLE code:

Get Change Log:


METHOD extract_changed_data .

  DATA lt_change_log_list        TYPE        wdr_context_change_list.
  DATA ls_change_log             TYPE        wdr_context_change.
  DATA lt_context_changes        TYPE        wd_this->elements_context_changes.
  DATA ls_context_changes        TYPE        wd_this->element_context_changes.
  DATA lo_nd_context_changes     TYPE REF TO if_wd_context_node.

  FIELD-SYMBOLS <lv_old_value> TYPE ANY.
  FIELD-SYMBOLS <lv_new_value> TYPE ANY.

* Get actual changes
  lt_change_log_list = wd_this->go_context->get_context_change_log( and_reset = abap_false ).

* Build list of actual context change log content to be displayed by view
  LOOP AT lt_change_log_list INTO ls_change_log WHERE attribute_name IS NOT INITIAL.
    ls_context_changes-node_name      = ls_change_log-node_name.
    ls_context_changes-sequence       = ls_change_log-sequence.
    ls_context_changes-node_path      = ls_change_log-node_path.
    ls_context_changes-change_kind    = ls_change_log-change_kind.
    ls_context_changes-element_index  = ls_change_log-element_index.
    ls_context_changes-attribute_name = ls_change_log-attribute_name.
*   Data values are provided as generic data references
*   ls_context_changes-old_value/ new_value : stringu7C7Bu578B 
    ASSIGN ls_change_log-old_value->* TO <lv_old_value>.
    ASSIGN ls_change_log-new_value->* TO <lv_new_value>.
    ls_context_changes-old_value      = <lv_old_value>.
    ls_context_changes-new_value      = <lv_new_value>.
*   Save actual user input in context -> will be displayed
    INSERT ls_context_changes INTO TABLE lt_context_changes.
  ENDLOOP.

* Store data in context
  lo_nd_context_changes = wd_context->get_child_node( wd_this->wdctx_context_changes ).
  lo_nd_context_changes->bind_table( lt_context_changes ).

ENDMETHOD.

Stop log::


method ONACTIONSTOP_LOG .

  wd_comp_controller->go_context->disable_context_change_log( ).

endmethod.

Continue log:


method ONACTIONCONTINUE_LOG .

  wd_comp_controller->go_context->enable_context_change_log( ).

endmethod.

Clear log:


method ONACTIONCLEAR_LOG .

  wd_comp_controller->go_context->reset_context_change_log( ).


endmethod.

Hope it can help you a little.

Best wishes.