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: 

Raise event if db record has changed

Former Member
0 Kudos

Hello all,

is it possible to raise a event if something has changed on the db and catch the event in a object instance in different user sessions?

Regards

Sebastian

1 ACCEPTED SOLUTION

Vinod_Chandran
Active Contributor
0 Kudos

I think this you have to do in the database level. Not sure whether this is possible in SAP.

Message was edited by: Vinod C

12 REPLIES 12

Vinod_Chandran
Active Contributor
0 Kudos

I think this you have to do in the database level. Not sure whether this is possible in SAP.

Message was edited by: Vinod C

0 Kudos

Hello Vinod,

thank you for your reply. I fear i have to agree with you Vinod.

Regards

Sebastian

0 Kudos

Hi,

You can do this by creating a db trigger, am afraid most of the BASIS people may not agree to this.

I can give you more details if you are interested...

BTW, what is your DB ?

Ravi.

0 Kudos

Hi Ravi,

I am of course interested in. We use Oracle 9.2.

I will be anxious to see what solution you have.

Regards

Sebastian

jayanthi_jayaraman
Active Contributor
0 Kudos

Hi,

You can use LOG DATA CHANGES in Technical settings.

Just read the following.

The logging flag defines whether changes to the data records of a table should be logged. If logging is activated, every change (with UPDATE, DELETE) to an existing data record by a user or an application program is recorded in a log table in the database.

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.

Dependencies

Logging only takes place if parameter rec/client in the system profile is set correctly. Setting the flag on its own does not cause the table changes to be logged.

The existing logs can be displayed with Transaction Table history (SCU3).

0 Kudos

Hi Jayanthi,

thanks for your quick reply, but I knew this mechanism.

At the moment I change the timestamp of the record when it will be updated. When I retrieve the attributes of my object first I compare the current record timestamp with the object timestamp. If there are any difference I´ll get the new attributes.

What I would like to do is to raise a event when I change a record by calling a instance method to inform an other instance in an other "user session" that it have to update the member attributes.

But such as Vinod supposed, I fear it won´t be possible in sap.

jayanthi_jayaraman
Active Contributor
0 Kudos

Hi,

I am not sure.Just check whether this is helpful.

http://www.sqlite.org/lang_createtrigger.html

Is it possible for you to create a module in PAI of the database table before it is getting committed and write

the trigger in

EXEC SQL.

....

ENDEXEC.

Message was edited by: Jayanthi Jayaraman

0 Kudos

Hi Jayanthi,

I´ve read through the link you posted. It seems do be a viable solution.

But how can I catch the event in sap?

What do you mean with PAI of the database? I thought only dynpros have PAI.

In my case, the database update function is encapsulated in a function module which will be called from a instance method. Wouldn´t it be possible to write the trigger ( EXEC SQL .... ) in the function module?

Regards

Sebastian

0 Kudos

Sebastian,

This is exactly what I was about to tell you. Thanks Jayanthi for the link.

Now you dont have to create triggers every time, Its like your DB object for table. You create once and it will be residing on the table till it is dropped/table is recreated.

Once you create a trigger in DB, you should have a facility to monitor if the trigger has gone "INVALID" or not. NO DB COMMIT will happen if the trigger is INVALID. So this can be bit tricky also. !

I had used to log delta changes for a DW system, in which case we insert records into a temp table using the trigger. In your case its slightly different as you want to trigger an event. I may still have to dig around to see if that is possible or not.

Ravi.

0 Kudos

Hello Ravi,

on help.sap.com I found a documentation how to create a trigger, too. http://help.sap.com/saphelp_erp2004/helpdata/en/a7/41ee0b605911d3a98800a0c9449261/frameset.htm

But, it seems to me that a trigger could only call sql-statements or sql procedures directly on the db and not raise an event which can be caught or handled by the sap system.

...?

Regards

Sebastian

0 Kudos

Hi,

Generate table maintenance.Then in the program,uncomment the PAI Include and give it some valid name and create the same.In the screen which you are referring while generating the table maintenance,you have to call a module[should be defined in the PAI include which you created] which is going to trigger.

But I think you cannot use EXEC .... ENDEXEC.

Just make a try.

0 Kudos

Hello Jayanthi,

thank you for your assistance, Jayanthi. What I have forgotten to say is that I am delevoping a BSP application. So, I think it doesn´t work? Please correct me if I'm wrong.

I have several function modules which representing the api of the backend and can be called from the frontend ( BSP ).

The backend is written in ABAP OO. During the application is running several objects will be instantiated. The objects have methods for update, delete and insert records.

The dilemma is when different user are logged in and run the application at the same time the objects will be instantiated for each user, because they have their own sessions. To ensure that the objects have the actual attributes I make a query and compare the timestamps. I think it will be much easier and more efficient if it will be possible to catch an event which will be raised when something has changed.

Shared memory would be out of question as well, because several user allowed to make changes.

Now,I have come to the conclusion that I have to reconsider my concept. ;-(

Even if my motto is: nothing is impossible

Regards

Sebastian