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

Former Member
0 Likes
1,151

there is a module pool pgm which is updating the database table with new records also. the problem is that sometimes the updates are not reflected in the database.

while debugging i found that when any new record is created then sy-subrc is checked. if it is 0 then 'Commit work' is written.

when i get sy-subrc 0 and press F5 then cursore moves to 'Commit work' and there i need to press F5 2-3 times then only program proceeds further.

is this the case that 'Commit work' is failed. how can i know that?

8 REPLIES 8
Read only

Former Member
0 Likes
1,069

one more thing i want to add.

is 'Commit work' is case-sensitive statement?

Read only

Former Member
0 Likes
1,069

Hi,

No...Sometimes Commit takes some time to save the changes to the database.

Use a 'Commit and Wait.' statement and see.

Regards

Subramanian

Read only

Former Member
0 Likes
1,069

Hi,

Commit work is function. Basically for the first F5 it opens the function and second F5 would execute the function. Thus you may have to press F5 twice. There should not any problem with the code.

Regards,

Vara

Read only

Former Member
0 Likes
1,069

Hi,

COMMIT WORK..is a syntax...It is not case sensitive..

You can give all the possible combinations as long as the spelling is correct..

cOMMIt Work.

Thanks,

Naren

Read only

Clemenss
Active Contributor
0 Likes
1,069

Hi ANURITA,

first you should know that in (classic) debugger implicit COMMIT may occur because the program flow is interrupted by screen I/O.

Usually SAP standard transactions will pass the necessary database updates to an independent process, a so-called update process. This is done using update functions - they are called as "CALL FUNCTION '...' IN UPDATE TASK. That means the function modules name and all parameter values are stored intermediate for update handling.

COMMIT WORK will do a couple of things:

All previous direct database updates (INSERT, UPDATE, DELETE and MODIFY) are finalized, the results are fixed in the database and get visible for all users.

All functions previously called IN UPDATE TASK are executed by an update process. After all functions are processed without any error, the results are commited to the database (finalized) and all existing locks are released - A user may access the object (order, master data, ...)

Also all FORM routines which have been called using the addition ON COMMIT (PERFORM ... ON COMMIT) are executed.

If, in any of the above steps, an error occurs, the system will not finalize the database changes but execute a ROLLBACK. That means, all changes are thrown away. Additionally, all PERFORM ... ON ROLLBACK is executed.

The reason is that database remains consistent: All changes are done or nothing.

For this reason, it can (dependent on the system and situation) take some seconds for changes to take effect.

Have a look at the SAP LUW concept, start here:

<a href="http://help.sap.com/saphelp_erp2005vp/helpdata/en/fc/eb3b64358411d1829f0000e829fbfe/content.htm">Committing Database Changes</a>

Regards,

Clemens

Read only

Former Member
0 Likes
1,069

while debugging i also found that there is a function module for CREATING new record and other for UPDATING the existing record. inside both the function module 'commit work' is written. and when CALL FUNCTION is over again if sy-subrc = 0. COMMIT WORK. is written.

does it hamper database to update with new record correctly?

Read only

Former Member
0 Likes
1,069

whenever new record is created it is taking the values of the previous record displayed.

Read only

Clemenss
Active Contributor
0 Likes
1,069

Anurita,

too many COMMITs will not haper the update process. But this does not look like a standard SAP program. Normally you have one COMMIT or one ROLLBACK per transaction.

The problem you describe as "whenever new record is created it is taking the values of the previous record displayed" could be a mistake in the processing logic.

What program are we talking about?

Regards,

Clemens