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

Database table triggers

Former Member
0 Likes
2,213

Dear Experts,

I have a custom table(Ztable) on which I need to trigger a specific program everytime a record is inserted into this database table.

This table might get updated thru various programs around 50 programs, so I cannot go to each program and make a change. So can some one suggest me a way, such that everytime

a DB table gets updated I want the system to generate some kind of event/ Idoc/ Signal informing about the

record being created with the record data.

In short I want a functionality similar to that of

Triggers in SQL.

Thanks

-Amit

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,579

Hi Amit,

I'm pretty sure that there's no such thing in SAP as database triggers, which you could use to retrofit your application to suit your needs (essentially not required, because you'd do that differently in SAP).

Basically I'd recommend refactoring your programs - I know it's a pain, but if the design was poor in the first place, it's the right thing to do. I don't think you want to switch your coding to database level as indicated in a previous posting.

If the design of the applications would've been right in the first place, you would have some kind of update module (e.g. an update function) that all programs call for updating your custom table. With this kind of approach your requirement is simple to implement, because then you'd only need to update the coding in the update module. That's why proper modularization of programs is so important.

Anyhow, probably you know all that and are just like most of us in the awkward position of implementing new requirements on existing, organically grown, poorly designed coding with the common hammer argument of minimal costs. However, I personally think that it's better to bite the bullet at some time, because certain refactorings are clearly beneficial as they will simplify program support and maintenance.

Cheers, harald

3 REPLIES 3
Read only

Sandra_Rossi
Active Contributor
0 Likes
1,579

Do a PL/SQL program then. That doesn't exist in SAP.

Read only

Clemenss
Active Contributor
0 Likes
1,579

Hi Amit,

create a class mit static method to create event. Use RPR_ABAP_SOURCE_SCAN to find the 50 or so (Z-) programs using your table. insert the line with the method call at all update/insert for the Z table.

If you don't wait, this is finished until noon.

Regards,

Clemens

Read only

Former Member
0 Likes
1,580

Hi Amit,

I'm pretty sure that there's no such thing in SAP as database triggers, which you could use to retrofit your application to suit your needs (essentially not required, because you'd do that differently in SAP).

Basically I'd recommend refactoring your programs - I know it's a pain, but if the design was poor in the first place, it's the right thing to do. I don't think you want to switch your coding to database level as indicated in a previous posting.

If the design of the applications would've been right in the first place, you would have some kind of update module (e.g. an update function) that all programs call for updating your custom table. With this kind of approach your requirement is simple to implement, because then you'd only need to update the coding in the update module. That's why proper modularization of programs is so important.

Anyhow, probably you know all that and are just like most of us in the awkward position of implementing new requirements on existing, organically grown, poorly designed coding with the common hammer argument of minimal costs. However, I personally think that it's better to bite the bullet at some time, because certain refactorings are clearly beneficial as they will simplify program support and maintenance.

Cheers, harald