Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

Events not updating the database correctly

Former Member
0 Kudos

Hi All,

We need to update the created date and time as well as changed date and time for a custom table.Please have a look at the below piece of code.But the date never gets commited as well as when there is any change made to the entries in the table they are not getting commited.Please help.

Thanks,

Sham.

LOOP AT total.
    READ TABLE extract WITH KEY <vim_xtotal_key>.
    IF sy-subrc EQ 0.
      l_index = sy-tabix.
    ELSE.
      CLEAR l_index.
    ENDIF.
    MOVE total TO w_mat.
    IF status-action EQ 'A'.
      w_mat-created_on = sy-datum.
      w_mat-creation_time = sy-uzeit.
      w_mat-created_by = sy-uname.
      w_mat-changed_on = sy-datum.
      w_mat-changed_by = sy-uname.
      w_mat-changed_time = sy-uzeit.
    ELSE.
      w_mat-changed_on = sy-datum.
      w_mat-changed_by = sy-uname.
      w_mat-changed_time = sy-uzeit.
    ENDIF.
    OVERLAY total WITH w_mat.
    MODIFY total.
    CHECK l_index GT 0.
    extract = total.
    MODIFY extract INDEX l_index.
  ENDLOOP.
  sy-subrc = 0.
ENDFORM.

Added code tags

Edited by: Rob Burbank on Feb 27, 2009 11:06 AM

2 REPLIES 2

Former Member
0 Kudos

Hi ,

Try using

commit work

statement after the enloop and check if it gets updated.

Regards,

Siddarth

Former Member
0 Kudos
total-created_on  = sy-datum.  "w_mat-created_on = sy-datum.similarly for other values
MODIFY total .
"total is table with header line 
"other option: MODIFY total from wrk_mat TRANSPORTING created_on etc