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: 

How to enable logging of database changes of Z tables into a log table.

Former Member
0 Kudos

Dear Team,

We have 8 Z tables and we need to log the changes in these tables. Earlier Change Document process was proposed but now we know that the possible changes in the Z tables will be many and this can cause too many entries in CDHDR and CDPOS tables. Going through so many entries of Change Document tables will decrease the system performance. The other option involves enabling the Log data base changes for the Z data base tables, but this will also cause the system to slow down as per SAP F1 help on "Log data changes" checkbox.

description-"Note: Activating logging slows down accesses that change the table. First of all, a record must be written in the log table for each change. Secondly, many users access this log table in parallel. This could cause lock situations even though the users are working with different application tables."

So we came to a solution where we can create a Z table and we will log the above mentioned Z table changes in the Z Change table but I have no idea how to implement the suggested solution. Please help me on this.

Regards

Amit

1 ACCEPTED SOLUTION

former_member404244
Active Contributor
0 Kudos

Hi,

Have a suggestion..

Have custom fleld as LOG with char 1 and date field (sy-datum) in all the 8 ztables. The ztables are updated either through SM30 or from custom program, making sure who ever changes the record if manually then fill that flag field as 'X' and if by program then populate the field with value 'X'.So you will know based on the flag field whether changed or not.similarly for date field updatin as well.

Now create a custom program to update the new ztable . Schedule this program daily may be at midnight..Read the 8 ztables with having flag = 'X' and update the new ztable. Once done clear the FLAG from all the 8 ztables to space for that day and update the date field in the custom program.

So for that particular day the records were written to new ztable and all the 8 ztables are having flag value as space and date will be sy-datum.

Now for next day again do the same procedure.

Hope this gives you an idea.

Regards,

Nagaraj

3 REPLIES 3

Former Member
0 Kudos

Hi Amit,

It depends on how these Z tables are going to be updated,

1) Programmatic - That is you have reports/module pool programs updating these tables. In this case you could build a common FM/Class(which will update the Z log table) which will have to be used by the developers in your project whenever they are using INSERT/MODIFY/UPDATE/DELETE statements on the Z Tables.

2) Manually through table maintenance views - you can use the modification events under the table maintenance generator for this, there are several events available with which you can capture the changes.

These are my thoughts and not a conclusion, as i am not sure if there is any other standard way of doing it other than log changes option.

Regards,

Chen

Edited by: Chen K V on Jun 1, 2011 2:06 PM

former_member404244
Active Contributor
0 Kudos

Hi,

Have a suggestion..

Have custom fleld as LOG with char 1 and date field (sy-datum) in all the 8 ztables. The ztables are updated either through SM30 or from custom program, making sure who ever changes the record if manually then fill that flag field as 'X' and if by program then populate the field with value 'X'.So you will know based on the flag field whether changed or not.similarly for date field updatin as well.

Now create a custom program to update the new ztable . Schedule this program daily may be at midnight..Read the 8 ztables with having flag = 'X' and update the new ztable. Once done clear the FLAG from all the 8 ztables to space for that day and update the date field in the custom program.

So for that particular day the records were written to new ztable and all the 8 ztables are having flag value as space and date will be sy-datum.

Now for next day again do the same procedure.

Hope this gives you an idea.

Regards,

Nagaraj

Former Member
0 Kudos

Hi Team,

We wrote a custom Function module for the same. We called the FM whenever we had to modify the table concerned.

Regards,

Amit