‎2015 Aug 18 2:06 PM
Hello ABAP experts,
I am quite new to SAP LUW, want to execute 2 SQL statements in one unit and didn't find anyhting in the web ...
So to keep it simple I have the following programme.
On COMMIT WORK it first executs form insert1 and then update1.
If sy-subrc <> 0 in from insert1 I want to do a rollback, but I am not allowed to use ROLLBACK WORK statement in that form.
So what possibilities do I have to raise an error without aborting the whole programme and to rollback the work?
Thanks in advance,
Thomas
‎2015 Aug 18 3:53 PM
Hi Thomas,
the forms you have passed to the update task are executed in that sequence as your PERFORM Statements. Each form has to check the returncode of the SQL Statements and if there is an error it needs to stop the update Task. So if "insert1" gets SY-SUBRC = 4 it should raise an abort message (Type A) which will automatically perform a rollback work and will stop the LUW immediately.
Regards
Oliver
‎2015 Aug 18 2:13 PM
You should perform all the validations before the COMMIT WORK statement. The INSERT statement will fail only if the key is already existing in the table. That check can be performed well in advance, not waiting for the actual INSERT to happen.
Thanks,
Juwin
‎2015 Aug 18 2:48 PM
Agree with Juwin.
Not sure what your requirement . Why would you first insert and then update the same table.
Still one way can be to call the subroutine for update inside the subroutine for Insert instead of calling it in ON COMMIT based on the sy-subrc value after insert statement.
If the INSERT has failed there is nothing to ROLLBACK as the data is not inserted in database.
R
‎2015 Aug 18 3:53 PM
Hi Thomas,
the forms you have passed to the update task are executed in that sequence as your PERFORM Statements. Each form has to check the returncode of the SQL Statements and if there is an error it needs to stop the update Task. So if "insert1" gets SY-SUBRC = 4 it should raise an abort message (Type A) which will automatically perform a rollback work and will stop the LUW immediately.
Regards
Oliver
‎2015 Aug 18 4:15 PM
Hi,
The Error Handling for Bundled Updates - ABAP Programming (BC-ABA), is not very clear, but you could try if 'E' message achieves what you want in dialog. However, when executed in background, the 'E' message would still terminate execution.
As others already pointed out, error in update processing should be treated as "unrecoverable error" or "system error" in SAP - as something worthy of termination. Or in other words, it's not a good idea to try to work around application errors in update processing.
I don't know much about "BDS Barcodes" but as a general rule, it's never a good idea to try to modify SAP standard tables direcly.
cheers
Janis
‎2015 Aug 20 2:57 PM
Thanks for your replies.
The real programme is more complex than the one above, but it is only a interim solution, so I it's maybe a bit more dirty than usual :
There are three statements on 3 different tables:
These statements are one unit.
As this programme is doing a mass processing, I thought that for every unit it is possible to catch an error and write it in a protocol without changing something in that unit ... and then going on with the next unit.
So if an error happens I just use MESSAGE and TYPE 'A'. This is the common way, right?
Thanks,
Thomas