Application Development and Automation 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: 
Read only

COMMIT WORK AND WAIT USE

Former Member
0 Likes
33,369

Hi Friends,

what is mean by COMMIT WORK AND WAIT.

when we use ths syntax...??

situation pls.

regards,

venu.

6 REPLIES 6
Read only

Former Member
0 Likes
11,334

Hi,

The statement COMMIT WORK completes the current SAP LUW and opens a new one, storing all change requests for the current SAP LUW in the process. In this case, COMMIT WORK performs the following actions:

The statement WAIT causes a change in the work process, which is linked to rolling out and rolling in all loaded programs. For this reason, the time in sec should not be less than a second in order not to load the system with too frequent changing of the work process.

Each time the statement WAIT is used, a database commit is issued. For this reason, WAIT must not be used between Open SQL statements that open or close a database cursor.

Thanks,

Suman.

Read only

Former Member
11,334

Hi,

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.

regards

Sandipan

Read only

Former Member
0 Likes
11,334

The statement COMMIT WORK completes the current SAP LUW and opens a new one, storing all change requests for the current SAP LUW in the process. In this case, COMMIT WORK performs the following actions:

- It executes all subroutines registered using PERFORM ON COMMIT.

- Triggering an internal event for the Persistence Service of the Object Services.

- It handles all SAP locks set in the current program according to the value of the formal parameter _SCOPE of the corresponding lock function modules.

- It triggers a database commit that also terminates the current database LUW and closes all database cursors.

- Triggers the TRANSACTION_FINISHED events of the system class CL_SYSTEM_TRANSACTION_STATE. The parameter KIND is set to the value of the constant CL_SYSTEM_TRANSACTION_STATE=>COMMIT_WORK.

- In a program executed using batch input, or if you have called the program using the USING addition of the statement CALL TRANSACTION, COMMIT WORK terminates the batch input processing when using the corresponding settings.

This executes all high-priority (VB1) update function modules in the order of their registration and in a common database LUW. If you do not specify the addition AND WAIT, the program does not wait until the update work process has executed it (asynchronous updating), but instead is resumed immediately after COMMIT WORK. However, if the addition AND WAIT is specified, program processing after COMMIT WORK will not continue until the update work process has executed the high-priority update function modules (synchronous updating).

(Copyed from ABAP Reference - You'll find more details there)

Read only

Former Member
0 Likes
11,334

Hi Venu,

Thanks for your points.

Suman.

Read only

Former Member
0 Likes
11,334

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.

COMMIT

Basic form

COMMIT WORK.

Addition

... AND WAIT

Effect

Executes a database commit and thus closes a logical processing unit or Logical Unit of Work ( LUW ) (see also Transaction processing ). This means that

all database changes are made irrevocable and cannot be reversed with ROLLBACK WORK and

all database locks are released.

COMMIT WORK also

calls the subroutines specified by PERFORM ... ON COMMIT ,

executes asynchronously any update requests (see CALL FUNCTION ... IN UPDATE TASK ) specified in these subroutines or started just before,

processes the function modules specified in CALL FUNCTION ... IN BACKGROUND TASK ,

cancels all existing locks (see SAP locking concept ) if no update requests exist,

closes all open database cursors (see OPEN CURSOR ) and

resets the time slice counter to 0.

COMMIT WORK belongs to the Open SQL command set.

Return code value

The SY-SUBRC is set to 0.

Notes

All subroutines called with PERFORM ... ON COMMIT are processed in the LUW concluded by the COMMIT WORK command. All V1 update requests specified in CALL FUNCTION ... IN UPDATE TASK are also executed in one LUW . When all V1 update requests have been successfully concluded, the V2 update requests ("update with start delayed") are processed, each in one LUW . Parallel to this, the function modules specified in CALL FUNCTION ... IN BACKGROUND TASK are each executed in one LUW per destination.

COMMIT WORK commands processed within CALL DIALOG processing

- execute a database commit (see above),

- close all open database cursors,

- reset the time slice counter and

- call the function modules specified by CALL FUNCTION IN

BACKGROUND TASK in the CALL DIALOG processing.

However, subroutines and function modules called with PERFORM ... ON COMMIT or CALL FUNCTION ... IN UPDATE TASK in the CALL DIALOG processing are not executed in the calling transaction until a COMMIT WORK occurs.

Since COMMIT WORK closes all open database cursors, any attempt to continue a SELECT loop after a COMMIT WORK results in a runtime error. For the same reason, a FETCH after a COMMIT WORK on the now closed cursors also produces a runtime error. You must therefore ensure that any open cursors are no longer used after the COMMIT WORK .

With batch input and CALL TRANSACTION ... USING , COMMIT WORK successfully concludes the processing.

Addition

... AND WAIT

Effect

The addition ... AND WAIT makes the program wait until the type V1 updates have been completed.

The return code value is set as follows:

SY-SUBRC = 0 The update was successfully performed.

SY-SUBRC <> 0 The update could not be successfully performed.

Note

Runtime errors

COMMIT_IN_PERFORM_ON_COMMIT : COMMIT WORK is not allowed in a FORM callled with PERFORM ... ON COMMIT .

COMMIT_IN_POSTING : COMMIT WORK is not allowed in the update task.

if its useful reward points

Read only

Former Member
0 Likes
11,334

hi

hope it will help you.

Reward if help.

ROLLBACK WORK

Terminates a SAP-LUW without storing the changes.

The statement ROLLBACK WORK closes the current SAP-LUW and opens a new one. In doing so, all change requests of the current SAP-LUW are canceled. To do this, ROLLBACK WORK carries out the following actions:

COMMIT work

Terminates an SAP LUW and stores the changes

The statement COMMIT WORK completes the current SAP LUW and opens a new one, storing all change requests for the current SAP LUW in the process.