Application Development and Automation 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: 
Read only

Trigger an event or custom logic whenever data changed in table

kjyothiraditya
Participant
0 Likes
5,135

Hi Experts,

Any pointers on how to trigger an event whenever data changes in a standard table ?? The changes can be made from tcode or a bapi or a program.

Also I have to capture before and after values too .

Regards,

Jyothir aditya

Hi Experts,

Any pointers on how to trigger an event whenever data changes in a standard table ?? The changes can be made from tcode or a bapi or a program.

Also I have to capture before and after values too .

Regards,

Jyothir aditya

5 REPLIES 5
Read only

Sandra_Rossi
Active Contributor
4,249

There's no "one solution for everything".

Some programs may use technologies like change documents, or not.

At database level, there are "triggers" (concept not specific to SAP, no ABAP).

Read only

0 Likes
4,249

Yes, change documents log the data to cdhdr/pos tables. But I want to trigger a custom program during this change and also moreover it is a standard table. Don't know if we could change the settings of data elements of standard table.

About 'trigger at database level', can you please tell me what exactly you are referring to

Read only

4,249

If the standard program handles change documents, then you can change the flag of the data element (basic principle of change documents).

A change document may trigger a workflow event (transactions SWEC and SWED). You may define a function module exit to trigger some code without triggering a workflow or task. There are some discussions about it in the forum and in the SAP Library.

I think you can find many information in the web by searching triggers specifically to your type of database. For instance, a table update may update the columns date & time of this update.

Read only

0 Likes
4,249

Hi Sandra,

Many thanks for clarifying!

It is a standard table and I see many fields don't have change documents enabled (even the primary key). So I guess change documents is not feasible as there are several transactions that could change the data.

Can you please elaborate how we can use db trigger ? Would it affect if the db changes to HANA ? And also can you please guide how date and time will help and we need the before and after value also ?

Would table logging help ?

Read only

0 Likes
4,249

By default, change documents are not activated (I think). I don't understand why you say "is not feasible" - probably it's your conclusion based on your scenario.

Again, as I said; you can find information in the web. As you're talking about HANA, here is the link to CREATE TRIGGER: https://help.sap.com/viewer/4fe29514fd584807ac9f2a04f6754767/2.0.01/en-US/20d5a65575191014946db96aae....

Date & time was just one example (sometimes people want to record at what date & time was done an update to a given record; a trigger is an easy solution).

"Table logging" is both activated at client level (profile parameter rec/client), and at the technical properties of DDIC database tables. If the logging is effective for one table, all ABAP SQL statements (except SELECT/FETCH) will write the whole line to the table DBTABLOG.