‎2010 Apr 22 4:01 AM
hi all:
I create a class with methods to insert , modify and delete trasaction data,
when commit work fails, I want to throw an exception, what exception should I use
for this case?
‎2010 Apr 22 2:32 PM
If you want to raise an exception every time your commit fails, then you just need to create your own custom exception class and raise it inside your methods every time commit fails.
By the way, in order for you to know if your commit command failed or not- ensure that you add the AND WAIT command so that the sy-subrc field changes for success and error. Otherwise, your COMMIT WORK will always return 0 sy-subrc.
‎2010 Apr 22 5:27 AM
Hi,
Two non-catchable exceptions for commit work.
COMMIT_IN_PERFORM_ON_COMMIT
COMMIT_IN_POSTING
Regards and Best wishes.
‎2010 Apr 22 8:14 AM
do you throw an exception in a class method if commit work fails, what do you usually do ?
‎2010 Apr 22 2:32 PM
If you want to raise an exception every time your commit fails, then you just need to create your own custom exception class and raise it inside your methods every time commit fails.
By the way, in order for you to know if your commit command failed or not- ensure that you add the AND WAIT command so that the sy-subrc field changes for success and error. Otherwise, your COMMIT WORK will always return 0 sy-subrc.
‎2010 Apr 28 1:31 PM
In general, you should do your commit using CALL FUNCTION IN UPDATE TASK. As this runs in a different process, you will never be able to catch an exception in your main task, even if you throw one in the Open SQL code. What you should do is carefully validate your data before posting it to the database, so that commit cannot fail for data integrity reasons. If it fails for technical reasons (DB down etc.) there is nothing that your code could do about it anyway, so in this case even getting an exception would be no use. What exactly is it you are trying to accomplish?
-- Sebastian