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 consistency INSERT and UPDATE

Former Member
0 Kudos

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.

1 ACCEPTED SOLUTION

MarcinPciak
Active Contributor
0 Kudos

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

5 REPLIES 5

Former Member
0 Kudos

>

>> 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

Former Member
0 Kudos

hi,

refer LUW...PERFORM on COMMIT

matt
Active Contributor
0 Kudos

Read the documentation about transaction processing and the update task and Logical Units of Work. LUW.

MarcinPciak
Active Contributor
0 Kudos

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

0 Kudos

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.