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: 

COMMIT WORK AND WAIT.

Former Member
0 Kudos
2,383

Hi,

Just wonder what is the different if i add 'COMMIT WORK AND WAIT." and without COMMIT WORK AND WAIT.?

It seems to me that the table zvpafinal still works the same, even though i remove COMMIT WORK AND WAIT?

Example :

DELETE FROM ZVPAFINAL.

MODIFY zvpafinal FROM TABLE it_zvpa.

COMMIT WORK AND WAIT.

Thanks

1 ACCEPTED SOLUTION

Former Member
437

Commit work is used to update a database table.

It executes all subroutines registered using PERFORM ON COMMIT.

If you do not specify the addition AND WAIT, the program does not wait until the update work process has executed it (asynchronous updating). If you specify the addition AND WAIT, however, program processing after COMMIT WORK will not continue until the update work process has executed the high-priority update function modules (synchronous updating).

sy-subrc Meaning

0 You have specified the AND WAIT addition,and the updating of the update FM was successful.

4 You have specified the AND WAIT addition, and the updating of the update FM was not successful.

The COMMIT WORK statement always sets sy-subrc to 0 if the AND WAIT addition is not specified.

4 REPLIES 4

Former Member
0 Kudos
437

Hi,

When you delete or insert the values system will automaticaly commit the work.No need to write again.

COMMIT WORK [AND WAIT]

Writes all the database changes and releases all the database locks. Triggers updating. The AND WAIT addition forces the program to wait until the system has finished updating the database. Otherwise, updating is asynchronous.

ak_upadhyay
Contributor
0 Kudos
437

Hi,

COMMIT WORK

This is the standard form, which specifies asynchronous processing. Your program does not wait for the requested functions to finish processing.

COMMIT WORK AND WAIT

This form specifies synchronous processing. The commit statement waits for the requested functions to finish processing. Control returns to your program after all high priority (V1) function modules have run successfully.

The AND WAIT form is convenient for switching old programs to synchronous processing without having to re-write the code. Functionally, using AND WAIT for update-task updates is just the same as dialog-task updates with PERFORM ON COMMIT.

Reward points if useful....

Regards

AK

Former Member
438

Commit work is used to update a database table.

It executes all subroutines registered using PERFORM ON COMMIT.

If you do not specify the addition AND WAIT, the program does not wait until the update work process has executed it (asynchronous updating). If you specify the addition AND WAIT, however, program processing after COMMIT WORK will not continue until the update work process has executed the high-priority update function modules (synchronous updating).

sy-subrc Meaning

0 You have specified the AND WAIT addition,and the updating of the update FM was successful.

4 You have specified the AND WAIT addition, and the updating of the update FM was not successful.

The COMMIT WORK statement always sets sy-subrc to 0 if the AND WAIT addition is not specified.

Former Member
0 Kudos
437

Hi,

To apply the changes made to the runtime objects of persistent classes to the actual persistent objects in the database, execute the COMMIT WORK statement. (Alternatively, use COMMIT WORK AND WAIT or SET UPDATE TASK LOCAL). Unless you are executing an object-oriented transaction from within the Transaction Service, you must include the COMMIT WORK statement explicitly in the program. Otherwise, it is encapsulated in the Transaction Service. (If you explicitly include the COMMIT WORK statement as described here, the t op-level transaction runs in compatibility mode).

The function of the COMMIT WORK statement is extended when you use it in conjunction with Object Services. Before COMMIT WORK closes the SAP LUW and triggers an update, it calls internal methods of the Persistence Service. These methods bundle the changes made to managed objects of the Persistence Service and pass them to a special update function module using CALL FUNCTION ... IN UPDATE TASK. Thus the Persistence Service works with traditional update methods. The update module is usually registered after any update modules that have already been registered. The update is then triggered and the update task executes the update module in the order in which they were registered.

After the system executes the COMMIT WORK statement, it sets the attributes of each persistent object in the ABAP program to initial. (That is, it calls the IF_OS_STATE~INVALIDATE method).

Local Update

If you want to change managed objects directly, rather than using the update module, you must change the update mode of the implicitly used Transaction Service. That is, the following statements must be executed before the COMMIT WORK statement:

DATA TM type ref to IF_OS_TRANSACTION_MANAGER.

DATA T type ref to IF_OS_TRANSACTION.

...

TM = CL_OS_SYSTEM=>GET_TRANSACTION_MANAGER( ).

T = TM->GET_CURRENT_TRANSACTION( ).

T->SET_MODE_UPDATE( OSCON_DMODE_DIRECT ).

COMMIT WORK.

To ensure database consistency, the local update is activated internally using SET UPDATE TASK LOCAL. In such cases, the system raises an exception if there are already update modules registered in the update task. You can only register additional classical update modules after setting the mode. They will then also be updated locally.

if its useful reward points