‎2008 Jul 30 11:15 AM
I
Commit work sets sy-subrc always to zero.
In this case how can we know if commit work fails.
Please provide more details and efficient usage of commit statements in a report
‎2008 Jul 30 11:32 AM
Hi,
Use the following code.
if sy-subrc eq 0.
commit work and wait.
else.
raise error message.
endif.
Regards,
Navee.
‎2008 Jul 30 11:16 AM
hi check this..
may the insert or modify or update fails but not commit work...i think there is no fail case in the commit work.
‎2008 Jul 30 11:17 AM
Hi,
commit work is used mainly in case of database changes...
if in the report at certain point you want to make chages to databasethen you can use commit work....to update changes to your database.....
mot of the times in bapis you have to use expicit commit work for database changes....
check this link.
http://www.abapprogramming.net/2008/05/sap-abap-syntax-for-commit.html
‎2008 Jul 30 11:18 AM
Hi,
Use this code IN SUITABLE POSITION IN YOUR CODE.
IF SY-SUBRC NE 0
MESSAGE.................
ENDIF.Regards,
Anirban
‎2008 Jul 30 11:19 AM
use
COMMIT WORK AND WAIT.
it will set sy-subrc = 0 if update is successfull otherwise
sy-subrc NE 0.
With luck,
Pritam.
‎2008 Jul 30 11:24 AM
‎2008 Jul 30 11:28 AM
hiii
use FM
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'.
* EXPORTING
* WAIT = WAIT
* IMPORTING
* RETURN = RETURNit will give you message and if sy-subrc NE 0 then will give you error with message
regards
twinkal
‎2008 Jul 30 11:31 AM
see the Implemetation of
BAPI_TRANSACTION_COMMIT, how they handled the commit work.
In this case how can we know if commit work fails.
From SAP help
sy-subrc Meaning
0 You have specified the AND WAIT addition, and the updating of the update function modules was successful.
4 You have specified the AND WAIT addition, and the updating of the update function modules was not successful.
‎2008 Jul 30 11:32 AM
Hi,
Use the following code.
if sy-subrc eq 0.
commit work and wait.
else.
raise error message.
endif.
Regards,
Navee.
‎2008 Jul 30 11:45 AM
Hi,
Usage of commit statements is as follows:
COMMIT WORK.
Addition
u2026 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 u2026 ON COMMIT ,
executes asynchronously any update requests (see CALL FUNCTION u2026 IN UPDATE TASK ) specified in these subroutines or started just before,
processes the function modules specified in CALL FUNCTION u2026 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 u2026 ON COMMIT are processed in the LUW concluded by the COMMIT WORK command. All V1 update requests specified in CALL FUNCTION u2026 IN UPDATE TASK are also executed in one LUW . When all V1 update requests have been successfully concluded, the V2 update requests (u201Dupdate with start delayedu201D) are processed, each in one LUW . Parallel to this, the function modules specified in CALL FUNCTION u2026 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 u2026 ON COMMIT or CALL FUNCTION u2026 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 u2026 USING , COMMIT WORK successfully concludes the processing.
Addition
u2026 AND WAIT
Effect
The addition u2026 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 u2026 ON COMMIT .
COMMIT_IN_POSTING : COMMIT WORK is not allowed in the update task.
Hope it will help you.
Feel free to ask any doubt.
Regards
Aparna
‎2008 Jul 30 11:56 AM
really wonder what all replies you get for some quesiton without a thought..
Commit is generally used after INSERT , MODIFY . Update commands.
It makes sense to check the sy-subrc after these statements
not after commit.
ex:
Insert <> from ....
if sy-subrc eq 0.
......
endif.
commit work.
Br,
Vijay.
‎2008 Jul 30 11:58 AM
Hi,
Use COMMIT WORK and WAIT
The addition ... AND WAIT makes the program wait for the type V1 update (update with immediate start) to be executed.
The Return Code is set as follows:
SY-SUBRC = 0:
The update was performed successfully.
SY-SUBRC <> 0:
The update was not performed successfully.
Best of luck,
Bhumika
‎2008 Jul 30 12:27 PM