06-26-2009 3:22 PM
Hello all,
I have the following FORM:
FORM save_data
.... ...
INSERT z_table1.
......
find some info *****
.....
UPDATE z_table2 SET ... WHERE ...
....
ENDFORM. "save_data
When running this code, apparently it is has happened the following:
After performing the "INSERT z_table1" the network connection to the SAP server was lost and the "UPDATE z_table2" was not performed.
Since after an INSERT the system always performs COMMIT, the result is a logical inconsistency because z_table2 was not UPDATEd.
¿How can I avoid this situation to happen again in the future?
Thank you.
06-26-2009 9:23 PM
Hi,
Do as Guys suggested above. First read about
[DB LUW|http://help.sap.com/saphelp_46c/helpdata/en/41/7af4bca79e11d1950f0000e82de14a/frameset.htm]
[SAP LUW|http://help.sap.com/saphelp_46c/helpdata/en/41/7af4bfa79e11d1950f0000e82de14a/frameset.htm] thereafter.
As Rob said, DB COMMIT will only be triggered when:
Implicitly
- system displays a screen
- dialog message is displayed
- RFC call is executed
- new transaction is called (CALL TRANSACTION) or new report is executed (SUBMIT)
Explicitly
- by COMMIT statement
Generally DB COMMIT is triggered once work process is released. Here when you execute one statement after another within one DB LUW it will either execute all or nothing. Refer above links and the topic will become more clear. Good practice would be using bundling methods to perform DB activites within one SAP LUW (also explained above).
Regards
Marcin
06-26-2009 3:53 PM
>
>> Since after an INSERT the system always performs COMMIT, the result is a logical inconsistency because z_table2 was not UPDATEd.
There is no automatic COMMIT after an INSERT. That is done explicitly by you (with a COMMIT ststement) or implicitly when the program ends.
Rob
06-26-2009 3:56 PM
06-26-2009 3:56 PM
Read the documentation about transaction processing and the update task and Logical Units of Work. LUW.
06-26-2009 9:23 PM
Hi,
Do as Guys suggested above. First read about
[DB LUW|http://help.sap.com/saphelp_46c/helpdata/en/41/7af4bca79e11d1950f0000e82de14a/frameset.htm]
[SAP LUW|http://help.sap.com/saphelp_46c/helpdata/en/41/7af4bfa79e11d1950f0000e82de14a/frameset.htm] thereafter.
As Rob said, DB COMMIT will only be triggered when:
Implicitly
- system displays a screen
- dialog message is displayed
- RFC call is executed
- new transaction is called (CALL TRANSACTION) or new report is executed (SUBMIT)
Explicitly
- by COMMIT statement
Generally DB COMMIT is triggered once work process is released. Here when you execute one statement after another within one DB LUW it will either execute all or nothing. Refer above links and the topic will become more clear. Good practice would be using bundling methods to perform DB activites within one SAP LUW (also explained above).
Regards
Marcin
06-29-2009 9:37 AM
Thank you Marcin,
You gave me the clue:
A COMMIT was performed because there was a
MESSAGE iNNN
Right after the INSERT and before the UPDATE.
I've placed that MESSAGE after all Data Base operations ara performed, so I expect this problem wont happen again in the future.
Thank you all for yor contributions.
Best regards.