‎2010 Jul 26 9:47 AM
Hello All,
I have a requirement where in I want to store changed data from one Z table into another. When I make any changes to the existing data in one Z table I need to log the changes (old values) in another Z table. I have tried to check events in table maintainence generator, but do not get the old values in any event. Apart from using a module pool is there a way using events for a table maintenance where in changes/deletions can be recorded into another table(history table).
Thanks and Regards,
Sachin
‎2010 Jul 26 10:23 AM
Hi,
You can activate the "log table changes" in technical setting of your Ztable in SE11 , then use SCU3 to analysis the changes.
Pole
‎2010 Jul 26 10:59 AM
Try this code snippet in Event '01' of the TMG:
DATA: f_index LIKE sy-tabix, "Index to note the lines found
st_zabc TYPE zabc,
it_zabc_old TYPE STANDARD TABLE OF zabc,
st_zabc_old TYPE zabc.
BREAK-POINT.
LOOP AT total.
IF <action> = aendern.
READ TABLE extract WITH KEY total.
IF sy-subrc EQ 0.
f_index = sy-tabix.
st_zabc = total.
SELECT SINGLE * FROM zabc INTO st_zabc_old
WHERE zzf1 = st_zabc-zzf1
AND zzf2 = st_zabc-zzf2.
CHECK sy-subrc = 0.
APPEND st_zabc_old TO it_zabc_old.
CLEAR st_zabc_old.
ELSE.
CLEAR f_index.
ENDIF.
"(make desired changes to the line total)
MODIFY total.
CHECK f_index GT 0.
extract = total.
MODIFY extract INDEX f_index.
ENDIF.
ENDLOOP.
" You can use the table IT_ZABC_OLD to save the old data to another table.
sy-subrc = 0.Hope this helps.
BR,
Suhas
‎2010 Jul 26 1:34 PM