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: 

Database Transaction In SAP

Former Member
0 Kudos

Hi,

Does SAP support database transations, what I am doing is getting the values from one Zdatabase table , and taking a value which holds the total, adding one to this , and placing the record in a differnt ztable, and then incrementing the 'total' value in the orginal; ztable , I obviously want to make sure the whole transaction occurs or nothing, I'm using insert , update in opensql.

Thanks

1 ACCEPTED SOLUTION

RichHeilman
Developer Advocate
Developer Advocate
0 Kudos

Yes it does, I'm not too familiar with it. Check out the statements, COMMIT WORK, ROLLBACK WORK, and call function modules in UPDATE TASK.

Regards,

Rich Heilman

4 REPLIES 4

former_member181962
Active Contributor
0 Kudos

Hi Sims,

The required all-or-nothing cane be done using a flag based approach.

You can set a flag for succesful updates in both Z tables and based on that flag, you can say

<b>Commit work.</b>

In case of failure use,

<b>Rollback work.</b>

Regards,

Ravi

RichHeilman
Developer Advocate
Developer Advocate
0 Kudos

Yes it does, I'm not too familiar with it. Check out the statements, COMMIT WORK, ROLLBACK WORK, and call function modules in UPDATE TASK.

Regards,

Rich Heilman

Former Member
0 Kudos

You can achieve that by creating Lock objects through SE11. Create one lock object including these tables. Once you do that, the system will generate a ENQUEUE and a DEQUEUE function module. You need to call the ENQUEUE function module before making any updates to the table and then the DEQUEUE after making the updates. This ensures that your data is locked in one single transaction. Now coming to making all updates or no updates, you need to do the entire sequence in one single task. The sequence is

CALL ENQUEUE FUNCTION MODULE

DO THE UPDATES.

CALL DEQUEUE FUNCTION MODULE.

Srinivas

0 Kudos

And of course as always, Rich and Ravi are correct in saying that you will do a commit or rollback depending on the situation. But the key is to do all of them in one task.